Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Add propagated flag to start span to start span with propagated paren…
Browse files Browse the repository at this point in the history
…t spanContext
  • Loading branch information
İbrahim Gürses committed Dec 13, 2018
1 parent abebffb commit 88e78f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/opentracing/Tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ThundraTracer extends Tracer {

const parentContext = fields.parentContext ? fields.parentContext : Utils.getParentContext(fields.references);

if (parentContext && !this.activeSpans.get(parentContext.spanId)) {
if (!fields.propagated && (parentContext && !this.activeSpans.get(parentContext.spanId))) {
throw new Error('Invalid spanId : ' + parentContext.spanId);
}

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/Trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ export class Trace {
if (propagatedSpanContext) {
this.pluginContext.transactionId = Utils.getConfiguration(
envVariableKeys.THUNDRA_LAMBDA_TRACE_USE_PROPAGATED_TRANSACTION_ID) === 'true' ?
originalContext.awsRequestId : propagatedSpanContext.transactionId;
propagatedSpanContext.transactionId : originalContext.awsRequestId;

this.pluginContext.traceId = propagatedSpanContext.traceId;
this.pluginContext.spanId = propagatedSpanContext.spanId;

this.tracer.transactionId = this.pluginContext.transactionId;

this.rootSpan = this.tracer._startSpan(originalContext.functionName, {
propagated : true,
parentContext : propagatedSpanContext,
rootTraceId: this.pluginContext.traceId,
domainName: DomainNames.API,
Expand Down

0 comments on commit 88e78f5

Please sign in to comment.