---
title: "Span Trace Propagation"
url: https://develop.sentry.dev/sdk/telemetry/spans/span-trace-propagation/
---

# Span Trace Propagation

🚧 This document is work in progress.

This document uses key words such as "MUST", "SHOULD", and "MAY" as defined in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt) to indicate requirement levels.

## [Continue an incoming trace](https://develop.sentry.dev/sdk/telemetry/spans/span-trace-propagation.md#continue-an-incoming-trace)

To continue a trace from an upstream service, the SDK must expose a method to extract the traceparent and baggage information and apply these to the applicable scope. The method MUST NOT create a new segment span on its own.

```js
Sentry.continueTrace({
  sentryTrace: request.headers['sentry-trace'],
  baggage: request.headers['baggage'],
}, () => {
  Sentry.startSpan({ name: 'test' }, () => {
    // ....
  });
})
```

Newly created root spans should now contain these properties, such as `trace_id` and `parent_span_id`.

The exact function signature of the `continueTrace` function depends on what's canonical in your SDK. It MAY require explicitly passing `sentry-trace` and `baggage`, or it MAY allow providing a dictionary of headers/environment variables.

## [Continue an outgoing trace](https://develop.sentry.dev/sdk/telemetry/spans/span-trace-propagation.md#continue-an-outgoing-trace)

To propagate a trace to a downstream service, the SDK MUST expose methods to fetch the required information to allow the next service to continue the trace.

```js
const traceData = Sentry.getTraceData()
```

## [Starting a new trace](https://develop.sentry.dev/sdk/telemetry/spans/span-trace-propagation.md#starting-a-new-trace)

The SDK MUST offer a method to clear trace propagation data, allowing to create spans with a fresh new trace.

```js
Sentry.startNewTrace(() => {
  Sentry.startSpan({ name: 'segment under trace 1' }, () => {...});
})

Sentry.startNewTrace(() => {
  Sentry.startSpan({ name: 'segment under trace 2' }, () => {...});
})
```
