1
- import { Span as SpanInterface , SpanProps } from '@sentry/types' ;
1
+ import { Span as SpanInterface , SpanContext } from '@sentry/types' ;
2
2
import { uuid4 } from '@sentry/utils' ;
3
3
4
4
export const TRACEPARENT_REGEXP = / ^ [ \t ] * ( [ 0 - 9 a - f ] { 32 } ) ? - ? ( [ 0 - 9 a - f ] { 16 } ) ? - ? ( [ 0 1 ] ) ? [ \t ] * $ / ;
5
5
6
6
/**
7
7
* Span contains all data about a span
8
8
*/
9
- export class Span implements SpanInterface , SpanProps {
9
+ export class Span implements SpanInterface , SpanContext {
10
10
/**
11
11
* Trace ID
12
12
*/
@@ -67,44 +67,44 @@ export class Span implements SpanInterface, SpanProps {
67
67
*/
68
68
public finishedSpans : Span [ ] = [ ] ;
69
69
70
- public constructor ( spanProps ?: SpanProps ) {
71
- if ( ! spanProps ) {
70
+ public constructor ( SpanContext ?: SpanContext ) {
71
+ if ( ! SpanContext ) {
72
72
return this ;
73
73
}
74
74
75
- if ( spanProps . traceId ) {
76
- this . _traceId = spanProps . traceId ;
75
+ if ( SpanContext . traceId ) {
76
+ this . _traceId = SpanContext . traceId ;
77
77
}
78
- if ( spanProps . spanId ) {
79
- this . _spanId = spanProps . spanId ;
78
+ if ( SpanContext . spanId ) {
79
+ this . _spanId = SpanContext . spanId ;
80
80
}
81
- if ( spanProps . parentSpanId ) {
82
- this . _parentSpanId = spanProps . parentSpanId ;
81
+ if ( SpanContext . parentSpanId ) {
82
+ this . _parentSpanId = SpanContext . parentSpanId ;
83
83
}
84
- if ( spanProps . sampled ) {
85
- this . sampled = spanProps . sampled ;
84
+ if ( SpanContext . sampled ) {
85
+ this . sampled = SpanContext . sampled ;
86
86
}
87
- if ( spanProps . transaction ) {
88
- this . transaction = spanProps . transaction ;
87
+ if ( SpanContext . transaction ) {
88
+ this . transaction = SpanContext . transaction ;
89
89
}
90
- if ( spanProps . op ) {
91
- this . op = spanProps . op ;
90
+ if ( SpanContext . op ) {
91
+ this . op = SpanContext . op ;
92
92
}
93
- if ( spanProps . description ) {
94
- this . description = spanProps . description ;
93
+ if ( SpanContext . description ) {
94
+ this . description = SpanContext . description ;
95
95
}
96
- if ( spanProps . data ) {
97
- this . data = spanProps . data ;
96
+ if ( SpanContext . data ) {
97
+ this . data = SpanContext . data ;
98
98
}
99
- if ( spanProps . tags ) {
100
- this . tags = spanProps . tags ;
99
+ if ( SpanContext . tags ) {
100
+ this . tags = SpanContext . tags ;
101
101
}
102
102
}
103
103
104
104
/** JSDoc */
105
- public newSpan ( spanProps ?: Pick < SpanProps , Exclude < keyof SpanProps , 'spanId' > > ) : Span {
105
+ public newSpan ( SpanContext ?: Pick < SpanContext , Exclude < keyof SpanContext , 'spanId' > > ) : Span {
106
106
const span = new Span ( {
107
- ...spanProps ,
107
+ ...SpanContext ,
108
108
parentSpanId : this . _spanId ,
109
109
sampled : this . sampled ,
110
110
traceId : this . _traceId ,
@@ -121,7 +121,7 @@ export class Span implements SpanInterface, SpanProps {
121
121
*/
122
122
public static fromTraceparent (
123
123
traceparent : string ,
124
- spanProps ?: Pick < SpanProps , Exclude < keyof SpanProps , 'spanId' | 'sampled' | 'traceid' > > ,
124
+ SpanContext ?: Pick < SpanContext , Exclude < keyof SpanContext , 'spanId' | 'sampled' | 'traceid' > > ,
125
125
) : Span | undefined {
126
126
const matches = traceparent . match ( TRACEPARENT_REGEXP ) ;
127
127
if ( matches ) {
@@ -133,7 +133,7 @@ export class Span implements SpanInterface, SpanProps {
133
133
}
134
134
135
135
return new Span ( {
136
- ...spanProps ,
136
+ ...SpanContext ,
137
137
parentSpanId : matches [ 2 ] ,
138
138
sampled,
139
139
traceId : matches [ 1 ] ,
0 commit comments