Skip to content

Commit c2baeac

Browse files
authored
feat(v8): Remove usage of span.description and span.name (#10697)
ref #10677 Removes all usage of setting/getting `span.description` and `span.name`, and removes the `span.setName` method.
1 parent 18f7107 commit c2baeac

File tree

54 files changed

+180
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+180
-430
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,8 @@ jobs:
10561056
'sveltekit-2',
10571057
'generic-ts3.8',
10581058
'node-experimental-fastify-app',
1059-
'node-hapi-app',
1059+
# TODO(v8): Re-enable hapi tests
1060+
# 'node-hapi-app',
10601061
'node-exports-test-app',
10611062
'vue-3'
10621063
]

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/backgroundtab-custom/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ sentryTest('should finish a custom transaction when the page goes background', a
2323
const transactionHandle = await page.evaluateHandle('window.transaction');
2424

2525
const id_before = await getPropertyValue(transactionHandle, 'span_id');
26-
const name_before = await getPropertyValue(transactionHandle, 'name');
26+
const nameBefore = JSON.parse(await transactionHandle.evaluate((t: any) => JSON.stringify(t))).description;
2727
const status_before = await getPropertyValue(transactionHandle, 'status');
2828
const tags_before = await getPropertyValue(transactionHandle, 'tags');
2929

30-
expect(name_before).toBe('test-transaction');
30+
expect(nameBefore).toBe('test-transaction');
3131
expect(status_before).toBeUndefined();
3232
expect(tags_before).toStrictEqual({});
3333

3434
await page.locator('#go-background').click();
3535

3636
const id_after = await getPropertyValue(transactionHandle, 'span_id');
37-
const name_after = await getPropertyValue(transactionHandle, 'name');
37+
const nameAfter = JSON.parse(await transactionHandle.evaluate((t: any) => JSON.stringify(t))).description;
3838
const status_after = await getPropertyValue(transactionHandle, 'status');
3939
const tags_after = await getPropertyValue(transactionHandle, 'tags');
4040

4141
expect(id_before).toBe(id_after);
42-
expect(name_after).toBe(name_before);
42+
expect(nameAfter).toBe('test-transaction');
4343
expect(status_after).toBe('cancelled');
4444
expect(tags_after).toStrictEqual({ visibilitychange: 'document.hidden' });
4545
});

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/pageloadWithHeartbeatTimeout/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test';
2-
import type { Event } from '@sentry/types';
2+
import type { SerializedEvent } from '@sentry/types';
33

44
import { sentryTest } from '../../../../utils/fixtures';
55
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers';
@@ -16,11 +16,10 @@ sentryTest(
1616

1717
const url = await getLocalTestPath({ testDir: __dirname });
1818

19-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
19+
const eventData = await getFirstSentryEnvelopeRequest<SerializedEvent>(page, url);
2020

2121
expect(eventData.contexts?.trace?.op).toBe('pageload');
2222
expect(
23-
// eslint-disable-next-line deprecation/deprecation
2423
eventData.spans?.find(span => span.description === 'pageload-child-span' && span.status === 'cancelled'),
2524
).toBeDefined();
2625
},

dev-packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ sentryTest('should finish a custom transaction when the page goes background', a
2323
const transactionHandle = await page.evaluateHandle('window.transaction');
2424

2525
const id_before = await getPropertyValue(transactionHandle, 'span_id');
26-
const name_before = await getPropertyValue(transactionHandle, 'name');
26+
const nameBefore = JSON.parse(await transactionHandle.evaluate((t: any) => JSON.stringify(t))).description;
2727
const status_before = await getPropertyValue(transactionHandle, 'status');
2828
const tags_before = await getPropertyValue(transactionHandle, 'tags');
2929

30-
expect(name_before).toBe('test-transaction');
30+
expect(nameBefore).toBe('test-transaction');
3131
expect(status_before).toBeUndefined();
3232
expect(tags_before).toStrictEqual({});
3333

3434
await page.locator('#go-background').click();
3535

3636
const id_after = await getPropertyValue(transactionHandle, 'span_id');
37-
const name_after = await getPropertyValue(transactionHandle, 'name');
37+
const nameAfter = JSON.parse(await transactionHandle.evaluate((t: any) => JSON.stringify(t))).description;
3838
const status_after = await getPropertyValue(transactionHandle, 'status');
3939
const tags_after = await getPropertyValue(transactionHandle, 'tags');
4040

4141
expect(id_before).toBe(id_after);
42-
expect(name_after).toBe(name_before);
42+
expect(nameAfter).toBe('test-transaction');
4343
expect(status_after).toBe('cancelled');
4444
expect(tags_after).toStrictEqual({ visibilitychange: 'document.hidden' });
4545
});

dev-packages/browser-integration-tests/suites/tracing/browsertracing/pageloadWithHeartbeatTimeout/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test';
2-
import type { Event } from '@sentry/types';
2+
import type { SerializedEvent } from '@sentry/types';
33

44
import { sentryTest } from '../../../../utils/fixtures';
55
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers';
@@ -16,11 +16,10 @@ sentryTest(
1616

1717
const url = await getLocalTestPath({ testDir: __dirname });
1818

19-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
19+
const eventData = await getFirstSentryEnvelopeRequest<SerializedEvent>(page, url);
2020

2121
expect(eventData.contexts?.trace?.op).toBe('pageload');
2222
expect(
23-
// eslint-disable-next-line deprecation/deprecation
2423
eventData.spans?.find(span => span.description === 'pageload-child-span' && span.status === 'cancelled'),
2524
).toBeDefined();
2625
},

packages/angular/src/tracing.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class TraceService implements OnDestroy {
173173
if (activeTransaction) {
174174
// eslint-disable-next-line deprecation/deprecation
175175
this._routingSpan = activeTransaction.startChild({
176-
description: `${navigationEvent.url}`,
176+
name: `${navigationEvent.url}`,
177177
op: ANGULAR_ROUTING_OP,
178178
origin: 'auto.ui.angular',
179179
tags: {
@@ -327,7 +327,7 @@ export class TraceDirective implements OnInit, AfterViewInit {
327327
if (activeTransaction) {
328328
// eslint-disable-next-line deprecation/deprecation
329329
this._tracingSpan = activeTransaction.startChild({
330-
description: `<${this.componentName}>`,
330+
name: `<${this.componentName}>`,
331331
op: ANGULAR_INIT_OP,
332332
origin: 'auto.ui.angular.trace_directive',
333333
});
@@ -371,7 +371,7 @@ export function TraceClassDecorator(): ClassDecorator {
371371
if (activeTransaction) {
372372
// eslint-disable-next-line deprecation/deprecation
373373
tracingSpan = activeTransaction.startChild({
374-
description: `<${target.name}>`,
374+
name: `<${target.name}>`,
375375
op: ANGULAR_INIT_OP,
376376
origin: 'auto.ui.angular.trace_class_decorator',
377377
});
@@ -410,7 +410,7 @@ export function TraceMethodDecorator(): MethodDecorator {
410410
if (activeTransaction) {
411411
// eslint-disable-next-line deprecation/deprecation
412412
activeTransaction.startChild({
413-
description: `<${target.constructor.name}>`,
413+
name: `<${target.constructor.name}>`,
414414
endTimestamp: now,
415415
op: `${ANGULAR_OP}.${String(propertyKey)}`,
416416
origin: 'auto.ui.angular.trace_method_decorator',

packages/angular/test/tracing.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,13 @@ describe('Angular Tracing', () => {
373373
expect(transaction.startChild).toHaveBeenCalledWith({
374374
op: 'ui.angular.init',
375375
origin: 'auto.ui.angular.trace_directive',
376-
description: '<unknown>',
376+
name: '<unknown>',
377377
});
378378

379379
env.destroy();
380380
});
381381

382-
it('should use component name as span description', async () => {
382+
it('should use component name as span name', async () => {
383383
const directive = new TraceDirective();
384384
const finishMock = jest.fn();
385385
const customStartTransaction = jest.fn(defaultStartTransaction);
@@ -400,7 +400,7 @@ describe('Angular Tracing', () => {
400400
expect(transaction.startChild).toHaveBeenCalledWith({
401401
op: 'ui.angular.init',
402402
origin: 'auto.ui.angular.trace_directive',
403-
description: '<test-component>',
403+
name: '<test-component>',
404404
});
405405

406406
env.destroy();
@@ -472,7 +472,7 @@ describe('Angular Tracing', () => {
472472
});
473473

474474
expect(transaction.startChild).toHaveBeenCalledWith({
475-
description: '<DecoratedComponent>',
475+
name: '<DecoratedComponent>',
476476
op: 'ui.angular.init',
477477
origin: 'auto.ui.angular.trace_class_decorator',
478478
});
@@ -526,15 +526,15 @@ describe('Angular Tracing', () => {
526526

527527
expect(transaction.startChild).toHaveBeenCalledTimes(2);
528528
expect(transaction.startChild.mock.calls[0][0]).toEqual({
529-
description: '<DecoratedComponent>',
529+
name: '<DecoratedComponent>',
530530
op: 'ui.angular.ngOnInit',
531531
origin: 'auto.ui.angular.trace_method_decorator',
532532
startTimestamp: expect.any(Number),
533533
endTimestamp: expect.any(Number),
534534
});
535535

536536
expect(transaction.startChild.mock.calls[1][0]).toEqual({
537-
description: '<DecoratedComponent>',
537+
name: '<DecoratedComponent>',
538538
op: 'ui.angular.ngAfterViewInit',
539539
origin: 'auto.ui.angular.trace_method_decorator',
540540
startTimestamp: expect.any(Number),

packages/core/src/tracing/sentrySpan.ts

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ export class SentrySpan implements SpanInterface {
144144
...spanContext.attributes,
145145
});
146146

147-
// eslint-disable-next-line deprecation/deprecation
148-
this._name = spanContext.name || spanContext.description;
147+
this._name = spanContext.name;
149148

150149
if (spanContext.parentSpanId) {
151150
this._parentSpanId = spanContext.parentSpanId;
@@ -165,38 +164,6 @@ export class SentrySpan implements SpanInterface {
165164
// This rule conflicts with another eslint rule :(
166165
/* eslint-disable @typescript-eslint/member-ordering */
167166

168-
/**
169-
* An alias for `description` of the Span.
170-
* @deprecated Use `spanToJSON(span).description` instead.
171-
*/
172-
public get name(): string {
173-
return this._name || '';
174-
}
175-
176-
/**
177-
* Update the name of the span.
178-
* @deprecated Use `spanToJSON(span).description` instead.
179-
*/
180-
public set name(name: string) {
181-
this.updateName(name);
182-
}
183-
184-
/**
185-
* Get the description of the Span.
186-
* @deprecated Use `spanToJSON(span).description` instead.
187-
*/
188-
public get description(): string | undefined {
189-
return this._name;
190-
}
191-
192-
/**
193-
* Get the description of the Span.
194-
* @deprecated Use `spanToJSON(span).description` instead.
195-
*/
196-
public set description(description: string | undefined) {
197-
this._name = description;
198-
}
199-
200167
/**
201168
* The ID of the trace.
202169
* @deprecated Use `spanContext().traceId` instead.
@@ -486,15 +453,6 @@ export class SentrySpan implements SpanInterface {
486453
return this;
487454
}
488455

489-
/**
490-
* @inheritdoc
491-
*
492-
* @deprecated Use `.updateName()` instead.
493-
*/
494-
public setName(name: string): void {
495-
this.updateName(name);
496-
}
497-
498456
/**
499457
* @inheritDoc
500458
*/
@@ -551,7 +509,7 @@ export class SentrySpan implements SpanInterface {
551509
public toContext(): SpanContext {
552510
return dropUndefinedKeys({
553511
data: this._getData(),
554-
description: this._name,
512+
name: this._name,
555513
endTimestamp: this._endTime,
556514
// eslint-disable-next-line deprecation/deprecation
557515
op: this.op,
@@ -574,8 +532,7 @@ export class SentrySpan implements SpanInterface {
574532
public updateWithContext(spanContext: SpanContext): this {
575533
// eslint-disable-next-line deprecation/deprecation
576534
this.data = spanContext.data || {};
577-
// eslint-disable-next-line deprecation/deprecation
578-
this._name = spanContext.name || spanContext.description;
535+
this._name = spanContext.name;
579536
this._endTime = spanContext.endTimestamp;
580537
// eslint-disable-next-line deprecation/deprecation
581538
this.op = spanContext.op;

packages/core/src/tracing/transaction.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
9191
// This sadly conflicts with the getter/setter ordering :(
9292
/* eslint-disable @typescript-eslint/member-ordering */
9393

94-
/**
95-
* Getter for `name` property.
96-
* @deprecated Use `spanToJSON(span).description` instead.
97-
*/
98-
public get name(): string {
99-
return this._name;
100-
}
101-
102-
/**
103-
* Setter for `name` property, which also sets `source` as custom.
104-
* @deprecated Use `updateName()` and `setMetadata()` instead.
105-
*/
106-
public set name(newName: string) {
107-
// eslint-disable-next-line deprecation/deprecation
108-
this.setName(newName);
109-
}
110-
11194
/**
11295
* Get the metadata for this transaction.
11396
* @deprecated Use `spanGetMetadata(transaction)` instead.
@@ -138,19 +121,10 @@ export class Transaction extends SentrySpan implements TransactionInterface {
138121

139122
/* eslint-enable @typescript-eslint/member-ordering */
140123

141-
/**
142-
* Setter for `name` property, which also sets `source` on the metadata.
143-
*
144-
* @deprecated Use `.updateName()` and `.setAttribute()` instead.
145-
*/
146-
public setName(name: string, source: TransactionSource = 'custom'): void {
147-
this._name = name;
148-
this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
149-
}
150-
151124
/** @inheritdoc */
152125
public updateName(name: string): this {
153126
this._name = name;
127+
this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom');
154128
return this;
155129
}
156130

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

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,16 @@ describe('span', () => {
77
/* eslint-disable deprecation/deprecation */
88
it('works with name', () => {
99
const span = new SentrySpan({ name: 'span name' });
10-
expect(span.name).toEqual('span name');
11-
expect(span.description).toEqual('span name');
12-
});
13-
14-
it('works with description', () => {
15-
const span = new SentrySpan({ description: 'span name' });
16-
expect(span.name).toEqual('span name');
17-
expect(span.description).toEqual('span name');
18-
});
19-
20-
it('works without name', () => {
21-
const span = new SentrySpan({});
22-
expect(span.name).toEqual('');
23-
expect(span.description).toEqual(undefined);
24-
});
25-
26-
it('allows to update the name via setter', () => {
27-
const span = new SentrySpan({ name: 'span name' });
28-
expect(span.name).toEqual('span name');
29-
expect(span.description).toEqual('span name');
30-
31-
span.name = 'new name';
32-
33-
expect(span.name).toEqual('new name');
34-
expect(span.description).toEqual('new name');
35-
});
36-
37-
it('allows to update the name via setName', () => {
38-
const span = new SentrySpan({ name: 'span name' });
39-
expect(span.name).toEqual('span name');
40-
expect(span.description).toEqual('span name');
41-
42-
// eslint-disable-next-line deprecation/deprecation
43-
span.setName('new name');
44-
45-
expect(span.name).toEqual('new name');
46-
expect(span.description).toEqual('new name');
10+
expect(spanToJSON(span).description).toEqual('span name');
4711
});
4812

4913
it('allows to update the name via updateName', () => {
5014
const span = new SentrySpan({ name: 'span name' });
51-
expect(span.name).toEqual('span name');
52-
expect(span.description).toEqual('span name');
15+
expect(spanToJSON(span).description).toEqual('span name');
5316

5417
span.updateName('new name');
5518

56-
expect(span.name).toEqual('new name');
57-
expect(span.description).toEqual('new name');
19+
expect(spanToJSON(span).description).toEqual('new name');
5820
});
5921
});
6022
/* eslint-enable deprecation/deprecation */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('startSpan', () => {
105105
}
106106
expect(ref).toBeDefined();
107107

108-
expect(ref.name).toEqual('GET users/[id]');
108+
expect(spanToJSON(ref).description).toEqual('GET users/[id]');
109109
expect(ref.status).toEqual(isError ? 'internal_error' : undefined);
110110
});
111111

@@ -192,7 +192,7 @@ describe('startSpan', () => {
192192
}
193193

194194
expect(ref.spanRecorder.spans).toHaveLength(2);
195-
expect(ref.spanRecorder.spans[1].description).toEqual('SELECT * from users');
195+
expect(spanToJSON(ref.spanRecorder.spans[1]).description).toEqual('SELECT * from users');
196196
expect(ref.spanRecorder.spans[1].parentSpanId).toEqual(ref.spanId);
197197
expect(ref.spanRecorder.spans[1].status).toEqual(isError ? 'internal_error' : undefined);
198198
});

0 commit comments

Comments
 (0)