Skip to content

Commit e226550

Browse files
authored
feat(v8/core): Remove span.attributes top level field (#11378)
ref #10100
1 parent 6a09675 commit e226550

File tree

5 files changed

+8
-29
lines changed

5 files changed

+8
-29
lines changed

packages/core/src/tracing/sentrySpan.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,6 @@ export class SentrySpan implements Span {
8888
// This rule conflicts with another eslint rule :(
8989
/* eslint-disable @typescript-eslint/member-ordering */
9090

91-
/**
92-
* Attributes for the span.
93-
* @deprecated Use `spanToJSON(span).atttributes` instead.
94-
*/
95-
public get attributes(): SpanAttributes {
96-
return this._attributes;
97-
}
98-
99-
/**
100-
* Attributes for the span.
101-
* @deprecated Use `setAttributes()` instead.
102-
*/
103-
public set attributes(attributes: SpanAttributes) {
104-
this._attributes = attributes;
105-
}
106-
10791
/**
10892
* Timestamp in seconds (epoch time) indicating when the span started.
10993
* @deprecated Use `spanToJSON()` instead.

packages/core/src/tracing/trace.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,12 @@ function _startTransaction(transactionContext: TransactionArguments): Transactio
301301
const client = getClient();
302302
const options: Partial<ClientOptions> = (client && client.getOptions()) || {};
303303

304+
const { name, parentSampled, attributes } = transactionContext;
304305
const [sampled, sampleRate] = sampleSpan(options, {
305-
name: transactionContext.name,
306-
parentSampled: transactionContext.parentSampled,
306+
name,
307+
parentSampled,
308+
attributes,
307309
transactionContext,
308-
attributes: transactionContext.attributes,
309310
});
310311

311312
// eslint-disable-next-line deprecation/deprecation

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('transaction', () => {
5757
request: {},
5858
});
5959

60-
expect(transaction.attributes).toEqual({
60+
expect(spanToJSON(transaction).data).toEqual({
6161
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',
6262
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
6363
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 0.5,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function startTrackingInteractions(): void {
110110
const startTime = msToSec((browserPerformanceTimeOrigin as number) + entry.startTime);
111111
const duration = msToSec(entry.duration);
112112

113-
const spanOptions: StartSpanOptions = {
113+
const spanOptions: StartSpanOptions & Required<Pick<StartSpanOptions, 'attributes'>> = {
114114
name: htmlTreeAsString(entry.target),
115115
op: `ui.interaction.${entry.name}`,
116116
startTime: startTime,
@@ -121,7 +121,7 @@ export function startTrackingInteractions(): void {
121121

122122
const componentName = getComponentName(entry.target);
123123
if (componentName) {
124-
spanOptions.attributes = { 'ui.component_name': componentName };
124+
spanOptions.attributes['ui.component_name'] = componentName;
125125
}
126126

127127
const span = startInactiveSpan(spanOptions);

packages/types/src/transaction.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { DynamicSamplingContext } from './envelope';
33
import type { MeasurementUnit } from './measurement';
44
import type { ExtractedNodeRequestData, WorkerLocation } from './misc';
55
import type { PolymorphicRequest } from './polymorphics';
6-
import type { SentrySpanArguments, Span, SpanAttributes } from './span';
6+
import type { SentrySpanArguments, Span } from './span';
77

88
/**
99
* Interface holding Transaction-specific properties
@@ -63,12 +63,6 @@ export interface Transaction extends Omit<TransactionArguments, 'name' | 'op' |
6363
*/
6464
startTimestamp: number;
6565

66-
/**
67-
* Attributes for the transaction.
68-
* @deprecated Use `getSpanAttributes(transaction)` instead.
69-
*/
70-
attributes: SpanAttributes;
71-
7266
/**
7367
* Metadata about the transaction.
7468
* @deprecated Use attributes or store data on the scope instead.

0 commit comments

Comments
 (0)