Skip to content

Commit 96f57a4

Browse files
committed
set sentry.span.source attribute
1 parent fb9a0ae commit 96f57a4

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

packages/core/src/semanticAttributes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
*/
66
export const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';
7+
export const SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE = 'sentry.span.source';
78

89
/**
910
* Attributes that holds the sample rate that was locally applied to a span.

packages/core/src/spans/captureSpan.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,
1010
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,
1111
SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,
12+
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
13+
SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE,
1214
SEMANTIC_ATTRIBUTE_USER_EMAIL,
1315
SEMANTIC_ATTRIBUTE_USER_ID,
1416
SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,
@@ -90,6 +92,10 @@ function applyCommonSpanAttributes(
9092
[SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,
9193
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,
9294
[SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,
95+
// Backfill sentry.span.source from sentry.source for the PoC
96+
// TODO(v11): Stop sending `sentry.source` attribute and only send `sentry.span.source`
97+
// probably easiest done by just renaming SEMANTIC_ATTRIBUTE_SENTRY_SOURCE
98+
[SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: spanJSON.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE],
9399
...(sendDefaultPii
94100
? {
95101
[SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,

packages/opentelemetry/src/streamingSpanExporter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
safeSetSpanJSONAttributes,
66
SEMANTIC_ATTRIBUTE_SENTRY_OP,
77
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
8+
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
89
SpanBuffer,
910
} from '@sentry/core';
1011
import { getSpanData, type ISentrySpanExporter } from './spanExporter';
@@ -39,6 +40,7 @@ export class StreamingSpanExporter implements ISentrySpanExporter {
3940
const allData = {
4041
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,
4142
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
43+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
4244
...data,
4345
};
4446
safeSetSpanJSONAttributes(spanJSON, allData);

0 commit comments

Comments
 (0)