@autter/runtime-node 1.6.0 → 1.7.0
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 +58 -5
- package/dist/{chunk-ARN26OK6.cjs → chunk-GYTQLITW.cjs} +126 -39
- package/dist/{chunk-UGNPCOIW.cjs → chunk-HKVFURYT.cjs} +11 -11
- package/dist/{chunk-FBKYOHU2.js → chunk-KA4AOZX2.js} +41 -31
- package/dist/{chunk-OY2HTUWY.js → chunk-LG52CW3V.js} +118 -31
- package/dist/{chunk-Y4T7SQMO.js → chunk-QUC6OUE7.js} +1 -1
- package/dist/{chunk-UKYTXZOQ.cjs → chunk-RV4MJNM2.cjs} +65 -55
- package/dist/cli.cjs +8 -8
- package/dist/cli.js +2 -2
- package/dist/index.cjs +465 -295
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +284 -114
- package/dist/testing.cjs +8 -8
- package/dist/testing.js +2 -2
- package/package.json +1 -1
|
@@ -119,6 +119,43 @@ var compat_manifest_default = {
|
|
|
119
119
|
ingester: "1.6.0",
|
|
120
120
|
migrations: [],
|
|
121
121
|
sdks: { "@autter/runtime-browser": "1.6.0", "@autter/runtime-next": "1.6.0", "@autter/runtime-node": "1.6.0" }
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: "sourcemap_upload_keys",
|
|
125
|
+
title: "Upload-only keys for source maps (autter_rtu_)",
|
|
126
|
+
ingester: "1.7.0",
|
|
127
|
+
migrations: [],
|
|
128
|
+
route: "/v1/sourcemaps",
|
|
129
|
+
sdks: {}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "source_map_verify",
|
|
133
|
+
title: "Source map check by debug id (autter-runtime sourcemaps verify)",
|
|
134
|
+
ingester: "1.7.0",
|
|
135
|
+
migrations: ["0017-source-maps-debug-id"],
|
|
136
|
+
route: "/v1/sourcemaps/check",
|
|
137
|
+
sdks: {}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "ingest_drop_counts",
|
|
141
|
+
title: "Rejected and dropped records per repository",
|
|
142
|
+
ingester: "1.8.0",
|
|
143
|
+
migrations: ["0018-runtime-ingest-drops"],
|
|
144
|
+
sdks: {}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: "telemetry_sender_via",
|
|
148
|
+
title: "How each service's telemetry arrives (SDK, OpenTelemetry Collector or browser relay)",
|
|
149
|
+
ingester: "1.8.0",
|
|
150
|
+
migrations: ["0019-sdk-versions-via"],
|
|
151
|
+
sdks: {}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: "frame_resolution_counts",
|
|
155
|
+
title: "Resolved and unresolved browser frames per occurrence",
|
|
156
|
+
ingester: "1.8.0",
|
|
157
|
+
migrations: ["0020-occurrence-frame-resolution"],
|
|
158
|
+
sdks: {}
|
|
122
159
|
}
|
|
123
160
|
]
|
|
124
161
|
};
|
|
@@ -464,7 +501,7 @@ import { request as httpsRequest } from "https";
|
|
|
464
501
|
// package.json
|
|
465
502
|
var package_default = {
|
|
466
503
|
name: "@autter/runtime-node",
|
|
467
|
-
version: "1.
|
|
504
|
+
version: "1.7.0",
|
|
468
505
|
description: "Autter Runtime for Node.js: request wide events, coded errors, operation logging, same-origin browser relay and a curated OpenTelemetry server tracker",
|
|
469
506
|
license: "MIT",
|
|
470
507
|
type: "module",
|
|
@@ -539,6 +576,55 @@ var package_default = {
|
|
|
539
576
|
]
|
|
540
577
|
};
|
|
541
578
|
|
|
579
|
+
// src/shared.ts
|
|
580
|
+
var SHARED_STATE_KEY = /* @__PURE__ */ Symbol.for("@autter/runtime-node");
|
|
581
|
+
var SHARED_STATE_LAYOUT = 1;
|
|
582
|
+
function isObject(value) {
|
|
583
|
+
return typeof value === "object" && value !== null;
|
|
584
|
+
}
|
|
585
|
+
var VERSION = package_default.version;
|
|
586
|
+
function resolveShared() {
|
|
587
|
+
const fresh = { v: SHARED_STATE_LAYOUT, sdk: VERSION };
|
|
588
|
+
const host = globalThis;
|
|
589
|
+
let existing;
|
|
590
|
+
try {
|
|
591
|
+
existing = host[SHARED_STATE_KEY];
|
|
592
|
+
if (existing === void 0) {
|
|
593
|
+
Object.defineProperty(host, SHARED_STATE_KEY, {
|
|
594
|
+
value: fresh,
|
|
595
|
+
configurable: true,
|
|
596
|
+
enumerable: false,
|
|
597
|
+
writable: false
|
|
598
|
+
});
|
|
599
|
+
return fresh;
|
|
600
|
+
}
|
|
601
|
+
} catch {
|
|
602
|
+
return fresh;
|
|
603
|
+
}
|
|
604
|
+
if (isObject(existing) && existing.v === SHARED_STATE_LAYOUT) return existing;
|
|
605
|
+
debugLog(
|
|
606
|
+
`another copy of @autter/runtime-node uses shared state layout ${String(isObject(existing) ? existing.v : typeof existing)}; this copy (${VERSION}, layout ${SHARED_STATE_LAYOUT}) keeps its own state`
|
|
607
|
+
);
|
|
608
|
+
return fresh;
|
|
609
|
+
}
|
|
610
|
+
var shared = resolveShared();
|
|
611
|
+
function sharedSlot(name, init) {
|
|
612
|
+
const fresh = init();
|
|
613
|
+
try {
|
|
614
|
+
const existing = shared[name];
|
|
615
|
+
if (!isObject(existing)) {
|
|
616
|
+
shared[name] = fresh;
|
|
617
|
+
return fresh;
|
|
618
|
+
}
|
|
619
|
+
for (const [key, value] of Object.entries(fresh)) {
|
|
620
|
+
if (existing[key] === void 0) existing[key] = value;
|
|
621
|
+
}
|
|
622
|
+
return existing;
|
|
623
|
+
} catch {
|
|
624
|
+
return fresh;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
542
628
|
// src/compat.ts
|
|
543
629
|
var SDK_IDENTITY = {
|
|
544
630
|
name: "@autter/runtime-node",
|
|
@@ -631,7 +717,7 @@ function envDisabled() {
|
|
|
631
717
|
return value === "0" || value === "false" || value === "off";
|
|
632
718
|
}
|
|
633
719
|
var defaultWarn = (message) => console.warn(`[autter-runtime] ${message}`);
|
|
634
|
-
var
|
|
720
|
+
var compat = sharedSlot("compat", () => ({ state: freshState(null, false) }));
|
|
635
721
|
function freshState(endpoint, enabled, sdk = SDK_IDENTITY, warn = defaultWarn) {
|
|
636
722
|
return {
|
|
637
723
|
endpoint,
|
|
@@ -646,7 +732,7 @@ function freshState(endpoint, enabled, sdk = SDK_IDENTITY, warn = defaultWarn) {
|
|
|
646
732
|
};
|
|
647
733
|
}
|
|
648
734
|
function configureCompatCheck(options) {
|
|
649
|
-
state = freshState(
|
|
735
|
+
compat.state = freshState(
|
|
650
736
|
options.endpoint.replace(/\/$/, ""),
|
|
651
737
|
options.enabled !== false && !envDisabled(),
|
|
652
738
|
options.sdk ?? SDK_IDENTITY,
|
|
@@ -654,21 +740,21 @@ function configureCompatCheck(options) {
|
|
|
654
740
|
);
|
|
655
741
|
}
|
|
656
742
|
function ensureCompatConfigured(endpoint) {
|
|
657
|
-
if (state.endpoint === null && !envDisabled()) {
|
|
658
|
-
state = freshState(endpoint.replace(/\/$/, ""), true);
|
|
743
|
+
if (compat.state.endpoint === null && !envDisabled()) {
|
|
744
|
+
compat.state = freshState(endpoint.replace(/\/$/, ""), true);
|
|
659
745
|
}
|
|
660
746
|
}
|
|
661
747
|
function noteCompatFeature(id) {
|
|
662
748
|
try {
|
|
663
|
-
if (!state.enabled || state.features.has(id) || !featureById(id)) return;
|
|
664
|
-
state.features.add(id);
|
|
665
|
-
if (state.info) {
|
|
749
|
+
if (!compat.state.enabled || compat.state.features.has(id) || !featureById(id)) return;
|
|
750
|
+
compat.state.features.add(id);
|
|
751
|
+
if (compat.state.info) {
|
|
666
752
|
evaluateAndWarn();
|
|
667
753
|
return;
|
|
668
754
|
}
|
|
669
|
-
if (state.started) return;
|
|
670
|
-
state.started = true;
|
|
671
|
-
const current = state;
|
|
755
|
+
if (compat.state.started) return;
|
|
756
|
+
compat.state.started = true;
|
|
757
|
+
const current = compat.state;
|
|
672
758
|
setTimeout(() => void runCheck(current), 0).unref();
|
|
673
759
|
} catch {
|
|
674
760
|
}
|
|
@@ -679,7 +765,7 @@ async function runCheck(current) {
|
|
|
679
765
|
const { info, error } = await fetchIngesterCompat(current.endpoint, {
|
|
680
766
|
probeRoutes: routesFor(current.features)
|
|
681
767
|
});
|
|
682
|
-
if (state !== current) return;
|
|
768
|
+
if (compat.state !== current) return;
|
|
683
769
|
if (!info) {
|
|
684
770
|
debugLog(`compat check skipped: ${error ?? "ingester version unknown"}`);
|
|
685
771
|
return;
|
|
@@ -703,8 +789,8 @@ function routesFor(features) {
|
|
|
703
789
|
return routes;
|
|
704
790
|
}
|
|
705
791
|
function mergeInfo(next) {
|
|
706
|
-
const prev = state.info;
|
|
707
|
-
state.info = {
|
|
792
|
+
const prev = compat.state.info;
|
|
793
|
+
compat.state.info = {
|
|
708
794
|
version: next.version ?? prev?.version ?? null,
|
|
709
795
|
...next.legacy || prev?.legacy ? { legacy: true } : {},
|
|
710
796
|
...next.schema ?? prev?.schema ? { schema: next.schema ?? prev?.schema } : {},
|
|
@@ -712,17 +798,17 @@ function mergeInfo(next) {
|
|
|
712
798
|
};
|
|
713
799
|
}
|
|
714
800
|
function evaluateAndWarn() {
|
|
715
|
-
const info = state.info;
|
|
801
|
+
const info = compat.state.info;
|
|
716
802
|
if (!info) return;
|
|
717
|
-
if (info.version === null && state.endpoint) {
|
|
718
|
-
const unprobed = routesFor(state.features).filter(
|
|
719
|
-
(route) => info.routes?.[route] === void 0 && !state.pendingProbes.has(route)
|
|
803
|
+
if (info.version === null && compat.state.endpoint) {
|
|
804
|
+
const unprobed = routesFor(compat.state.features).filter(
|
|
805
|
+
(route) => info.routes?.[route] === void 0 && !compat.state.pendingProbes.has(route)
|
|
720
806
|
);
|
|
721
807
|
if (unprobed.length) {
|
|
722
|
-
const current = state;
|
|
808
|
+
const current = compat.state;
|
|
723
809
|
for (const route of unprobed) current.pendingProbes.add(route);
|
|
724
810
|
void Promise.all(unprobed.map((route) => probeRoute(current.endpoint, route, {}).then((exists) => [route, exists]))).then((results) => {
|
|
725
|
-
if (state !== current) return;
|
|
811
|
+
if (compat.state !== current) return;
|
|
726
812
|
const routes = {};
|
|
727
813
|
for (const [route, exists] of results) if (exists !== null) routes[route] = exists;
|
|
728
814
|
mergeInfo({ version: null, legacy: true, routes });
|
|
@@ -731,31 +817,31 @@ function evaluateAndWarn() {
|
|
|
731
817
|
});
|
|
732
818
|
}
|
|
733
819
|
}
|
|
734
|
-
for (const issue of evaluateCompat({ features: state.features, ingester: info })) {
|
|
820
|
+
for (const issue of evaluateCompat({ features: compat.state.features, ingester: info })) {
|
|
735
821
|
warnOnce(issue);
|
|
736
822
|
}
|
|
737
823
|
}
|
|
738
824
|
function warnOnce(issue) {
|
|
739
825
|
const key = `${issue.feature}:${issue.kind}`;
|
|
740
|
-
if (state.warned.has(key)) return;
|
|
741
|
-
state.warned.add(key);
|
|
826
|
+
if (compat.state.warned.has(key)) return;
|
|
827
|
+
compat.state.warned.add(key);
|
|
742
828
|
try {
|
|
743
|
-
state.warn(issue.message);
|
|
829
|
+
compat.state.warn(issue.message);
|
|
744
830
|
} catch {
|
|
745
831
|
}
|
|
746
832
|
}
|
|
747
833
|
function observeIngesterResponse(response) {
|
|
748
834
|
try {
|
|
749
|
-
if (!state.enabled) return;
|
|
835
|
+
if (!compat.state.enabled) return;
|
|
750
836
|
const fromHeader = headerInfo(response.headers);
|
|
751
837
|
if (fromHeader) {
|
|
752
|
-
if (state.info?.version !== fromHeader.version) {
|
|
838
|
+
if (compat.state.info?.version !== fromHeader.version) {
|
|
753
839
|
mergeInfo(fromHeader);
|
|
754
840
|
evaluateAndWarn();
|
|
755
841
|
}
|
|
756
842
|
return;
|
|
757
843
|
}
|
|
758
|
-
if (response.status === 404 && response.route && !state.info?.version) {
|
|
844
|
+
if (response.status === 404 && response.route && !compat.state.info?.version) {
|
|
759
845
|
mergeInfo({ version: null, legacy: true, routes: { [response.route]: false } });
|
|
760
846
|
evaluateAndWarn();
|
|
761
847
|
}
|
|
@@ -764,16 +850,16 @@ function observeIngesterResponse(response) {
|
|
|
764
850
|
}
|
|
765
851
|
function noteRelayRejection(eventTypes, status, headers) {
|
|
766
852
|
try {
|
|
767
|
-
if (!state.enabled || status !== 400 || headerInfo(headers)) return [];
|
|
853
|
+
if (!compat.state.enabled || status !== 400 || headerInfo(headers)) return [];
|
|
768
854
|
const named = [];
|
|
769
855
|
for (const id of featuresForBrowserEvents(eventTypes)) {
|
|
770
856
|
const feature = featureById(id);
|
|
771
857
|
const key = `${id}:relay_rejected`;
|
|
772
|
-
if (state.warned.has(key)) continue;
|
|
773
|
-
state.warned.add(key);
|
|
858
|
+
if (compat.state.warned.has(key)) continue;
|
|
859
|
+
compat.state.warned.add(key);
|
|
774
860
|
named.push(id);
|
|
775
861
|
try {
|
|
776
|
-
state.warn(
|
|
862
|
+
compat.state.warn(
|
|
777
863
|
`The ingester rejected a browser batch containing ${feature.title.toLowerCase()} events. ${feature.title} needs ingester >= ${feature.ingester}; yours is 1.4.0 or older (it predates version reporting), so those batches are dropped. ${ingesterUpgradeHint(COMPAT_MANIFEST)}`
|
|
778
864
|
);
|
|
779
865
|
} catch {
|
|
@@ -799,6 +885,7 @@ export {
|
|
|
799
885
|
registerFlushTarget,
|
|
800
886
|
unregisterFlushTargets,
|
|
801
887
|
installAutterAutoFlush,
|
|
888
|
+
sharedSlot,
|
|
802
889
|
SDK_IDENTITY,
|
|
803
890
|
compatRequest,
|
|
804
891
|
fetchIngesterCompat,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
var _chunkGYTQLITWcjs = require('./chunk-GYTQLITW.cjs');
|
|
5
6
|
|
|
6
7
|
// ../runtime-core/dist/index.js
|
|
7
8
|
var SENSITIVE_KEY_PATTERNS = [
|
|
@@ -993,7 +994,7 @@ var _crypto = require('crypto');
|
|
|
993
994
|
|
|
994
995
|
var _fs = require('fs');
|
|
995
996
|
var _path = require('path');
|
|
996
|
-
var sinkStats = { dropped: 0 };
|
|
997
|
+
var sinkStats = _chunkGYTQLITWcjs.sharedSlot.call(void 0, "sinks", () => ({ dropped: 0 }));
|
|
997
998
|
function otlpSink(options = {}) {
|
|
998
999
|
let context = null;
|
|
999
1000
|
let queue = [];
|
|
@@ -1069,7 +1070,7 @@ function otlpSink(options = {}) {
|
|
|
1069
1070
|
Math.max(1, Math.min(3e3, deadline - Date.now()))
|
|
1070
1071
|
)
|
|
1071
1072
|
});
|
|
1072
|
-
|
|
1073
|
+
_chunkGYTQLITWcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers, route: "/v1/logs" });
|
|
1073
1074
|
if (!response.ok)
|
|
1074
1075
|
throw new Error(`Runtime log export failed (${response.status})`);
|
|
1075
1076
|
failure = void 0;
|
|
@@ -1119,7 +1120,7 @@ function otlpSink(options = {}) {
|
|
|
1119
1120
|
}
|
|
1120
1121
|
queue.push({ record, bytes });
|
|
1121
1122
|
queueBytes += bytes;
|
|
1122
|
-
|
|
1123
|
+
_chunkGYTQLITWcjs.noteCompatFeature.call(void 0, "operation_logging");
|
|
1123
1124
|
scheduleFlush();
|
|
1124
1125
|
},
|
|
1125
1126
|
flush,
|
|
@@ -1362,18 +1363,22 @@ function memorySink() {
|
|
|
1362
1363
|
}
|
|
1363
1364
|
|
|
1364
1365
|
// src/logger.ts
|
|
1365
|
-
var
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1366
|
+
var shared = _chunkGYTQLITWcjs.sharedSlot.call(void 0, "logger", () => ({
|
|
1367
|
+
local: new (0, _async_hooks.AsyncLocalStorage)(),
|
|
1368
|
+
config: null,
|
|
1369
|
+
sinks: [],
|
|
1370
|
+
extraSinks: /* @__PURE__ */ new Set()
|
|
1371
|
+
}));
|
|
1372
|
+
var local = shared.local;
|
|
1373
|
+
var extraSinks = shared.extraSinks;
|
|
1369
1374
|
var fallbackConsole = null;
|
|
1370
1375
|
function redact(attributes) {
|
|
1371
|
-
return _nullishCoalesce(_optionalChain([
|
|
1376
|
+
return _nullishCoalesce(_optionalChain([shared, 'access', _16 => _16.config, 'optionalAccess', _17 => _17.redact, 'call', _18 => _18(attributes)]), () => ( redactAttributes(attributes)));
|
|
1372
1377
|
}
|
|
1373
1378
|
var safe = (attributes = {}) => boundContext(attributes, redact);
|
|
1374
1379
|
var merge = (current, next) => mergeContext(current, next, redact);
|
|
1375
1380
|
function activeSinks() {
|
|
1376
|
-
if (config) return extraSinks.size ? [...sinks, ...extraSinks] : sinks;
|
|
1381
|
+
if (shared.config) return extraSinks.size ? [...shared.sinks, ...extraSinks] : shared.sinks;
|
|
1377
1382
|
if (extraSinks.size) return [...extraSinks];
|
|
1378
1383
|
fallbackConsole ??= consoleSink();
|
|
1379
1384
|
return [fallbackConsole];
|
|
@@ -1407,12 +1412,12 @@ function traceAttributes(state) {
|
|
|
1407
1412
|
}
|
|
1408
1413
|
function emit(level, message, attributes, extra = {}, options = {}) {
|
|
1409
1414
|
const state = options.state !== void 0 ? _nullishCoalesce(options.state, () => ( void 0)) : local.getStore();
|
|
1410
|
-
if (_optionalChain([state, 'optionalAccess',
|
|
1415
|
+
if (_optionalChain([state, 'optionalAccess', _19 => _19.sealed])) return;
|
|
1411
1416
|
const summary = extra["autter.event.type"] === "operation";
|
|
1412
1417
|
if (!summary) recordLogBreadcrumb(level, message, attributes, state);
|
|
1413
|
-
if (!summary && LEVEL_SEVERITY[level] < LEVEL_SEVERITY[_nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
1418
|
+
if (!summary && LEVEL_SEVERITY[level] < LEVEL_SEVERITY[_nullishCoalesce(_optionalChain([shared, 'access', _20 => _20.config, 'optionalAccess', _21 => _21.options, 'optionalAccess', _22 => _22.minLevel]), () => ( "debug"))])
|
|
1414
1419
|
return;
|
|
1415
|
-
if (!summary && state && _optionalChain([config, 'optionalAccess',
|
|
1420
|
+
if (!summary && state && _optionalChain([shared, 'access', _23 => _23.config, 'optionalAccess', _24 => _24.options, 'optionalAccess', _25 => _25.inline]) !== false) {
|
|
1416
1421
|
const { "exception.stacktrace": _stack, ...inlineAttrs } = userContext(
|
|
1417
1422
|
attributes,
|
|
1418
1423
|
redact
|
|
@@ -1420,8 +1425,8 @@ function emit(level, message, attributes, extra = {}, options = {}) {
|
|
|
1420
1425
|
appendInlineLog(state.inline, level, message, inlineAttrs, redact);
|
|
1421
1426
|
if (level === "debug" || level === "info") return;
|
|
1422
1427
|
}
|
|
1423
|
-
const span = _nullishCoalesce(options.span, () => ( _optionalChain([_api.trace, 'access',
|
|
1424
|
-
const user = merge(_nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
1428
|
+
const span = _nullishCoalesce(options.span, () => ( _optionalChain([_api.trace, 'access', _26 => _26.getActiveSpan, 'call', _27 => _27(), 'optionalAccess', _28 => _28.spanContext, 'call', _29 => _29()])));
|
|
1429
|
+
const user = merge(_nullishCoalesce(_optionalChain([state, 'optionalAccess', _30 => _30.attributes]), () => ( {})), attributes);
|
|
1425
1430
|
const exceptions = Object.fromEntries(
|
|
1426
1431
|
Object.entries(user).filter(([key]) => key.startsWith("exception."))
|
|
1427
1432
|
);
|
|
@@ -1432,8 +1437,8 @@ function emit(level, message, attributes, extra = {}, options = {}) {
|
|
|
1432
1437
|
...operationAttributes(state),
|
|
1433
1438
|
...user
|
|
1434
1439
|
};
|
|
1435
|
-
const enrichers = _optionalChain([config, 'optionalAccess',
|
|
1436
|
-
if (summary && state && _optionalChain([enrichers, 'optionalAccess',
|
|
1440
|
+
const enrichers = _optionalChain([shared, 'access', _31 => _31.config, 'optionalAccess', _32 => _32.options, 'optionalAccess', _33 => _33.enrich]);
|
|
1441
|
+
if (summary && state && _optionalChain([enrichers, 'optionalAccess', _34 => _34.length])) {
|
|
1437
1442
|
const event2 = { level, message, attributes: raw };
|
|
1438
1443
|
for (const enrich of enrichers) {
|
|
1439
1444
|
try {
|
|
@@ -1460,11 +1465,11 @@ function emit(level, message, attributes, extra = {}, options = {}) {
|
|
|
1460
1465
|
}
|
|
1461
1466
|
}
|
|
1462
1467
|
function configureRuntimeLogger(next) {
|
|
1463
|
-
config = next;
|
|
1464
|
-
sinks = defaultSinks(next);
|
|
1465
|
-
for (const sink of sinks) {
|
|
1468
|
+
shared.config = next;
|
|
1469
|
+
shared.sinks = defaultSinks(next);
|
|
1470
|
+
for (const sink of shared.sinks) {
|
|
1466
1471
|
try {
|
|
1467
|
-
_optionalChain([sink, 'access',
|
|
1472
|
+
_optionalChain([sink, 'access', _35 => _35.start, 'optionalCall', _36 => _36({
|
|
1468
1473
|
endpoint: next.endpoint,
|
|
1469
1474
|
apiKey: next.apiKey,
|
|
1470
1475
|
service: next.service,
|
|
@@ -1477,14 +1482,14 @@ function configureRuntimeLogger(next) {
|
|
|
1477
1482
|
}
|
|
1478
1483
|
}
|
|
1479
1484
|
function loggerConfigured() {
|
|
1480
|
-
return config;
|
|
1485
|
+
return shared.config;
|
|
1481
1486
|
}
|
|
1482
1487
|
function addRuntimeSink(sink) {
|
|
1483
1488
|
extraSinks.add(sink);
|
|
1484
1489
|
return () => extraSinks.delete(sink);
|
|
1485
1490
|
}
|
|
1486
1491
|
function notifyException(error, attributes = {}) {
|
|
1487
|
-
if (!extraSinks.size && !sinks.some((sink) => sink.exception)) return;
|
|
1492
|
+
if (!extraSinks.size && !shared.sinks.some((sink) => sink.exception)) return;
|
|
1488
1493
|
const state = local.getStore();
|
|
1489
1494
|
const record = {
|
|
1490
1495
|
time: Date.now(),
|
|
@@ -1493,36 +1498,36 @@ function notifyException(error, attributes = {}) {
|
|
|
1493
1498
|
type: isError(error) ? error.name : "Error",
|
|
1494
1499
|
attributes: { ...attributes, ...errorAttributes(error) },
|
|
1495
1500
|
...state ? { operationId: state.id } : {},
|
|
1496
|
-
..._optionalChain([state, 'optionalAccess',
|
|
1501
|
+
..._optionalChain([state, 'optionalAccess', _37 => _37.requestId]) ? { requestId: state.requestId } : {}
|
|
1497
1502
|
};
|
|
1498
|
-
for (const sink of [...sinks, ...extraSinks]) {
|
|
1503
|
+
for (const sink of [...shared.sinks, ...extraSinks]) {
|
|
1499
1504
|
try {
|
|
1500
|
-
_optionalChain([sink, 'access',
|
|
1505
|
+
_optionalChain([sink, 'access', _38 => _38.exception, 'optionalCall', _39 => _39(record)]);
|
|
1501
1506
|
} catch (e19) {
|
|
1502
1507
|
}
|
|
1503
1508
|
}
|
|
1504
1509
|
}
|
|
1505
1510
|
function runtimeLogStats() {
|
|
1506
1511
|
return {
|
|
1507
|
-
buffered: sinks.reduce((sum, sink) => sum + (_nullishCoalesce(_optionalChain([sink, 'access',
|
|
1512
|
+
buffered: shared.sinks.reduce((sum, sink) => sum + (_nullishCoalesce(_optionalChain([sink, 'access', _40 => _40.buffered, 'optionalCall', _41 => _41()]), () => ( 0))), 0),
|
|
1508
1513
|
dropped: sinkStats.dropped
|
|
1509
1514
|
};
|
|
1510
1515
|
}
|
|
1511
1516
|
async function flushRuntimeLogs() {
|
|
1512
|
-
if (!config) return;
|
|
1517
|
+
if (!shared.config) return;
|
|
1513
1518
|
const results = await Promise.allSettled(
|
|
1514
|
-
sinks.map((sink) => Promise.resolve().then(() => _optionalChain([sink, 'access',
|
|
1519
|
+
shared.sinks.map((sink) => Promise.resolve().then(() => _optionalChain([sink, 'access', _42 => _42.flush, 'optionalCall', _43 => _43()])))
|
|
1515
1520
|
);
|
|
1516
1521
|
const failed = results.find((result) => result.status === "rejected");
|
|
1517
1522
|
if (failed) throw failed.reason;
|
|
1518
1523
|
}
|
|
1519
1524
|
async function shutdownRuntimeLogger() {
|
|
1520
|
-
const active = sinks;
|
|
1525
|
+
const active = shared.sinks;
|
|
1521
1526
|
const results = await Promise.allSettled(
|
|
1522
|
-
active.map((sink) => Promise.resolve().then(() => _optionalChain([sink, 'access',
|
|
1527
|
+
active.map((sink) => Promise.resolve().then(() => _optionalChain([sink, 'access', _44 => _44.shutdown, 'optionalCall', _45 => _45()])))
|
|
1523
1528
|
);
|
|
1524
|
-
config = null;
|
|
1525
|
-
sinks = [];
|
|
1529
|
+
shared.config = null;
|
|
1530
|
+
shared.sinks = [];
|
|
1526
1531
|
const failed = results.find((result) => result.status === "rejected");
|
|
1527
1532
|
if (failed) throw failed.reason;
|
|
1528
1533
|
}
|
|
@@ -1560,7 +1565,7 @@ var runtimeLogger = createRuntimeLogger();
|
|
|
1560
1565
|
function captureExceptionAsLog(error, attributes = {}) {
|
|
1561
1566
|
const isErr = isError(error);
|
|
1562
1567
|
const message = isErr ? error.message : String(error);
|
|
1563
|
-
const stack = isErr && error.stack ? error.stack : _nullishCoalesce(_optionalChain([new Error(), 'access',
|
|
1568
|
+
const stack = isErr && error.stack ? error.stack : _nullishCoalesce(_optionalChain([new Error(), 'access', _46 => _46.stack, 'optionalAccess', _47 => _47.split, 'call', _48 => _48("\n"), 'access', _49 => _49.filter, 'call', _50 => _50((line, i) => i === 0 || !/captureException/.test(line)), 'access', _51 => _51.join, 'call', _52 => _52("\n")]), () => ( ""));
|
|
1564
1569
|
noteOperationError(error);
|
|
1565
1570
|
emit(
|
|
1566
1571
|
"error",
|
|
@@ -1614,7 +1619,7 @@ function operationHandle(state) {
|
|
|
1614
1619
|
setContext: (attrs) => {
|
|
1615
1620
|
if (!state.sealed) {
|
|
1616
1621
|
state.attributes = merge(state.attributes, attrs);
|
|
1617
|
-
_optionalChain([_api.trace, 'access',
|
|
1622
|
+
_optionalChain([_api.trace, 'access', _53 => _53.getActiveSpan, 'call', _54 => _54(), 'optionalAccess', _55 => _55.setAttributes, 'call', _56 => _56(traceAttributes(state))]);
|
|
1618
1623
|
}
|
|
1619
1624
|
},
|
|
1620
1625
|
outcome: (status, message) => setOutcome(state, status, message),
|
|
@@ -1674,7 +1679,7 @@ function emitSummary(state, options = {}) {
|
|
|
1674
1679
|
}
|
|
1675
1680
|
function reportExplicitFailure(state) {
|
|
1676
1681
|
if (state.outcome === "failed" && state.explicitOutcome && !state.errorThrown)
|
|
1677
|
-
_optionalChain([config, 'optionalAccess',
|
|
1682
|
+
_optionalChain([shared, 'access', _57 => _57.config, 'optionalAccess', _58 => _58.reportOutcome, 'call', _59 => _59(state.name, _nullishCoalesce(state.message, () => ( "Operation failed")), {
|
|
1678
1683
|
...traceAttributes(state),
|
|
1679
1684
|
"autter.outcome.stack": _nullishCoalesce(state.reportingStack, () => ( ""))
|
|
1680
1685
|
})]);
|
|
@@ -1682,7 +1687,7 @@ function reportExplicitFailure(state) {
|
|
|
1682
1687
|
function startOperation(name, fn, attributes, options, internal = {}) {
|
|
1683
1688
|
const parent = _nullishCoalesce(internal.forkParent, () => ( local.getStore()));
|
|
1684
1689
|
const carrier = options.from ? parseCarrier(options.from) : null;
|
|
1685
|
-
const traceparent = _optionalChain([carrier, 'optionalAccess',
|
|
1690
|
+
const traceparent = _optionalChain([carrier, 'optionalAccess', _60 => _60.traceparent]) ? parseTraceparent(carrier.traceparent) : null;
|
|
1686
1691
|
const linked = internal.forkParent !== void 0 || parent && !parent.sealed;
|
|
1687
1692
|
const state = newState(
|
|
1688
1693
|
name,
|
|
@@ -1694,7 +1699,7 @@ function startOperation(name, fn, attributes, options, internal = {}) {
|
|
|
1694
1699
|
...traceparent ? { parentTraceId: traceparent.traceId } : {}
|
|
1695
1700
|
} : {
|
|
1696
1701
|
...linked && parent ? { parentId: parent.id, base: parent.attributes } : {},
|
|
1697
|
-
..._optionalChain([parent, 'optionalAccess',
|
|
1702
|
+
..._optionalChain([parent, 'optionalAccess', _61 => _61.requestId]) ? { requestId: parent.requestId } : {}
|
|
1698
1703
|
}
|
|
1699
1704
|
);
|
|
1700
1705
|
if (linked && parent) state.breadcrumbs = parent.breadcrumbs ??= new BreadcrumbTrail();
|
|
@@ -1708,16 +1713,16 @@ function startOperation(name, fn, attributes, options, internal = {}) {
|
|
|
1708
1713
|
thrown = error;
|
|
1709
1714
|
noteOperationError(error, true, state);
|
|
1710
1715
|
rememberThrownBreadcrumbs(error, state);
|
|
1711
|
-
_optionalChain([config, 'optionalAccess',
|
|
1716
|
+
_optionalChain([shared, 'access', _62 => _62.config, 'optionalAccess', _63 => _63.captureThrown, 'optionalCall', _64 => _64(error)]);
|
|
1712
1717
|
throw error;
|
|
1713
1718
|
} finally {
|
|
1714
|
-
_optionalChain([_api.trace, 'access',
|
|
1719
|
+
_optionalChain([_api.trace, 'access', _65 => _65.getActiveSpan, 'call', _66 => _66(), 'optionalAccess', _67 => _67.setAttributes, 'call', _68 => _68({
|
|
1715
1720
|
...traceAttributes(state),
|
|
1716
1721
|
"autter.operation.outcome": state.outcome,
|
|
1717
1722
|
"autter.operation.kind": state.kind
|
|
1718
1723
|
})]);
|
|
1719
1724
|
if (state.outcome === "failed" && !thrown)
|
|
1720
|
-
_optionalChain([config, 'optionalAccess',
|
|
1725
|
+
_optionalChain([shared, 'access', _69 => _69.config, 'optionalAccess', _70 => _70.reportOutcome, 'call', _71 => _71(
|
|
1721
1726
|
state.name,
|
|
1722
1727
|
_nullishCoalesce(state.message, () => ( "Operation failed")),
|
|
1723
1728
|
{
|
|
@@ -1738,7 +1743,7 @@ function startOperation(name, fn, attributes, options, internal = {}) {
|
|
|
1738
1743
|
}
|
|
1739
1744
|
}
|
|
1740
1745
|
] : [];
|
|
1741
|
-
const promise = _optionalChain([config, 'optionalAccess',
|
|
1746
|
+
const promise = _optionalChain([shared, 'access', _72 => _72.config, 'optionalAccess', _73 => _73.run]) ? shared.config.run(state.name, run, traceAttributes(state), links) : run();
|
|
1742
1747
|
if (!options.waitUntil) return promise;
|
|
1743
1748
|
const waitUntil = options.waitUntil;
|
|
1744
1749
|
return promise.finally(() => {
|
|
@@ -1761,7 +1766,7 @@ var runtimeContext = {
|
|
|
1761
1766
|
const state = currentOperation();
|
|
1762
1767
|
if (!state) return;
|
|
1763
1768
|
state.attributes = merge(state.attributes, attributes);
|
|
1764
|
-
_optionalChain([_api.trace, 'access',
|
|
1769
|
+
_optionalChain([_api.trace, 'access', _74 => _74.getActiveSpan, 'call', _75 => _75(), 'optionalAccess', _76 => _76.setAttributes, 'call', _77 => _77(traceAttributes(state))]);
|
|
1765
1770
|
},
|
|
1766
1771
|
/** Set the outcome explicitly (wins over status/thrown-error rules). */
|
|
1767
1772
|
outcome(status, message) {
|
|
@@ -1784,11 +1789,11 @@ var runtimeContext = {
|
|
|
1784
1789
|
},
|
|
1785
1790
|
/** Current operation id. */
|
|
1786
1791
|
get id() {
|
|
1787
|
-
return _optionalChain([local, 'access',
|
|
1792
|
+
return _optionalChain([local, 'access', _78 => _78.getStore, 'call', _79 => _79(), 'optionalAccess', _80 => _80.id]);
|
|
1788
1793
|
},
|
|
1789
1794
|
/** Current request id (inherited by child operations and forks). */
|
|
1790
1795
|
get requestId() {
|
|
1791
|
-
return _optionalChain([local, 'access',
|
|
1796
|
+
return _optionalChain([local, 'access', _81 => _81.getStore, 'call', _82 => _82(), 'optionalAccess', _83 => _83.requestId]);
|
|
1792
1797
|
},
|
|
1793
1798
|
/**
|
|
1794
1799
|
* Run `fn` as a child operation whose parent link is captured NOW, so it
|
|
@@ -1802,7 +1807,7 @@ var runtimeContext = {
|
|
|
1802
1807
|
carrier() {
|
|
1803
1808
|
const state = local.getStore();
|
|
1804
1809
|
if (!state) return void 0;
|
|
1805
|
-
const span = _optionalChain([_api.trace, 'access',
|
|
1810
|
+
const span = _optionalChain([_api.trace, 'access', _84 => _84.getActiveSpan, 'call', _85 => _85(), 'optionalAccess', _86 => _86.spanContext, 'call', _87 => _87()]);
|
|
1806
1811
|
const traceparent = span ? formatTraceparent(span.traceId, span.spanId, (span.traceFlags & 1) === 1) : void 0;
|
|
1807
1812
|
return createCarrier({
|
|
1808
1813
|
op: state.id,
|
|
@@ -1815,18 +1820,23 @@ var runtimeContext = {
|
|
|
1815
1820
|
// src/breadcrumbs.ts
|
|
1816
1821
|
var INVALID_TRACE_ID = "00000000000000000000000000000000";
|
|
1817
1822
|
var MAX_TRACE_TRAILS = 200;
|
|
1818
|
-
var
|
|
1819
|
-
|
|
1820
|
-
|
|
1823
|
+
var trails = _chunkGYTQLITWcjs.sharedSlot.call(void 0, "breadcrumbs", () => ({
|
|
1824
|
+
byTrace: /* @__PURE__ */ new Map(),
|
|
1825
|
+
process: new BreadcrumbTrail(),
|
|
1826
|
+
thrown: /* @__PURE__ */ new WeakMap()
|
|
1827
|
+
}));
|
|
1828
|
+
var byTrace = trails.byTrace;
|
|
1829
|
+
var processTrail = trails.process;
|
|
1830
|
+
var thrownTrails = trails.thrown;
|
|
1821
1831
|
function redact2(attributes) {
|
|
1822
|
-
return _nullishCoalesce(_optionalChain([loggerConfigured, 'call',
|
|
1832
|
+
return _nullishCoalesce(_optionalChain([loggerConfigured, 'call', _88 => _88(), 'optionalAccess', _89 => _89.redact, 'call', _90 => _90(attributes)]), () => ( redactAttributes(attributes)));
|
|
1823
1833
|
}
|
|
1824
1834
|
function trailFor(create, state = local.getStore()) {
|
|
1825
1835
|
if (state) {
|
|
1826
1836
|
if (!state.breadcrumbs && create) state.breadcrumbs = new BreadcrumbTrail();
|
|
1827
1837
|
return state.breadcrumbs;
|
|
1828
1838
|
}
|
|
1829
|
-
const traceId = _optionalChain([_api.trace, 'access',
|
|
1839
|
+
const traceId = _optionalChain([_api.trace, 'access', _91 => _91.getActiveSpan, 'call', _92 => _92(), 'optionalAccess', _93 => _93.spanContext, 'call', _94 => _94(), 'access', _95 => _95.traceId]);
|
|
1830
1840
|
if (traceId && traceId !== INVALID_TRACE_ID) {
|
|
1831
1841
|
let trail = byTrace.get(traceId);
|
|
1832
1842
|
if (!trail && create) {
|
|
@@ -1845,8 +1855,8 @@ function addBreadcrumb(input) {
|
|
|
1845
1855
|
try {
|
|
1846
1856
|
const crumb = normalizeBreadcrumb(input, redact2);
|
|
1847
1857
|
if (!crumb) return;
|
|
1848
|
-
_optionalChain([trailFor, 'call',
|
|
1849
|
-
|
|
1858
|
+
_optionalChain([trailFor, 'call', _96 => _96(true), 'optionalAccess', _97 => _97.add, 'call', _98 => _98(crumb)]);
|
|
1859
|
+
_chunkGYTQLITWcjs.noteCompatFeature.call(void 0, "breadcrumbs");
|
|
1850
1860
|
} catch (e21) {
|
|
1851
1861
|
}
|
|
1852
1862
|
}
|
|
@@ -1863,7 +1873,7 @@ function recordLogBreadcrumb(level, message, attributes, state) {
|
|
|
1863
1873
|
}
|
|
1864
1874
|
}
|
|
1865
1875
|
const crumb = normalizeBreadcrumb({ type: "log", level, message, data }, redact2);
|
|
1866
|
-
if (crumb) _optionalChain([trailFor, 'call',
|
|
1876
|
+
if (crumb) _optionalChain([trailFor, 'call', _99 => _99(true, state), 'optionalAccess', _100 => _100.add, 'call', _101 => _101(crumb)]);
|
|
1867
1877
|
} catch (e22) {
|
|
1868
1878
|
}
|
|
1869
1879
|
}
|
|
@@ -1881,7 +1891,7 @@ function breadcrumbEventAttributes(scrub, error) {
|
|
|
1881
1891
|
try {
|
|
1882
1892
|
const thrown = error !== null && typeof error === "object" ? thrownTrails.get(error) : void 0;
|
|
1883
1893
|
const trail = _nullishCoalesce(thrown, () => ( trailFor(false)));
|
|
1884
|
-
if (!_optionalChain([trail, 'optionalAccess',
|
|
1894
|
+
if (!_optionalChain([trail, 'optionalAccess', _102 => _102.size])) return {};
|
|
1885
1895
|
const json = breadcrumbsAttribute(trail.list(), scrub, attributeBudget());
|
|
1886
1896
|
return json ? { [BREADCRUMBS_ATTRIBUTE]: json } : {};
|
|
1887
1897
|
} catch (e23) {
|