-
Notifications
You must be signed in to change notification settings - Fork 423
Description
Open Telemetry defines the concept of "span links." Span links are metadata that tie a message entity to the span that generated them. Consider a message queuing system like Amazon SQS. In such a system, an application can post one or many messages at once. This posting will occur in one or multiple transactions. Another, or the same, application may then retrieve messages from this queue, typically as a batch of messages. The order in which the messages are retrieved is not guaranteed; which is to say, one retrieval may include messages that were generated from multiple different transactions. These messages will include metadata that details the transaction identifiers. This metadata should then be used to "link" the messages back to their original transaction just as a baseline distributed trace between synchronous services does.
We need to update our OTEL support to recognize spans that have been tagged with span link data, and replicate it through our standard New Relic system through attribute mapping.
We map OTEL spans to NR spans in:
node-newrelic/lib/otel/traces/segment-synthesis.js
Lines 37 to 65 in e383c4e
| switch (rule.type) { | |
| case 'consumer': { | |
| return createConsumerSegment(this.agent, otelSpan, rule) | |
| } | |
| case 'db': { | |
| return createDbSegment(this.agent, otelSpan, rule) | |
| } | |
| case 'external': { | |
| return createHttpExternalSegment(this.agent, otelSpan, rule, this.logger) | |
| } | |
| case 'internal': { | |
| return createInternalSegment(this.agent, otelSpan, rule) | |
| } | |
| case 'producer': { | |
| return createProducerSegment(this.agent, otelSpan, rule) | |
| } | |
| case 'server': { | |
| return createServerSegment(this.agent, otelSpan, rule) | |
| } | |
| default: { | |
| this.logger.debug('Found type: %s, no synthesis rule currently built', rule.type) | |
| } | |
| } |
OTEL spans that have link data have a .links property set to an array of links. See:
- https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_sdk-node.node.ReadableSpan.html
- https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_sdk-node._opentelemetry_api.Link.html
Utilizing that information, we will update the NR span with the following attributes:
type(string): must be set toSpanLink.timestamp(number): milliseconds epoch relative. Given that the interface for aLinkdoes not specify a timestamp field being available, this must be derived from thestartTimeof the containingSpan.id(string): the identifier of the containingSpan(span.context.spanId).trace.id(string): the trace identifier of the containingSpan(span.context.traceId).linkedSpanId(string): the linked span identifier of the upstream span (e.g.span.links[0].context.spanId).linkedTraceId(string): the linked span trace identifier of the upstream span (e.g.span.links[0].context.traceId).
Any attributes defined on the link may be added as custom attributes, e.g. span.links[0].attributes.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status