@cloudcare/browser-rum 2.0.19 → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -11
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/domain/assembly.js +12 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js +10 -0
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +2 -2
- package/cjs/domain/rumSession.js +21 -6
- package/cjs/domain/tracing/ddtraceTracer.js +75 -0
- package/cjs/domain/tracing/jaegerTracer.js +58 -0
- package/cjs/domain/tracing/skywalkingTracer.js +93 -0
- package/cjs/domain/tracing/tracer.js +51 -60
- package/cjs/domain/tracing/w3cTraceParentTracer.js +51 -0
- package/cjs/domain/tracing/zipkinMultiTracer.js +58 -0
- package/cjs/domain/tracing/zipkinSingleTracer.js +51 -0
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/assembly.js +12 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js +11 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +2 -2
- package/esm/domain/rumSession.js +21 -6
- package/esm/domain/tracing/ddtraceTracer.js +67 -0
- package/esm/domain/tracing/jaegerTracer.js +50 -0
- package/esm/domain/tracing/skywalkingTracer.js +84 -0
- package/esm/domain/tracing/tracer.js +44 -57
- package/esm/domain/tracing/w3cTraceParentTracer.js +43 -0
- package/esm/domain/tracing/zipkinMultiTracer.js +50 -0
- package/esm/domain/tracing/zipkinSingleTracer.js +43 -0
- package/package.json +3 -3
- package/src/boot/rumPublicApi.js +0 -1
- package/src/domain/.DS_Store +0 -0
- package/src/domain/assembly.js +12 -3
- package/src/domain/rumEventsCollection/error/errorCollection.js +16 -2
- package/src/domain/rumEventsCollection/resource/matchRequestTiming.js +1 -0
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +3 -4
- package/src/domain/rumSession.js +24 -7
- package/src/domain/tracing/ddtraceTracer.js +70 -0
- package/src/domain/tracing/jaegerTracer.js +47 -0
- package/src/domain/tracing/skywalkingTracer.js +80 -0
- package/src/domain/tracing/tracer.js +40 -68
- package/src/domain/tracing/w3cTraceParentTracer.js +40 -0
- package/src/domain/tracing/zipkinMultiTracer.js +46 -0
- package/src/domain/tracing/zipkinSingleTracer.js +40 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function TraceIdentifier() {
|
|
2
|
+
this.buffer = new Uint8Array(8)
|
|
3
|
+
getCrypto().getRandomValues(this.buffer)
|
|
4
|
+
this.buffer[0] = this.buffer[0] & 0x7f
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
TraceIdentifier.prototype = {
|
|
8
|
+
// buffer: new Uint8Array(8),
|
|
9
|
+
toString: function (radix) {
|
|
10
|
+
var high = this.readInt32(0)
|
|
11
|
+
var low = this.readInt32(4)
|
|
12
|
+
var str = ''
|
|
13
|
+
|
|
14
|
+
while (1) {
|
|
15
|
+
var mod = (high % radix) * 4294967296 + low
|
|
16
|
+
|
|
17
|
+
high = Math.floor(high / radix)
|
|
18
|
+
low = Math.floor(mod / radix)
|
|
19
|
+
str = (mod % radix).toString(radix) + str
|
|
20
|
+
|
|
21
|
+
if (!high && !low) {
|
|
22
|
+
break
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return str
|
|
26
|
+
},
|
|
27
|
+
toDecimalString: function () {
|
|
28
|
+
return this.toString(10)
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
readInt32: function (offset) {
|
|
32
|
+
return (
|
|
33
|
+
this.buffer[offset] * 16777216 +
|
|
34
|
+
(this.buffer[offset + 1] << 16) +
|
|
35
|
+
(this.buffer[offset + 2] << 8) +
|
|
36
|
+
this.buffer[offset + 3]
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function getCrypto() {
|
|
41
|
+
return window.crypto || window.msCrypto
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param {*} configuration 配置信息
|
|
46
|
+
*/
|
|
47
|
+
export function DDtraceTracer(configuration) {
|
|
48
|
+
this._spanId = new TraceIdentifier().toDecimalString()
|
|
49
|
+
this._traceId = new TraceIdentifier().toDecimalString()
|
|
50
|
+
}
|
|
51
|
+
DDtraceTracer.prototype = {
|
|
52
|
+
isTracingSupported: function() {
|
|
53
|
+
return getCrypto() !== undefined
|
|
54
|
+
},
|
|
55
|
+
getSpanId:function() {
|
|
56
|
+
return this._spanId
|
|
57
|
+
},
|
|
58
|
+
getTraceId: function() {
|
|
59
|
+
return this._traceId
|
|
60
|
+
},
|
|
61
|
+
makeTracingHeaders: function() {
|
|
62
|
+
return {
|
|
63
|
+
'x-datadog-origin': 'rum',
|
|
64
|
+
// 'x-datadog-parent-id': spanId.toDecimalString(),
|
|
65
|
+
'x-datadog-sampled': '1',
|
|
66
|
+
'x-datadog-sampling-priority': '1',
|
|
67
|
+
'x-datadog-trace-id': this.getTraceId()
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// === Generate a random 64-bit number in fixed-length hex format
|
|
2
|
+
function randomTraceId() {
|
|
3
|
+
const digits = '0123456789abcdef';
|
|
4
|
+
let n = '';
|
|
5
|
+
for (let i = 0; i < 16; i += 1) {
|
|
6
|
+
const rand = Math.floor(Math.random() * 16);
|
|
7
|
+
n += digits[rand];
|
|
8
|
+
}
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {*} configuration 配置信息
|
|
15
|
+
*/
|
|
16
|
+
export function JaegerTracer(configuration) {
|
|
17
|
+
const rootSpanId = randomTraceId();
|
|
18
|
+
// this._traceId = randomTraceId() + rootSpanId // 默认用128bit,兼容其他配置
|
|
19
|
+
if (configuration.traceId128Bit) {
|
|
20
|
+
// 128bit生成traceid
|
|
21
|
+
this._traceId = randomTraceId() + rootSpanId
|
|
22
|
+
} else {
|
|
23
|
+
this._traceId = rootSpanId
|
|
24
|
+
}
|
|
25
|
+
this._spanId = rootSpanId
|
|
26
|
+
}
|
|
27
|
+
JaegerTracer.prototype = {
|
|
28
|
+
isTracingSupported: function() {
|
|
29
|
+
return true
|
|
30
|
+
},
|
|
31
|
+
getSpanId:function() {
|
|
32
|
+
return this._spanId
|
|
33
|
+
},
|
|
34
|
+
getTraceId: function() {
|
|
35
|
+
return this._traceId
|
|
36
|
+
},
|
|
37
|
+
getUberTraceId: function() {
|
|
38
|
+
//{trace-id}:{span-id}:{parent-span-id}:{flags}
|
|
39
|
+
return this._traceId + ':' + this._spanId + ':' + '0' + ':' + '1'
|
|
40
|
+
},
|
|
41
|
+
makeTracingHeaders: function() {
|
|
42
|
+
return {
|
|
43
|
+
'uber-trace-id': this.getUberTraceId(),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {base64Encode, urlParse} from '@cloudcare/browser-core'
|
|
2
|
+
// start SkyWalking
|
|
3
|
+
function uuid() {
|
|
4
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
5
|
+
/* tslint:disable */
|
|
6
|
+
const r = (Math.random() * 16) | 0;
|
|
7
|
+
/* tslint:disable */
|
|
8
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
9
|
+
|
|
10
|
+
return v.toString(16);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {*} traceId
|
|
16
|
+
* @param {*} traceSegmentId
|
|
17
|
+
* @param {*} applicationId
|
|
18
|
+
* @param {*} version
|
|
19
|
+
* @param {*} requestUrlHost
|
|
20
|
+
*/
|
|
21
|
+
function getSkyWalkingSw8(traceId, traceSegmentId, applicationId, env ,version,requestUrlHost) {
|
|
22
|
+
try {
|
|
23
|
+
var traceIdStr = String(base64Encode(traceId));
|
|
24
|
+
var segmentId = String(base64Encode(traceSegmentId));
|
|
25
|
+
var service = String(base64Encode(applicationId + '_rum_' + env));
|
|
26
|
+
var instance = String(base64Encode(version));
|
|
27
|
+
var endpoint = String(base64Encode(window.location.href));
|
|
28
|
+
var peer = String(base64Encode(requestUrlHost));
|
|
29
|
+
var index = '0'
|
|
30
|
+
// var values = `${1}-${traceIdStr}-${segmentId}-${index}-${service}-${instance}-${endpoint}-${peer}`;
|
|
31
|
+
return '1-' + traceIdStr + '-'+ segmentId + '-' +index + '-'+ service + '-'+ instance + '-'+ endpoint + '-'+ peer
|
|
32
|
+
} catch(err) {
|
|
33
|
+
return ''
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {*} configuration 配置信息
|
|
39
|
+
* @param {*} requestUrl 请求的url
|
|
40
|
+
*/
|
|
41
|
+
export function SkyWalkingTracer(configuration, requestUrl) {
|
|
42
|
+
this._spanId = uuid()
|
|
43
|
+
this._traceId = uuid()
|
|
44
|
+
this._applicationId = configuration.applicationId
|
|
45
|
+
this._env = configuration.env
|
|
46
|
+
this._version = configuration.version
|
|
47
|
+
this._urlParse = urlParse(requestUrl).getParse()
|
|
48
|
+
}
|
|
49
|
+
SkyWalkingTracer.prototype = {
|
|
50
|
+
isTracingSupported: function() {
|
|
51
|
+
if (this._env && this._version && this._urlParse) return true
|
|
52
|
+
return false
|
|
53
|
+
},
|
|
54
|
+
getSpanId:function() {
|
|
55
|
+
return this._spanId
|
|
56
|
+
},
|
|
57
|
+
getTraceId: function() {
|
|
58
|
+
return this._traceId
|
|
59
|
+
},
|
|
60
|
+
getSkyWalkingSw8:function() {
|
|
61
|
+
try {
|
|
62
|
+
var traceIdStr = String(base64Encode(this._traceId));
|
|
63
|
+
var segmentId = String(base64Encode(this._spanId));
|
|
64
|
+
var service = String(base64Encode(this._applicationId + '_rum_' + this.env));
|
|
65
|
+
var instance = String(base64Encode(this._version));
|
|
66
|
+
var endpoint = String(base64Encode(window.location.href));
|
|
67
|
+
var peer = String(base64Encode(this._urlParse.Host));
|
|
68
|
+
var index = '0'
|
|
69
|
+
// var values = `${1}-${traceIdStr}-${segmentId}-${index}-${service}-${instance}-${endpoint}-${peer}`;
|
|
70
|
+
return '1-' + traceIdStr + '-'+ segmentId + '-' +index + '-'+ service + '-'+ instance + '-'+ endpoint + '-'+ peer
|
|
71
|
+
} catch(err) {
|
|
72
|
+
return ''
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
makeTracingHeaders: function() {
|
|
76
|
+
return {
|
|
77
|
+
'sw8': this.getSkyWalkingSw8(),
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -3,8 +3,15 @@ import {
|
|
|
3
3
|
each,
|
|
4
4
|
extend,
|
|
5
5
|
isArray,
|
|
6
|
+
TraceType,
|
|
6
7
|
getOrigin
|
|
7
8
|
} from '@cloudcare/browser-core'
|
|
9
|
+
import { DDtraceTracer} from './ddtraceTracer'
|
|
10
|
+
import { SkyWalkingTracer} from './skywalkingTracer'
|
|
11
|
+
import { JaegerTracer} from './jaegerTracer'
|
|
12
|
+
import { ZipkinSingleTracer} from './zipkinSingleTracer'
|
|
13
|
+
import { ZipkinMultiTracer} from './zipkinMultiTracer'
|
|
14
|
+
import { W3cTraceParentTracer} from './w3cTraceParentTracer'
|
|
8
15
|
|
|
9
16
|
export function clearTracingIfCancelled(context) {
|
|
10
17
|
if (context.status === 0) {
|
|
@@ -53,20 +60,10 @@ export function startTracer(configuration) {
|
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
|
-
|
|
57
|
-
function injectHeadersIfTracingAllowed(configuration, context, inject) {
|
|
58
|
-
if (!isTracingSupported() || !isAllowedUrl(configuration, context.url)) {
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
context.traceId = new TraceIdentifier()
|
|
62
|
-
context.spanId = new TraceIdentifier()
|
|
63
|
-
inject(makeTracingHeaders(context.traceId, context.spanId))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
63
|
function isAllowedUrl(configuration, requestUrl) {
|
|
67
64
|
var requestOrigin = getOrigin(requestUrl)
|
|
68
65
|
var flag = false
|
|
69
|
-
each(configuration.
|
|
66
|
+
each(configuration.allowedTracingOrigins, function (allowedOrigin) {
|
|
70
67
|
if (
|
|
71
68
|
requestOrigin === allowedOrigin ||
|
|
72
69
|
(allowedOrigin instanceof RegExp && allowedOrigin.test(requestOrigin))
|
|
@@ -78,63 +75,38 @@ function isAllowedUrl(configuration, requestUrl) {
|
|
|
78
75
|
return flag
|
|
79
76
|
}
|
|
80
77
|
|
|
81
|
-
export function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
function getCrypto() {
|
|
86
|
-
return window.crypto || window.msCrypto
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function makeTracingHeaders(traceId, spanId) {
|
|
90
|
-
return {
|
|
91
|
-
'x-datadog-origin': 'rum',
|
|
92
|
-
// 'x-datadog-parent-id': spanId.toDecimalString(),
|
|
93
|
-
'x-datadog-sampled': '1',
|
|
94
|
-
'x-datadog-sampling-priority': '1',
|
|
95
|
-
'x-datadog-trace-id': traceId.toDecimalString()
|
|
78
|
+
export function injectHeadersIfTracingAllowed(configuration, context, inject) {
|
|
79
|
+
if (!isAllowedUrl(configuration, context.url) || !configuration.traceType) {
|
|
80
|
+
return
|
|
96
81
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return str
|
|
125
|
-
},
|
|
126
|
-
toDecimalString: function () {
|
|
127
|
-
return this.toString(10)
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
readInt32: function (offset) {
|
|
131
|
-
return (
|
|
132
|
-
this.buffer[offset] * 16777216 +
|
|
133
|
-
(this.buffer[offset + 1] << 16) +
|
|
134
|
-
(this.buffer[offset + 2] << 8) +
|
|
135
|
-
this.buffer[offset + 3]
|
|
136
|
-
)
|
|
82
|
+
var tracer;
|
|
83
|
+
switch(configuration.traceType) {
|
|
84
|
+
case TraceType.DDTRACE:
|
|
85
|
+
tracer = new DDtraceTracer();
|
|
86
|
+
break;
|
|
87
|
+
case TraceType.SKYWALKING_V3:
|
|
88
|
+
tracer = new SkyWalkingTracer(configuration, context.url);
|
|
89
|
+
break;
|
|
90
|
+
case TraceType.ZIPKIN_MULTI_HEADER:
|
|
91
|
+
tracer = new ZipkinMultiTracer(configuration);
|
|
92
|
+
break;
|
|
93
|
+
case TraceType.JAEGER:
|
|
94
|
+
tracer = new JaegerTracer(configuration);
|
|
95
|
+
break;
|
|
96
|
+
case TraceType.W3C_TRACEPARENT:
|
|
97
|
+
tracer = new W3cTraceParentTracer(configuration);
|
|
98
|
+
break;
|
|
99
|
+
case TraceType.ZIPKIN_SINGLE_HEADER:
|
|
100
|
+
tracer = new ZipkinSingleTracer(configuration);
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (!tracer || !tracer.isTracingSupported()) {
|
|
106
|
+
return
|
|
137
107
|
}
|
|
138
|
-
}
|
|
139
108
|
|
|
140
|
-
|
|
109
|
+
context.traceId = tracer.getTraceId()
|
|
110
|
+
context.spanId = tracer.getSpanId()
|
|
111
|
+
inject(tracer.makeTracingHeaders())
|
|
112
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// === Generate a random 64-bit number in fixed-length hex format
|
|
2
|
+
function randomTraceId() {
|
|
3
|
+
const digits = '0123456789abcdef';
|
|
4
|
+
let n = '';
|
|
5
|
+
for (let i = 0; i < 16; i += 1) {
|
|
6
|
+
const rand = Math.floor(Math.random() * 16);
|
|
7
|
+
n += digits[rand];
|
|
8
|
+
}
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {*} configuration 配置信息
|
|
15
|
+
*/
|
|
16
|
+
export function W3cTraceParentTracer(configuration) {
|
|
17
|
+
const rootSpanId = randomTraceId();
|
|
18
|
+
this._traceId = randomTraceId() + rootSpanId
|
|
19
|
+
this._spanId = rootSpanId
|
|
20
|
+
}
|
|
21
|
+
W3cTraceParentTracer.prototype = {
|
|
22
|
+
isTracingSupported: function() {
|
|
23
|
+
return true
|
|
24
|
+
},
|
|
25
|
+
getSpanId:function() {
|
|
26
|
+
return this._spanId
|
|
27
|
+
},
|
|
28
|
+
getTraceId: function() {
|
|
29
|
+
return this._traceId
|
|
30
|
+
},
|
|
31
|
+
getTraceParent: function() {
|
|
32
|
+
// '{version}-{traceId}-{spanId}-{sampleDecision}'
|
|
33
|
+
return '00-' + this._traceId + '-' + this._spanId + '-01'
|
|
34
|
+
},
|
|
35
|
+
makeTracingHeaders: function() {
|
|
36
|
+
return {
|
|
37
|
+
'traceparent': this.getTraceParent()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// === Generate a random 64-bit number in fixed-length hex format
|
|
2
|
+
function randomTraceId() {
|
|
3
|
+
const digits = '0123456789abcdef';
|
|
4
|
+
let n = '';
|
|
5
|
+
for (let i = 0; i < 16; i += 1) {
|
|
6
|
+
const rand = Math.floor(Math.random() * 16);
|
|
7
|
+
n += digits[rand];
|
|
8
|
+
}
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {*} configuration 配置信息
|
|
15
|
+
*/
|
|
16
|
+
export function ZipkinMultiTracer(configuration) {
|
|
17
|
+
const rootSpanId = randomTraceId();
|
|
18
|
+
if (configuration.traceId128Bit) {
|
|
19
|
+
// 128bit生成traceid
|
|
20
|
+
this._traceId = randomTraceId() + rootSpanId
|
|
21
|
+
} else {
|
|
22
|
+
this._traceId = rootSpanId
|
|
23
|
+
}
|
|
24
|
+
this._spanId = rootSpanId
|
|
25
|
+
}
|
|
26
|
+
ZipkinMultiTracer.prototype = {
|
|
27
|
+
isTracingSupported: function() {
|
|
28
|
+
return true
|
|
29
|
+
},
|
|
30
|
+
getSpanId:function() {
|
|
31
|
+
return this._spanId
|
|
32
|
+
},
|
|
33
|
+
getTraceId: function() {
|
|
34
|
+
return this._traceId
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
makeTracingHeaders: function() {
|
|
38
|
+
return {
|
|
39
|
+
'X-B3-TraceId': this.getTraceId(),
|
|
40
|
+
'X-B3-SpanId': this.getSpanId(),
|
|
41
|
+
// 'X-B3-ParentSpanId': '',
|
|
42
|
+
'X-B3-Sampled': '1',
|
|
43
|
+
// 'X-B3-Flags': '0'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// === Generate a random 64-bit number in fixed-length hex format
|
|
2
|
+
function randomTraceId() {
|
|
3
|
+
const digits = '0123456789abcdef';
|
|
4
|
+
let n = '';
|
|
5
|
+
for (let i = 0; i < 16; i += 1) {
|
|
6
|
+
const rand = Math.floor(Math.random() * 16);
|
|
7
|
+
n += digits[rand];
|
|
8
|
+
}
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {*} configuration 配置信息
|
|
15
|
+
*/
|
|
16
|
+
export function ZipkinSingleTracer(configuration) {
|
|
17
|
+
const rootSpanId = randomTraceId();
|
|
18
|
+
this._traceId = randomTraceId() + rootSpanId
|
|
19
|
+
this._spanId = rootSpanId
|
|
20
|
+
}
|
|
21
|
+
ZipkinSingleTracer.prototype = {
|
|
22
|
+
isTracingSupported: function() {
|
|
23
|
+
return true
|
|
24
|
+
},
|
|
25
|
+
getSpanId:function() {
|
|
26
|
+
return this._spanId
|
|
27
|
+
},
|
|
28
|
+
getTraceId: function() {
|
|
29
|
+
return this._traceId
|
|
30
|
+
},
|
|
31
|
+
getB3Str: function() {
|
|
32
|
+
//{TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
|
|
33
|
+
return this._traceId + '-' + this._spanId + '-1'
|
|
34
|
+
},
|
|
35
|
+
makeTracingHeaders: function() {
|
|
36
|
+
return {
|
|
37
|
+
'b3': this.getB3Str()
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|