Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
8.46.0
Framework Version
NextJS 15.1.1
Link to Sentry event
N/A
Reproduction Example/SDK Setup
Clone my repro: https://github.com/Lms24/nextjs-trace-envelope-header
Steps to Reproduce
To reproduce:
npm install
npm run build && npm run start
sh req.sh
Observe that trace_id, sample_rate and transaction fields (+others) are not continued from incoming trace (see req.sh
). Meaning, it seems like the NextJS SDK starts a new trace for the server-side instead of continuing the passed trace via the headers.
Expected Result
- The SDK continues the incoming trace, freezes the DSC values passed in via
baggage
- When sending its transaction event, the SDK puts the frozen DSC values into the
trace
envelope header and sends the continued trace data inevent.context.trace
Actual Result
- The SDK doesn't continue the incoming trace but seems to start a new trace
- When sending its transaction event, SDK populates the DSC from the new trace and sends the new trace
Additional information
The logs suggest that there might be 2 ongoing root spans which possibly(?) conflict with each other?
Sentry Logger [log]: [Tracing] Inheriting remote parent's sampled decision for GET /api/test: true
Sentry Logger [log]: [Tracing] Starting sampled root span
op: < unknown op >
name: GET /api/test
ID: 6d6d1a6095cd996c
parent ID: 9a124d0d6c081115
Sentry Logger [log]: [Tracing] Inheriting parent's sampled decision for executing api route (pages) /api/test: true
Sentry Logger [log]: [Tracing] Starting sampled span
op: < unknown op >
name: executing api route (pages) /api/test
ID: 134e7d6841094ac1
parent ID: 6d6d1a6095cd996c
root ID: 6d6d1a6095cd996c
root description: GET /api/test
Sentry Logger [info]: Starting a new trace with id 1f225918b9444512867b7f0fed977fa5
Sentry Logger [log]: [Tracing] Starting sampled root span
op: http.server
name: GET /api/test
ID: dfd3fc2e5a4b4818
Sentry Logger [log]: [Tracing] Finishing "http.server" root span "GET /api/test" with ID dfd3fc2e5a4b4818
Sentry Logger [log]: Flushing events...
Sentry Logger [log]: SpanExporter exported 1 spans, 0 spans are waiting for their parent spans to finish
Sentry Logger [log]: Flushing outcomes...
Sentry Logger [log]: No outcomes to send
Sentry Logger [log]: [Tracing] Finishing "< unknown op >" span "executing api route (pages) /api/test" with ID 134e7d6841094ac1
Sentry Logger [log]: [Tracing] Finishing "< unknown op >" root span "GET /api/test" with ID 6d6d1a6095cd996c
Sentry Logger [log]: SpanExporter exported 2 spans, 0 spans are waiting for their parent spans to finish
event trace context: {
span_id: 'dfd3fc2e5a4b4818',
trace_id: '2f656955b869439a0f839731c22cc4eb',
data: {
'sentry.source': 'route',
'sentry.sample_rate': 0.99,
'sentry.op': 'http.server',
'sentry.origin': 'auto.http.nextjs',
'http.response.status_code': 200
},
origin: 'auto.http.nextjs',
op: 'http.server',
status: 'ok'
}
{
envelopeTraceHeader: {
environment: 'production',
release: '0UzErXa-sfDtF-53wmU7x',
public_key: 'c64221a14c2b788162c7b81c2f94d65e',
trace_id: '2f656955b869439a0f839731c22cc4eb',
sample_rate: '0.99',
transaction: 'GET /api/test',
sampled: 'true'
}
}
Sentry Logger [log]: Event processor "NextLowQualityTransactionsFilter" dropped event
Sentry Logger [log]: Recording outcome: "event_processor:transaction"
Sentry Logger [log]: An event processor returned `null`, will not send event.
Sentry Logger [log]: Done flushing events