|
9 | 9 | class Span { |
10 | 10 | constructor(traceRoot) { |
11 | 11 | this.traceRoot = traceRoot |
12 | | - this.startTime = traceRoot.getTraceStartTime() |
13 | 12 | } |
14 | 13 | } |
15 | 14 |
|
16 | 15 | class SpanBuilder { |
17 | 16 | constructor(traceRoot) { |
18 | 17 | this.traceRoot = traceRoot |
| 18 | + this.annotations = [] |
| 19 | + this.startTime = traceRoot.getTraceStartTime() |
| 20 | + } |
| 21 | + |
| 22 | + setApiId(apiId) { |
| 23 | + this.apiId = apiId |
| 24 | + return this |
| 25 | + } |
| 26 | + |
| 27 | + setRpc(rpc) { |
| 28 | + this.rpc = rpc |
| 29 | + return this |
| 30 | + } |
| 31 | + |
| 32 | + setEndPoint(endPoint) { |
| 33 | + this.endPoint = endPoint |
| 34 | + return this |
| 35 | + } |
| 36 | + |
| 37 | + setRemoteAddress(remoteAddress) { |
| 38 | + this.remoteAddress = remoteAddress |
| 39 | + return this |
| 40 | + } |
| 41 | + |
| 42 | + addAnnotation(annotation) { |
| 43 | + this.annotations.push(annotation) |
| 44 | + return this |
| 45 | + } |
| 46 | + |
| 47 | + setExceptionInfo(id, message) { |
| 48 | + this.exceptionInfo = { id, message } |
| 49 | + return this |
| 50 | + } |
| 51 | + |
| 52 | + setAcceptorHost(acceptorHost) { |
| 53 | + this.acceptorHost = acceptorHost |
| 54 | + return this |
| 55 | + } |
| 56 | + |
| 57 | + setParentApplicationName(parentApplicationName) { |
| 58 | + this.parentApplicationName = parentApplicationName |
| 59 | + return this |
| 60 | + } |
| 61 | + |
| 62 | + setParentApplicationType(parentApplicationType) { |
| 63 | + this.parentApplicationType = parentApplicationType |
| 64 | + return this |
19 | 65 | } |
20 | 66 |
|
21 | 67 | build() { |
22 | | - return new Span(this.traceRoot) |
| 68 | + const span = new Span(this.traceRoot) |
| 69 | + this.startTime = this.startTime || Date.now() |
| 70 | + span.apiId = this.apiId |
| 71 | + span.rpc = this.rpc |
| 72 | + span.endPoint = this.endPoint |
| 73 | + span.remoteAddress = this.remoteAddress |
| 74 | + span.annotations = this.annotations |
| 75 | + span.exceptionInfo = this.exceptionInfo |
| 76 | + span.acceptorHost = this.acceptorHost |
| 77 | + span.parentApplicationName = this.parentApplicationName |
| 78 | + span.parentApplicationType = this.parentApplicationType |
| 79 | + return span |
23 | 80 | } |
24 | 81 | } |
25 | 82 |
|
|
0 commit comments