Skip to content

Commit 2b69368

Browse files
authored
ref: Remove deprecated origin field on span start options (#11058)
This is now always set as attribute.
1 parent bb004f2 commit 2b69368

File tree

19 files changed

+191
-130
lines changed

19 files changed

+191
-130
lines changed

packages/core/src/tracing/sentrySpan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class SentrySpan implements Span {
7575

7676
this._attributes = {};
7777
this.setAttributes({
78-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanContext.origin || 'manual',
78+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',
7979
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,
8080
...spanContext.attributes,
8181
});

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Event, Span, StartSpanOptions } from '@sentry/types';
22
import {
33
SEMANTIC_ATTRIBUTE_SENTRY_OP,
4+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
45
Scope,
56
addTracingExtensions,
67
getCurrentScope,
@@ -197,20 +198,21 @@ describe('startSpan', () => {
197198
expect(spanToJSON(spans[1]).op).toEqual('db.query');
198199
});
199200

200-
it.each([
201-
{ origin: 'auto.http.browser' },
202-
{ attributes: { 'sentry.origin': 'auto.http.browser' } },
203-
// attribute should take precedence over top level origin
204-
{ origin: 'manual', attributes: { 'sentry.origin': 'auto.http.browser' } },
205-
])('correctly sets the span origin', async () => {
201+
it('correctly sets the span origin', async () => {
206202
let _span: Span | undefined = undefined;
207203
client.on('spanEnd', span => {
208204
_span = span;
209205
});
210206
try {
211-
await startSpan({ name: 'GET users/[id]', origin: 'auto.http.browser' }, () => {
212-
return callback();
213-
});
207+
await startSpan(
208+
{
209+
name: 'GET users/[id]',
210+
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.browser' },
211+
},
212+
() => {
213+
return callback();
214+
},
215+
);
214216
} catch (e) {
215217
//
216218
}

packages/core/test/lib/utils/spanUtils.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ describe('spanToJSON', () => {
8585
parentSpanId: '1234',
8686
spanId: '5678',
8787
traceId: 'abcd',
88-
origin: 'auto',
8988
startTimestamp: 123,
9089
endTimestamp: 456,
90+
attributes: {
91+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto',
92+
},
9193
});
9294
span.setStatus({ code: SPAN_STATUS_OK });
9395

packages/ember/addon/instance-initializers/sentry-performance.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ export function _instrumentEmberRouter(
122122
const routeInfo = routerService.recognize(url);
123123
activeRootSpan = startBrowserTracingPageLoadSpan(client, {
124124
name: `route:${routeInfo.name}`,
125-
origin: 'auto.pageload.ember',
126125
attributes: {
127126
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
127+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.ember',
128128
url,
129129
toRoute: routeInfo.name,
130130
},
@@ -149,9 +149,9 @@ export function _instrumentEmberRouter(
149149

150150
activeRootSpan = startBrowserTracingNavigationSpan(client, {
151151
name: `route:${toRoute}`,
152-
origin: 'auto.navigation.ember',
153152
attributes: {
154153
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
154+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.ember',
155155
fromRoute,
156156
toRoute,
157157
},
@@ -295,8 +295,10 @@ function processComponentRenderAfter(
295295
startInactiveSpan({
296296
name: payload.containerKey || payload.object,
297297
op,
298-
origin: 'auto.ui.ember',
299298
startTimestamp: begin.now,
299+
attributes: {
300+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.ember',
301+
},
300302
})?.end(now);
301303
}
302304
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Span } from '@opentelemetry/api';
2-
import { _INTERNAL } from '@sentry/opentelemetry';
2+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
33
import type { SpanOrigin } from '@sentry/types';
44

55
/** Adds an origin to an OTEL Span. */
66
export function addOriginToSpan(span: Span, origin: SpanOrigin): void {
7-
_INTERNAL.addOriginToSpan(span, origin);
7+
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
88
}

packages/node-experimental/test/integration/transactions.test.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { TraceFlags, context, trace } from '@opentelemetry/api';
22
import type { SpanProcessor } from '@opentelemetry/sdk-trace-base';
3-
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
3+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
44
import { SentrySpanProcessor } from '@sentry/opentelemetry';
55
import type { TransactionEvent } from '@sentry/types';
66
import { logger } from '@sentry/utils';
@@ -36,9 +36,9 @@ describe('Integration | Transactions', () => {
3636
{
3737
op: 'test op',
3838
name: 'test name',
39-
origin: 'auto.test',
4039
attributes: {
4140
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
41+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.test',
4242
},
4343
},
4444
span => {
@@ -179,26 +179,36 @@ describe('Integration | Transactions', () => {
179179
Sentry.addBreadcrumb({ message: 'test breadcrumb 1', timestamp: 123456 });
180180

181181
Sentry.withIsolationScope(() => {
182-
Sentry.startSpan({ op: 'test op', name: 'test name', source: 'task', origin: 'auto.test' }, span => {
183-
Sentry.addBreadcrumb({ message: 'test breadcrumb 2', timestamp: 123456 });
182+
Sentry.startSpan(
183+
{
184+
op: 'test op',
185+
name: 'test name',
186+
attributes: {
187+
[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
188+
[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.test',
189+
},
190+
},
191+
span => {
192+
Sentry.addBreadcrumb({ message: 'test breadcrumb 2', timestamp: 123456 });
184193

185-
span.setAttributes({
186-
'test.outer': 'test value',
187-
});
194+
span.setAttributes({
195+
'test.outer': 'test value',
196+
});
188197

189-
const subSpan = Sentry.startInactiveSpan({ name: 'inner span 1' });
190-
subSpan.end();
198+
const subSpan = Sentry.startInactiveSpan({ name: 'inner span 1' });
199+
subSpan.end();
191200

192-
Sentry.setTag('test.tag', 'test value');
201+
Sentry.setTag('test.tag', 'test value');
193202

194-
Sentry.startSpan({ name: 'inner span 2' }, innerSpan => {
195-
Sentry.addBreadcrumb({ message: 'test breadcrumb 3', timestamp: 123456 });
203+
Sentry.startSpan({ name: 'inner span 2' }, innerSpan => {
204+
Sentry.addBreadcrumb({ message: 'test breadcrumb 3', timestamp: 123456 });
196205

197-
innerSpan.setAttributes({
198-
'test.inner': 'test value',
206+
innerSpan.setAttributes({
207+
'test.inner': 'test value',
208+
});
199209
});
200-
});
201-
});
210+
},
211+
);
202212
});
203213

204214
Sentry.withIsolationScope(() => {
@@ -493,8 +503,10 @@ describe('Integration | Transactions', () => {
493503
{
494504
op: 'test op',
495505
name: 'test name',
496-
origin: 'auto.test',
497-
attributes: { [Sentry.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task' },
506+
attributes: {
507+
[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
508+
[Sentry.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.test',
509+
},
498510
},
499511
() => {
500512
const subSpan = Sentry.startInactiveSpan({ name: 'inner span 1' });

packages/node/src/handlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type * as http from 'http';
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33
import type { Transaction } from '@sentry/core';
4+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
45
import {
56
SEMANTIC_ATTRIBUTE_SENTRY_OP,
67
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
@@ -68,10 +69,10 @@ export function tracingHandler(): (
6869
return startInactiveSpan({
6970
name,
7071
op: 'http.server',
71-
origin: 'auto.http.node.tracingHandler',
7272
forceTransaction: true,
7373
attributes: {
7474
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
75+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.node.tracingHandler',
7576
},
7677
metadata: {
7778
// The request should already have been stored in `scope.sdkProcessingMetadata` (which will become

packages/opentelemetry/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { addOriginToSpan } from './utils/addOriginToSpan';
21
import { maybeCaptureExceptionForTimedEvent } from './utils/captureExceptionForTimedEvent';
32
import { getRequestSpanData } from './utils/getRequestSpanData';
43

@@ -46,7 +45,6 @@ export { getClient } from '@sentry/core';
4645
* @hidden
4746
*/
4847
const _INTERNAL = {
49-
addOriginToSpan,
5048
maybeCaptureExceptionForTimedEvent,
5149
getRequestSpanData,
5250
} as const;

packages/opentelemetry/src/trace.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { TraceState, suppressTracing } from '@opentelemetry/core';
66
import {
77
SDK_VERSION,
88
SEMANTIC_ATTRIBUTE_SENTRY_OP,
9-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
109
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
1110
getClient,
1211
getCurrentScope,
@@ -143,11 +142,7 @@ function getTracer(): Tracer {
143142

144143
function _applySentryAttributesToSpan(span: Span, options: OpenTelemetrySpanContext): void {
145144
// eslint-disable-next-line deprecation/deprecation
146-
const { origin, op, source } = options;
147-
148-
if (origin) {
149-
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
150-
}
145+
const { op, source } = options;
151146

152147
if (op) {
153148
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, op);

packages/opentelemetry/test/integration/transactions.test.ts

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import type { SpanContext } from '@opentelemetry/api';
22
import { ROOT_CONTEXT } from '@opentelemetry/api';
33
import { TraceFlags, context, trace } from '@opentelemetry/api';
44
import type { SpanProcessor } from '@opentelemetry/sdk-trace-base';
5-
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, addBreadcrumb, getClient, setTag, withIsolationScope } from '@sentry/core';
5+
import {
6+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
7+
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
8+
addBreadcrumb,
9+
getClient,
10+
setTag,
11+
withIsolationScope,
12+
} from '@sentry/core';
613
import type { Event, TransactionEvent } from '@sentry/types';
714
import { logger } from '@sentry/utils';
815

@@ -42,9 +49,9 @@ describe('Integration | Transactions', () => {
4249
{
4350
op: 'test op',
4451
name: 'test name',
45-
origin: 'auto.test',
4652
attributes: {
4753
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
54+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.test',
4855
},
4956
},
5057
span => {
@@ -185,26 +192,36 @@ describe('Integration | Transactions', () => {
185192
addBreadcrumb({ message: 'test breadcrumb 1', timestamp: 123456 });
186193

187194
withIsolationScope(() => {
188-
startSpan({ op: 'test op', name: 'test name', source: 'task', origin: 'auto.test' }, span => {
189-
addBreadcrumb({ message: 'test breadcrumb 2', timestamp: 123456 });
195+
startSpan(
196+
{
197+
op: 'test op',
198+
name: 'test name',
199+
source: 'task',
200+
attributes: {
201+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.test',
202+
},
203+
},
204+
span => {
205+
addBreadcrumb({ message: 'test breadcrumb 2', timestamp: 123456 });
190206

191-
span.setAttributes({
192-
'test.outer': 'test value',
193-
});
207+
span.setAttributes({
208+
'test.outer': 'test value',
209+
});
194210

195-
const subSpan = startInactiveSpan({ name: 'inner span 1' });
196-
subSpan.end();
211+
const subSpan = startInactiveSpan({ name: 'inner span 1' });
212+
subSpan.end();
197213

198-
setTag('test.tag', 'test value');
214+
setTag('test.tag', 'test value');
199215

200-
startSpan({ name: 'inner span 2' }, innerSpan => {
201-
addBreadcrumb({ message: 'test breadcrumb 3', timestamp: 123456 });
216+
startSpan({ name: 'inner span 2' }, innerSpan => {
217+
addBreadcrumb({ message: 'test breadcrumb 3', timestamp: 123456 });
202218

203-
innerSpan.setAttributes({
204-
'test.inner': 'test value',
219+
innerSpan.setAttributes({
220+
'test.inner': 'test value',
221+
});
205222
});
206-
});
207-
});
223+
},
224+
);
208225
});
209226

210227
withIsolationScope(() => {
@@ -346,12 +363,22 @@ describe('Integration | Transactions', () => {
346363

347364
// We simulate the correct context we'd normally get from the SentryPropagator
348365
context.with(trace.setSpanContext(ROOT_CONTEXT, spanContext), () => {
349-
startSpan({ op: 'test op', name: 'test name', source: 'task', origin: 'auto.test' }, () => {
350-
const subSpan = startInactiveSpan({ name: 'inner span 1' });
351-
subSpan.end();
366+
startSpan(
367+
{
368+
op: 'test op',
369+
name: 'test name',
370+
source: 'task',
371+
attributes: {
372+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.test',
373+
},
374+
},
375+
() => {
376+
const subSpan = startInactiveSpan({ name: 'inner span 1' });
377+
subSpan.end();
352378

353-
startSpan({ name: 'inner span 2' }, () => {});
354-
});
379+
startSpan({ name: 'inner span 2' }, () => {});
380+
},
381+
);
355382
});
356383

357384
await client.flush();
@@ -551,19 +578,29 @@ describe('Integration | Transactions', () => {
551578

552579
// We simulate the correct context we'd normally get from the SentryPropagator
553580
context.with(trace.setSpanContext(ROOT_CONTEXT, spanContext), () => {
554-
startSpan({ op: 'test op', name: 'test name', source: 'task', origin: 'auto.test' }, span => {
555-
expect(span.spanContext().traceState?.get(SENTRY_TRACE_STATE_DSC)).toEqual(dscString);
581+
startSpan(
582+
{
583+
op: 'test op',
584+
name: 'test name',
585+
source: 'task',
586+
attributes: {
587+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.test',
588+
},
589+
},
590+
span => {
591+
expect(span.spanContext().traceState?.get(SENTRY_TRACE_STATE_DSC)).toEqual(dscString);
556592

557-
const subSpan = startInactiveSpan({ name: 'inner span 1' });
593+
const subSpan = startInactiveSpan({ name: 'inner span 1' });
558594

559-
expect(subSpan.spanContext().traceState?.get(SENTRY_TRACE_STATE_DSC)).toEqual(dscString);
595+
expect(subSpan.spanContext().traceState?.get(SENTRY_TRACE_STATE_DSC)).toEqual(dscString);
560596

561-
subSpan.end();
597+
subSpan.end();
562598

563-
startSpan({ name: 'inner span 2' }, subSpan => {
564-
expect(subSpan.spanContext().traceState?.get(SENTRY_TRACE_STATE_DSC)).toEqual(dscString);
565-
});
566-
});
599+
startSpan({ name: 'inner span 2' }, subSpan => {
600+
expect(subSpan.spanContext().traceState?.get(SENTRY_TRACE_STATE_DSC)).toEqual(dscString);
601+
});
602+
},
603+
);
567604
});
568605

569606
await client.flush();

0 commit comments

Comments
 (0)