Skip to content

Commit

Permalink
fix: Dont clash between span and scope trace context data
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Dec 2, 2019
1 parent 9cc5548 commit 7d5d3f2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
12 changes: 3 additions & 9 deletions packages/apm/src/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ export class Span implements SpanInterface, SpanContext {
}

return this._hub.captureEvent({
contexts: { trace: this.getTraceContext() },
spans: finishedSpans,
start_timestamp: this.startTimestamp,
tags: this.tags,
Expand All @@ -312,22 +311,17 @@ export class Span implements SpanInterface, SpanContext {
* @inheritDoc
*/
public getTraceContext(): object {
const context = {
return {
data: this.data,
description: this.description,
op: this.op,
parent_span_id: this._parentSpanId,
span_id: this._spanId,
// Undefined status will be dropped by `JSON.stringify` anyway so it's safe to read it directly like that
status: this.tags.status,
tags: this.tags,
trace_id: this._traceId,
};

if (this.tags.status) {
// TODO: Fixme, just use better typings
(context as any).status = this.tags.status;
}

return context;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/hub/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export class Scope implements ScopeInterface {
}
if (this._span) {
event.contexts = event.contexts || {};
event.contexts.trace = this._span;
event.contexts.trace = this._span.getTraceContext();
}

this._applyFingerprint(event);
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface SpanContext {
/**
* Completion status of the Span.
*/
status?: boolean;
status?: SpanStatus;
/**
* Parent Span ID
*/
Expand Down

0 comments on commit 7d5d3f2

Please sign in to comment.