forked from pinpoint-apm/pinpoint-node-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspan-event.js
50 lines (44 loc) · 1.31 KB
/
span-event.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Pinpoint Node.js Agent
* Copyright 2020-present NAVER Corp.
* Apache License v2.0
*/
'use strict'
class SpanEvent {
constructor(span, sequence) {
if (!span || sequence === undefined || sequence === null) {
throw new Error('Can not initialize SpanEvent', span, sequence)
}
this.spanId = span.spanId // optional
this.sequence = sequence // required
this.startTime = 0 // required
this.elapsedTime = 0 // optional
this.startElapsed = 0 // required
// this.rpc = null // optional, deprecated
this.serviceType = null // required
this.endPoint = span.endPoint // optional
this.annotations = [] // optional
this.depth = -1 // optional
this.nextSpanId = -1 // optional
this.destinationId = span.endPoint // optional
this.apiId = null // optional
this.exceptionInfo = null // optional
this.asyncId = null // optional
this.nextAsyncId = null // optional
this.asyncSequence = null // optional
this.dummyId = null // optional
this.nextDummyId = null // optional
}
markElapsedTime() {
if (this.startTime) {
this.elapsedTime = Date.now() - this.startTime
}
}
get endElapsed() {
return this.elapsedTime
}
isValid() {
return this.sequence > -1 && this.spanId && this.serviceType
}
}
module.exports = SpanEvent