8. Routing Data

10 minutes  

The Routing Connector in OpenTelemetry is a powerful feature that allows you to direct data (traces, metrics, or logs) to different pipelines based on specific criteria. This is especially useful in scenarios where you want to apply different processing or exporting logic to subsets of your telemetry data.

For example, you might want to send production data to one exporter while directing test or development data to another. Similarly, you could route certain spans based on their attributes, such as service name, environment, or span name, to apply custom processing or storage logic.

Exercise
  • Inside the [WORKSHOP] directory, create a new subdirectory named 8-routing.
  • Next, copy all contents from the 7-transform-data directory into 8-routing.
  • After copying, remove any *.out and *.log files.
  • Change all terminal windows to the [WORKSHOP]/8-routing directory.

Your updated directory structure will now look like this:

WORKSHOP
β”œβ”€β”€ 1-agent
β”œβ”€β”€ 2-gateway
β”œβ”€β”€ 3-filelog
β”œβ”€β”€ 4-resilience
β”œβ”€β”€ 5-dropping-spans
β”œβ”€β”€ 6-sensitive-data
β”œβ”€β”€ 7-transform-data
β”œβ”€β”€ 8-routing
β”‚   β”œβ”€β”€β”€checkpoint-dir
β”‚   β”œβ”€β”€ agent.yaml
β”‚   β”œβ”€β”€ health.json
β”‚   β”œβ”€β”€ gateway.yaml
β”‚   β”œβ”€β”€ log-gen.sh (or .ps1)
β”‚Β Β  └── trace.json
└── otelcol

Next, we will configure the routing connector and the respective pipelines.