@arms/rum-core 0.0.25-beta.16 → 0.0.25-beta.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/{es/index.js → lib/index.d.ts} +1 -1
- package/lib/model/client.d.ts +20 -0
- package/lib/model/context.d.ts +18 -0
- package/lib/model/reporter.d.ts +30 -0
- package/lib/model/shell.d.ts +33 -0
- package/lib/types/client.d.ts +133 -0
- package/lib/types/collector.d.ts +7 -0
- package/lib/types/processor.d.ts +8 -0
- package/lib/types/reporter.d.ts +8 -0
- package/lib/types/rum-event.d.ts +164 -0
- package/lib/types/shell.d.ts +28 -0
- package/lib/utils/base.d.ts +39 -0
- package/lib/utils/base.js +21 -9
- package/lib/utils/exception.d.ts +7 -0
- package/lib/utils/is.d.ts +12 -0
- package/lib/utils/is.js +1 -1
- package/lib/utils/match.d.ts +7 -0
- package/lib/utils/number.d.ts +17 -0
- package/lib/utils/polyfills.d.ts +7 -0
- package/lib/utils/trace.d.ts +28 -0
- package/package.json +3 -4
- package/es/model/client.js +0 -73
- package/es/model/context.js +0 -38
- package/es/model/reporter.js +0 -131
- package/es/model/shell.js +0 -80
- package/es/style.js +0 -1
- package/es/types/client.js +0 -4
- package/es/types/collector.js +0 -1
- package/es/types/processor.js +0 -1
- package/es/types/reporter.js +0 -1
- package/es/types/rum-event.js +0 -24
- package/es/types/shell.js +0 -1
- package/es/utils/base.js +0 -131
- package/es/utils/exception.js +0 -10
- package/es/utils/is.js +0 -33
- package/es/utils/match.js +0 -37
- package/es/utils/number.js +0 -40
- package/es/utils/polyfills.js +0 -28
- package/es/utils/trace.js +0 -101
package/es/utils/trace.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { isMatchOption } from "./match";
|
|
2
|
-
import { isArray, isBoolean, isNumber } from "./is";
|
|
3
|
-
import { encode } from "js-base64";
|
|
4
|
-
export function isTraceOption(option) {
|
|
5
|
-
return option && isMatchOption(option.match) && isArray(option.propagatorTypes);
|
|
6
|
-
}
|
|
7
|
-
export function makeTracingHeaders(traceId, spanId, sampled, propagatorTypes, subOption) {
|
|
8
|
-
if (subOption === void 0) {
|
|
9
|
-
subOption = {};
|
|
10
|
-
}
|
|
11
|
-
var tracingHeaders = {};
|
|
12
|
-
var sample = sampled ? '1' : '0';
|
|
13
|
-
// skywalking 标准具备排他性,如果包含sw8,则只使用sw8
|
|
14
|
-
if (propagatorTypes.includes('sw8')) {
|
|
15
|
-
propagatorTypes = ['sw8'];
|
|
16
|
-
}
|
|
17
|
-
propagatorTypes.forEach(function (propagatorType) {
|
|
18
|
-
switch (propagatorType) {
|
|
19
|
-
case 'jaeger':
|
|
20
|
-
tracingHeaders['uber-trace-id'] = traceId + ":" + spanId + ":0:" + sample;
|
|
21
|
-
break;
|
|
22
|
-
case 'b3':
|
|
23
|
-
// https://github.com/openzipkin/b3-propagation
|
|
24
|
-
tracingHeaders['b3'] = traceId + "-" + spanId + "-" + sample;
|
|
25
|
-
break;
|
|
26
|
-
case 'b3multi':
|
|
27
|
-
tracingHeaders['X-B3-TraceId'] = traceId;
|
|
28
|
-
tracingHeaders['X-B3-SpanId'] = spanId;
|
|
29
|
-
tracingHeaders['X-B3-Sampled'] = sample;
|
|
30
|
-
break;
|
|
31
|
-
case 'sw8':
|
|
32
|
-
// https://github.com/apache/skywalking-client-js
|
|
33
|
-
var traceIdStr = String(encode(traceId));
|
|
34
|
-
var segmentId = String(encode(spanId));
|
|
35
|
-
var service = String(encode(subOption.appId));
|
|
36
|
-
var instance = String(encode(subOption.appVersion));
|
|
37
|
-
var endpoint = String(encode(subOption.viewName));
|
|
38
|
-
var peer = String(encode(subOption.host));
|
|
39
|
-
tracingHeaders['sw8'] = sample + "-" + traceIdStr + "-" + segmentId + "-" + 0 + "-" + service + "-" + instance + "-" + endpoint + "-" + peer;
|
|
40
|
-
break;
|
|
41
|
-
case 'tracecontext':
|
|
42
|
-
default:
|
|
43
|
-
// https://www.w3.org/TR/trace-context/
|
|
44
|
-
tracingHeaders['traceparent'] = "00-" + traceId + "-" + spanId + "-0" + sample;
|
|
45
|
-
if (subOption.tracestate) {
|
|
46
|
-
tracingHeaders['tracestate'] = subOption.tracestate;
|
|
47
|
-
}
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
if (subOption.baggage) {
|
|
52
|
-
tracingHeaders['baggage'] = subOption.baggage;
|
|
53
|
-
}
|
|
54
|
-
return tracingHeaders;
|
|
55
|
-
}
|
|
56
|
-
export function parseTracingOptions(tracingOption) {
|
|
57
|
-
var defPropagatorTypes = ['tracecontext'];
|
|
58
|
-
if (isBoolean(tracingOption) || !tracingOption) {
|
|
59
|
-
return {
|
|
60
|
-
enable: !!tracingOption,
|
|
61
|
-
sample: 100,
|
|
62
|
-
propagatorTypes: defPropagatorTypes,
|
|
63
|
-
allowedUrls: [],
|
|
64
|
-
tracestate: true,
|
|
65
|
-
baggage: false
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
var _tracingOption$enable = tracingOption.enable,
|
|
69
|
-
enable = _tracingOption$enable === void 0 ? true : _tracingOption$enable,
|
|
70
|
-
_tracingOption$sample = tracingOption.sample,
|
|
71
|
-
sample = _tracingOption$sample === void 0 ? 100 : _tracingOption$sample,
|
|
72
|
-
_tracingOption$propag = tracingOption.propagatorTypes,
|
|
73
|
-
propagatorTypes = _tracingOption$propag === void 0 ? defPropagatorTypes : _tracingOption$propag,
|
|
74
|
-
_tracingOption$allowe = tracingOption.allowedUrls,
|
|
75
|
-
allowedUrls = _tracingOption$allowe === void 0 ? [] : _tracingOption$allowe,
|
|
76
|
-
_tracingOption$traces = tracingOption.tracestate,
|
|
77
|
-
tracestate = _tracingOption$traces === void 0 ? true : _tracingOption$traces,
|
|
78
|
-
_tracingOption$baggag = tracingOption.baggage,
|
|
79
|
-
baggage = _tracingOption$baggag === void 0 ? false : _tracingOption$baggag;
|
|
80
|
-
var traceOptions = [];
|
|
81
|
-
if (isArray(allowedUrls) && allowedUrls.length) {
|
|
82
|
-
allowedUrls.forEach(function (item) {
|
|
83
|
-
if (isMatchOption(item)) {
|
|
84
|
-
traceOptions.push({
|
|
85
|
-
match: item,
|
|
86
|
-
propagatorTypes: propagatorTypes
|
|
87
|
-
});
|
|
88
|
-
} else if (isTraceOption(item)) {
|
|
89
|
-
traceOptions.push(item);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
enable: isBoolean(enable) ? enable : true,
|
|
95
|
-
sample: isNumber(sample) ? sample : 100,
|
|
96
|
-
propagatorTypes: propagatorTypes,
|
|
97
|
-
allowedUrls: traceOptions,
|
|
98
|
-
tracestate: tracestate,
|
|
99
|
-
baggage: baggage
|
|
100
|
-
};
|
|
101
|
-
}
|