Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(node): Add test verifying startNewTrace respects tracesSampleRate
Ensures TraceFlags.NONE on the remote span context does not cause
the sampler to inherit a false sampling decision from the parent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
  • Loading branch information
logaretm and claude committed Mar 26, 2026
commit 46e1ab924f646068ba46d8378d720208dd47e32a
11 changes: 11 additions & 0 deletions packages/opentelemetry/test/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,17 @@ describe('startNewTrace', () => {
});
});
Comment thread
logaretm marked this conversation as resolved.

it('allows spans to be sampled based on tracesSampleRate', () => {
startNewTrace(() => {
const span = startInactiveSpan({ name: 'sampled-span' });
// tracesSampleRate is 1 in mockSdkInit, so spans should be sampled
// This verifies that TraceFlags.NONE on the remote span context does not
// cause the sampler to inherit a "not sampled" decision from the parent
expect(spanIsSampled(span)).toBe(true);
span.end();
});
});

it('does not leak the new traceId to the outer scope', () => {
const outerPropagationContext = getCurrentScope().getPropagationContext();
const outerTraceId = outerPropagationContext.traceId;
Expand Down