From b4c34bda23b5a3b02b1b5396f3b322b4c0302a3c Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 5 May 2021 10:38:34 -0400 Subject: [PATCH] fix: use invalid parent for sampler when options.root --- packages/opentelemetry-tracing/src/Tracer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-tracing/src/Tracer.ts b/packages/opentelemetry-tracing/src/Tracer.ts index 3b58b1739db..314ccbba726 100644 --- a/packages/opentelemetry-tracing/src/Tracer.ts +++ b/packages/opentelemetry-tracing/src/Tracer.ts @@ -16,8 +16,8 @@ import * as api from '@opentelemetry/api'; import { - InstrumentationLibrary, IdGenerator, + InstrumentationLibrary, RandomIdGenerator, sanitizeAttributes, } from '@opentelemetry/core'; @@ -87,7 +87,9 @@ export class Tracer implements api.Tracer { const attributes = sanitizeAttributes(options.attributes); // make sampling decision const samplingResult = this._sampler.shouldSample( - context, + options.root + ? api.setSpanContext(context, api.INVALID_SPAN_CONTEXT) + : context, traceId, name, spanKind,