Skip to content

Commit 81db979

Browse files
committed
feat: Remove tags from spans & transactions
1 parent 060bcf8 commit 81db979

File tree

7 files changed

+5
-89
lines changed

7 files changed

+5
-89
lines changed

packages/core/src/tracing/sentrySpan.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type {
2-
Primitive,
32
Span as SpanInterface,
43
SpanAttributeValue,
54
SpanAttributes,
@@ -63,12 +62,6 @@ export class SpanRecorder {
6362
* Span contains all data about a span
6463
*/
6564
export class SentrySpan implements SpanInterface {
66-
/**
67-
* Tags for the span.
68-
* @deprecated Use `spanToJSON(span).atttributes` instead.
69-
*/
70-
public tags: { [key: string]: Primitive };
71-
7265
/**
7366
* Data for the span.
7467
* @deprecated Use `spanToJSON(span).atttributes` instead.
@@ -115,8 +108,6 @@ export class SentrySpan implements SpanInterface {
115108
this._spanId = spanContext.spanId || uuid4().substring(16);
116109
this._startTime = spanContext.startTimestamp || timestampInSeconds();
117110
// eslint-disable-next-line deprecation/deprecation
118-
this.tags = spanContext.tags ? { ...spanContext.tags } : {};
119-
// eslint-disable-next-line deprecation/deprecation
120111
this.data = spanContext.data ? { ...spanContext.data } : {};
121112

122113
this._attributes = {};
@@ -338,21 +329,6 @@ export class SentrySpan implements SpanInterface {
338329
return childSpan;
339330
}
340331

341-
/**
342-
* Sets the tag attribute on the current span.
343-
*
344-
* Can also be used to unset a tag, by passing `undefined`.
345-
*
346-
* @param key Tag key
347-
* @param value Tag value
348-
* @deprecated Use `setAttribute()` instead.
349-
*/
350-
public setTag(key: string, value: Primitive): this {
351-
// eslint-disable-next-line deprecation/deprecation
352-
this.tags = { ...this.tags, [key]: value };
353-
return this;
354-
}
355-
356332
/**
357333
* Sets the data attribute on the current span
358334
* @param key Data key
@@ -435,8 +411,6 @@ export class SentrySpan implements SpanInterface {
435411
spanId: this._spanId,
436412
startTimestamp: this._startTime,
437413
status: this._status,
438-
// eslint-disable-next-line deprecation/deprecation
439-
tags: this.tags,
440414
traceId: this._traceId,
441415
});
442416
}
@@ -457,8 +431,6 @@ export class SentrySpan implements SpanInterface {
457431
this._spanId = spanContext.spanId || this._spanId;
458432
this._startTime = spanContext.startTimestamp || this._startTime;
459433
this._status = spanContext.status;
460-
// eslint-disable-next-line deprecation/deprecation
461-
this.tags = spanContext.tags || {};
462434
this._traceId = spanContext.traceId || this._traceId;
463435

464436
return this;
@@ -490,8 +462,6 @@ export class SentrySpan implements SpanInterface {
490462
span_id: this._spanId,
491463
start_timestamp: this._startTime,
492464
status: this._status,
493-
// eslint-disable-next-line deprecation/deprecation
494-
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
495465
timestamp: this._endTime,
496466
trace_id: this._traceId,
497467
origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,

packages/core/src/tracing/transaction.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
292292
// TODO: Pass spans serialized via `spanToJSON()` here instead in v8.
293293
spans: finishedSpans,
294294
start_timestamp: this._startTime,
295-
// eslint-disable-next-line deprecation/deprecation
296-
tags: this.tags,
297295
timestamp: this._endTime,
298296
transaction: this._name,
299297
type: 'transaction',

packages/core/src/utils/spanUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ export const TRACE_FLAG_SAMPLED = 0x1;
1111
*/
1212
export function spanToTraceContext(span: Span): TraceContext {
1313
const { spanId: span_id, traceId: trace_id } = span.spanContext();
14-
const { data, op, parent_span_id, status, tags, origin } = spanToJSON(span);
14+
const { data, op, parent_span_id, status, origin } = spanToJSON(span);
1515

1616
return dropUndefinedKeys({
1717
data,
1818
op,
1919
parent_span_id,
2020
span_id,
2121
status,
22-
tags,
2322
trace_id,
2423
origin,
2524
});

packages/opentelemetry/src/spanExporter.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function createTransactionForOtelSpan(span: ReadableSpan): Transaction {
145145

146146
const parentSampled = span.attributes[InternalSentrySemanticAttributes.PARENT_SAMPLED] as boolean | undefined;
147147

148-
const { op, description, tags, data, origin, source } = getSpanData(span);
148+
const { op, description, data, origin, source } = getSpanData(span);
149149
const metadata = getSpanMetadata(span);
150150
const capturedSpanScopes = getSpanScopes(span);
151151

@@ -167,7 +167,6 @@ function createTransactionForOtelSpan(span: ReadableSpan): Transaction {
167167
},
168168
data: removeSentryAttributes(data),
169169
origin,
170-
tags,
171170
sampled: true,
172171
});
173172

@@ -203,7 +202,7 @@ function createAndFinishSpanForOtelSpan(node: SpanNode, sentryParentSpan: Sentry
203202
const spanId = span.spanContext().spanId;
204203
const { attributes } = span;
205204

206-
const { op, description, tags, data, origin } = getSpanData(span);
205+
const { op, description, data, origin } = getSpanData(span);
207206
const allData = { ...removeSentryAttributes(attributes), ...data };
208207

209208
// eslint-disable-next-line deprecation/deprecation
@@ -215,7 +214,6 @@ function createAndFinishSpanForOtelSpan(node: SpanNode, sentryParentSpan: Sentry
215214
startTimestamp: convertOtelTimeToSeconds(span.startTime),
216215
spanId,
217216
origin,
218-
tags,
219217
});
220218

221219
node.children.forEach(child => {
@@ -226,7 +224,6 @@ function createAndFinishSpanForOtelSpan(node: SpanNode, sentryParentSpan: Sentry
226224
}
227225

228226
function getSpanData(span: ReadableSpan): {
229-
tags: Record<string, string>;
230227
data: Record<string, unknown>;
231228
op?: string;
232229
description: string;
@@ -239,15 +236,14 @@ function getSpanData(span: ReadableSpan): {
239236
const op = definedOp || inferredOp;
240237
const source = definedSource || inferredSource;
241238

242-
const tags = getTags(span);
243239
const data = { ...inferredData, ...getData(span) };
244240

245241
return {
246242
op,
247243
description,
248244
source,
249245
origin,
250-
tags,
246+
251247
data,
252248
};
253249
}
@@ -270,18 +266,6 @@ function removeSentryAttributes(data: Record<string, unknown>): Record<string, u
270266
return cleanedData;
271267
}
272268

273-
function getTags(span: ReadableSpan): Record<string, string> {
274-
const attributes = span.attributes;
275-
const tags: Record<string, string> = {};
276-
277-
if (attributes[SemanticAttributes.HTTP_STATUS_CODE]) {
278-
const statusCode = attributes[SemanticAttributes.HTTP_STATUS_CODE] as string | number;
279-
tags['http.status_code'] = `${statusCode}`;
280-
}
281-
282-
return tags;
283-
}
284-
285269
function getData(span: ReadableSpan): Record<string, unknown> {
286270
const attributes = span.attributes;
287271
const data: Record<string, unknown> = {

packages/profiling-node/test/hubextensions.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { __PRIVATE__wrapStartTransactionWithProfiling } from '../src/hubextensio
1515
function makeTransactionMock(options = {}): Transaction {
1616
return {
1717
metadata: {},
18-
tags: {},
1918
sampled: true,
2019
contexts: {},
2120
startChild: () => ({ end: () => void 0 }),
@@ -29,10 +28,6 @@ function makeTransactionMock(options = {}): Transaction {
2928
// @ts-expect-error - contexts is private
3029
this.contexts[key] = context;
3130
},
32-
setTag(this: Transaction, key: string, value: any) {
33-
// eslint-disable-next-line deprecation/deprecation
34-
this.tags[key] = value;
35-
},
3631
setMetadata(this: Transaction, metadata: Partial<TransactionMetadata>) {
3732
// eslint-disable-next-line deprecation/deprecation
3833
this.metadata = { ...metadata } as TransactionMetadata;

packages/types/src/span.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export interface SpanJSON {
5050
span_id: string;
5151
start_timestamp: number;
5252
status?: string;
53-
tags?: { [key: string]: Primitive };
5453
timestamp?: number;
5554
trace_id: string;
5655
origin?: SpanOrigin;
@@ -134,12 +133,6 @@ export interface SpanContext {
134133
*/
135134
traceId?: string | undefined;
136135

137-
/**
138-
* Tags of the Span.
139-
* @deprecated Pass `attributes` instead.
140-
*/
141-
tags?: { [key: string]: Primitive };
142-
143136
/**
144137
* Data of the Span.
145138
* @deprecated Pass `attributes` instead.
@@ -206,12 +199,6 @@ export interface Span extends Omit<SpanContext, 'name' | 'op' | 'status' | 'orig
206199
*/
207200
endTimestamp?: number | undefined;
208201

209-
/**
210-
* Tags for the span.
211-
* @deprecated Use `spanToJSON(span).atttributes` instead.
212-
*/
213-
tags: { [key: string]: Primitive };
214-
215202
/**
216203
* Data for the span.
217204
* @deprecated Use `spanToJSON(span).atttributes` instead.
@@ -250,17 +237,6 @@ export interface Span extends Omit<SpanContext, 'name' | 'op' | 'status' | 'orig
250237
*/
251238
end(endTimestamp?: SpanTimeInput): void;
252239

253-
/**
254-
* Sets the tag attribute on the current span.
255-
*
256-
* Can also be used to unset a tag, by passing `undefined`.
257-
*
258-
* @param key Tag key
259-
* @param value Tag value
260-
* @deprecated Use `setAttribute()` instead.
261-
*/
262-
setTag(key: string, value: Primitive): this;
263-
264240
/**
265241
* Sets the data attribute on the current span
266242
* @param key Data key

packages/types/src/transaction.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Context } from './context';
22
import type { DynamicSamplingContext } from './envelope';
33
import type { MeasurementUnit } from './measurement';
4-
import type { ExtractedNodeRequestData, Primitive, WorkerLocation } from './misc';
4+
import type { ExtractedNodeRequestData, WorkerLocation } from './misc';
55
import type { PolymorphicRequest } from './polymorphics';
66
import type { Span, SpanAttributes, SpanContext } from './span';
77

@@ -66,12 +66,6 @@ export interface Transaction extends Omit<TransactionContext, 'name' | 'op'>, Sp
6666
*/
6767
startTimestamp: number;
6868

69-
/**
70-
* Tags for the transaction.
71-
* @deprecated Use `getSpanAttributes(transaction)` instead.
72-
*/
73-
tags: { [key: string]: Primitive };
74-
7569
/**
7670
* Data for the transaction.
7771
* @deprecated Use `getSpanAttributes(transaction)` instead.

0 commit comments

Comments
 (0)