You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To improve organization during the workshop, consider customizing your terminal windows or shells with unique names and colours. This will make it easier to identify and switch between them quickly.
12
+
To improve organization during the workshop, consider customizing your terminal windows or shells with unique names and colors. This will make it easier to identify and switch between them quickly.
13
13
{{% /notice %}}
14
14
15
15
Run the following command from the `1-agent` directory (ensure you’re using the correct OpenTelemetry Collector binary you downloaded):
Copy file name to clipboardExpand all lines: content/en/ninja-workshops/10-advanced-otel/80-routing/8-1-routing-test.md
+14-12Lines changed: 14 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ It should also start up normally and state : `Everything is ready. Begin running
20
20
21
21
-**Create a trace for different Environments**
22
22
Find your `Test` terminal window and navigate to the `[WORKSHOP]/8-routing`.
23
-
To test your configuration, you need to generate span data with the correct `ResourceSpan` attributes to trigger the routing rule. Copy the following JSON and save it as `security.json` in the `[WORKSHOP]\8-routing` directory.
23
+
To test your configuration, you need to generate span data with the correct `ResourceSpan` attributes to trigger the routing rule. Copy the following JSON and save it as `security.json` in the `[WORKSHOP]/8-routing` directory.
24
24
25
25
{{% tabs %}}
26
26
{{% tab title="Compacted JSON" %}}
@@ -100,27 +100,29 @@ To test your configuration, you need to generate span data with the correct `Res
Make sure the are **NO**`*.out` files in the `[WORKSHOP]/8-routing`folder.
103
+
Before proceeding, ensure that there are no`*.out` files in the `[WORKSHOP]/8-routing`directory.
104
104
105
105
-**Send a Regular Span**:
106
-
Find your `Test` terminal window and navigate to the `[WORKSHOP]/8-routing` folder. From there, send a regular span using the `trace.json` file to confirm that communication is functioning as expected.
107
-
Both the `agent` and `gateway` should display debug information, including the span you just sent. Additionally, the gateway should generate a new `gateway-traces-default.out` file, as this is now the destination for regular spans.
106
+
1. Open your test terminal and navigate to the `[WORKSHOP]/8-routing` directory.
107
+
2. Send a regular span using the `trace.json` file to confirm proper communication.
108
+
109
+
Both the `agent` and `gateway` should display debug information, including the span you just sent. The gateway will also generate a new `gateway-traces-default.out` file, as this is now the designated destination for regular spans.
If you check `gateway-traces-default.out`, it should contain the `span` sent using the `cURL` command. You will also see an empty `gateway-traces-security.out` file, as the routing configuration creates output files immediately, even if no matching spans have been processed yet.
111
113
{{% /notice %}}
112
114
113
115
-**Send a Security Span**:
114
-
Make sure both the `agent` and `gateway` are running, then send a security span using the `security.json` file to test the routing rule in the gateway.
115
-
Both the `agent` and `gateway` should display debug information, including the span you just sent. Additionally, the gateway should write a line to the `gateway-traces-security.out` file, as this is the destination for spans where the `deployment.environment` resourceSpan attribute matches `"security_applications"`.
116
+
1. Ensure both the `agent` and `gateway` are running.
117
+
2. Send a security span using the `security.json` file to test the gateway’s routing rule.
118
+
119
+
Again, both the `agent` and `gateway` should display debug information, including the span you just sent. This time, the `gateway` will write a line to the `gateway-traces-security.out` file, which is designated for spans where the `deployment.environment` resource attribute matches `"security_applications"`.
If you verify the `./gateway-traces-security.out`is should only contain the spans from the `"security_applications"` deployment.environment.
122
+
If you verify the `./gateway-traces-security.out`it should only contain the spans from the `"security_applications"` deployment.environment.
119
123
{{% /notice %}}
120
124
121
-
You can repeat this scenario multiple times, and each trace should be written to its corresponding output file.
122
-
123
-
125
+
You can repeat this scenario multiple times, and each trace will be written to its corresponding output file.
124
126
{{% /notice %}}
125
127
126
128
### Conclusion
@@ -135,6 +137,6 @@ By inspecting the output files, we confirmed that the OpenTelemetry Collector *c
135
137
136
138
You can now extend this approach by defining additional routing rules to further categorize spans, metrics, and logs based on different attributes.
137
139
138
-
If you want to know more about the `routing` connector, you can find it [here](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector)
140
+
If you want to know more about the `routing` connector, you can find it [here](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector)
139
141
140
-
Stop the `agent` and `gateway` using Command-c/Ctrl-c.
Copy file name to clipboardExpand all lines: content/en/ninja-workshops/10-advanced-otel/80-routing/_index.md
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,11 +35,10 @@ WORKSHOP
35
35
36
36
{{% /tab %}}
37
37
38
-
Open the `gateway.yaml`and add the following configuration:
38
+
In the following exercise, you will configure the `routing connector` in the `gateway.yaml`file. This setup will enable the `gateway` to route traces based on the `deployment.environment` attribute in the spans you send. By doing so, you can process and handle traces differently depending on their attributes.
In this exercise, you will configure the `routing connector` in the `gateway.yaml` file. This setup will enable the `gateway` to route traces based on the `deployment.environment` attribute in the spans you send. By doing so, you can process and handle traces differently depending on their attributes.
41
+
Open the `gateway.yaml` and add the following configuration:
43
42
44
43
-**Add the `connectors:` section**:
45
44
In OpenTelemetry configuration files, `connectors` have their own dedicated section, similar to receivers and processors. In the `gateway.yaml`file, insert the `connectors:` section below the receivers section and above the processors section.
@@ -53,8 +52,9 @@ In OpenTelemetry configuration files, `connectors` have their own dedicated sect
53
52
```
54
53
55
54
-**Add the `routing` connector**:
56
-
We are setting up a `resourceSpans` attribute rule. In this configuration, spans will be routed if the `deployment.environment` resourceSpan attribute matches `"security_applications"`.
57
-
This same approach can also be applied to `metrics` and `logs`, allowing you to route them based on attributes in `resourceMetrics` or `resourceLogs` in a similar way. Add the following under the `connectors:` section:
55
+
In this configuration, spans will be routed if the `deployment.environment` resource attribute matches `"security_applications"`.
56
+
57
+
This same approach can also be applied to `metrics` and `logs`, allowing you to route them based on attributes in `resourceMetrics` or `resourceLogs` similarly. Add the following under the `connectors:` section:
58
58
59
59
```yaml
60
60
routing:
@@ -101,17 +101,16 @@ To enable routing we need to define two pipelines for traces:
101
101
102
102
```yaml
103
103
pipelines:
104
-
#traces:
105
-
#traces/standard:
104
+
#traces:
105
+
#traces/standard:
106
106
traces/security: # Array of Trace Receivers
107
107
receivers: [routing] # Only receives spans from the routing connector
108
108
processors:
109
109
- memory_limiter
110
110
- resource/add_mode
111
111
exporters: [file/traces/security] # Location for spans matching rule
112
-
#metrics:
112
+
#metrics:
113
113
```
114
-
115
114
116
115
- **Update the `traces` pipeline to handle routing**:
117
116
To enable `routing`, you need to update the original `traces` pipeline by adding `routing` as an exporter. This will send your span data through the `routing connector` for evaluation.
0 commit comments