@blueking/open-telemetry 0.0.7 → 0.0.8
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/dist/bk-rum.global.js +7 -7
- package/dist/bk-rum.global.js.map +1 -1
- package/dist/index.js +130 -153
- package/dist/index.js.map +1 -1
- package/dist/plugins/csp-violation.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80,14 +80,14 @@ function S(e, t) {
|
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region \0@oxc-project+runtime@0.128.0/helpers/toPropertyKey.js
|
|
83
|
-
function
|
|
83
|
+
function C(e) {
|
|
84
84
|
var t = S(e, "string");
|
|
85
85
|
return x(t) == "symbol" ? t : t + "";
|
|
86
86
|
}
|
|
87
87
|
//#endregion
|
|
88
88
|
//#region \0@oxc-project+runtime@0.128.0/helpers/defineProperty.js
|
|
89
|
-
function
|
|
90
|
-
return (t =
|
|
89
|
+
function w(e, t, n) {
|
|
90
|
+
return (t = C(t)) in e ? Object.defineProperty(e, t, {
|
|
91
91
|
value: n,
|
|
92
92
|
enumerable: !0,
|
|
93
93
|
configurable: !0,
|
|
@@ -96,7 +96,7 @@ function C(e, t, n) {
|
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region \0@oxc-project+runtime@0.128.0/helpers/objectSpread2.js
|
|
99
|
-
function
|
|
99
|
+
function ie(e, t) {
|
|
100
100
|
var n = Object.keys(e);
|
|
101
101
|
if (Object.getOwnPropertySymbols) {
|
|
102
102
|
var r = Object.getOwnPropertySymbols(e);
|
|
@@ -109,9 +109,9 @@ function w(e, t) {
|
|
|
109
109
|
function T(e) {
|
|
110
110
|
for (var t = 1; t < arguments.length; t++) {
|
|
111
111
|
var n = arguments[t] == null ? {} : arguments[t];
|
|
112
|
-
t % 2 ?
|
|
113
|
-
|
|
114
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) :
|
|
112
|
+
t % 2 ? ie(Object(n), !0).forEach(function(t) {
|
|
113
|
+
w(e, t, n[t]);
|
|
114
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : ie(Object(n)).forEach(function(t) {
|
|
115
115
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -119,72 +119,72 @@ function T(e) {
|
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/core/config.ts
|
|
122
|
-
var
|
|
123
|
-
let n =
|
|
122
|
+
var E = "http://localhost:4318", ae = 60 * 1e3, oe = "unknown_service", D = (e) => e.replace(/\/+$/, ""), se = (e, t) => {
|
|
123
|
+
let n = D(e || E);
|
|
124
124
|
return n.endsWith(`/v1/${t}`) ? n : n.endsWith("/v1") ? `${n}/${t}` : `${n}/v1/${t}`;
|
|
125
|
-
},
|
|
125
|
+
}, O = (e, t) => {
|
|
126
126
|
var n, r, i, a, o;
|
|
127
127
|
let s = e == null || (n = e.signals) == null ? void 0 : n[t], c = e == null || (r = e.signals) == null || (r = r.endpoints) == null ? void 0 : r[t], l = e != null && e.token || e != null && e.headers || s != null && s.headers ? T(T(T({}, e != null && e.token ? { Authorization: `Bearer ${e.token}` } : {}), (i = e == null ? void 0 : e.headers) == null ? {} : i), (a = s == null ? void 0 : s.headers) == null ? {} : a) : void 0;
|
|
128
128
|
return {
|
|
129
129
|
concurrencyLimit: s == null ? void 0 : s.concurrencyLimit,
|
|
130
|
-
endpoint: c ?
|
|
130
|
+
endpoint: c ? D(c) : se((o = s == null ? void 0 : s.endpoint) == null ? e == null ? void 0 : e.endpoint : o, t),
|
|
131
131
|
headers: l,
|
|
132
132
|
timeoutMillis: s == null ? void 0 : s.timeoutMillis
|
|
133
133
|
};
|
|
134
|
-
},
|
|
134
|
+
}, ce = (e) => typeof e != "number" || !Number.isFinite(e) ? 1 : Math.max(0, Math.min(1, e)), k = (e, t) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : t, le = (e, t) => typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : t, ue = (e, t) => typeof e != "number" || !Number.isFinite(e) ? t : Math.max(0, Math.min(1, e)), de = (e) => e.body, A = () => ({ enabled: !1 }), j = (e) => T({ enabled: !0 }, e), fe = (e) => e ? { enabled: !0 } : A(), pe = (e) => e === !1 ? A() : { enabled: !0 }, me = (e) => {
|
|
135
135
|
var t;
|
|
136
|
-
return e ?
|
|
136
|
+
return e ? j(typeof e == "boolean" ? {
|
|
137
137
|
maxBodySize: 10 * 1024,
|
|
138
|
-
redact:
|
|
138
|
+
redact: de
|
|
139
139
|
} : {
|
|
140
|
-
maxBodySize:
|
|
141
|
-
redact: (t = e.redact) == null ?
|
|
142
|
-
}) :
|
|
140
|
+
maxBodySize: k(e.maxBodySize, 10 * 1024),
|
|
141
|
+
redact: (t = e.redact) == null ? de : t
|
|
142
|
+
}) : A();
|
|
143
143
|
}, he = (e) => {
|
|
144
144
|
var t;
|
|
145
145
|
return {
|
|
146
|
-
action: typeof (e == null ? void 0 : e.action) == "object" ?
|
|
146
|
+
action: typeof (e == null ? void 0 : e.action) == "object" ? j({ eventNames: (t = e.action.eventNames) == null ? [
|
|
147
147
|
"click",
|
|
148
148
|
"submit",
|
|
149
149
|
"keydown"
|
|
150
|
-
] : t }) : e != null && e.action ?
|
|
150
|
+
] : t }) : e != null && e.action ? j({ eventNames: [
|
|
151
151
|
"click",
|
|
152
152
|
"submit",
|
|
153
153
|
"keydown"
|
|
154
|
-
] }) :
|
|
155
|
-
device: typeof (e == null ? void 0 : e.device) == "object" ?
|
|
154
|
+
] }) : A(),
|
|
155
|
+
device: typeof (e == null ? void 0 : e.device) == "object" ? j({ storageKey: e.device.storageKey }) : (e == null ? void 0 : e.device) === !1 ? A() : j({}),
|
|
156
156
|
httpBody: me(e == null ? void 0 : e.httpBody),
|
|
157
|
-
session: typeof (e == null ? void 0 : e.session) == "object" ?
|
|
158
|
-
inactivityMs:
|
|
159
|
-
maxLifetimeMs:
|
|
157
|
+
session: typeof (e == null ? void 0 : e.session) == "object" ? j({
|
|
158
|
+
inactivityMs: k(e.session.inactivityMs, 1800 * 1e3),
|
|
159
|
+
maxLifetimeMs: k(e.session.maxLifetimeMs, 1440 * 60 * 1e3),
|
|
160
160
|
storageKey: e.session.storageKey
|
|
161
|
-
}) : (e == null ? void 0 : e.session) === !1 ?
|
|
161
|
+
}) : (e == null ? void 0 : e.session) === !1 ? A() : j({
|
|
162
162
|
inactivityMs: 1800 * 1e3,
|
|
163
163
|
maxLifetimeMs: 1440 * 60 * 1e3
|
|
164
164
|
}),
|
|
165
165
|
pageView: pe(e == null ? void 0 : e.pageView),
|
|
166
166
|
resource: pe(e == null ? void 0 : e.resource),
|
|
167
|
-
error: typeof (e == null ? void 0 : e.error) == "object" ?
|
|
168
|
-
maxPerWindow:
|
|
169
|
-
windowMs:
|
|
170
|
-
}) : (e == null ? void 0 : e.error) === !1 ?
|
|
167
|
+
error: typeof (e == null ? void 0 : e.error) == "object" ? j({
|
|
168
|
+
maxPerWindow: k(e.error.maxPerWindow, 5),
|
|
169
|
+
windowMs: k(e.error.windowMs, 6e4)
|
|
170
|
+
}) : (e == null ? void 0 : e.error) === !1 ? A() : j({
|
|
171
171
|
maxPerWindow: 5,
|
|
172
172
|
windowMs: 6e4
|
|
173
173
|
}),
|
|
174
174
|
webVitals: pe(e == null ? void 0 : e.webVitals),
|
|
175
|
-
blankScreen: typeof (e == null ? void 0 : e.blankScreen) == "object" ?
|
|
176
|
-
checkDelay:
|
|
175
|
+
blankScreen: typeof (e == null ? void 0 : e.blankScreen) == "object" ? j({
|
|
176
|
+
checkDelay: le(e.blankScreen.checkDelay, 3e3),
|
|
177
177
|
ignoreSelectors: e.blankScreen.ignoreSelectors,
|
|
178
178
|
rootSelector: e.blankScreen.rootSelector,
|
|
179
|
-
threshold:
|
|
180
|
-
}) : (e == null ? void 0 : e.blankScreen) === !1 ?
|
|
179
|
+
threshold: ue(e.blankScreen.threshold, .8)
|
|
180
|
+
}) : (e == null ? void 0 : e.blankScreen) === !1 ? A() : j({
|
|
181
181
|
checkDelay: 3e3,
|
|
182
182
|
threshold: .8
|
|
183
183
|
}),
|
|
184
|
-
websocket:
|
|
185
|
-
longTask: typeof (e == null ? void 0 : e.longTask) == "object" ?
|
|
186
|
-
cspViolation:
|
|
187
|
-
routeTiming:
|
|
184
|
+
websocket: fe(e == null ? void 0 : e.websocket),
|
|
185
|
+
longTask: typeof (e == null ? void 0 : e.longTask) == "object" ? j({ threshold: le(e.longTask.threshold, 50) }) : e != null && e.longTask ? j({ threshold: 50 }) : A(),
|
|
186
|
+
cspViolation: fe(e == null ? void 0 : e.cspViolation),
|
|
187
|
+
routeTiming: fe(e == null ? void 0 : e.routeTiming)
|
|
188
188
|
};
|
|
189
189
|
}, ge = (e) => {
|
|
190
190
|
var t, n, r, i, a, o, s, c;
|
|
@@ -207,7 +207,7 @@ var ae = "http://localhost:4318", oe = 60 * 1e3, se = "unknown_service", E = (e)
|
|
|
207
207
|
var t, n;
|
|
208
208
|
return {
|
|
209
209
|
environment: (t = e == null ? void 0 : e.environment) == null ? "production" : t,
|
|
210
|
-
name: (n = e == null ? void 0 : e.name) == null ?
|
|
210
|
+
name: (n = e == null ? void 0 : e.name) == null ? oe : n,
|
|
211
211
|
version: e == null ? void 0 : e.version
|
|
212
212
|
};
|
|
213
213
|
}, xe = (e) => T(T({
|
|
@@ -215,11 +215,11 @@ var ae = "http://localhost:4318", oe = 60 * 1e3, se = "unknown_service", E = (e)
|
|
|
215
215
|
"rum.provider": "blueking",
|
|
216
216
|
[b.serviceName]: e.name
|
|
217
217
|
}, e.version ? { [b.serviceVersion]: e.version } : {}), {}, { "telemetry.sdk.language": "webjs" }), Se = (e) => ({
|
|
218
|
-
endpoint:
|
|
219
|
-
traces:
|
|
220
|
-
metrics:
|
|
221
|
-
logs:
|
|
222
|
-
}), Ce = (e) => ({ rate:
|
|
218
|
+
endpoint: D((e == null ? void 0 : e.endpoint) || E),
|
|
219
|
+
traces: O(e, "traces"),
|
|
220
|
+
metrics: O(e, "metrics"),
|
|
221
|
+
logs: O(e, "logs")
|
|
222
|
+
}), Ce = (e) => ({ rate: ce(e == null ? void 0 : e.rate) }), we = (e) => {
|
|
223
223
|
var t, n, r, i, a, o, s, c, l, u, d, f;
|
|
224
224
|
return {
|
|
225
225
|
getPageAttributes: (t = (n = e.attributes) == null ? void 0 : n.page) == null ? (() => ({
|
|
@@ -246,7 +246,7 @@ var ae = "http://localhost:4318", oe = 60 * 1e3, se = "unknown_service", E = (e)
|
|
|
246
246
|
enabled: (r = e.enabled) == null ? !0 : r,
|
|
247
247
|
hooks: we(e),
|
|
248
248
|
instrumentations: (i = e.instrumentations) == null ? [] : i,
|
|
249
|
-
metricIntervalMillis:
|
|
249
|
+
metricIntervalMillis: ae,
|
|
250
250
|
plugins: (a = e.plugins) == null ? [] : a,
|
|
251
251
|
resourceAttributes: xe(s),
|
|
252
252
|
rum: ge(e.rum),
|
|
@@ -287,7 +287,7 @@ function M(e) {
|
|
|
287
287
|
//#region src/core/plugin.ts
|
|
288
288
|
var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !== !1, Oe = (e) => e, ke = class {
|
|
289
289
|
constructor(e) {
|
|
290
|
-
|
|
290
|
+
w(this, "plugins", void 0), w(this, "startedPlugins", []), this.plugins = e;
|
|
291
291
|
}
|
|
292
292
|
flush() {
|
|
293
293
|
var e = this;
|
|
@@ -369,13 +369,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
369
369
|
}
|
|
370
370
|
}, Be = class {
|
|
371
371
|
constructor(e = {}, t) {
|
|
372
|
-
|
|
372
|
+
w(this, "attributes", {}), w(this, "setOptionalAttribute", (e, t) => {
|
|
373
373
|
if (t === void 0) {
|
|
374
374
|
delete this.attributes[e];
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
377
|
this.attributes[e] = t;
|
|
378
|
-
}),
|
|
378
|
+
}), w(this, "user", {}), w(this, "view", {}), w(this, "getAttributes", () => T({}, this.attributes)), w(this, "getUser", () => T({}, this.user)), w(this, "getView", () => T({}, this.view)), w(this, "setAttributes", (e) => {
|
|
379
379
|
for (let [t, n] of Object.entries(e)) {
|
|
380
380
|
if (n === void 0) {
|
|
381
381
|
delete this.attributes[t];
|
|
@@ -383,7 +383,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
383
383
|
}
|
|
384
384
|
this.attributes[t] = n;
|
|
385
385
|
}
|
|
386
|
-
}),
|
|
386
|
+
}), w(this, "setUser", (e) => {
|
|
387
387
|
if (this.user = T(T({}, this.user), e), "id" in e) {
|
|
388
388
|
if (e.id === void 0) {
|
|
389
389
|
delete this.attributes[b.userId];
|
|
@@ -391,7 +391,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
391
391
|
}
|
|
392
392
|
this.attributes[b.userId] = e.id;
|
|
393
393
|
}
|
|
394
|
-
}),
|
|
394
|
+
}), w(this, "setView", (e) => {
|
|
395
395
|
this.view = T(T({}, this.view), e), this.setOptionalAttribute(b.viewId, e.id), this.setOptionalAttribute(b.viewUrl, e.url), this.setOptionalAttribute(b.viewUrlPathGroup, e.urlPathGroup), this.setOptionalAttribute(b.viewLoadingType, e.loadingType);
|
|
396
396
|
}), this.setAttributes(e), t && this.setUser(t);
|
|
397
397
|
}
|
|
@@ -534,47 +534,42 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
534
534
|
name: "blank-screen",
|
|
535
535
|
enabled: e.enabled,
|
|
536
536
|
init(i) {
|
|
537
|
-
var a,
|
|
537
|
+
var a, o;
|
|
538
538
|
if (typeof window > "u" || typeof document > "u") return;
|
|
539
|
-
let
|
|
539
|
+
let s = e.enabled ? (a = e.rootSelector) == null ? Qe : a : Qe, c = e.enabled ? e.checkDelay : $e, l = e.enabled ? e.threshold : et, u = [...tt, ...e.enabled ? (o = e.ignoreSelectors) == null ? [] : o : []], d = i.meter.createCounter("browser.blank_screen.count", { description: "Number of suspected blank screen detections" }), f = () => {
|
|
540
540
|
try {
|
|
541
541
|
var e, t;
|
|
542
|
-
let n = document.querySelector(
|
|
542
|
+
let n = document.querySelector(s), r = 0, a = 0;
|
|
543
543
|
for (let [e, t] of L) {
|
|
544
544
|
let i = document.elementFromPoint(window.innerWidth * e, window.innerHeight * t);
|
|
545
|
-
if (rt(i,
|
|
545
|
+
if (rt(i, u)) {
|
|
546
546
|
a += 1;
|
|
547
547
|
continue;
|
|
548
548
|
}
|
|
549
549
|
(i === n || i === document.body || i === document.documentElement) && (r += 1);
|
|
550
550
|
}
|
|
551
|
-
let
|
|
552
|
-
if (
|
|
553
|
-
let
|
|
554
|
-
errorType:
|
|
551
|
+
let o = L.length - a;
|
|
552
|
+
if (o === 0) return;
|
|
553
|
+
let c = r / o, f = c >= l, p = nt(document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)), m = T(T({}, I({
|
|
554
|
+
errorType: f ? "blank_screen" : "none",
|
|
555
555
|
eventLabel: "白屏",
|
|
556
|
-
result:
|
|
556
|
+
result: f ? P.error : P.success,
|
|
557
557
|
spanSubtype: "blank_screen",
|
|
558
558
|
spanType: F.error,
|
|
559
|
-
targetLabel:
|
|
560
|
-
targetValue:
|
|
559
|
+
targetLabel: s,
|
|
560
|
+
targetValue: c
|
|
561
561
|
})), {}, {
|
|
562
|
-
"blank_screen.score":
|
|
563
|
-
"blank_screen.threshold":
|
|
564
|
-
"blank_screen.root":
|
|
565
|
-
"blank_screen.detected":
|
|
562
|
+
"blank_screen.score": c,
|
|
563
|
+
"blank_screen.threshold": l,
|
|
564
|
+
"blank_screen.root": s,
|
|
565
|
+
"blank_screen.detected": f,
|
|
566
566
|
"blank_screen.sample_total": L.length,
|
|
567
|
-
"blank_screen.sample_valid":
|
|
567
|
+
"blank_screen.sample_valid": o,
|
|
568
568
|
"blank_screen.sample_loading": a,
|
|
569
|
-
"blank_screen.center_element":
|
|
569
|
+
"blank_screen.center_element": p,
|
|
570
570
|
"blank_screen.dom_node_count": (e = (t = document.body) == null ? void 0 : t.getElementsByTagName("*").length) == null ? 0 : e
|
|
571
571
|
});
|
|
572
|
-
|
|
573
|
-
severityNumber: o.ERROR,
|
|
574
|
-
severityText: "ERROR",
|
|
575
|
-
body: "browser.blank_screen",
|
|
576
|
-
attributes: h
|
|
577
|
-
}));
|
|
572
|
+
f && (d.add(1, i.applyRedact({ "blank_screen.root": s })), i.startSpan("browser.blank_screen", m).end());
|
|
578
573
|
} catch (e) {
|
|
579
574
|
if (i.config.debug) {
|
|
580
575
|
var n;
|
|
@@ -583,7 +578,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
583
578
|
}
|
|
584
579
|
};
|
|
585
580
|
n = it(() => {
|
|
586
|
-
r || (t = window.setTimeout(
|
|
581
|
+
r || (t = window.setTimeout(f, c));
|
|
587
582
|
});
|
|
588
583
|
},
|
|
589
584
|
shutdown() {
|
|
@@ -722,34 +717,29 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
722
717
|
let n = z(mt, ht), r = (t) => {
|
|
723
718
|
let r = R(`${t.violatedDirective}|${t.blockedURI}|${t.sourceFile}|${t.lineNumber}`), i = n.allow(r);
|
|
724
719
|
if (!i.allowed) return;
|
|
725
|
-
let a = _t(e.config.hooks.redactUrl, t.blockedURI),
|
|
726
|
-
e.
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
"csp.window_count": i.count,
|
|
749
|
-
[b.exceptionFingerprint]: r,
|
|
750
|
-
"error.source": "csp"
|
|
751
|
-
}, c ? { "csp.original_policy": t.originalPolicy } : {})
|
|
752
|
-
});
|
|
720
|
+
let a = _t(e.config.hooks.redactUrl, t.blockedURI), o = t.sourceFile ? e.config.hooks.redactUrl(t.sourceFile) : void 0, s = i.count === 1;
|
|
721
|
+
e.startSpan("csp.violation", T(T(T({}, e.config.hooks.getPageAttributes()), I({
|
|
722
|
+
errorType: "csp",
|
|
723
|
+
eventLabel: "CSP 错误",
|
|
724
|
+
result: P.error,
|
|
725
|
+
spanSubtype: "csp",
|
|
726
|
+
spanType: F.error,
|
|
727
|
+
targetLabel: a == null ? t.effectiveDirective : a,
|
|
728
|
+
targetValue: t.statusCode
|
|
729
|
+
})), {}, {
|
|
730
|
+
"csp.blocked_uri": a,
|
|
731
|
+
"csp.violated_directive": t.violatedDirective,
|
|
732
|
+
"csp.effective_directive": t.effectiveDirective,
|
|
733
|
+
"csp.disposition": t.disposition,
|
|
734
|
+
"csp.source_file": o,
|
|
735
|
+
"csp.line_number": t.lineNumber,
|
|
736
|
+
"csp.column_number": t.columnNumber,
|
|
737
|
+
"csp.status_code": t.statusCode,
|
|
738
|
+
"csp.fingerprint": r,
|
|
739
|
+
"csp.window_count": i.count,
|
|
740
|
+
[b.exceptionFingerprint]: r,
|
|
741
|
+
"error.source": "csp"
|
|
742
|
+
}, s ? { "csp.original_policy": t.originalPolicy } : {})).end();
|
|
753
743
|
};
|
|
754
744
|
document.addEventListener("securitypolicyviolation", r), t = () => document.removeEventListener("securitypolicyviolation", r);
|
|
755
745
|
},
|
|
@@ -873,47 +863,34 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
873
863
|
}, Ft = (e) => e.slice(0, 80), It = (e) => {
|
|
874
864
|
var t, n;
|
|
875
865
|
return (t = (n = e.split("\n").find((e) => e.trim().startsWith("at "))) == null ? void 0 : n.trim()) == null ? "" : t;
|
|
876
|
-
}, Lt = (e) => e === "unhandledrejection" ? "promise" : e === "resource" ? "resource_load" : "js", V = ({ context: e, error:
|
|
877
|
-
let
|
|
878
|
-
if (!
|
|
879
|
-
let
|
|
880
|
-
message:
|
|
881
|
-
name:
|
|
882
|
-
},
|
|
883
|
-
errorType: Lt(
|
|
866
|
+
}, Lt = (e) => e === "unhandledrejection" ? "promise" : e === "resource" ? "resource_load" : "js", V = ({ context: e, error: n, exceptionType: r, extra: i = {}, source: a, spanName: o, throttle: s }) => {
|
|
867
|
+
let c = Nt(n), l = Pt(n), u = R(`${a}|${c}|${l.slice(0, 256)}`), d = s.allow(u);
|
|
868
|
+
if (!d.allowed) return;
|
|
869
|
+
let f = n instanceof Error ? n : {
|
|
870
|
+
message: c,
|
|
871
|
+
name: r == null ? a : r
|
|
872
|
+
}, p = T(T(T(T({}, e.config.hooks.getPageAttributes()), e.config.hooks.getErrorAttributes()), I({
|
|
873
|
+
errorType: Lt(a),
|
|
884
874
|
eventLabel: "错误",
|
|
885
875
|
result: P.error,
|
|
886
|
-
spanSubtype: Lt(
|
|
876
|
+
spanSubtype: Lt(a),
|
|
887
877
|
spanType: F.error,
|
|
888
|
-
targetLabel:
|
|
878
|
+
targetLabel: n instanceof Error ? n.name : r == null ? a : r
|
|
889
879
|
})), {}, {
|
|
890
|
-
"exception.message":
|
|
891
|
-
[b.exceptionMessageShort]: Ft(
|
|
892
|
-
"exception.stacktrace":
|
|
893
|
-
[b.exceptionStackTopFrame]: It(
|
|
894
|
-
"exception.type":
|
|
895
|
-
[b.exceptionFingerprint]:
|
|
880
|
+
"exception.message": c,
|
|
881
|
+
[b.exceptionMessageShort]: Ft(c),
|
|
882
|
+
"exception.stacktrace": l,
|
|
883
|
+
[b.exceptionStackTopFrame]: It(l),
|
|
884
|
+
"exception.type": n instanceof Error ? n.name : r == null ? a : r,
|
|
885
|
+
[b.exceptionFingerprint]: u,
|
|
896
886
|
"error.handled": !1,
|
|
897
|
-
"error.source":
|
|
898
|
-
"error.window_count":
|
|
899
|
-
},
|
|
900
|
-
|
|
901
|
-
severityText: "ERROR",
|
|
902
|
-
body: d,
|
|
903
|
-
attributes: _
|
|
904
|
-
});
|
|
905
|
-
if (h) {
|
|
906
|
-
h.setAttributes(e.applyRedact(_)), h.recordException(g), h.setStatus({
|
|
907
|
-
code: t.ERROR,
|
|
908
|
-
message: d
|
|
909
|
-
}), v();
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
let y = e.startSpan(l, _);
|
|
913
|
-
y.recordException(g), y.setStatus({
|
|
887
|
+
"error.source": a,
|
|
888
|
+
"error.window_count": d.count
|
|
889
|
+
}, i), m = e.startSpan(o, p);
|
|
890
|
+
m.recordException(f), m.setStatus({
|
|
914
891
|
code: t.ERROR,
|
|
915
|
-
message:
|
|
916
|
-
}),
|
|
892
|
+
message: c
|
|
893
|
+
}), m.end();
|
|
917
894
|
}, Rt = (e) => {
|
|
918
895
|
let t = [];
|
|
919
896
|
return {
|
|
@@ -1823,13 +1800,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1823
1800
|
}
|
|
1824
1801
|
constructor(o) {
|
|
1825
1802
|
var x = this;
|
|
1826
|
-
|
|
1803
|
+
w(this, "loggerProvider", void 0), w(this, "meterProvider", void 0), w(this, "phase", "idle"), w(this, "pluginManager", void 0), w(this, "plugins", void 0), w(this, "registeredInstrumentations", void 0), w(this, "runtimeContext", void 0), w(this, "sampled", void 0), w(this, "teardownCallbacks", []), w(this, "tracerProvider", void 0), w(this, "applyRedact", (e) => this.config.hooks.redactAttributes(e)), w(this, "config", void 0), w(this, "emitLog", (e) => {
|
|
1827
1804
|
var t;
|
|
1828
1805
|
let n = T(T({}, e), {}, { attributes: this.applyRedact(T(T({}, this.getRuntimeAttributes()), (t = e.attributes) == null ? {} : t)) });
|
|
1829
1806
|
this.logger.emit(n);
|
|
1830
|
-
}),
|
|
1807
|
+
}), w(this, "flush", M(function* () {
|
|
1831
1808
|
yield x.pluginManager.flush(), yield x.tracerProvider.forceFlush(), yield x.meterProvider.forceFlush(), yield x.loggerProvider.forceFlush();
|
|
1832
|
-
})),
|
|
1809
|
+
})), w(this, "getRuntimeAttributes", () => this.runtimeContext.getAttributes()), w(this, "logger", void 0), w(this, "meter", void 0), w(this, "reportAction", ({ attributes: e = {}, targetTag: t, targetText: n, type: r }) => {
|
|
1833
1810
|
var i;
|
|
1834
1811
|
if (!this.sampled) return;
|
|
1835
1812
|
let a = n == null ? void 0 : n.slice(0, 32);
|
|
@@ -1840,7 +1817,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1840
1817
|
spanType: F.action,
|
|
1841
1818
|
targetLabel: (i = a == null ? t : a) == null ? r : i
|
|
1842
1819
|
})), {}, { [b.actionType]: r }, a ? { [b.targetTextShort]: a } : {}), t ? { [b.targetTag]: t } : {}), e)).end();
|
|
1843
|
-
}),
|
|
1820
|
+
}), w(this, "reportCustomEvent", ({ attributes: e = {}, error: n, name: r }) => {
|
|
1844
1821
|
if (!this.sampled) {
|
|
1845
1822
|
if (this.config.debug) {
|
|
1846
1823
|
var i;
|
|
@@ -1860,13 +1837,13 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1860
1837
|
code: t.ERROR,
|
|
1861
1838
|
message: n.message
|
|
1862
1839
|
})), a.end();
|
|
1863
|
-
}),
|
|
1840
|
+
}), w(this, "setRuntimeAttributes", (e) => {
|
|
1864
1841
|
this.runtimeContext.setAttributes(e);
|
|
1865
|
-
}),
|
|
1842
|
+
}), w(this, "setUser", (e) => {
|
|
1866
1843
|
this.runtimeContext.setUser(e);
|
|
1867
|
-
}),
|
|
1844
|
+
}), w(this, "setView", (e) => {
|
|
1868
1845
|
this.runtimeContext.setView(e);
|
|
1869
|
-
}),
|
|
1846
|
+
}), w(this, "shutdown", M(function* () {
|
|
1870
1847
|
if (x.phase !== "stopped") {
|
|
1871
1848
|
for (yield x.flush(); x.teardownCallbacks.length;) {
|
|
1872
1849
|
var e;
|
|
@@ -1878,7 +1855,7 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1878
1855
|
}
|
|
1879
1856
|
yield x.tracerProvider.shutdown(), yield x.meterProvider.shutdown(), yield x.loggerProvider.shutdown(), a.disable(), r.disable(), n.disable(), x.phase = "stopped";
|
|
1880
1857
|
}
|
|
1881
|
-
})),
|
|
1858
|
+
})), w(this, "start", M(function* () {
|
|
1882
1859
|
if (!(x.phase === "started" || x.phase === "starting")) {
|
|
1883
1860
|
if (x.phase === "stopped") throw Error("[bk-ot] instance has been shut down and cannot be restarted; create a new instance instead.");
|
|
1884
1861
|
if (!x.config.enabled) {
|
|
@@ -1913,25 +1890,25 @@ var De = (e, t) => typeof e.enabled == "function" ? e.enabled(t) : e.enabled !==
|
|
|
1913
1890
|
}
|
|
1914
1891
|
x.phase = "started";
|
|
1915
1892
|
}
|
|
1916
|
-
})),
|
|
1893
|
+
})), w(this, "startSpan", (t, n = {}, r) => this.tracer.startSpan(t, {
|
|
1917
1894
|
kind: e.INTERNAL,
|
|
1918
1895
|
startTime: r == null ? void 0 : r.startTime,
|
|
1919
1896
|
attributes: this.applyRedact(T(T({}, this.getRuntimeAttributes()), n))
|
|
1920
|
-
})),
|
|
1921
|
-
let S = m(this.config.resourceAttributes),
|
|
1922
|
-
exporter:
|
|
1897
|
+
})), w(this, "tracer", void 0), w(this, "use", (e) => (this.assertBeforeStart("use"), this.sampled && this.plugins.push(e), this)), w(this, "useInstrumentation", (e) => (this.assertBeforeStart("useInstrumentation"), this.config.enabled && this.registeredInstrumentations.push(e), this)), this.config = Te(o), this.sampled = this.config.enabled && Bn(this.config);
|
|
1898
|
+
let S = m(this.config.resourceAttributes), C = Un(new f(Vn(this.config.transport.traces)), "traces", this.config.debug), ie = Un(new d(Vn(this.config.transport.metrics)), "metrics", this.config.debug), E = Un(new u(Vn(this.config.transport.logs)), "logs", this.config.debug), ae = new ze(this.config.spanProcessor === "simple" ? new te(C) : new y(C, this.config.spanBatch), this.config), oe = new v({
|
|
1899
|
+
exporter: ie,
|
|
1923
1900
|
exportIntervalMillis: this.config.metricIntervalMillis
|
|
1924
|
-
}),
|
|
1901
|
+
}), D = new h(E);
|
|
1925
1902
|
this.tracerProvider = new re({
|
|
1926
1903
|
resource: S,
|
|
1927
1904
|
sampler: new ee({ root: new ne(+!!this.sampled) }),
|
|
1928
|
-
spanProcessors: [
|
|
1905
|
+
spanProcessors: [ae]
|
|
1929
1906
|
}), this.meterProvider = new _({
|
|
1930
1907
|
resource: S,
|
|
1931
|
-
readers: [
|
|
1908
|
+
readers: [oe]
|
|
1932
1909
|
}), this.loggerProvider = new g({
|
|
1933
1910
|
resource: S,
|
|
1934
|
-
processors: [
|
|
1911
|
+
processors: [D]
|
|
1935
1912
|
}), this.tracer = this.tracerProvider.getTracer(Hn), this.meter = this.meterProvider.getMeter(Hn), this.logger = this.loggerProvider.getLogger(Hn), this.runtimeContext = new Be({ "rum.sampled": this.sampled }, this.config.user), this.registeredInstrumentations = this.config.enabled ? [...this.config.instrumentations] : [], this.plugins = [...this.config.enabled ? Wn(this.config) : [], ...this.sampled ? [...Gn(this.config), ...this.config.plugins] : []], this.pluginManager = new ke(this.plugins), this.config.autoStart && this.start().catch((e) => {
|
|
1936
1913
|
var t;
|
|
1937
1914
|
(t = globalThis.console) == null || t.warn("[bk-ot] auto start failed:", e);
|