OpenTelemetry provides a rich tracing ecosystem, with an API for recording trace telemetry, an SDK for exporting span data, and context propagation for tracing across application boundaries.
This page describes how New Relic handles OpenTelemetry spans it receives via the New Relic OTLP endpoint. To send OpenTelemetry traces to New Relic, you'll need to configure your trace source to export data to the New Relic OpenTelemetry Collector via the OTLP endpoint. See the following pages:
- For endpoint configuration requirements, see New Relic OTLP endpoint.
- For instructions to configure services with OpenTelemetry, see OpenTelemetry APM monitoring.
OTLP span mapping
New Relic maps OTLP spans to the Span data type. The table below describes how fields from the trace proto message definitions are interpreted:
OTLP proto field | New Relic |
|---|---|
| Each key/value is an attribute on the |
|
|
|
|
| Each key/value is an attribute on the |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Each key/value is an attribute on the |
|
|
| Each event is recorded as a |
| Stored as |
| Stored as |
| Each key/value is stored as an attribute on |
| Stored as |
|
|
|
|
|
|
Table footnotes
[1] In case of conflict in resource attributes, scope attributes, span attributes, and top level span fields, the order of precedent (highest to lowest) is the top level Span.* fields > Span.attributes > ScopeSpans.InstrumentationScope.attributes > ResourceSpans.Resource.attributes.
See OTLP attribute types for details on New Relic OTLP endpoint supported attribute types and OTLP attribute limits for details on validation performed on attributes.
Span links
New Relic supports OpenTelemetry span links, which allow you to create causal relationships between spans that don't have a direct parent-child connection. Span links are essential for understanding distributed traces that get split across asynchronous boundaries like message queues, event streams, and batch processing systems.
When to use span links
Use span links in the following scenarios:
- Message queue producers and consumers: Link a consuming span back to the producing span when processing messages from queues like AWS SQS, RabbitMQ, or Kafka.
- Fan-in patterns: Link multiple producer traces to a single consumer trace that aggregates their outputs.
- Batch processing: Link spans that process batched messages back to their individual originating traces.
- Long-running workflows: Connect spans across workflow steps that exceed normal trace duration limits.
Implementing span links
To implement span links in your OpenTelemetry instrumentation, you need to:
- Extract trace context from the incoming message or event
- Create a span link when starting a new span in the consumer
- Ensure trace context is propagated through your messaging infrastructure
The following examples show how to implement span links in different languages:
Best practices for span links
When implementing span links, follow these best practices:
Always propagate trace context: Ensure W3C trace context (
traceparentandtracestateheaders) are included in message headers or metadata.Validate span context: Always check if the extracted span context is valid before creating a span link. Invalid contexts should not create links.
Use appropriate span kinds: Set
PRODUCERkind for message publishing spans andCONSUMERkind for message processing spans.Add messaging attributes: Include semantic conventions for messaging systems (like
messaging.system,messaging.destination,messaging.operation) to provide context.Consider sampling: Both linked traces must be sampled to appear in New Relic. Adjust sampling strategies for critical workflows that use span links.
Handle batch processing carefully: When processing batched messages, create individual span links for each message to maintain traceability.
Viewing span links in New Relic
Once you've implemented span links in your instrumentation, you can view and navigate them in the New Relic UI:
- Navigate to the trace details page for a trace
- Look for the span links badge in the filter bar showing the number of spans with links
- Select a span with links to see the Span links tab in the span details pane
- Click on linked traces to navigate between related traces
For detailed information on using span links in the UI, see Understanding span links.