Back to Node Newrelic

Span Links

documentation/internals/span-links.md

13.19.21.4 KB
Original Source

Span Links

Span links are supported in our agent primarily to support the propagation of span link metadata from Open Telemetry instrumentations. A span link describes how to link an entity to the transaction that produced it. This is most common in distributed messaging systems:

  1. A system will generate a message and post it to something like RabbitMQ.
  2. The posting happens in a unique transaction.
  3. Another part of the system will monitor the queue for messages.
  4. Retrieving messages from the queue happens in a unique transaction.
  5. Retrieved messages could be from multiple different transactions.
  6. The span link data associated with each retrieved message relates the message back to the unique transaction that originally posted it.

Implementation

  1. lib/otel/traces/segment-synthesis: The final step of the synthesize method attaches links to the current trace segment.
  2. lib/spans/span-event: The createSpan method propagates links from the trace segment to the span.
  3. lib/spans/span-event-aggregator: The _toPayloadSync method injects span links into the events data subsequent to the span they are attached to.

The _toPayloadSync method is what is invoked at harvest time. The result is the data structure that is sent to the collector.