Configuring OTel for multiple observability backends
Overview​
With Multiplayer’s System Architecture Observability functionality (Radar) you can automatically discover, track, and detect drift in your system architecture, dependencies and APIs by directly connecting to your infrastructure.
Radar leverages OpenTelemetry (OTel) to receive, process, and export telemetry data from your system.
Your approach to implementing the Multiplayer OTel integration will be slightly different depending on your current use of OTel.
If you’ll be using OTel to send telemetry data to a single observability backend (Multiplayer), would only need to add these two environment variables.
If you’ll be using OTel to send telemetry data to multiple observability backends, you would need to follow these steps.
Configuring OTel for multiple observability backends​
After you have set up OTel and initialized the Tracer Provider, you’ll need to:
- Define and Configure Exporters: Exporters send collected telemetry data to observability backends. You’ll need one exporter for Multiplayer and one (or more) for other backends.
- Add Span Processors: These handle the export of collected spans (individual operations being traced) to the configured exporters.
- Set the Provider and Propagator: This ensures that the tracer and context propagation are used globally in your application.
- Initialize the SDK: This step initializes the OTel SDK with the desired instrumentation (automatic tracing for supported libraries).
Here is an example:
const provider = new node.NodeTracerProvider({
resource: getResource(),
sampler: new ParentBasedSampler({
root: new TraceIdRatioBasedSampler(OTEL_TRACES_SAMPLER_ARG),
}),
})
const traceExporter1 = new OTLPTraceExporter({
url: 'https://api.multiplayer.app/v1/traces',
headers: {
Authorization: '{{Multiplayer_token}}',
},
})
provider.addSpanProcessor(new BatchSpanProcessor(traceExporter1))
const traceExporter2 = new OTLPTraceExporter({
url: 'https://{{SOME_COLLECTOR}}/v1/traces',
headers: {
some_header: 'some_value',
},
})
provider.addSpanProcessor(new BatchSpanProcessor(traceExporter2))
provider.register()
api.trace.setGlobalTracerProvider(provider)
api.propagation.setGlobalPropagator(
new W3CTraceContextPropagator(),
)
const sdk = new NodeSDK({
instrumentations,
})
sdk.start()
Key points to keep in mind:
- Configuration of Multiple Exporters:
- The
traceExporter1
sends data to Multiplayer's endpoint with an authorization token. - The
traceExporter2
sends data to another collector with specific headers.
- The
- Provider and Span Processors:
- The
NodeTracerProvider
is configured with a sampling strategy. - Span processors (
BatchSpanProcessor
) are added to handle the export of spans to the configured exporters.
- The
- Global Registration:
- The tracer provider and propagator are set globally to ensure all telemetry data adheres to the specified configuration.
const traceExporter1 = new OTLPTraceExporter({
url: 'https://api.multiplayer.app/v1/traces',
headers: {
Authorization: '{{Multiplayer_token}}',
},
})
provider.addSpanProcessor(new BatchSpanProcessor(traceExporter1))
const traceExporter2 = new OTLPTraceExporter({
url: 'https://{{SOME_COLLECTOR}}/v1/traces',
headers: {
some_header: 'some_value',
},
})
provider.addSpanProcessor(new BatchSpanProcessor(traceExporter2))
Next Steps​
You did it! What’s next?