Skip to content

Commit 7213d49

Browse files
committed
stop deleting sentry.source and remove attribute spread in spanToStreamedSpanJSON
1 parent de1e0c2 commit 7213d49

5 files changed

Lines changed: 10 additions & 19 deletions

File tree

packages/core/src/semanticAttributes.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
/**
22
* Use this attribute to represent the source of a span name.
33
* Must be one of: custom, url, route, view, component, task
4-
* TODO: Deprecate this attribute in favour of SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE
4+
* TODO(v11): rename this to sentry.span.source'
55
*/
66
export const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';
77

8-
/**
9-
* Use this attribute to represent the source of a span name.
10-
* Must be one of: custom, url, route, view, component, task
11-
*/
12-
export const SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE = 'sentry.span.source';
13-
148
/**
159
* Attributes that holds the sample rate that was locally applied to a span.
1610
* If this attribute is not defined, it means that the span inherited a sampling decision.

packages/core/src/tracing/sentrySpan.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ export class SentrySpan implements Span {
264264
end_timestamp: this._endTime ?? this._startTime,
265265
is_segment: this._isStandaloneSpan || this === getRootSpan(this),
266266
status: getSimpleStatusMessage(this._status),
267-
// spread to avoid mutating the original object when later processing the span
268-
attributes: { ...this._attributes },
267+
attributes: this._attributes,
269268
links: getStreamedSpanLinks(this._links),
270269
};
271270
}

packages/core/src/tracing/spans/captureSpan.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
1010
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
1111
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
12-
SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE,
1312
SEMANTIC_ATTRIBUTE_USER_EMAIL,
1413
SEMANTIC_ATTRIBUTE_USER_ID,
1514
SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,
@@ -68,13 +67,14 @@ export function captureSpan(span: Span, client: Client): SerializedStreamedSpanW
6867
: spanJSON;
6968

7069
// Backfill sentry.span.source from sentry.source. Only `sentry.span.source` is respected by Sentry.
71-
// TODO(v11): Ensure we always only send `sentry.span.source` and remove this backfill.
70+
// TODO(v11): Remove this backfill once we renamed SEMANTIC_ATTRIBUTE_SENTRY_SOURCE to sentry.span.source
7271
const spanNameSource = processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
7372
if (spanNameSource) {
7473
safeSetSpanJSONAttributes(processedSpan, {
75-
[SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: spanNameSource,
74+
// Purposefully not using a constant defined here like in other attributes:
75+
// This will be the name for SEMANTIC_ATTRIBUTE_SENTRY_SOURCE in v11
76+
'sentry.span.source': spanNameSource,
7677
});
77-
delete processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
7878
}
7979

8080
return {

packages/core/src/utils/spanUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ export function spanToStreamedSpanJSON(span: Span): StreamedSpanJSON {
230230
end_timestamp: spanTimeInputToSeconds(endTime),
231231
is_segment: span === INTERNAL_getSegmentSpan(span),
232232
status: getSimpleStatusMessage(status),
233-
// spread to avoid mutating the original object when later processing the span
234-
attributes: { ...attributes },
233+
attributes,
235234
links: getStreamedSpanLinks(links),
236235
};
237236
}

packages/core/test/lib/tracing/spans/captureSpan.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,
1212
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
1313
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
14-
SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE,
1514
SEMANTIC_ATTRIBUTE_USER_EMAIL,
1615
SEMANTIC_ATTRIBUTE_USER_ID,
1716
SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,
@@ -84,7 +83,7 @@ describe('captureSpan', () => {
8483
value: span.spanContext().spanId,
8584
type: 'string',
8685
},
87-
[SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: {
86+
'sentry.span.source': {
8887
value: 'custom',
8988
type: 'string',
9089
},
@@ -174,7 +173,7 @@ describe('captureSpan', () => {
174173
value: span.spanContext().spanId,
175174
type: 'string',
176175
},
177-
[SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: {
176+
'sentry.span.source': {
178177
value: 'custom',
179178
type: 'string',
180179
},
@@ -254,7 +253,7 @@ describe('captureSpan', () => {
254253
value: span.spanContext().spanId,
255254
type: 'string',
256255
},
257-
[SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: {
256+
'sentry.span.source': {
258257
value: 'custom',
259258
type: 'string',
260259
},

0 commit comments

Comments
 (0)