Skip to content

Commit f5d1ee7

Browse files
nicohrubeccodex
andauthored
ref(core): Use SENTRY_ORIGIN convention constant in shared tracing (#24983)
Uses `SENTRY_ORIGIN` from `@sentry/conventions/attributes` in core, browser-utils, OpenTelemetry tests, and Effect tracing/logging. It has the same `sentry.origin` value; transmitted data and public exports are unchanged. Part of #24961 / [JS-3868](https://linear.app/getsentry/issue/JS-3868). Co-authored-by: GPT-6 <codex@openai.com>
1 parent e74d7cf commit f5d1ee7

20 files changed

Lines changed: 88 additions & 101 deletions

File tree

‎packages/browser-utils/src/performance/entries.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
getActiveSpan,
77
parseUrl,
88
RESOURCE_SPAN_NAME_FALLBACK,
9-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
109
setMeasurement,
1110
spanToJSON,
1211
filterCollectedUrl,
@@ -28,6 +27,7 @@ import {
2827
URL_DOMAIN,
2928
URL_FULL,
3029
URL_SCHEME,
30+
SENTRY_ORIGIN,
3131
} from '@sentry/conventions/attributes';
3232
import {
3333
BROWSER_CACHE,
@@ -123,7 +123,7 @@ export function startTrackingLongTasks(): void {
123123
name: UI_LONG_TASK_SPAN_NAME_FALLBACK,
124124
op: UI_LONG_TASK,
125125
attributes: {
126-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
126+
[SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
127127
},
128128
});
129129
}
@@ -164,7 +164,7 @@ export function startTrackingLongAnimationFrames(): void {
164164
const duration = msToSec(entry.duration);
165165

166166
const attributes: SpanAttributes = {
167-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
167+
[SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
168168
};
169169

170170
const initialScript = entry.scripts[0];
@@ -291,7 +291,7 @@ export function _addPaintSpan(
291291
name: entry.name,
292292
attributes: {
293293
[SENTRY_OP]: BROWSER_PAINT,
294-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
294+
[SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
295295
[BROWSER_PAINT_TYPE]: entry.name,
296296
},
297297
});
@@ -370,7 +370,7 @@ function _addPerformanceNavigationTiming(
370370
name: spanStreamingEnabled ? BROWSER_NAVIGATION_TIMING_SPAN_NAMES[op] : entry.name,
371371
attributes: {
372372
[SENTRY_OP]: op,
373-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
373+
[SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
374374
[URL_FULL]: filterCollectedUrl(entry.name),
375375
...(event === 'redirect' && entry.redirectCount != null ? { 'http.redirect_count': entry.redirectCount } : {}),
376376
},
@@ -411,7 +411,7 @@ function _addRequest(
411411
name: spanStreamingEnabled ? BROWSER_NAVIGATION_TIMING_SPAN_NAMES[BROWSER_REQUEST] : entry.name,
412412
attributes: {
413413
[SENTRY_OP]: BROWSER_REQUEST,
414-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
414+
[SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
415415
[URL_FULL]: url,
416416
},
417417
});
@@ -420,7 +420,7 @@ function _addRequest(
420420
name: spanStreamingEnabled ? BROWSER_NAVIGATION_TIMING_SPAN_NAMES[BROWSER_RESPONSE] : entry.name,
421421
attributes: {
422422
[SENTRY_OP]: BROWSER_RESPONSE,
423-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
423+
[SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
424424
[URL_FULL]: url,
425425
},
426426
});
@@ -453,7 +453,7 @@ export function _addResourceSpans(
453453
}
454454

455455
const attributes: SpanAttributes = {
456-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
456+
[SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
457457
};
458458

459459
const parsedUrl = parseUrl(resourceUrl);

‎packages/browser-utils/src/web-vitals/emitSpan.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Integration, Span, SpanAttributes } from '@sentry/core';
2-
import { getClient, getCurrentScope, getRootSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';
2+
import { getClient, getCurrentScope, getRootSpan, spanToJSON } from '@sentry/core';
33
import { startInactiveSpan } from '@sentry/core/browser';
44
import {
55
SENTRY_EXCLUSIVE_TIME,
@@ -10,6 +10,7 @@ import {
1010
SENTRY_TRANSACTION,
1111
USER_AGENT_ORIGINAL,
1212
SENTRY_OP,
13+
SENTRY_ORIGIN,
1314
} from '@sentry/conventions/attributes';
1415
import { WINDOW } from '../types';
1516
import type { MetricNavigationType } from '../instrumentation/performanceObserver';
@@ -85,7 +86,7 @@ export function _emitWebVitalSpan(options: WebVitalSpanOptions): void {
8586
const segmentName = segmentSpan ? spanToJSON(segmentSpan).name : getCurrentScope().getScopeData().transactionName;
8687

8788
const attributes: SpanAttributes = {
88-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,
89+
[SENTRY_ORIGIN]: origin,
8990
[SENTRY_OP]: op,
9091
[SENTRY_EXCLUSIVE_TIME]: 0,
9192
[`browser.web_vital.${metricName}.value`]: value,

‎packages/browser-utils/test/performance/browserMetrics.test.ts‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
import { SENTRY_OP } from '@sentry/conventions/attributes';
1+
import { SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';
22
import type { Span, SpanAttributes } from '@sentry/core';
3-
import {
4-
getClient,
5-
getMainCarrier,
6-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
7-
SentrySpan,
8-
setCurrentClient,
9-
spanToJSON,
10-
} from '@sentry/core';
3+
import { getClient, getMainCarrier, SentrySpan, setCurrentClient, spanToJSON } from '@sentry/core';
114
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
125
import {
136
_addNavigationSpans,
@@ -247,7 +240,7 @@ describe('_addResourceSpans', () => {
247240
end_timestamp: timeOrigin + startTime + duration,
248241
attributes: {
249242
[SENTRY_OP]: 'resource.css',
250-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
243+
[SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
251244
['http.response.body.decoded_size']: entry.decodedBodySize,
252245
['http.response.body.size']: entry.encodedBodySize,
253246
['http.response.size']: entry.transferSize,
@@ -430,7 +423,7 @@ describe('_addResourceSpans', () => {
430423
expect.objectContaining({
431424
attributes: expect.objectContaining({
432425
[SENTRY_OP]: 'resource.css',
433-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
426+
[SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
434427
['http.response.body.decoded_size']: entry.decodedBodySize,
435428
['http.response.body.size']: entry.encodedBodySize,
436429
['http.response.size']: entry.transferSize,
@@ -469,7 +462,7 @@ describe('_addResourceSpans', () => {
469462
expect.objectContaining({
470463
attributes: expect.objectContaining({
471464
[SENTRY_OP]: 'resource.css',
472-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
465+
[SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
473466
'server.address': 'example.com',
474467
'url.domain': 'example.com',
475468
'http.request.same_origin': true,
@@ -521,7 +514,7 @@ describe('_addResourceSpans', () => {
521514
expect.objectContaining({
522515
attributes: {
523516
[SENTRY_OP]: 'resource.css',
524-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
517+
[SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
525518
'server.address': 'example.com',
526519
'url.domain': 'example.com',
527520
'http.request.same_origin': true,

‎packages/core/src/fetch.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import {
99
URL_FRAGMENT,
1010
URL_FULL,
1111
URL_QUERY,
12+
SENTRY_ORIGIN,
1213
} from '@sentry/conventions/attributes';
1314
import { HTTP_CLIENT } from '@sentry/conventions/op';
1415
import type { Client } from './client';
1516
import { getClient } from './currentScopes';
16-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes';
1717
import { setHttpStatus, SPAN_STATUS_ERROR, spanIsIgnored } from './tracing';
1818
import { startInactiveSpan } from './tracing/trace';
1919
import { SentryNonRecordingSpan } from './tracing/sentryNonRecordingSpan';
@@ -385,7 +385,7 @@ function getFetchSpanAttributes(
385385
type: 'fetch',
386386
// oxlint-disable-next-line typescript/no-deprecated
387387
[HTTP_REQUEST_METHOD]: method,
388-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
388+
[SENTRY_ORIGIN]: spanOrigin,
389389
[SENTRY_OP]: HTTP_CLIENT,
390390
[URL_DOMAIN]: domain,
391391
};

‎packages/core/src/integrations/http/server-subscription.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import { continueTrace, startSpanManual } from '../../tracing/trace';
3939
import { getSpanStatusFromHttpCode, SPAN_STATUS_ERROR } from '../../tracing';
4040
import { hasSpanStreamingEnabled } from '../../tracing/spans/hasSpanStreamingEnabled';
4141
import { HTTP_SPAN_NAME_FALLBACK } from '../../tracing/spans/spanNames';
42-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';
4342
import { safeMathRandom } from '../../utils/randomSafeContext';
4443
import type { SpanStatus } from '../../types/spanStatus';
4544
import {
@@ -66,6 +65,7 @@ import {
6665
URL_QUERY,
6766
URL_SCHEME,
6867
USER_AGENT_ORIGINAL,
68+
SENTRY_ORIGIN,
6969
} from '@sentry/conventions/attributes';
7070
import { HTTP_SERVER } from '@sentry/conventions/op';
7171
import { filterCollectedUrl, filterCollectedUrlQuery } from '../../utils/data-collection/filterCollectedUrl';
@@ -326,7 +326,7 @@ function buildServerSpanWrap(
326326
attributes: {
327327
// Sentry-specific attributes
328328
[SENTRY_OP]: HTTP_SERVER,
329-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.server',
329+
[SENTRY_ORIGIN]: 'auto.http.server',
330330
[SENTRY_SEGMENT_NAME_SOURCE]: 'url',
331331
[SENTRY_KIND]: 'server',
332332
// Network attributes

‎packages/core/src/integrations/mcp-server/spans.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
*/
77

88
import { getClient } from '../../currentScopes';
9-
import { SENTRY_OP, SENTRY_SEGMENT_NAME_SOURCE } from '@sentry/conventions/attributes';
9+
import { SENTRY_OP, SENTRY_SEGMENT_NAME_SOURCE, SENTRY_ORIGIN } from '@sentry/conventions/attributes';
1010
import {
1111
MCP_NOTIFICATION_CLIENT_TO_SERVER,
1212
MCP_NOTIFICATION_SERVER_TO_CLIENT,
1313
MCP_SERVER,
1414
} from '@sentry/conventions/op';
15-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';
1615
import { hasSpanStreamingEnabled } from '../../tracing/spans/hasSpanStreamingEnabled';
1716
import { MCP_NOTIFICATION_SPAN_NAME_FALLBACK, MCP_SERVER_SPAN_NAME_FALLBACK } from '../../tracing/spans/spanNames';
1817
import { startSpan } from '../../tracing/trace';
@@ -72,7 +71,7 @@ function buildSentryAttributes(type: McpSpanConfig['type']): Record<string, stri
7271

7372
return {
7473
[SENTRY_OP]: op,
75-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,
74+
[SENTRY_ORIGIN]: origin,
7675
[SENTRY_SEGMENT_NAME_SOURCE]: MCP_ROUTE_SOURCE_VALUE,
7776
};
7877
}

‎packages/core/src/integrations/supabase.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
/* eslint-disable @typescript-eslint/no-explicit-any */
55
/* eslint-disable max-lines */
6-
import { DB_OPERATION_NAME, DB_SYSTEM_NAME, SENTRY_OP } from '@sentry/conventions/attributes';
6+
import { DB_OPERATION_NAME, DB_SYSTEM_NAME, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';
77
import { DB } from '@sentry/conventions/op';
88
import { addBreadcrumb } from '../breadcrumbs';
99
import { getClient } from '../currentScopes';
1010
import { DEBUG_BUILD } from '../debug-build';
1111
import { captureException } from '../exports';
1212
import { defineIntegration } from '../integration';
13-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
1413
import { setHttpStatus, SPAN_STATUS_ERROR, SPAN_STATUS_OK } from '../tracing';
1514
import { hasSpanStreamingEnabled } from '../tracing/spans/hasSpanStreamingEnabled';
1615
import { startSpanManual } from '../tracing/trace';
@@ -297,7 +296,7 @@ function instrumentAuthOperation(operation: AuthOperationFn, isAdmin = false): A
297296
{
298297
name,
299298
attributes: {
300-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',
299+
[SENTRY_ORIGIN]: 'auto.db.supabase',
301300
[SENTRY_OP]: DB,
302301
[DB_SYSTEM_NAME]: 'postgresql',
303302
[DB_OPERATION_NAME]: operationName,
@@ -464,7 +463,7 @@ function instrumentPostgRESTFilterBuilder(
464463
'db.sdk': getHeader(typedThis.headers, 'X-Client-Info'),
465464
[DB_SYSTEM_NAME]: 'postgresql',
466465
[DB_OPERATION_NAME]: operation,
467-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.supabase',
466+
[SENTRY_ORIGIN]: 'auto.db.supabase',
468467
[SENTRY_OP]: DB,
469468
};
470469

‎packages/core/src/logs/console-integration.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { SENTRY_ORIGIN } from '@sentry/conventions/attributes';
12
import { getClient } from '../currentScopes';
23
import { addConsoleInstrumentationHandler } from '../instrument/console';
34
import { defineIntegration } from '../integration';
4-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
55
import type { ConsoleLevel } from '../types/instrument';
66
import type { IntegrationFn } from '../types/integration';
77
import { CONSOLE_LEVELS } from '../utils/debug-logger';
@@ -17,7 +17,7 @@ interface CaptureConsoleOptions {
1717
const INTEGRATION_NAME = 'ConsoleLogs' as const;
1818

1919
const DEFAULT_ATTRIBUTES = {
20-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.log.console',
20+
[SENTRY_ORIGIN]: 'auto.log.console',
2121
};
2222

2323
const _consoleLoggingIntegration = ((options: Partial<CaptureConsoleOptions> = {}) => {

‎packages/core/src/tracing/sentrySpan.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import {
66
SENTRY_EXCLUSIVE_TIME,
77
SENTRY_SEGMENT_NAME_SOURCE,
88
SENTRY_OP,
9+
SENTRY_ORIGIN,
910
} from '@sentry/conventions/attributes';
10-
import { SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
11+
import { SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME } from '../semanticAttributes';
1112
import type { Client } from '../client';
1213
import type { TransactionEvent } from '../types/event';
1314
import type { SpanLink } from '../types/link';
@@ -103,7 +104,7 @@ export class SentrySpan implements Span {
103104

104105
this._attributes = {};
105106
this.setAttributes({
106-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',
107+
[SENTRY_ORIGIN]: 'manual',
107108
[SENTRY_OP]: spanContext.op,
108109
...spanContext.attributes,
109110
});
@@ -278,7 +279,7 @@ export class SentrySpan implements Span {
278279
status: getStatusMessage(this._status),
279280
timestamp: this._endTime,
280281
trace_id: this._traceId,
281-
origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined,
282+
origin: this._attributes[SENTRY_ORIGIN] as SpanOrigin | undefined,
282283
profile_id: this._attributes[SENTRY_PROFILE_ID] as string | undefined,
283284
exclusive_time: this._attributes[SENTRY_EXCLUSIVE_TIME] as number | undefined,
284285
measurements: timedEventsToMeasurements(this._events),

‎packages/core/src/trpc.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {
55
SENTRY_SEGMENT_NAME_SOURCE,
66
TRPC_PROCEDURE_PATH,
77
TRPC_PROCEDURE_TYPE,
8+
SENTRY_ORIGIN,
89
} from '@sentry/conventions/attributes';
910
import { RPC } from '@sentry/conventions/op';
1011
import { getClient, withIsolationScope } from './currentScopes';
1112
import { captureException } from './exports';
12-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes';
1313
import { startSpanManual } from './tracing/trace';
1414
import { normalize } from './utils/normalize';
1515
import { setNormalizationDepthOverrideHint } from './utils/normalizationHints';
@@ -97,7 +97,7 @@ export function trpcMiddleware(options: SentryTrpcMiddlewareOptions = {}) {
9797
attributes: {
9898
[SENTRY_OP]: RPC,
9999
[SENTRY_SEGMENT_NAME_SOURCE]: 'route',
100-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.rpc.trpc',
100+
[SENTRY_ORIGIN]: 'auto.rpc.trpc',
101101
[RPC_SYSTEM_NAME]: 'trpc',
102102
[RPC_METHOD]: String(path),
103103
[TRPC_PROCEDURE_PATH]: String(path),

0 commit comments

Comments
 (0)