# Source: https://docs.datadoghq.com/tracing/trace_collection/span_links.md

---
title: Span Links
description: >-
  Correlate spans across traces and operations using OpenTelemetry span links
  for complex distributed system workflows.
breadcrumbs: Docs > APM > Application Instrumentation > Span Links
---

# Span Links

{% image
   source="https://datadog-docs.imgix.net/images/tracing/span_links/span_links_tab_2.3e7409ef1ab88eb6d387aff1190b4ca0.png?auto=format"
   alt="Span Links tab" /%}

## Overview{% #overview %}

Span links are an [OpenTelemetry concept](https://opentelemetry.io/docs/concepts/signals/traces/#span-links) and a part of the [OpenTelemetry Tracing API](https://opentelemetry.io/docs/specs/otel/trace/api/#link). Datadog supports span links for:

- Applications instrumented with [OpenTelemetry SDKs](https://opentelemetry.io/docs/specs/otel/trace/sdk/).
- Applications instrumented with [Datadog SDKs](https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/?tab=datadogapi).

Span links correlate one or more spans together that are causally related but don't have a typical parent-child relationship. These links may correlate spans within the same trace or across different traces.

Span links help trace operations in distributed systems, where workflows often deviate from linear execution patterns. They are useful to trace the flow of operations in systems that execute requests in batches or process events asynchronously.

Datadog supports both forward and backward span links, allowing users to visualize and navigate span relationships across traces in both directions.

- Forward Links: A span can be linked to another span that occurs later in time, whether it belongs to the same trace or a different one. This enables you to navigate from earlier operations to subsequent ones across traces.
- Backward Links: Similarly, a span can be linked to a span that occurred earlier in time, either within the same trace or across different traces. This allows you to trace back from later operations to previous ones.

## Common use cases{% #common-use-cases %}

Span links are most applicable in fan-in scenarios, where multiple operations converge into a single span. The single span links back to multiple converging operations.

For example:

- **Scatter-Gather and Map-Reduce**: Here, span links trace and correlate multiple parallel processes that converge into a single combined process. They connect the results of these parallel processes to their collective outcome.

- **Message Aggregation**: In systems like Kafka Streams, span links connect each message in a group of messages to their aggregated result, showing how individual messages contribute to the final output.

- **Transactional Messaging**: In scenarios where multiple messages are part of a single transaction, such as in message queues, span links trace the relationship between each message and the overarching transactional process.

- **Event Sourcing**: Span links in event sourcing track how multiple change messages contribute to the current state of an entity.

## Creating span links{% #creating-span-links %}

If your application is instrumented with:

- The OpenTelemetry SDK, follow the OpenTelemetry manual instrumentation documentation for your language. For example, [Create spans with links for Java](https://opentelemetry.io/docs/instrumentation/java/manual/#create-spans-with-links).
- The Datadog SDK, follow the [Adding span links](https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/php/#adding-span-links) examples.

## Minimum support{% #minimum-support %}

**Note**\*: This section documents minimum support for generating span links with Datadog APM client libraries (with the OpenTelemetry API). Span links generated by the OpenTelemetry SDK are sent to Datadog through [OTLP Ingest](https://docs.datadoghq.com/opentelemetry/interoperability/otlp_ingest_in_the_agent).

Agent v7.52.0 or greater is required to generate span links using [Datadog tracing libraries](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/). Support for span links was introduced in the following releases:

| Language  | Minimum tracing library version |
| --------- | ------------------------------- |
| C++/Proxy | Not yet supported               |
| Go        | 1.61.0                          |
| Java      | 1.26.0                          |
| .NET      | 2.53.0                          |
| Node      | 5.3.0                           |
| PHP       | 0.97.0                          |
| Python    | 2.5.0                           |
| Ruby      | 2.0.0                           |

## Viewing span links{% #viewing-span-links %}

You can view span links from the [Trace Explorer](https://docs.datadoghq.com/tracing/trace_explorer/trace_view/?tab=spanlinks#more-information) in Datadog.

## Further reading{% #further-reading %}

- [OpenTelemetry Span Links](https://opentelemetry.io/docs/concepts/signals/traces/#span-links)
- [Custom Instrumentation with the OpenTelemetry API](https://docs.datadoghq.com/tracing/trace_collection/otel_instrumentation/)
- [Custom Instrumentation with Datadog Libraries](https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/)