@cloudcare/browser-rum 3.2.8 → 3.2.9
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/configuration.js +1 -0
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/tracing/ddtraceTracer.js +11 -1
- package/cjs/domain/tracing/ddtraceTracer.js.map +1 -1
- package/cjs/domain/tracing/jaegerTracer.js +10 -0
- package/cjs/domain/tracing/jaegerTracer.js.map +1 -1
- package/cjs/domain/tracing/skywalkingTracer.js +11 -2
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +3 -3
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/cjs/domain/tracing/w3cTraceParentTracer.js +10 -1
- package/cjs/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinMultiTracer.js +10 -0
- package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinSingleTracer.js +10 -0
- package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/configuration.js +1 -0
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/tracing/ddtraceTracer.js +11 -1
- package/esm/domain/tracing/ddtraceTracer.js.map +1 -1
- package/esm/domain/tracing/jaegerTracer.js +10 -1
- package/esm/domain/tracing/jaegerTracer.js.map +1 -1
- package/esm/domain/tracing/skywalkingTracer.js +12 -3
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/domain/tracing/tracer.js +3 -3
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/esm/domain/tracing/w3cTraceParentTracer.js +11 -2
- package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinMultiTracer.js +10 -1
- package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinSingleTracer.js +10 -1
- package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/package.json +4 -4
- package/src/domain/configuration.js +6 -0
- package/src/domain/tracing/ddtraceTracer.js +14 -1
- package/src/domain/tracing/jaegerTracer.js +13 -1
- package/src/domain/tracing/skywalkingTracer.js +15 -3
- package/src/domain/tracing/tracer.js +3 -3
- package/src/domain/tracing/w3cTraceParentTracer.js +18 -2
- package/src/domain/tracing/zipkinMultiTracer.js +13 -1
- package/src/domain/tracing/zipkinSingleTracer.js +13 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TraceIdentifier, getCrypto } from './traceIdentifier';
|
|
2
|
-
|
|
2
|
+
import { getType } from '@cloudcare/browser-core';
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @param {*} configuration 配置信息
|
|
@@ -9,6 +9,12 @@ export function ZipkinMultiTracer(configuration, traceSampled) {
|
|
|
9
9
|
this._spanId = new TraceIdentifier();
|
|
10
10
|
this._traceSampled = traceSampled;
|
|
11
11
|
this.is128Bit = configuration.traceId128Bit;
|
|
12
|
+
if (configuration.generateTraceId && getType(configuration.generateTraceId) === 'function') {
|
|
13
|
+
var customTraceId = configuration.generateTraceId();
|
|
14
|
+
if (getType(customTraceId) === 'string') {
|
|
15
|
+
this.customTraceId = customTraceId;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
ZipkinMultiTracer.prototype = {
|
|
14
20
|
isTracingSupported: function isTracingSupported() {
|
|
@@ -18,6 +24,9 @@ ZipkinMultiTracer.prototype = {
|
|
|
18
24
|
return this._spanId.toPaddedHexadecimalString();
|
|
19
25
|
},
|
|
20
26
|
getTraceId: function getTraceId() {
|
|
27
|
+
if (this.customTraceId) {
|
|
28
|
+
return this.customTraceId;
|
|
29
|
+
}
|
|
21
30
|
return this.is128Bit ? '0000000000000000' + this._traceId.toPaddedHexadecimalString() : this._traceId.toPaddedHexadecimalString();
|
|
22
31
|
},
|
|
23
32
|
makeTracingHeaders: function makeTracingHeaders() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zipkinMultiTracer.js","names":["TraceIdentifier","getCrypto","ZipkinMultiTracer","configuration","traceSampled","_traceId","_spanId","_traceSampled","is128Bit","traceId128Bit","prototype","isTracingSupported","undefined","getSpanId","toPaddedHexadecimalString","getTraceId","makeTracingHeaders"],"sources":["../../../src/domain/tracing/zipkinMultiTracer.js"],"sourcesContent":["import { TraceIdentifier, getCrypto } from './traceIdentifier'\
|
|
1
|
+
{"version":3,"file":"zipkinMultiTracer.js","names":["TraceIdentifier","getCrypto","getType","ZipkinMultiTracer","configuration","traceSampled","_traceId","_spanId","_traceSampled","is128Bit","traceId128Bit","generateTraceId","customTraceId","prototype","isTracingSupported","undefined","getSpanId","toPaddedHexadecimalString","getTraceId","makeTracingHeaders"],"sources":["../../../src/domain/tracing/zipkinMultiTracer.js"],"sourcesContent":["import { TraceIdentifier, getCrypto } from './traceIdentifier'\nimport { getType } from '@cloudcare/browser-core'\n/**\n *\n * @param {*} configuration 配置信息\n */\nexport function ZipkinMultiTracer(configuration, traceSampled) {\n this._traceId = new TraceIdentifier()\n this._spanId = new TraceIdentifier()\n this._traceSampled = traceSampled\n this.is128Bit = configuration.traceId128Bit\n if (\n configuration.generateTraceId &&\n getType(configuration.generateTraceId) === 'function'\n ) {\n const customTraceId = configuration.generateTraceId()\n if (getType(customTraceId) === 'string') {\n this.customTraceId = customTraceId\n }\n }\n}\nZipkinMultiTracer.prototype = {\n isTracingSupported: function () {\n return getCrypto() !== undefined\n },\n getSpanId: function () {\n return this._spanId.toPaddedHexadecimalString()\n },\n getTraceId: function () {\n if (this.customTraceId) {\n return this.customTraceId\n }\n return this.is128Bit\n ? '0000000000000000' + this._traceId.toPaddedHexadecimalString()\n : this._traceId.toPaddedHexadecimalString()\n },\n\n makeTracingHeaders: function () {\n return {\n 'X-B3-TraceId': this.getSpanId(),\n 'X-B3-SpanId': this.getTraceId(),\n // 'X-B3-ParentSpanId': '',\n 'X-B3-Sampled': this._traceSampled ? '1' : '0'\n // 'X-B3-Flags': '0'\n }\n }\n}\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,SAAS,QAAQ,mBAAmB;AAC9D,SAASC,OAAO,QAAQ,yBAAyB;AACjD;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,aAAa,EAAEC,YAAY,EAAE;EAC7D,IAAI,CAACC,QAAQ,GAAG,IAAIN,eAAe,CAAC,CAAC;EACrC,IAAI,CAACO,OAAO,GAAG,IAAIP,eAAe,CAAC,CAAC;EACpC,IAAI,CAACQ,aAAa,GAAGH,YAAY;EACjC,IAAI,CAACI,QAAQ,GAAGL,aAAa,CAACM,aAAa;EAC3C,IACEN,aAAa,CAACO,eAAe,IAC7BT,OAAO,CAACE,aAAa,CAACO,eAAe,CAAC,KAAK,UAAU,EACrD;IACA,IAAMC,aAAa,GAAGR,aAAa,CAACO,eAAe,CAAC,CAAC;IACrD,IAAIT,OAAO,CAACU,aAAa,CAAC,KAAK,QAAQ,EAAE;MACvC,IAAI,CAACA,aAAa,GAAGA,aAAa;IACpC;EACF;AACF;AACAT,iBAAiB,CAACU,SAAS,GAAG;EAC5BC,kBAAkB,EAAE,SAAAA,mBAAA,EAAY;IAC9B,OAAOb,SAAS,CAAC,CAAC,KAAKc,SAAS;EAClC,CAAC;EACDC,SAAS,EAAE,SAAAA,UAAA,EAAY;IACrB,OAAO,IAAI,CAACT,OAAO,CAACU,yBAAyB,CAAC,CAAC;EACjD,CAAC;EACDC,UAAU,EAAE,SAAAA,WAAA,EAAY;IACtB,IAAI,IAAI,CAACN,aAAa,EAAE;MACtB,OAAO,IAAI,CAACA,aAAa;IAC3B;IACA,OAAO,IAAI,CAACH,QAAQ,GAChB,kBAAkB,GAAG,IAAI,CAACH,QAAQ,CAACW,yBAAyB,CAAC,CAAC,GAC9D,IAAI,CAACX,QAAQ,CAACW,yBAAyB,CAAC,CAAC;EAC/C,CAAC;EAEDE,kBAAkB,EAAE,SAAAA,mBAAA,EAAY;IAC9B,OAAO;MACL,cAAc,EAAE,IAAI,CAACH,SAAS,CAAC,CAAC;MAChC,aAAa,EAAE,IAAI,CAACE,UAAU,CAAC,CAAC;MAChC;MACA,cAAc,EAAE,IAAI,CAACV,aAAa,GAAG,GAAG,GAAG;MAC3C;IACF,CAAC;EACH;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TraceIdentifier, getCrypto } from './traceIdentifier';
|
|
2
|
-
|
|
2
|
+
import { getType } from '@cloudcare/browser-core';
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @param {*} configuration 配置信息
|
|
@@ -8,6 +8,12 @@ export function ZipkinSingleTracer(configuration, traceSampled) {
|
|
|
8
8
|
this._traceId = new TraceIdentifier();
|
|
9
9
|
this._spanId = new TraceIdentifier();
|
|
10
10
|
this._traceSampled = traceSampled;
|
|
11
|
+
if (configuration.generateTraceId && getType(configuration.generateTraceId) === 'function') {
|
|
12
|
+
var customTraceId = configuration.generateTraceId();
|
|
13
|
+
if (getType(customTraceId) === 'string') {
|
|
14
|
+
this.customTraceId = customTraceId;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
ZipkinSingleTracer.prototype = {
|
|
13
19
|
isTracingSupported: function isTracingSupported() {
|
|
@@ -17,6 +23,9 @@ ZipkinSingleTracer.prototype = {
|
|
|
17
23
|
return this._spanId.toPaddedHexadecimalString();
|
|
18
24
|
},
|
|
19
25
|
getTraceId: function getTraceId() {
|
|
26
|
+
if (this.customTraceId) {
|
|
27
|
+
return this.customTraceId;
|
|
28
|
+
}
|
|
20
29
|
return this._traceId.toPaddedHexadecimalString();
|
|
21
30
|
},
|
|
22
31
|
getB3Str: function getB3Str() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zipkinSingleTracer.js","names":["TraceIdentifier","getCrypto","ZipkinSingleTracer","configuration","traceSampled","_traceId","_spanId","_traceSampled","prototype","isTracingSupported","undefined","getSpanId","toPaddedHexadecimalString","getTraceId","getB3Str","makeTracingHeaders","b3"],"sources":["../../../src/domain/tracing/zipkinSingleTracer.js"],"sourcesContent":["import { TraceIdentifier, getCrypto } from './traceIdentifier'\
|
|
1
|
+
{"version":3,"file":"zipkinSingleTracer.js","names":["TraceIdentifier","getCrypto","getType","ZipkinSingleTracer","configuration","traceSampled","_traceId","_spanId","_traceSampled","generateTraceId","customTraceId","prototype","isTracingSupported","undefined","getSpanId","toPaddedHexadecimalString","getTraceId","getB3Str","makeTracingHeaders","b3"],"sources":["../../../src/domain/tracing/zipkinSingleTracer.js"],"sourcesContent":["import { TraceIdentifier, getCrypto } from './traceIdentifier'\nimport { getType } from '@cloudcare/browser-core'\n/**\n *\n * @param {*} configuration 配置信息\n */\nexport function ZipkinSingleTracer(configuration, traceSampled) {\n this._traceId = new TraceIdentifier()\n this._spanId = new TraceIdentifier()\n this._traceSampled = traceSampled\n if (\n configuration.generateTraceId &&\n getType(configuration.generateTraceId) === 'function'\n ) {\n const customTraceId = configuration.generateTraceId()\n if (getType(customTraceId) === 'string') {\n this.customTraceId = customTraceId\n }\n }\n}\nZipkinSingleTracer.prototype = {\n isTracingSupported: function () {\n return getCrypto() !== undefined\n },\n getSpanId: function () {\n return this._spanId.toPaddedHexadecimalString()\n },\n getTraceId: function () {\n if (this.customTraceId) {\n return this.customTraceId\n }\n return this._traceId.toPaddedHexadecimalString()\n },\n getB3Str: function () {\n //{TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}\n return (\n this.getTraceId() +\n '-' +\n this.getSpanId() +\n '-' +\n (this._traceSampled ? '1' : '0')\n )\n },\n makeTracingHeaders: function () {\n return {\n b3: this.getB3Str()\n }\n }\n}\n"],"mappings":"AAAA,SAASA,eAAe,EAAEC,SAAS,QAAQ,mBAAmB;AAC9D,SAASC,OAAO,QAAQ,yBAAyB;AACjD;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,aAAa,EAAEC,YAAY,EAAE;EAC9D,IAAI,CAACC,QAAQ,GAAG,IAAIN,eAAe,CAAC,CAAC;EACrC,IAAI,CAACO,OAAO,GAAG,IAAIP,eAAe,CAAC,CAAC;EACpC,IAAI,CAACQ,aAAa,GAAGH,YAAY;EACjC,IACED,aAAa,CAACK,eAAe,IAC7BP,OAAO,CAACE,aAAa,CAACK,eAAe,CAAC,KAAK,UAAU,EACrD;IACA,IAAMC,aAAa,GAAGN,aAAa,CAACK,eAAe,CAAC,CAAC;IACrD,IAAIP,OAAO,CAACQ,aAAa,CAAC,KAAK,QAAQ,EAAE;MACvC,IAAI,CAACA,aAAa,GAAGA,aAAa;IACpC;EACF;AACF;AACAP,kBAAkB,CAACQ,SAAS,GAAG;EAC7BC,kBAAkB,EAAE,SAAAA,mBAAA,EAAY;IAC9B,OAAOX,SAAS,CAAC,CAAC,KAAKY,SAAS;EAClC,CAAC;EACDC,SAAS,EAAE,SAAAA,UAAA,EAAY;IACrB,OAAO,IAAI,CAACP,OAAO,CAACQ,yBAAyB,CAAC,CAAC;EACjD,CAAC;EACDC,UAAU,EAAE,SAAAA,WAAA,EAAY;IACtB,IAAI,IAAI,CAACN,aAAa,EAAE;MACtB,OAAO,IAAI,CAACA,aAAa;IAC3B;IACA,OAAO,IAAI,CAACJ,QAAQ,CAACS,yBAAyB,CAAC,CAAC;EAClD,CAAC;EACDE,QAAQ,EAAE,SAAAA,SAAA,EAAY;IACpB;IACA,OACE,IAAI,CAACD,UAAU,CAAC,CAAC,GACjB,GAAG,GACH,IAAI,CAACF,SAAS,CAAC,CAAC,GAChB,GAAG,IACF,IAAI,CAACN,aAAa,GAAG,GAAG,GAAG,GAAG,CAAC;EAEpC,CAAC;EACDU,kBAAkB,EAAE,SAAAA,mBAAA,EAAY;IAC9B,OAAO;MACLC,EAAE,EAAE,IAAI,CAACF,QAAQ,CAAC;IACpB,CAAC;EACH;AACF,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-rum",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.9",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@cloudcare/browser-core": "3.2.
|
|
9
|
-
"@cloudcare/browser-worker": "3.2.
|
|
8
|
+
"@cloudcare/browser-core": "3.2.9",
|
|
9
|
+
"@cloudcare/browser-worker": "3.2.9"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"dev": "webpack serve --open --mode=development",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
|
|
35
35
|
"description": "DataFlux RUM Web 端数据指标监控",
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "b613ce3dff95ad63a9c937e014f032769b1bc9e3"
|
|
37
37
|
}
|
|
@@ -90,6 +90,12 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
90
90
|
initConfiguration.injectTraceHeader,
|
|
91
91
|
'injectTraceHeader threw an error:'
|
|
92
92
|
),
|
|
93
|
+
generateTraceId:
|
|
94
|
+
initConfiguration.generateTraceId &&
|
|
95
|
+
catchUserErrors(
|
|
96
|
+
initConfiguration.generateTraceId,
|
|
97
|
+
'generateTraceId threw an error:'
|
|
98
|
+
),
|
|
93
99
|
excludedActivityUrls: isNullUndefinedDefaultValue(
|
|
94
100
|
initConfiguration.excludedActivityUrls,
|
|
95
101
|
[]
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { TraceIdentifier, getCrypto } from './traceIdentifier'
|
|
2
|
+
import { getType } from '@cloudcare/browser-core'
|
|
2
3
|
/**
|
|
3
4
|
*
|
|
4
5
|
* @param {*} configuration 配置信息
|
|
5
6
|
*/
|
|
6
|
-
export function DDtraceTracer(traceSampled) {
|
|
7
|
+
export function DDtraceTracer(configuration, traceSampled) {
|
|
7
8
|
this._spanId = new TraceIdentifier()
|
|
8
9
|
this._traceId = new TraceIdentifier()
|
|
9
10
|
this._traceSampled = traceSampled
|
|
11
|
+
if (
|
|
12
|
+
configuration.generateTraceId &&
|
|
13
|
+
getType(configuration.generateTraceId) === 'function'
|
|
14
|
+
) {
|
|
15
|
+
const customTraceId = configuration.generateTraceId()
|
|
16
|
+
if (getType(customTraceId) === 'string') {
|
|
17
|
+
this.customTraceId = customTraceId
|
|
18
|
+
}
|
|
19
|
+
}
|
|
10
20
|
}
|
|
11
21
|
DDtraceTracer.prototype = {
|
|
12
22
|
isTracingSupported: function () {
|
|
@@ -16,6 +26,9 @@ DDtraceTracer.prototype = {
|
|
|
16
26
|
return this._spanId.toDecimalString()
|
|
17
27
|
},
|
|
18
28
|
getTraceId: function () {
|
|
29
|
+
if (this.customTraceId) {
|
|
30
|
+
return this.customTraceId
|
|
31
|
+
}
|
|
19
32
|
return this._traceId.toDecimalString()
|
|
20
33
|
},
|
|
21
34
|
makeTracingHeaders: function () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TraceIdentifier, getCrypto } from './traceIdentifier'
|
|
2
|
-
|
|
2
|
+
import { getType } from '@cloudcare/browser-core'
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @param {*} configuration 配置信息
|
|
@@ -9,6 +9,15 @@ export function JaegerTracer(configuration, traceSampled) {
|
|
|
9
9
|
this._spanId = new TraceIdentifier()
|
|
10
10
|
this._traceSampled = traceSampled
|
|
11
11
|
this.is128Bit = configuration.traceId128Bit
|
|
12
|
+
if (
|
|
13
|
+
configuration.generateTraceId &&
|
|
14
|
+
getType(configuration.generateTraceId) === 'function'
|
|
15
|
+
) {
|
|
16
|
+
const customTraceId = configuration.generateTraceId()
|
|
17
|
+
if (getType(customTraceId) === 'string') {
|
|
18
|
+
this.customTraceId = customTraceId
|
|
19
|
+
}
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
JaegerTracer.prototype = {
|
|
14
23
|
isTracingSupported: function () {
|
|
@@ -18,6 +27,9 @@ JaegerTracer.prototype = {
|
|
|
18
27
|
return this._spanId.toPaddedHexadecimalString()
|
|
19
28
|
},
|
|
20
29
|
getTraceId: function () {
|
|
30
|
+
if (this.customTraceId) {
|
|
31
|
+
return this.customTraceId
|
|
32
|
+
}
|
|
21
33
|
return this.is128Bit
|
|
22
34
|
? '0000000000000000' + this._traceId.toPaddedHexadecimalString()
|
|
23
35
|
: this._traceId.toPaddedHexadecimalString()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { base64Encode, urlParse } from '@cloudcare/browser-core'
|
|
1
|
+
import { base64Encode, urlParse, getType } from '@cloudcare/browser-core'
|
|
2
2
|
// start SkyWalking
|
|
3
3
|
function uuid() {
|
|
4
4
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
@@ -68,6 +68,15 @@ export function SkyWalkingTracer(configuration, requestUrl, traceSampled) {
|
|
|
68
68
|
this._version = configuration.version
|
|
69
69
|
this._urlParse = urlParse(requestUrl).getParse()
|
|
70
70
|
this._traceSampled = traceSampled
|
|
71
|
+
if (
|
|
72
|
+
configuration.generateTraceId &&
|
|
73
|
+
getType(configuration.generateTraceId) === 'function'
|
|
74
|
+
) {
|
|
75
|
+
const customTraceId = configuration.generateTraceId()
|
|
76
|
+
if (getType(customTraceId) === 'string') {
|
|
77
|
+
this.customTraceId = customTraceId
|
|
78
|
+
}
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
SkyWalkingTracer.prototype = {
|
|
73
82
|
isTracingSupported: function () {
|
|
@@ -78,12 +87,15 @@ SkyWalkingTracer.prototype = {
|
|
|
78
87
|
return this._spanId
|
|
79
88
|
},
|
|
80
89
|
getTraceId: function () {
|
|
90
|
+
if (this.customTraceId) {
|
|
91
|
+
return this.customTraceId
|
|
92
|
+
}
|
|
81
93
|
return this._traceId
|
|
82
94
|
},
|
|
83
95
|
getSkyWalkingSw8: function () {
|
|
84
96
|
try {
|
|
85
|
-
var traceIdStr = String(base64Encode(this.
|
|
86
|
-
var segmentId = String(base64Encode(this.
|
|
97
|
+
var traceIdStr = String(base64Encode(this.getTraceId()))
|
|
98
|
+
var segmentId = String(base64Encode(this.getSpanId()))
|
|
87
99
|
var service = String(
|
|
88
100
|
base64Encode(this._applicationId + '_rum_' + this.env)
|
|
89
101
|
)
|
|
@@ -122,7 +122,7 @@ export function injectHeadersIfTracingAllowed(
|
|
|
122
122
|
traceType = tracingOption.traceType
|
|
123
123
|
switch (traceType) {
|
|
124
124
|
case TraceType.DDTRACE:
|
|
125
|
-
tracer = new DDtraceTracer(traceSampled)
|
|
125
|
+
tracer = new DDtraceTracer(configuration, traceSampled)
|
|
126
126
|
break
|
|
127
127
|
case TraceType.SKYWALKING_V3:
|
|
128
128
|
tracer = new SkyWalkingTracer(configuration, context.url, traceSampled)
|
|
@@ -134,10 +134,10 @@ export function injectHeadersIfTracingAllowed(
|
|
|
134
134
|
tracer = new JaegerTracer(configuration, traceSampled)
|
|
135
135
|
break
|
|
136
136
|
case TraceType.W3C_TRACEPARENT:
|
|
137
|
-
tracer = new W3cTraceParentTracer(traceSampled)
|
|
137
|
+
tracer = new W3cTraceParentTracer(configuration, traceSampled)
|
|
138
138
|
break
|
|
139
139
|
case TraceType.W3C_TRACEPARENT_64:
|
|
140
|
-
tracer = new W3cTraceParentTracer(traceSampled, true)
|
|
140
|
+
tracer = new W3cTraceParentTracer(configuration, traceSampled, true)
|
|
141
141
|
break
|
|
142
142
|
case TraceType.ZIPKIN_SINGLE_HEADER:
|
|
143
143
|
tracer = new ZipkinSingleTracer(configuration, traceSampled)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TraceIdentifier, getCrypto } from './traceIdentifier'
|
|
2
|
-
import { assign } from '@cloudcare/browser-core'
|
|
2
|
+
import { assign, getType } from '@cloudcare/browser-core'
|
|
3
3
|
|
|
4
4
|
// === Generate a random 64-bit number in fixed-length hex format
|
|
5
5
|
function randomTraceId() {
|
|
@@ -16,11 +16,24 @@ function randomTraceId() {
|
|
|
16
16
|
* @param {*} traceSampled
|
|
17
17
|
* @param {*} isHexTraceId 是否需要转换成10进制上报数据
|
|
18
18
|
*/
|
|
19
|
-
export function W3cTraceParentTracer(
|
|
19
|
+
export function W3cTraceParentTracer(
|
|
20
|
+
configuration,
|
|
21
|
+
traceSampled,
|
|
22
|
+
isHexTraceId
|
|
23
|
+
) {
|
|
20
24
|
this._traceId = new TraceIdentifier()
|
|
21
25
|
this._spanId = new TraceIdentifier()
|
|
22
26
|
this._traceSampled = traceSampled
|
|
23
27
|
this.isHexTraceId = isHexTraceId
|
|
28
|
+
if (
|
|
29
|
+
configuration.generateTraceId &&
|
|
30
|
+
getType(configuration.generateTraceId) === 'function'
|
|
31
|
+
) {
|
|
32
|
+
const customTraceId = configuration.generateTraceId()
|
|
33
|
+
if (getType(customTraceId) === 'string') {
|
|
34
|
+
this.customTraceId = customTraceId
|
|
35
|
+
}
|
|
36
|
+
}
|
|
24
37
|
}
|
|
25
38
|
W3cTraceParentTracer.prototype = {
|
|
26
39
|
isTracingSupported: function () {
|
|
@@ -32,6 +45,9 @@ W3cTraceParentTracer.prototype = {
|
|
|
32
45
|
: this._spanId.toPaddedHexadecimalString()
|
|
33
46
|
},
|
|
34
47
|
getTraceId: function () {
|
|
48
|
+
if (this.customTraceId) {
|
|
49
|
+
return this.customTraceId
|
|
50
|
+
}
|
|
35
51
|
if (this.isHexTraceId) {
|
|
36
52
|
// 转化为二进制之后上报
|
|
37
53
|
return this._traceId.toDecimalString()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TraceIdentifier, getCrypto } from './traceIdentifier'
|
|
2
|
-
|
|
2
|
+
import { getType } from '@cloudcare/browser-core'
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @param {*} configuration 配置信息
|
|
@@ -9,6 +9,15 @@ export function ZipkinMultiTracer(configuration, traceSampled) {
|
|
|
9
9
|
this._spanId = new TraceIdentifier()
|
|
10
10
|
this._traceSampled = traceSampled
|
|
11
11
|
this.is128Bit = configuration.traceId128Bit
|
|
12
|
+
if (
|
|
13
|
+
configuration.generateTraceId &&
|
|
14
|
+
getType(configuration.generateTraceId) === 'function'
|
|
15
|
+
) {
|
|
16
|
+
const customTraceId = configuration.generateTraceId()
|
|
17
|
+
if (getType(customTraceId) === 'string') {
|
|
18
|
+
this.customTraceId = customTraceId
|
|
19
|
+
}
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
ZipkinMultiTracer.prototype = {
|
|
14
23
|
isTracingSupported: function () {
|
|
@@ -18,6 +27,9 @@ ZipkinMultiTracer.prototype = {
|
|
|
18
27
|
return this._spanId.toPaddedHexadecimalString()
|
|
19
28
|
},
|
|
20
29
|
getTraceId: function () {
|
|
30
|
+
if (this.customTraceId) {
|
|
31
|
+
return this.customTraceId
|
|
32
|
+
}
|
|
21
33
|
return this.is128Bit
|
|
22
34
|
? '0000000000000000' + this._traceId.toPaddedHexadecimalString()
|
|
23
35
|
: this._traceId.toPaddedHexadecimalString()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TraceIdentifier, getCrypto } from './traceIdentifier'
|
|
2
|
-
|
|
2
|
+
import { getType } from '@cloudcare/browser-core'
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @param {*} configuration 配置信息
|
|
@@ -8,6 +8,15 @@ export function ZipkinSingleTracer(configuration, traceSampled) {
|
|
|
8
8
|
this._traceId = new TraceIdentifier()
|
|
9
9
|
this._spanId = new TraceIdentifier()
|
|
10
10
|
this._traceSampled = traceSampled
|
|
11
|
+
if (
|
|
12
|
+
configuration.generateTraceId &&
|
|
13
|
+
getType(configuration.generateTraceId) === 'function'
|
|
14
|
+
) {
|
|
15
|
+
const customTraceId = configuration.generateTraceId()
|
|
16
|
+
if (getType(customTraceId) === 'string') {
|
|
17
|
+
this.customTraceId = customTraceId
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
}
|
|
12
21
|
ZipkinSingleTracer.prototype = {
|
|
13
22
|
isTracingSupported: function () {
|
|
@@ -17,6 +26,9 @@ ZipkinSingleTracer.prototype = {
|
|
|
17
26
|
return this._spanId.toPaddedHexadecimalString()
|
|
18
27
|
},
|
|
19
28
|
getTraceId: function () {
|
|
29
|
+
if (this.customTraceId) {
|
|
30
|
+
return this.customTraceId
|
|
31
|
+
}
|
|
20
32
|
return this._traceId.toPaddedHexadecimalString()
|
|
21
33
|
},
|
|
22
34
|
getB3Str: function () {
|