Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/apm/src/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,13 @@ export class Span implements SpanInterface, SpanContext {
*/
public getTraceContext(): object {
return dropUndefinedKeys({
data: this.data,
data: Object.keys(this.data).length > 0 ? this.data : undefined,
description: this.description,
op: this.op,
parent_span_id: this._parentSpanId,
span_id: this._spanId,
status: this.tags.status,
tags: this.tags,
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
trace_id: this._traceId,
});
}
Expand All @@ -375,14 +375,14 @@ export class Span implements SpanInterface, SpanContext {
*/
public toJSON(): object {
return dropUndefinedKeys({
data: this.data,
data: Object.keys(this.data).length > 0 ? this.data : undefined,
description: this.description,
op: this.op,
parent_span_id: this._parentSpanId,
sampled: this.sampled,
span_id: this._spanId,
start_timestamp: this.startTimestamp,
tags: this.tags,
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
timestamp: this.timestamp,
trace_id: this._traceId,
transaction: this.transaction,
Expand Down
4 changes: 0 additions & 4 deletions packages/apm/test/span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,9 @@ describe('Span', () => {
expect(serialized).toHaveProperty('start_timestamp');
delete (serialized as { start_timestamp: number }).start_timestamp;
expect(serialized).toStrictEqual({
data: {},
parent_span_id: 'b',
sampled: false,
span_id: 'd',
tags: {},
trace_id: 'c',
});
});
Expand Down Expand Up @@ -257,9 +255,7 @@ describe('Span', () => {
const spanB = new Span({ spanId: 'd', traceId: 'c' });
const context = spanB.getTraceContext();
expect(context).toStrictEqual({
data: {},
span_id: 'd',
tags: {},
trace_id: 'c',
});
});
Expand Down
3 changes: 3 additions & 0 deletions packages/hub/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ export class Scope implements ScopeInterface {
if (this._transaction) {
event.transaction = this._transaction;
}
if (this._span) {
event.contexts = { trace: this._span.getTraceContext(), ...event.contexts };
}
Comment on lines +335 to +337
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only relevant code for this PR


this._applyFingerprint(event);

Expand Down