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
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.
Open the `gateway.yaml` and add the following configuration:
11
+
12
+
-**Add the `connectors:` section**:
13
+
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.
14
+
15
+
```yaml
16
+
connectors: # Section to configure connectors
17
+
18
+
processors:
19
+
20
+
```
21
+
22
+
-**Add the `routing` connector**:
23
+
In this configuration, spans will be routed if the `deployment.environment` resource attribute matches `"security_applications"`.
24
+
25
+
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:
26
+
27
+
```yaml
28
+
routing:
29
+
default_pipelines: [traces/standard] # Default pipeline to use if no matching rule
30
+
error_mode: ignore # Ignore errors in the routing
31
+
table: # Array with routing rules
32
+
# Connector will route any span to target pipeline if if the resourceSpn attribute matches this rule
33
+
- statement: route() where attributes["deployment.environment"] == "security_applications"
34
+
pipelines: [traces/security] # Target pipeline
35
+
```
36
+
37
+
- **Configure two `file:` Exporters**:
38
+
The `routing connector` requires different targets for routing. To achieve this, update the default `file/traces:` exporter and name it `file/traces/default:` and add a second file exporter called `file/traces/security:`. This will allow the routing connector to direct data to the appropriate target based on the rules you define.
-**Add both the `standard` and `security` traces pipelines**:
9
+
10
+
1.**Standard** pipeline: This pipeline will handle all spans that do not match the routing rule. Add it below the regular `traces:` pipeline, and leave the configuration unchanged for now.
11
+
12
+
```yaml
13
+
pipelines:
14
+
traces/standard: # New Default Traces/Spans Pipeline
15
+
receivers:
16
+
- routing # Routing Connector, Only receives data from Connector
- file/traces/security # File Exporter for spans matching rule
38
+
```
39
+
40
+
- **Update the `traces` pipeline to handle routing**: To enable `routing`, update the original `traces:` pipeline by adding `routing` as an exporter. This ensures that all span data is sent through the routing connector for evaluation.
41
+
42
+
For clarity, we are removing the `debug` exporter from this pipeline, so that debug output is only shown from the new exporters behind the routing connector.
43
+
44
+
```yaml
45
+
pipelines:
46
+
traces: # Original traces pipeline
47
+
receivers:
48
+
- otlp # Debug Exporter
49
+
exporters:
50
+
- routing # Routing Connector, Only exports data to Connector
Keep in mind that any existing processors have been removed from this pipeline. They are now handled by either the standard pipeline or the target pipelines, depending on the routing rules.
56
+
57
+
Additionally, the `batch` processor has been removed from the new pipelines. This ensures that `spans` are written immediately, rather than waiting for multiple spans to arrive before processing. This change speeds up the workshop and allows you to see results faster.
58
+
{{% /notice %}}
59
+
60
+
{{% /notice %}}
61
+
62
+
Again, validate the **Gateway** configuration using `otelbin.io` for spelling mistakes etc. Your `Traces:` pipeline should like this:
Copy file name to clipboardExpand all lines: content/en/ninja-workshops/10-advanced-otel/8-routing/_index.md
+1-149Lines changed: 1 addition & 149 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,152 +35,4 @@ WORKSHOP
35
35
36
36
{{% /tab %}}
37
37
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.
Open the `gateway.yaml` and add the following configuration:
42
-
43
-
-**Add the `connectors:` section**:
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.
45
-
46
-
```yaml
47
-
connectors: # Section to configure connectors
48
-
49
-
processors:
50
-
51
-
```
52
-
53
-
-**Add the `routing` connector**:
54
-
In this configuration, spans will be routed if the `deployment.environment` resource attribute matches `"security_applications"`.
55
-
56
-
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:
57
-
58
-
```yaml
59
-
routing:
60
-
default_pipelines: [traces/standard] # Default pipeline to use if no matching rule
61
-
error_mode: ignore # Ignore errors in the routing
62
-
table: # Array with routing rules
63
-
# Connector will route any span to target pipeline if if the resourceSpn attribute matches this rule
64
-
- statement: route() where attributes["deployment.environment"] == "security_applications"
65
-
pipelines: [traces/security] # Target pipeline
66
-
```
67
-
68
-
- **Configure two `file:` Exporters**:
69
-
The `routing connector` requires different targets for routing. To achieve this, update the default `file/traces:` exporter and name it `file/traces/default:` and add a second file exporter called `file/traces/security:`. This will allow the routing connector to direct data to the appropriate target based on the rules you define.
# Path where trace data will be saved in OTLP json format
78
-
path: "./gateway-traces-security.out"
79
-
append: false # Overwrite the file each time
80
-
```
81
-
82
-
- **Add both the `standard` and `security` traces pipelines**:
83
-
84
-
1. **Standard** pipeline: This pipeline will handle all spans that do not match the routing rule. Add it below the regular `traces:` pipeline, and leave the configuration unchanged for now.
85
-
86
-
```yaml
87
-
pipelines:
88
-
traces/standard: # New Default Traces/Spans Pipeline
89
-
receivers:
90
-
- routing # Routing Connector, Only receives data from Connector
- file/traces/security # File Exporter for spans matching rule
112
-
```
113
-
114
-
- **Update the `traces` pipeline to handle routing**: To enable `routing`, update the original `traces:` pipeline by adding `routing` as an exporter. This ensures that all span data is sent through the routing connector for evaluation.
115
-
116
-
For clarity, we are removing the `debug` exporter from this pipeline, so that debug output is only shown from the new exporters behind the routing connector.
117
-
118
-
```yaml
119
-
pipelines:
120
-
traces: # Original traces pipeline
121
-
receivers:
122
-
- otlp # Debug Exporter
123
-
exporters:
124
-
- routing # Routing Connector, Only exports data to Connector
Keep in mind that any existing processors have been removed from this pipeline. They are now handled by either the standard pipeline or the target pipelines, depending on the routing rules.
130
-
131
-
Additionally, the `batch` processor has been removed from the new pipelines. This ensures that `spans` are written immediately, rather than waiting for multiple spans to arrive before processing. This change speeds up the workshop and allows you to see results faster.
132
-
{{% /notice %}}
133
-
134
-
{{% /notice %}}
135
-
136
-
Again, validate the **Gateway** configuration using `otelbin.io` for spelling mistakes etc. Your `Traces:` pipeline should like this:
0 commit comments