diff --git a/src/utils.ts b/src/utils.ts index fda5c356c1..4efa2e3467 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -341,7 +341,7 @@ export async function trace( let messageContext; let dstPropagationMetadata: undefined | string; - if (spanKind === SpanKind.CONSUMER) { + if (spanKind === SpanKind.CONSUMER && parentContext) { messageContext = span.setSpanOnContext(parentContext); } else { messageContext = span.setSpanOnContext(currentContext);