Skip to content

Commit e379e59

Browse files
dyladanvmarchaud
andauthored
fix: use invalid parent for sampler when options.root (#2185)
Co-authored-by: Valentin Marchaud <[email protected]>
1 parent 3f82ff4 commit e379e59

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/opentelemetry-tracing/src/Tracer.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import * as api from '@opentelemetry/api';
1818
import {
19-
InstrumentationLibrary,
2019
IdGenerator,
20+
InstrumentationLibrary,
2121
RandomIdGenerator,
2222
sanitizeAttributes,
2323
} from '@opentelemetry/core';
@@ -87,7 +87,9 @@ export class Tracer implements api.Tracer {
8787
const attributes = sanitizeAttributes(options.attributes);
8888
// make sampling decision
8989
const samplingResult = this._sampler.shouldSample(
90-
context,
90+
options.root
91+
? api.setSpanContext(context, api.INVALID_SPAN_CONTEXT)
92+
: context,
9193
traceId,
9294
name,
9395
spanKind,

0 commit comments

Comments
 (0)