Skip to content

Commit 18848c8

Browse files
committed
feat(v8): Remove deprecated span id fields
Removes `span.spanId`, `span.traceId`, and `span.parentSpanId`.
1 parent b846671 commit 18848c8

File tree

4 files changed

+21
-73
lines changed

4 files changed

+21
-73
lines changed

packages/core/src/tracing/sentrySpan.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -97,56 +97,6 @@ export class SentrySpan implements Span {
9797
// This rule conflicts with another eslint rule :(
9898
/* eslint-disable @typescript-eslint/member-ordering */
9999

100-
/**
101-
* The ID of the trace.
102-
* @deprecated Use `spanContext().traceId` instead.
103-
*/
104-
public get traceId(): string {
105-
return this._traceId;
106-
}
107-
108-
/**
109-
* The ID of the trace.
110-
* @deprecated You cannot update the traceId of a span after span creation.
111-
*/
112-
public set traceId(traceId: string) {
113-
this._traceId = traceId;
114-
}
115-
116-
/**
117-
* The ID of the span.
118-
* @deprecated Use `spanContext().spanId` instead.
119-
*/
120-
public get spanId(): string {
121-
return this._spanId;
122-
}
123-
124-
/**
125-
* The ID of the span.
126-
* @deprecated You cannot update the spanId of a span after span creation.
127-
*/
128-
public set spanId(spanId: string) {
129-
this._spanId = spanId;
130-
}
131-
132-
/**
133-
* @inheritDoc
134-
*
135-
* @deprecated Use `startSpan` functions instead.
136-
*/
137-
public set parentSpanId(string) {
138-
this._parentSpanId = string;
139-
}
140-
141-
/**
142-
* @inheritDoc
143-
*
144-
* @deprecated Use `spanToJSON(span).parent_span_id` instead.
145-
*/
146-
public get parentSpanId(): string | undefined {
147-
return this._parentSpanId;
148-
}
149-
150100
/**
151101
* Was this span chosen to be sent as part of the sample?
152102
* @deprecated Use `isRecording()` instead.

packages/core/test/lib/tracing/sentrySpan.test.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { timestampInSeconds } from '@sentry/utils';
22
import { SentrySpan } from '../../../src/tracing/sentrySpan';
33
import { SPAN_STATUS_ERROR } from '../../../src/tracing/spanstatus';
4-
import { TRACE_FLAG_NONE, TRACE_FLAG_SAMPLED, spanToJSON, spanToTraceContext } from '../../../src/utils/spanUtils';
4+
import {
5+
TRACE_FLAG_NONE,
6+
TRACE_FLAG_SAMPLED,
7+
spanIsSampled,
8+
spanToJSON,
9+
spanToTraceContext,
10+
} from '../../../src/utils/spanUtils';
511

612
describe('SentrySpan', () => {
713
describe('name', () => {
@@ -25,9 +31,9 @@ describe('SentrySpan', () => {
2531
const span = new SentrySpan({ sampled: true });
2632
// eslint-disable-next-line deprecation/deprecation
2733
const span2 = span.startChild();
28-
expect((span2 as any).parentSpanId).toBe((span as any).spanId);
29-
expect((span2 as any).traceId).toBe((span as any).traceId);
30-
expect((span2 as any).sampled).toBe((span as any).sampled);
34+
expect(spanToJSON(span2).parent_span_id).toBe(span.spanContext().spanId);
35+
expect(span.spanContext().traceId).toBe(span.spanContext().traceFlags);
36+
expect(spanIsSampled(span2)).toBe(spanIsSampled(span));
3137
});
3238
});
3339

@@ -58,18 +64,23 @@ describe('SentrySpan', () => {
5864
});
5965

6066
test('with parent', () => {
61-
const spanA = new SentrySpan({ traceId: 'a', spanId: 'b' }) as any;
62-
const spanB = new SentrySpan({ traceId: 'c', spanId: 'd', sampled: false, parentSpanId: spanA.spanId });
67+
const spanA = new SentrySpan({ traceId: 'a', spanId: 'b' });
68+
const spanB = new SentrySpan({
69+
traceId: 'c',
70+
spanId: 'd',
71+
sampled: false,
72+
parentSpanId: spanA.spanContext().spanId,
73+
});
6374
const serialized = spanToJSON(spanB);
6475
expect(serialized).toHaveProperty('parent_span_id', 'b');
6576
expect(serialized).toHaveProperty('span_id', 'd');
6677
expect(serialized).toHaveProperty('trace_id', 'c');
6778
});
6879

6980
test('should drop all `undefined` values', () => {
70-
const spanA = new SentrySpan({ traceId: 'a', spanId: 'b' }) as any;
81+
const spanA = new SentrySpan({ traceId: 'a', spanId: 'b' });
7182
const spanB = new SentrySpan({
72-
parentSpanId: spanA.spanId,
83+
parentSpanId: spanA.spanContext().spanId,
7384
spanId: 'd',
7485
traceId: 'c',
7586
});

packages/types/src/envelope.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ import type { Profile } from './profiling';
88
import type { ReplayEvent, ReplayRecordingData } from './replay';
99
import type { SdkInfo } from './sdkinfo';
1010
import type { SerializedSession, Session, SessionAggregates } from './session';
11-
import type { Transaction } from './transaction';
1211

1312
// Based on: https://develop.sentry.dev/sdk/envelopes/
1413

1514
// Based on https://github.com/getsentry/relay/blob/b23b8d3b2360a54aaa4d19ecae0231201f31df5e/relay-sampling/src/lib.rs#L685-L707
1615
export type DynamicSamplingContext = {
17-
trace_id: Transaction['traceId'];
16+
trace_id: string;
1817
public_key: DsnComponents['publicKey'];
1918
sample_rate?: string;
2019
release?: string;

packages/types/src/transaction.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,7 @@ export interface TraceparentData {
5757
/**
5858
* Transaction "Class", inherits Span only has `setName`
5959
*/
60-
export interface Transaction extends Omit<TransactionContext, 'name' | 'op'>, Span {
61-
/**
62-
* The ID of the transaction.
63-
* @deprecated Use `spanContext().spanId` instead.
64-
*/
65-
spanId: string;
66-
67-
/**
68-
* The ID of the trace.
69-
* @deprecated Use `spanContext().traceId` instead.
70-
*/
71-
traceId: string;
72-
60+
export interface Transaction extends Omit<TransactionContext, 'name' | 'op' | 'spanId' | 'traceId'>, Span {
7361
/**
7462
* Was this transaction chosen to be sent as part of the sample?
7563
* @deprecated Use `spanIsSampled(transaction)` instead.

0 commit comments

Comments
 (0)