Skip to main content
Trace propagation enables distributed tracing by passing trace context between services, processes, and systems.

Overview

Propagation involves:
  • Extracting trace context from incoming requests
  • Injecting trace context into outgoing requests
  • Maintaining parent-child relationships across services
  • Preserving sampling decisions

Trace Headers

sentry-trace

The primary header for Sentry tracing: Format: {trace_id}-{span_id}-{sampled}
  • trace_id: 32 hex characters (128 bits)
  • span_id: 16 hex characters (64 bits)
  • sampled: 1 (sampled) or 0 (not sampled)

baggage

Contains dynamic sampling context: Format: Key-value pairs separated by commas

traceparent (W3C)

Optional W3C Trace Context standard: Format: {version}-{trace_id}-{parent_id}-{flags}

Automatic Propagation

Sentry automatically propagates traces for HTTP requests:

tracePropagationTargets

Control which outgoing requests receive tracing headers:
Default Behavior:
  • Node.js: All outgoing requests
  • Browser: Same-origin requests only

Manual Propagation

Outgoing Requests

Incoming Requests

continueTrace

Continue a trace from incoming headers:
string
The sentry-trace header value.
string | string[]
The baggage header value(s).
function
required
Function to execute with the continued trace.
Example:

Cross-Service Tracing

Service A (Origin)

Service B (Receiver)

W3C Trace Context

Enable W3C traceparent header:
CORS Considerations: When enabling traceparent, ensure your server allows it:

Browser Propagation

Server-Side Rendering

Pass trace context from server to browser:

Client-Side

Message Queues

Propagate traces through async message queues:

Producer

Consumer

Database Connections

Propagate context through database operations:

Organization-Based Trace Continuation

Limit trace continuation to same organization:

Custom Propagation

Implement custom propagation logic:

Best Practices

1. Always Propagate Sampled Traces

2. Handle Missing Headers Gracefully

3. Be Careful with CORS

4. Validate Incoming Headers