Skip to content

Commit 060bcf8

Browse files
committed
ref: Remove usage of span tags
Mostly, we rewrite this to just use attributes.
1 parent 372e405 commit 060bcf8

File tree

9 files changed

+15
-141
lines changed

9 files changed

+15
-141
lines changed

packages/angular/src/tracing.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ export class TraceService implements OnDestroy {
144144
attributes: {
145145
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular',
146146
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
147-
},
148-
tags: {
149147
url: strippedUrl,
150148
...(navigationEvent.navigationTrigger && {
151149
navigationTrigger: navigationEvent.navigationTrigger,
@@ -176,8 +174,7 @@ export class TraceService implements OnDestroy {
176174
name: `${navigationEvent.url}`,
177175
op: ANGULAR_ROUTING_OP,
178176
origin: 'auto.ui.angular',
179-
tags: {
180-
'routing.instrumentation': '@sentry/angular',
177+
attributes: {
181178
url: strippedUrl,
182179
...(navigationEvent.navigationTrigger && {
183180
navigationTrigger: navigationEvent.navigationTrigger,

packages/core/src/tracing/spanstatus.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,7 @@ export function getSpanStatusFromHttpCode(httpStatus: number): SpanStatusType {
128128
* Additionally, the span's status is updated, depending on the http code.
129129
*/
130130
export function setHttpStatus(span: Span, httpStatus: number): void {
131-
// TODO (v8): Remove these calls
132-
// Relay does not require us to send the status code as a tag
133-
// For now, just because users might expect it to land as a tag we keep sending it.
134-
// Same with data.
135-
// In v8, we replace both, simply with
136-
// span.setAttribute('http.response.status_code', httpStatus);
137-
138-
// eslint-disable-next-line deprecation/deprecation
139-
span.setTag('http.status_code', String(httpStatus));
140-
// eslint-disable-next-line deprecation/deprecation
141-
span.setData('http.response.status_code', httpStatus);
131+
span.setAttribute('http.response.status_code', httpStatus);
142132

143133
const spanStatus = getSpanStatusFromHttpCode(httpStatus);
144134
if (spanStatus !== 'unknown_error') {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,20 @@ describe('setHttpStatus', () => {
2020

2121
setHttpStatus(span!, code);
2222

23-
const { status: spanStatus, data, tags } = spanToJSON(span!);
23+
const { status: spanStatus, data } = spanToJSON(span!);
2424

2525
expect(spanStatus).toBe(status);
2626
expect(data).toMatchObject({ 'http.response.status_code': code });
27-
expect(tags).toMatchObject({ 'http.status_code': String(code) });
2827
});
2928

3029
it("doesn't set the status for an unknown http status code", () => {
3130
const span = new SentrySpan({ name: 'test' });
3231

3332
setHttpStatus(span!, 600);
3433

35-
const { status: spanStatus, data, tags } = spanToJSON(span!);
34+
const { status: spanStatus, data } = spanToJSON(span!);
3635

3736
expect(spanStatus).toBeUndefined();
3837
expect(data).toMatchObject({ 'http.response.status_code': 600 });
39-
expect(tags).toMatchObject({ 'http.status_code': '600' });
4038
});
4139
});

packages/core/test/lib/utils/spanUtils.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ describe('spanToJSON', () => {
6868
parentSpanId: '1234',
6969
spanId: '5678',
7070
status: 'ok',
71-
tags: {
72-
foo: 'bar',
73-
},
7471
traceId: 'abcd',
7572
origin: 'auto',
7673
startTimestamp: 123,
@@ -83,9 +80,6 @@ describe('spanToJSON', () => {
8380
parent_span_id: '1234',
8481
span_id: '5678',
8582
status: 'ok',
86-
tags: {
87-
foo: 'bar',
88-
},
8983
trace_id: 'abcd',
9084
origin: 'auto',
9185
start_timestamp: 123,

packages/node/test/handlers.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ describe('tracingHandler', () => {
410410
// eslint-disable-next-line deprecation/deprecation
411411
expect(transaction.status).toBe('ok');
412412
expect(spanToJSON(transaction).status).toBe('ok');
413-
// eslint-disable-next-line deprecation/deprecation
414-
expect(transaction.tags).toEqual(expect.objectContaining({ 'http.status_code': '200' }));
415413
expect(spanToJSON(transaction).data).toEqual(expect.objectContaining({ 'http.response.status_code': 200 }));
416414
done();
417415
});

packages/opentelemetry-node/src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@ export { SentryPropagator } from './propagator';
33
export { maybeCaptureExceptionForTimedEvent } from './utils/captureExceptionForTimedEvent';
44
export { parseOtelSpanDescription } from './utils/parseOtelSpanDescription';
55
export { mapOtelStatus } from './utils/mapOtelStatus';
6-
7-
/* eslint-disable deprecation/deprecation */
8-
export { addOtelSpanData, getOtelSpanData, clearOtelSpanData } from './utils/spanData';
9-
export type { AdditionalOtelSpanData } from './utils/spanData';
10-
/* eslint-enable deprecation/deprecation */

packages/opentelemetry-node/src/utils/spanData.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

packages/remix/src/utils/instrumentServer.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function makeWrappedDocumentRequestFunction(remixVersion?: number) {
196196
op: 'function.remix.document_request',
197197
origin: 'auto.function.remix',
198198
name: spanToJSON(activeTransaction).description,
199-
tags: {
199+
attributes: {
200200
method: request.method,
201201
url: request.url,
202202
},
@@ -253,7 +253,7 @@ function makeWrappedDataFunction(
253253
op: `function.remix.${name}`,
254254
origin: 'auto.ui.remix',
255255
name: id,
256-
tags: {
256+
attributes: {
257257
name,
258258
},
259259
});
@@ -412,8 +412,6 @@ export function startRequestHandlerTransaction(
412412
attributes: {
413413
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.remix',
414414
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
415-
},
416-
tags: {
417415
method: request.method,
418416
},
419417
...traceparentData,

packages/tracing-internal/src/browser/metrics/index.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,11 @@ function _trackNavigator(transaction: Transaction): void {
448448
const connection = navigator.connection;
449449
if (connection) {
450450
if (connection.effectiveType) {
451-
// TODO: Can we rewrite this to an attribute?
452-
// eslint-disable-next-line deprecation/deprecation
453-
transaction.setTag('effectiveConnectionType', connection.effectiveType);
451+
transaction.setAttribute('effectiveConnectionType', connection.effectiveType);
454452
}
455453

456454
if (connection.type) {
457-
// TODO: Can we rewrite this to an attribute?
458-
// eslint-disable-next-line deprecation/deprecation
459-
transaction.setTag('connectionType', connection.type);
455+
transaction.setAttribute('connectionType', connection.type);
460456
}
461457

462458
if (isMeasurementValue(connection.rtt)) {
@@ -465,15 +461,11 @@ function _trackNavigator(transaction: Transaction): void {
465461
}
466462

467463
if (isMeasurementValue(navigator.deviceMemory)) {
468-
// TODO: Can we rewrite this to an attribute?
469-
// eslint-disable-next-line deprecation/deprecation
470-
transaction.setTag('deviceMemory', `${navigator.deviceMemory} GB`);
464+
transaction.setAttribute('deviceMemory', `${navigator.deviceMemory} GB`);
471465
}
472466

473467
if (isMeasurementValue(navigator.hardwareConcurrency)) {
474-
// TODO: Can we rewrite this to an attribute?
475-
// eslint-disable-next-line deprecation/deprecation
476-
transaction.setTag('hardwareConcurrency', String(navigator.hardwareConcurrency));
468+
transaction.setAttribute('hardwareConcurrency', String(navigator.hardwareConcurrency));
477469
}
478470
}
479471

@@ -485,36 +477,26 @@ function _tagMetricInfo(transaction: Transaction): void {
485477
// Capture Properties of the LCP element that contributes to the LCP.
486478

487479
if (_lcpEntry.element) {
488-
// TODO: Can we rewrite this to an attribute?
489-
// eslint-disable-next-line deprecation/deprecation
490-
transaction.setTag('lcp.element', htmlTreeAsString(_lcpEntry.element));
480+
transaction.setAttribute('lcp.element', htmlTreeAsString(_lcpEntry.element));
491481
}
492482

493483
if (_lcpEntry.id) {
494-
// TODO: Can we rewrite this to an attribute?
495-
// eslint-disable-next-line deprecation/deprecation
496-
transaction.setTag('lcp.id', _lcpEntry.id);
484+
transaction.setAttribute('lcp.id', _lcpEntry.id);
497485
}
498486

499487
if (_lcpEntry.url) {
500488
// Trim URL to the first 200 characters.
501-
// TODO: Can we rewrite this to an attribute?
502-
// eslint-disable-next-line deprecation/deprecation
503-
transaction.setTag('lcp.url', _lcpEntry.url.trim().slice(0, 200));
489+
transaction.setAttribute('lcp.url', _lcpEntry.url.trim().slice(0, 200));
504490
}
505491

506-
// TODO: Can we rewrite this to an attribute?
507-
// eslint-disable-next-line deprecation/deprecation
508-
transaction.setTag('lcp.size', _lcpEntry.size);
492+
transaction.setAttribute('lcp.size', _lcpEntry.size);
509493
}
510494

511495
// See: https://developer.mozilla.org/en-US/docs/Web/API/LayoutShift
512496
if (_clsEntry && _clsEntry.sources) {
513497
DEBUG_BUILD && logger.log('[Measurements] Adding CLS Data');
514498
_clsEntry.sources.forEach((source, index) =>
515-
// TODO: Can we rewrite this to an attribute?
516-
// eslint-disable-next-line deprecation/deprecation
517-
transaction.setTag(`cls.source.${index + 1}`, htmlTreeAsString(source.node)),
499+
transaction.setAttribute(`cls.source.${index + 1}`, htmlTreeAsString(source.node)),
518500
);
519501
}
520502
}

0 commit comments

Comments
 (0)