@@ -30,7 +30,7 @@ export class Span implements SpanInterface, SpanContext {
30
30
/**
31
31
* Timestamp when the span was created.
32
32
*/
33
- public readonly startTimestamp : number = new Date ( ) . getTime ( ) ;
33
+ public readonly startTimestamp : number = new Date ( ) . getTime ( ) / 1000 ;
34
34
35
35
/**
36
36
* Finish timestamp of the span.
@@ -67,44 +67,44 @@ export class Span implements SpanInterface, SpanContext {
67
67
*/
68
68
public finishedSpans : Span [ ] = [ ] ;
69
69
70
- public constructor ( SpanContext ?: SpanContext ) {
71
- if ( ! SpanContext ) {
70
+ public constructor ( spanContext ?: SpanContext ) {
71
+ if ( ! spanContext ) {
72
72
return this ;
73
73
}
74
74
75
- if ( SpanContext . traceId ) {
76
- this . _traceId = SpanContext . traceId ;
75
+ if ( spanContext . traceId ) {
76
+ this . _traceId = spanContext . traceId ;
77
77
}
78
- if ( SpanContext . spanId ) {
79
- this . _spanId = SpanContext . spanId ;
78
+ if ( spanContext . spanId ) {
79
+ this . _spanId = spanContext . spanId ;
80
80
}
81
- if ( SpanContext . parentSpanId ) {
82
- this . _parentSpanId = SpanContext . parentSpanId ;
81
+ if ( spanContext . parentSpanId ) {
82
+ this . _parentSpanId = spanContext . parentSpanId ;
83
83
}
84
- if ( SpanContext . sampled ) {
85
- this . sampled = SpanContext . sampled ;
84
+ if ( spanContext . sampled ) {
85
+ this . sampled = spanContext . sampled ;
86
86
}
87
- if ( SpanContext . transaction ) {
88
- this . transaction = SpanContext . transaction ;
87
+ if ( spanContext . transaction ) {
88
+ this . transaction = spanContext . transaction ;
89
89
}
90
- if ( SpanContext . op ) {
91
- this . op = SpanContext . op ;
90
+ if ( spanContext . op ) {
91
+ this . op = spanContext . op ;
92
92
}
93
- if ( SpanContext . description ) {
94
- this . description = SpanContext . description ;
93
+ if ( spanContext . description ) {
94
+ this . description = spanContext . description ;
95
95
}
96
- if ( SpanContext . data ) {
97
- this . data = SpanContext . data ;
96
+ if ( spanContext . data ) {
97
+ this . data = spanContext . data ;
98
98
}
99
- if ( SpanContext . tags ) {
100
- this . tags = SpanContext . tags ;
99
+ if ( spanContext . tags ) {
100
+ this . tags = spanContext . tags ;
101
101
}
102
102
}
103
103
104
104
/** JSDoc */
105
- public newSpan ( SpanContext ?: Pick < SpanContext , Exclude < keyof SpanContext , 'spanId' > > ) : Span {
105
+ public newSpan ( spanContext ?: Pick < SpanContext , Exclude < keyof SpanContext , 'spanId' > > ) : Span {
106
106
const span = new Span ( {
107
- ...SpanContext ,
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, SpanContext {
121
121
*/
122
122
public static fromTraceparent (
123
123
traceparent : string ,
124
- SpanContext ?: Pick < SpanContext , Exclude < keyof SpanContext , '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, SpanContext {
133
133
}
134
134
135
135
return new Span ( {
136
- ...SpanContext ,
136
+ ...spanContext ,
137
137
parentSpanId : matches [ 2 ] ,
138
138
sampled,
139
139
traceId : matches [ 1 ] ,
@@ -146,7 +146,7 @@ export class Span implements SpanInterface, SpanContext {
146
146
* Sets the finish timestamp on the current span
147
147
*/
148
148
public finish ( ) : void {
149
- this . timestamp = new Date ( ) . getTime ( ) ;
149
+ this . timestamp = new Date ( ) . getTime ( ) / 1000 ;
150
150
this . finishedSpans . push ( this ) ;
151
151
}
152
152
0 commit comments