Skip to content

Commit 14c7c6b

Browse files
authored
ref(v8): Remove deprecated span & transaction properties (#11400)
Removes a bunch of further deprecated properties on span & transaction.
1 parent b7a7ca3 commit 14c7c6b

File tree

3 files changed

+0
-165
lines changed

3 files changed

+0
-165
lines changed

packages/core/src/tracing/sentrySpan.ts

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import type {
88
SpanOrigin,
99
SpanStatus,
1010
SpanTimeInput,
11-
TraceContext,
12-
Transaction,
1311
} from '@sentry/types';
1412
import { dropUndefinedKeys, logger, timestampInSeconds, uuid4 } from '@sentry/utils';
1513
import { getClient } from '../currentScopes';
@@ -25,18 +23,12 @@ import {
2523
getStatusMessage,
2624
spanTimeInputToSeconds,
2725
spanToJSON,
28-
spanToTraceContext,
2926
} from '../utils/spanUtils';
3027

3128
/**
3229
* Span contains all data about a span
3330
*/
3431
export class SentrySpan implements Span {
35-
/**
36-
* @inheritDoc
37-
* @deprecated Use top level `Sentry.getRootSpan()` instead
38-
*/
39-
public transaction?: Transaction;
4032
protected _traceId: string;
4133
protected _spanId: string;
4234
protected _parentSpanId?: string | undefined;
@@ -85,43 +77,6 @@ export class SentrySpan implements Span {
8577
}
8678
}
8779

88-
// This rule conflicts with another eslint rule :(
89-
/* eslint-disable @typescript-eslint/member-ordering */
90-
91-
/**
92-
* Timestamp in seconds (epoch time) indicating when the span started.
93-
* @deprecated Use `spanToJSON()` instead.
94-
*/
95-
public get startTimestamp(): number {
96-
return this._startTime;
97-
}
98-
99-
/**
100-
* Timestamp in seconds (epoch time) indicating when the span started.
101-
* @deprecated In v8, you will not be able to update the span start time after creation.
102-
*/
103-
public set startTimestamp(startTime: number) {
104-
this._startTime = startTime;
105-
}
106-
107-
/**
108-
* Timestamp in seconds when the span ended.
109-
* @deprecated Use `spanToJSON()` instead.
110-
*/
111-
public get endTimestamp(): number | undefined {
112-
return this._endTime;
113-
}
114-
115-
/**
116-
* Timestamp in seconds when the span ended.
117-
* @deprecated Set the end time via `span.end()` instead.
118-
*/
119-
public set endTimestamp(endTime: number | undefined) {
120-
this._endTime = endTime;
121-
}
122-
123-
/* eslint-enable @typescript-eslint/member-ordering */
124-
12580
/** @inheritdoc */
12681
public spanContext(): SpanContextData {
12782
const { _spanId: spanId, _traceId: traceId, _sampled: sampled } = this;
@@ -157,10 +112,6 @@ export class SentrySpan implements Span {
157112
addChildSpanToSpan(this, childSpan);
158113

159114
const rootSpan = getRootSpan(this);
160-
// TODO: still set span.transaction here until we have a more permanent solution
161-
// Probably similarly to the weakmap we hold in node
162-
// eslint-disable-next-line deprecation/deprecation
163-
childSpan.transaction = rootSpan as Transaction;
164115

165116
if (DEBUG_BUILD && rootSpan) {
166117
const opStr = (spanContext && spanContext.op) || '< unknown op >';
@@ -251,35 +202,6 @@ export class SentrySpan implements Span {
251202
this._onSpanEnded();
252203
}
253204

254-
/**
255-
* @inheritDoc
256-
*
257-
* @deprecated Use `spanToJSON()` or access the fields directly instead.
258-
*/
259-
public toContext(): SentrySpanArguments {
260-
return dropUndefinedKeys({
261-
data: this._attributes,
262-
name: this._name,
263-
endTimestamp: this._endTime,
264-
op: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],
265-
parentSpanId: this._parentSpanId,
266-
sampled: this._sampled,
267-
spanId: this._spanId,
268-
startTimestamp: this._startTime,
269-
status: this._status,
270-
traceId: this._traceId,
271-
});
272-
}
273-
274-
/**
275-
* @inheritDoc
276-
*
277-
* @deprecated Use `spanToTraceContext()` util function instead.
278-
*/
279-
public getTraceContext(): TraceContext {
280-
return spanToTraceContext(this);
281-
}
282-
283205
/**
284206
* Get JSON representation of this span.
285207
*
@@ -309,14 +231,6 @@ export class SentrySpan implements Span {
309231
return !this._endTime && !!this._sampled;
310232
}
311233

312-
/**
313-
* Convert the object to JSON.
314-
* @deprecated Use `spanToJSON(span)` instead.
315-
*/
316-
public toJSON(): SpanJSON {
317-
return this.getSpanJSON();
318-
}
319-
320234
/** Emit `spanEnd` when the span is ended. */
321235
private _onSpanEnded(): void {
322236
const client = getClient();

packages/core/src/tracing/transaction.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type {
2-
Context,
32
Contexts,
43
DynamicSamplingContext,
54
Hub,
@@ -74,11 +73,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
7473
...this._attributes,
7574
};
7675

77-
// this is because transactions are also spans, and spans have a transaction pointer
78-
// TODO (v8): Replace this with another way to set the root span
79-
// eslint-disable-next-line deprecation/deprecation
80-
this.transaction = this;
81-
8276
// If Dynamic Sampling Context is provided during the creation of the transaction, we freeze it as it usually means
8377
// there is incoming Dynamic Sampling Context. (Either through an incoming request, a baggage meta-tag, or other means)
8478
const incomingDynamicSamplingContext = this._metadata.dynamicSamplingContext;
@@ -124,19 +118,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
124118
return this;
125119
}
126120

127-
/**
128-
* Set the context of a transaction event.
129-
* @deprecated Use either `.setAttribute()`, or set the context on the scope before creating the transaction.
130-
*/
131-
public setContext(key: string, context: Context | null): void {
132-
if (context === null) {
133-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
134-
delete this._contexts[key];
135-
} else {
136-
this._contexts[key] = context;
137-
}
138-
}
139-
140121
/**
141122
* @inheritDoc
142123
*
@@ -167,41 +148,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
167148
return this._hub.captureEvent(transaction);
168149
}
169150

170-
/**
171-
* @inheritDoc
172-
*/
173-
public toContext(): TransactionArguments {
174-
// eslint-disable-next-line deprecation/deprecation
175-
const spanContext = super.toContext();
176-
177-
return dropUndefinedKeys({
178-
...spanContext,
179-
name: this._name,
180-
trimEnd: this._trimEnd,
181-
});
182-
}
183-
184-
/**
185-
* @inheritdoc
186-
*
187-
* @experimental
188-
*
189-
* @deprecated Use top-level `getDynamicSamplingContextFromSpan` instead.
190-
*/
191-
public getDynamicSamplingContext(): Readonly<Partial<DynamicSamplingContext>> {
192-
return getDynamicSamplingContextFromSpan(this);
193-
}
194-
195-
/**
196-
* Override the current hub with a new one.
197-
* Used if you want another hub to finish the transaction.
198-
*
199-
* @internal
200-
*/
201-
public setHub(hub: Hub): void {
202-
this._hub = hub;
203-
}
204-
205151
/**
206152
* Finish the transaction & prepare the event to send to Sentry.
207153
*/

packages/types/src/transaction.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { Context } from './context';
21
import type { DynamicSamplingContext } from './envelope';
32
import type { MeasurementUnit } from './measurement';
43
import type { ExtractedNodeRequestData, WorkerLocation } from './misc';
@@ -58,23 +57,12 @@ export interface TraceparentData {
5857
* Transaction "Class", inherits Span only has `setName`
5958
*/
6059
export interface Transaction extends Omit<TransactionArguments, 'name' | 'op' | 'spanId' | 'traceId'>, Span {
61-
/**
62-
* @inheritDoc
63-
*/
64-
startTimestamp: number;
65-
6660
/**
6761
* Metadata about the transaction.
6862
* @deprecated Use attributes or store data on the scope instead.
6963
*/
7064
metadata: TransactionMetadata;
7165

72-
/**
73-
* Set the context of a transaction event.
74-
* @deprecated Use either `.setAttribute()`, or set the context on the scope before creating the transaction.
75-
*/
76-
setContext(key: string, context: Context): void;
77-
7866
/**
7967
* Set observed measurement for this transaction.
8068
*
@@ -86,25 +74,12 @@ export interface Transaction extends Omit<TransactionArguments, 'name' | 'op' |
8674
*/
8775
setMeasurement(name: string, value: number, unit: MeasurementUnit): void;
8876

89-
/**
90-
* Returns the current transaction properties as a `TransactionArguments`.
91-
* @deprecated Use `toJSON()` or access the fields directly instead.
92-
*/
93-
toContext(): TransactionArguments;
94-
9577
/**
9678
* Set metadata for this transaction.
9779
* @deprecated Use attributes or store data on the scope instead.
9880
*/
9981
setMetadata(newMetadata: Partial<TransactionMetadata>): void;
10082

101-
/**
102-
* Return the current Dynamic Sampling Context of this transaction
103-
*
104-
* @deprecated Use top-level `getDynamicSamplingContextFromSpan` instead.
105-
*/
106-
getDynamicSamplingContext(): Partial<DynamicSamplingContext>;
107-
10883
/**
10984
* Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.
11085
* Also the `sampled` decision will be inherited.

0 commit comments

Comments
 (0)