@cloudcare/browser-rum 3.0.16 → 3.0.18
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/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/domain/assembly.js +27 -8
- package/cjs/domain/configuration.js +130 -14
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +2 -2
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/cjs/domain/tracing/ddtraceTracer.js +6 -43
- package/cjs/domain/tracing/jaegerTracer.js +8 -27
- package/cjs/domain/tracing/traceIdentifier.js +49 -0
- package/cjs/domain/tracing/tracer.js +25 -19
- package/cjs/domain/tracing/w3cTraceParentTracer.js +11 -22
- package/cjs/domain/tracing/zipkinMultiTracer.js +9 -28
- package/cjs/domain/tracing/zipkinSingleTracer.js +7 -20
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/assembly.js +28 -9
- package/esm/domain/configuration.js +126 -14
- package/esm/domain/rumEventsCollection/actions/actionCollection.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +2 -2
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/esm/domain/tracing/ddtraceTracer.js +5 -42
- package/esm/domain/tracing/jaegerTracer.js +8 -27
- package/esm/domain/tracing/traceIdentifier.js +40 -0
- package/esm/domain/tracing/tracer.js +23 -20
- package/esm/domain/tracing/w3cTraceParentTracer.js +11 -22
- package/esm/domain/tracing/zipkinMultiTracer.js +9 -28
- package/esm/domain/tracing/zipkinSingleTracer.js +7 -20
- package/package.json +3 -3
- package/src/domain/assembly.js +47 -23
- package/src/domain/configuration.js +148 -19
- package/src/domain/rumEventsCollection/actions/actionCollection.js +1 -1
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +2 -2
- package/src/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/src/domain/tracing/ddtraceTracer.js +5 -46
- package/src/domain/tracing/jaegerTracer.js +11 -24
- package/src/domain/tracing/traceIdentifier.js +43 -0
- package/src/domain/tracing/tracer.js +34 -27
- package/src/domain/tracing/w3cTraceParentTracer.js +17 -21
- package/src/domain/tracing/zipkinMultiTracer.js +11 -23
- package/src/domain/tracing/zipkinSingleTracer.js +8 -18
|
@@ -4,9 +4,13 @@ import {
|
|
|
4
4
|
shallowClone,
|
|
5
5
|
isArray,
|
|
6
6
|
TraceType,
|
|
7
|
-
getOrigin,
|
|
8
7
|
performDraw,
|
|
9
|
-
isNumber
|
|
8
|
+
isNumber,
|
|
9
|
+
getType,
|
|
10
|
+
find,
|
|
11
|
+
isMatchOption,
|
|
12
|
+
matchList,
|
|
13
|
+
isString
|
|
10
14
|
} from '@cloudcare/browser-core'
|
|
11
15
|
import { DDtraceTracer } from './ddtraceTracer'
|
|
12
16
|
import { SkyWalkingTracer } from './skywalkingTracer'
|
|
@@ -15,11 +19,19 @@ import { ZipkinSingleTracer } from './zipkinSingleTracer'
|
|
|
15
19
|
import { ZipkinMultiTracer } from './zipkinMultiTracer'
|
|
16
20
|
import { W3cTraceParentTracer } from './w3cTraceParentTracer'
|
|
17
21
|
|
|
22
|
+
export function isTracingOption(item) {
|
|
23
|
+
var expectedItem = item
|
|
24
|
+
return (
|
|
25
|
+
getType(expectedItem) === 'object' &&
|
|
26
|
+
isMatchOption(expectedItem.match) &&
|
|
27
|
+
isString(expectedItem.traceType)
|
|
28
|
+
)
|
|
29
|
+
}
|
|
18
30
|
export function clearTracingIfNeeded(context) {
|
|
19
31
|
if (context.status === 0 && !context.isAborted) {
|
|
20
|
-
context.traceId = undefined
|
|
21
|
-
context.spanId = undefined
|
|
22
|
-
context.traceSampled = undefined
|
|
32
|
+
// context.traceId = undefined
|
|
33
|
+
// context.spanId = undefined
|
|
34
|
+
// context.traceSampled = undefined
|
|
23
35
|
}
|
|
24
36
|
}
|
|
25
37
|
|
|
@@ -84,20 +96,6 @@ export function startTracer(configuration, sessionManager) {
|
|
|
84
96
|
}
|
|
85
97
|
}
|
|
86
98
|
}
|
|
87
|
-
function isAllowedUrl(configuration, requestUrl) {
|
|
88
|
-
var requestOrigin = getOrigin(requestUrl)
|
|
89
|
-
var flag = false
|
|
90
|
-
each(configuration.allowedTracingOrigins, function (allowedOrigin) {
|
|
91
|
-
if (
|
|
92
|
-
requestOrigin === allowedOrigin ||
|
|
93
|
-
(allowedOrigin instanceof RegExp && allowedOrigin.test(requestOrigin))
|
|
94
|
-
) {
|
|
95
|
-
flag = true
|
|
96
|
-
return false
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
return flag
|
|
100
|
-
}
|
|
101
99
|
|
|
102
100
|
export function injectHeadersIfTracingAllowed(
|
|
103
101
|
configuration,
|
|
@@ -105,18 +103,24 @@ export function injectHeadersIfTracingAllowed(
|
|
|
105
103
|
sessionManager,
|
|
106
104
|
inject
|
|
107
105
|
) {
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
if (!sessionManager.findTrackedSession()) {
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
var tracingOption = find(
|
|
110
|
+
configuration.allowedTracingUrls,
|
|
111
|
+
function (tracingOption) {
|
|
112
|
+
return matchList([tracingOption.match], context.url, true)
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
if (!tracingOption) {
|
|
113
116
|
return
|
|
114
117
|
}
|
|
115
118
|
var traceSampled =
|
|
116
119
|
!isNumber(configuration.tracingSampleRate) ||
|
|
117
120
|
performDraw(configuration.tracingSampleRate)
|
|
118
|
-
var tracer
|
|
119
|
-
|
|
121
|
+
var tracer,
|
|
122
|
+
traceType = tracingOption.traceType
|
|
123
|
+
switch (traceType) {
|
|
120
124
|
case TraceType.DDTRACE:
|
|
121
125
|
tracer = new DDtraceTracer(traceSampled)
|
|
122
126
|
break
|
|
@@ -130,7 +134,10 @@ export function injectHeadersIfTracingAllowed(
|
|
|
130
134
|
tracer = new JaegerTracer(configuration, traceSampled)
|
|
131
135
|
break
|
|
132
136
|
case TraceType.W3C_TRACEPARENT:
|
|
133
|
-
tracer = new W3cTraceParentTracer(
|
|
137
|
+
tracer = new W3cTraceParentTracer(traceSampled)
|
|
138
|
+
break
|
|
139
|
+
case TraceType.W3C_TRACEPARENT_64:
|
|
140
|
+
tracer = new W3cTraceParentTracer(traceSampled, true)
|
|
134
141
|
break
|
|
135
142
|
case TraceType.ZIPKIN_SINGLE_HEADER:
|
|
136
143
|
tracer = new ZipkinSingleTracer(configuration, traceSampled)
|
|
@@ -1,41 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
function randomTraceId() {
|
|
3
|
-
var digits = '0123456789abcdef'
|
|
4
|
-
var n = ''
|
|
5
|
-
for (var i = 0; i < 16; i += 1) {
|
|
6
|
-
var rand = Math.floor(Math.random() * 16)
|
|
7
|
-
n += digits[rand]
|
|
8
|
-
}
|
|
9
|
-
return n
|
|
10
|
-
}
|
|
1
|
+
import { TraceIdentifier, getCrypto } from './traceIdentifier'
|
|
11
2
|
|
|
12
3
|
/**
|
|
13
4
|
*
|
|
14
|
-
* @param {*}
|
|
5
|
+
* @param {*} traceSampled
|
|
6
|
+
* @param {*} isHexTraceId 是否需要转换成10进制上报数据
|
|
15
7
|
*/
|
|
16
|
-
export function W3cTraceParentTracer(
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
this._spanId = rootSpanId
|
|
8
|
+
export function W3cTraceParentTracer(traceSampled, isHexTraceId) {
|
|
9
|
+
this._traceId = new TraceIdentifier()
|
|
10
|
+
this._spanId = new TraceIdentifier()
|
|
20
11
|
this._traceSampled = traceSampled
|
|
12
|
+
this.isHexTraceId = isHexTraceId
|
|
21
13
|
}
|
|
22
14
|
W3cTraceParentTracer.prototype = {
|
|
23
15
|
isTracingSupported: function () {
|
|
24
|
-
return
|
|
16
|
+
return getCrypto() !== undefined
|
|
25
17
|
},
|
|
26
18
|
getSpanId: function () {
|
|
27
|
-
return this.
|
|
19
|
+
return this.isHexTraceId
|
|
20
|
+
? this._spanId.toDecimalString()
|
|
21
|
+
: this._spanId.toPaddedHexadecimalString()
|
|
28
22
|
},
|
|
29
23
|
getTraceId: function () {
|
|
30
|
-
return this.
|
|
24
|
+
return this.isHexTraceId
|
|
25
|
+
? this._traceId.toDecimalString()
|
|
26
|
+
: '0000000000000000' + this._traceId.toPaddedHexadecimalString()
|
|
31
27
|
},
|
|
32
28
|
getTraceParent: function () {
|
|
33
29
|
// '{version}-{traceId}-{spanId}-{sampleDecision}'
|
|
34
30
|
return (
|
|
35
|
-
'00-' +
|
|
36
|
-
this._traceId +
|
|
31
|
+
'00-0000000000000000' +
|
|
32
|
+
this._traceId.toPaddedHexadecimalString() +
|
|
37
33
|
'-' +
|
|
38
|
-
this._spanId +
|
|
34
|
+
this._spanId.toPaddedHexadecimalString() +
|
|
39
35
|
'-' +
|
|
40
36
|
(this._traceSampled ? '01' : '00')
|
|
41
37
|
)
|
|
@@ -1,44 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
function randomTraceId() {
|
|
3
|
-
var digits = '0123456789abcdef'
|
|
4
|
-
var n = ''
|
|
5
|
-
for (var i = 0; i < 16; i += 1) {
|
|
6
|
-
var rand = Math.floor(Math.random() * 16)
|
|
7
|
-
n += digits[rand]
|
|
8
|
-
}
|
|
9
|
-
return n
|
|
10
|
-
}
|
|
1
|
+
import { TraceIdentifier, getCrypto } from './traceIdentifier'
|
|
11
2
|
|
|
12
3
|
/**
|
|
13
4
|
*
|
|
14
5
|
* @param {*} configuration 配置信息
|
|
15
6
|
*/
|
|
16
7
|
export function ZipkinMultiTracer(configuration, traceSampled) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// 128bit生成traceid
|
|
20
|
-
this._traceId = randomTraceId() + rootSpanId
|
|
21
|
-
} else {
|
|
22
|
-
this._traceId = rootSpanId
|
|
23
|
-
}
|
|
24
|
-
this._spanId = rootSpanId
|
|
8
|
+
this._traceId = new TraceIdentifier()
|
|
9
|
+
this._spanId = new TraceIdentifier()
|
|
25
10
|
this._traceSampled = traceSampled
|
|
11
|
+
this.is128Bit = configuration.traceId128Bit
|
|
26
12
|
}
|
|
27
13
|
ZipkinMultiTracer.prototype = {
|
|
28
14
|
isTracingSupported: function () {
|
|
29
|
-
return
|
|
15
|
+
return getCrypto() !== undefined
|
|
30
16
|
},
|
|
31
17
|
getSpanId: function () {
|
|
32
|
-
return this._spanId
|
|
18
|
+
return this._spanId.toPaddedHexadecimalString()
|
|
33
19
|
},
|
|
34
20
|
getTraceId: function () {
|
|
35
|
-
return this.
|
|
21
|
+
return this.is128Bit
|
|
22
|
+
? '0000000000000000' + this._traceId.toPaddedHexadecimalString()
|
|
23
|
+
: this._traceId.toPaddedHexadecimalString()
|
|
36
24
|
},
|
|
37
25
|
|
|
38
26
|
makeTracingHeaders: function () {
|
|
39
27
|
return {
|
|
40
|
-
'X-B3-TraceId': this.
|
|
41
|
-
'X-B3-SpanId': this.
|
|
28
|
+
'X-B3-TraceId': this.getSpanId(),
|
|
29
|
+
'X-B3-SpanId': this.getTraceId(),
|
|
42
30
|
// 'X-B3-ParentSpanId': '',
|
|
43
31
|
'X-B3-Sampled': this._traceSampled ? '1' : '0'
|
|
44
32
|
// 'X-B3-Flags': '0'
|
|
@@ -1,40 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
function randomTraceId() {
|
|
3
|
-
var digits = '0123456789abcdef'
|
|
4
|
-
var n = ''
|
|
5
|
-
for (var i = 0; i < 16; i += 1) {
|
|
6
|
-
var rand = Math.floor(Math.random() * 16)
|
|
7
|
-
n += digits[rand]
|
|
8
|
-
}
|
|
9
|
-
return n
|
|
10
|
-
}
|
|
1
|
+
import { TraceIdentifier, getCrypto } from './traceIdentifier'
|
|
11
2
|
|
|
12
3
|
/**
|
|
13
4
|
*
|
|
14
5
|
* @param {*} configuration 配置信息
|
|
15
6
|
*/
|
|
16
7
|
export function ZipkinSingleTracer(configuration, traceSampled) {
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
this._spanId = rootSpanId
|
|
8
|
+
this._traceId = new TraceIdentifier()
|
|
9
|
+
this._spanId = new TraceIdentifier()
|
|
20
10
|
this._traceSampled = traceSampled
|
|
21
11
|
}
|
|
22
12
|
ZipkinSingleTracer.prototype = {
|
|
23
13
|
isTracingSupported: function () {
|
|
24
|
-
return
|
|
14
|
+
return getCrypto() !== undefined
|
|
25
15
|
},
|
|
26
16
|
getSpanId: function () {
|
|
27
|
-
return this._spanId
|
|
17
|
+
return this._spanId.toPaddedHexadecimalString()
|
|
28
18
|
},
|
|
29
19
|
getTraceId: function () {
|
|
30
|
-
return this._traceId
|
|
20
|
+
return this._traceId.toPaddedHexadecimalString()
|
|
31
21
|
},
|
|
32
22
|
getB3Str: function () {
|
|
33
23
|
//{TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
|
|
34
24
|
return (
|
|
35
|
-
this.
|
|
25
|
+
this.getTraceId() +
|
|
36
26
|
'-' +
|
|
37
|
-
this.
|
|
27
|
+
this.getSpanId() +
|
|
38
28
|
'-' +
|
|
39
29
|
(this._traceSampled ? '1' : '0')
|
|
40
30
|
)
|