Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
10.45.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
https://codesandbox.io/p/devbox/vigilant-rain-9f43ql?file=%2Findex.mjs
importcryptofrom"node:crypto";import*asSentryfrom"@sentry/node";Sentry.init({tracesSampleRate: 1.0,});// sequential spans inside startNewTrace get different trace IDsawaitSentry.startNewTrace(async()=>{constspan1=Sentry.startInactiveSpan({op: "step.one",name: "Step One"});consttraceId1=span1.spanContext().traceId;span1.end();constspan2=Sentry.startInactiveSpan({op: "step.two",name: "Step Two"});consttraceId2=span2.spanContext().traceId;span2.end();console.log("startNewTrace:");console.log(" span1 traceId:",traceId1);console.log(" span2 traceId:",traceId2);console.log(" same trace:",traceId1===traceId2,"(expected true)");});// Workaround: continueTrace with a self-generated sentryTrace headerawaitSentry.continueTrace({sentryTrace: `${crypto.randomBytes(16).toString("hex")}-${crypto.randomBytes(8).toString("hex")}-1`,baggage: undefined,},async()=>{constspan1=Sentry.startInactiveSpan({op: "step.one",name: "Step One",});consttraceId1=span1.spanContext().traceId;span1.end();constspan2=Sentry.startInactiveSpan({op: "step.two",name: "Step Two",});consttraceId2=span2.spanContext().traceId;span2.end();console.log("\ncontinueTrace (workaround):");console.log(" span1 traceId:",traceId1);console.log(" span2 traceId:",traceId2);console.log(" same trace:",traceId1===traceId2,"(expected true)");},);awaitSentry.close();Steps to Reproduce
Run the provided js snippet in node with @sentry/node@10.45.0
Expected Result
All spans in the startNewTrace callback should share the same trace
Actual Result
Each span is assigned a new trace
Additional Context
I encountered this while trying to group a series of spans under a manually created trace. Used Claude to help debug and create this repro, the workaround is something I came up with that seemed to work but felt unintended.
Happy to provide any other information if needed.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
10.45.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
https://codesandbox.io/p/devbox/vigilant-rain-9f43ql?file=%2Findex.mjs
Steps to Reproduce
Run the provided js snippet in node with
@sentry/node@10.45.0Expected Result
All spans in the
startNewTracecallback should share the same traceActual Result
Each span is assigned a new trace
Additional Context
I encountered this while trying to group a series of spans under a manually created trace. Used Claude to help debug and create this repro, the workaround is something I came up with that seemed to work but felt unintended.
Happy to provide any other information if needed.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it.