@@ -16,7 +16,7 @@ import type {
16
16
import { dropUndefinedKeys , logger , timestampInSeconds , uuid4 } from '@sentry/utils' ;
17
17
18
18
import { DEBUG_BUILD } from '../debug-build' ;
19
- import { SEMANTIC_ATTRIBUTE_SENTRY_OP } from '../semanticAttributes' ;
19
+ import { SEMANTIC_ATTRIBUTE_SENTRY_OP , SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes' ;
20
20
import { getRootSpan } from '../utils/getRootSpan' ;
21
21
import {
22
22
TRACE_FLAG_NONE ,
@@ -105,11 +105,6 @@ export class Span implements SpanInterface {
105
105
*/
106
106
public instrumenter : Instrumenter ;
107
107
108
- /**
109
- * The origin of the span, giving context about what created the span.
110
- */
111
- public origin ?: SpanOrigin ;
112
-
113
108
protected _traceId : string ;
114
109
protected _spanId : string ;
115
110
protected _sampled : boolean | undefined ;
@@ -142,7 +137,9 @@ export class Span implements SpanInterface {
142
137
this . _attributes = spanContext . attributes ? { ...spanContext . attributes } : { } ;
143
138
// eslint-disable-next-line deprecation/deprecation
144
139
this . instrumenter = spanContext . instrumenter || 'sentry' ;
145
- this . origin = spanContext . origin || 'manual' ;
140
+
141
+ this . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN , spanContext . origin || 'manual' ) ;
142
+
146
143
// eslint-disable-next-line deprecation/deprecation
147
144
this . _name = spanContext . name || spanContext . description ;
148
145
@@ -332,6 +329,24 @@ export class Span implements SpanInterface {
332
329
this . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_OP , op ) ;
333
330
}
334
331
332
+ /**
333
+ * The origin of the span, giving context about what created the span.
334
+ *
335
+ * @deprecated Use `spanToJSON().origin` to read the origin instead.
336
+ */
337
+ public get origin ( ) : SpanOrigin | undefined {
338
+ return this . _attributes [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] as SpanOrigin | undefined ;
339
+ }
340
+
341
+ /**
342
+ * The origin of the span, giving context about what created the span.
343
+ *
344
+ * @deprecated Use `startSpan()` functions to set the origin instead.
345
+ */
346
+ public set origin ( origin : SpanOrigin | undefined ) {
347
+ this . setAttribute ( SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN , origin ) ;
348
+ }
349
+
335
350
/* eslint-enable @typescript-eslint/member-ordering */
336
351
337
352
/** @inheritdoc */
@@ -597,7 +612,7 @@ export class Span implements SpanInterface {
597
612
tags : Object . keys ( this . tags ) . length > 0 ? this . tags : undefined ,
598
613
timestamp : this . _endTime ,
599
614
trace_id : this . _traceId ,
600
- origin : this . origin ,
615
+ origin : this . _attributes [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] as SpanOrigin | undefined ,
601
616
} ) ;
602
617
}
603
618
0 commit comments