@autter/runtime-node 1.6.0 → 1.6.1
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 +43 -0
- package/dist/{chunk-ARN26OK6.cjs → chunk-4MVWIRBI.cjs} +89 -39
- package/dist/{chunk-FBKYOHU2.js → chunk-5KISVAVB.js} +41 -31
- package/dist/{chunk-UGNPCOIW.cjs → chunk-7OTD2YPT.cjs} +11 -11
- package/dist/{chunk-OY2HTUWY.js → chunk-HRDELHZP.js} +81 -31
- package/dist/{chunk-Y4T7SQMO.js → chunk-L5ENELB2.js} +1 -1
- package/dist/{chunk-UKYTXZOQ.cjs → chunk-UXTIMS3G.cjs} +65 -55
- package/dist/cli.cjs +8 -8
- package/dist/cli.js +2 -2
- package/dist/index.cjs +399 -290
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +215 -106
- package/dist/testing.cjs +8 -8
- package/dist/testing.js +2 -2
- package/package.json +1 -1
|
@@ -464,7 +464,7 @@ import { request as httpsRequest } from "https";
|
|
|
464
464
|
// package.json
|
|
465
465
|
var package_default = {
|
|
466
466
|
name: "@autter/runtime-node",
|
|
467
|
-
version: "1.6.
|
|
467
|
+
version: "1.6.1",
|
|
468
468
|
description: "Autter Runtime for Node.js: request wide events, coded errors, operation logging, same-origin browser relay and a curated OpenTelemetry server tracker",
|
|
469
469
|
license: "MIT",
|
|
470
470
|
type: "module",
|
|
@@ -539,6 +539,55 @@ var package_default = {
|
|
|
539
539
|
]
|
|
540
540
|
};
|
|
541
541
|
|
|
542
|
+
// src/shared.ts
|
|
543
|
+
var SHARED_STATE_KEY = /* @__PURE__ */ Symbol.for("@autter/runtime-node");
|
|
544
|
+
var SHARED_STATE_LAYOUT = 1;
|
|
545
|
+
function isObject(value) {
|
|
546
|
+
return typeof value === "object" && value !== null;
|
|
547
|
+
}
|
|
548
|
+
var VERSION = package_default.version;
|
|
549
|
+
function resolveShared() {
|
|
550
|
+
const fresh = { v: SHARED_STATE_LAYOUT, sdk: VERSION };
|
|
551
|
+
const host = globalThis;
|
|
552
|
+
let existing;
|
|
553
|
+
try {
|
|
554
|
+
existing = host[SHARED_STATE_KEY];
|
|
555
|
+
if (existing === void 0) {
|
|
556
|
+
Object.defineProperty(host, SHARED_STATE_KEY, {
|
|
557
|
+
value: fresh,
|
|
558
|
+
configurable: true,
|
|
559
|
+
enumerable: false,
|
|
560
|
+
writable: false
|
|
561
|
+
});
|
|
562
|
+
return fresh;
|
|
563
|
+
}
|
|
564
|
+
} catch {
|
|
565
|
+
return fresh;
|
|
566
|
+
}
|
|
567
|
+
if (isObject(existing) && existing.v === SHARED_STATE_LAYOUT) return existing;
|
|
568
|
+
debugLog(
|
|
569
|
+
`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`
|
|
570
|
+
);
|
|
571
|
+
return fresh;
|
|
572
|
+
}
|
|
573
|
+
var shared = resolveShared();
|
|
574
|
+
function sharedSlot(name, init) {
|
|
575
|
+
const fresh = init();
|
|
576
|
+
try {
|
|
577
|
+
const existing = shared[name];
|
|
578
|
+
if (!isObject(existing)) {
|
|
579
|
+
shared[name] = fresh;
|
|
580
|
+
return fresh;
|
|
581
|
+
}
|
|
582
|
+
for (const [key, value] of Object.entries(fresh)) {
|
|
583
|
+
if (existing[key] === void 0) existing[key] = value;
|
|
584
|
+
}
|
|
585
|
+
return existing;
|
|
586
|
+
} catch {
|
|
587
|
+
return fresh;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
542
591
|
// src/compat.ts
|
|
543
592
|
var SDK_IDENTITY = {
|
|
544
593
|
name: "@autter/runtime-node",
|
|
@@ -631,7 +680,7 @@ function envDisabled() {
|
|
|
631
680
|
return value === "0" || value === "false" || value === "off";
|
|
632
681
|
}
|
|
633
682
|
var defaultWarn = (message) => console.warn(`[autter-runtime] ${message}`);
|
|
634
|
-
var
|
|
683
|
+
var compat = sharedSlot("compat", () => ({ state: freshState(null, false) }));
|
|
635
684
|
function freshState(endpoint, enabled, sdk = SDK_IDENTITY, warn = defaultWarn) {
|
|
636
685
|
return {
|
|
637
686
|
endpoint,
|
|
@@ -646,7 +695,7 @@ function freshState(endpoint, enabled, sdk = SDK_IDENTITY, warn = defaultWarn) {
|
|
|
646
695
|
};
|
|
647
696
|
}
|
|
648
697
|
function configureCompatCheck(options) {
|
|
649
|
-
state = freshState(
|
|
698
|
+
compat.state = freshState(
|
|
650
699
|
options.endpoint.replace(/\/$/, ""),
|
|
651
700
|
options.enabled !== false && !envDisabled(),
|
|
652
701
|
options.sdk ?? SDK_IDENTITY,
|
|
@@ -654,21 +703,21 @@ function configureCompatCheck(options) {
|
|
|
654
703
|
);
|
|
655
704
|
}
|
|
656
705
|
function ensureCompatConfigured(endpoint) {
|
|
657
|
-
if (state.endpoint === null && !envDisabled()) {
|
|
658
|
-
state = freshState(endpoint.replace(/\/$/, ""), true);
|
|
706
|
+
if (compat.state.endpoint === null && !envDisabled()) {
|
|
707
|
+
compat.state = freshState(endpoint.replace(/\/$/, ""), true);
|
|
659
708
|
}
|
|
660
709
|
}
|
|
661
710
|
function noteCompatFeature(id) {
|
|
662
711
|
try {
|
|
663
|
-
if (!state.enabled || state.features.has(id) || !featureById(id)) return;
|
|
664
|
-
state.features.add(id);
|
|
665
|
-
if (state.info) {
|
|
712
|
+
if (!compat.state.enabled || compat.state.features.has(id) || !featureById(id)) return;
|
|
713
|
+
compat.state.features.add(id);
|
|
714
|
+
if (compat.state.info) {
|
|
666
715
|
evaluateAndWarn();
|
|
667
716
|
return;
|
|
668
717
|
}
|
|
669
|
-
if (state.started) return;
|
|
670
|
-
state.started = true;
|
|
671
|
-
const current = state;
|
|
718
|
+
if (compat.state.started) return;
|
|
719
|
+
compat.state.started = true;
|
|
720
|
+
const current = compat.state;
|
|
672
721
|
setTimeout(() => void runCheck(current), 0).unref();
|
|
673
722
|
} catch {
|
|
674
723
|
}
|
|
@@ -679,7 +728,7 @@ async function runCheck(current) {
|
|
|
679
728
|
const { info, error } = await fetchIngesterCompat(current.endpoint, {
|
|
680
729
|
probeRoutes: routesFor(current.features)
|
|
681
730
|
});
|
|
682
|
-
if (state !== current) return;
|
|
731
|
+
if (compat.state !== current) return;
|
|
683
732
|
if (!info) {
|
|
684
733
|
debugLog(`compat check skipped: ${error ?? "ingester version unknown"}`);
|
|
685
734
|
return;
|
|
@@ -703,8 +752,8 @@ function routesFor(features) {
|
|
|
703
752
|
return routes;
|
|
704
753
|
}
|
|
705
754
|
function mergeInfo(next) {
|
|
706
|
-
const prev = state.info;
|
|
707
|
-
state.info = {
|
|
755
|
+
const prev = compat.state.info;
|
|
756
|
+
compat.state.info = {
|
|
708
757
|
version: next.version ?? prev?.version ?? null,
|
|
709
758
|
...next.legacy || prev?.legacy ? { legacy: true } : {},
|
|
710
759
|
...next.schema ?? prev?.schema ? { schema: next.schema ?? prev?.schema } : {},
|
|
@@ -712,17 +761,17 @@ function mergeInfo(next) {
|
|
|
712
761
|
};
|
|
713
762
|
}
|
|
714
763
|
function evaluateAndWarn() {
|
|
715
|
-
const info = state.info;
|
|
764
|
+
const info = compat.state.info;
|
|
716
765
|
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)
|
|
766
|
+
if (info.version === null && compat.state.endpoint) {
|
|
767
|
+
const unprobed = routesFor(compat.state.features).filter(
|
|
768
|
+
(route) => info.routes?.[route] === void 0 && !compat.state.pendingProbes.has(route)
|
|
720
769
|
);
|
|
721
770
|
if (unprobed.length) {
|
|
722
|
-
const current = state;
|
|
771
|
+
const current = compat.state;
|
|
723
772
|
for (const route of unprobed) current.pendingProbes.add(route);
|
|
724
773
|
void Promise.all(unprobed.map((route) => probeRoute(current.endpoint, route, {}).then((exists) => [route, exists]))).then((results) => {
|
|
725
|
-
if (state !== current) return;
|
|
774
|
+
if (compat.state !== current) return;
|
|
726
775
|
const routes = {};
|
|
727
776
|
for (const [route, exists] of results) if (exists !== null) routes[route] = exists;
|
|
728
777
|
mergeInfo({ version: null, legacy: true, routes });
|
|
@@ -731,31 +780,31 @@ function evaluateAndWarn() {
|
|
|
731
780
|
});
|
|
732
781
|
}
|
|
733
782
|
}
|
|
734
|
-
for (const issue of evaluateCompat({ features: state.features, ingester: info })) {
|
|
783
|
+
for (const issue of evaluateCompat({ features: compat.state.features, ingester: info })) {
|
|
735
784
|
warnOnce(issue);
|
|
736
785
|
}
|
|
737
786
|
}
|
|
738
787
|
function warnOnce(issue) {
|
|
739
788
|
const key = `${issue.feature}:${issue.kind}`;
|
|
740
|
-
if (state.warned.has(key)) return;
|
|
741
|
-
state.warned.add(key);
|
|
789
|
+
if (compat.state.warned.has(key)) return;
|
|
790
|
+
compat.state.warned.add(key);
|
|
742
791
|
try {
|
|
743
|
-
state.warn(issue.message);
|
|
792
|
+
compat.state.warn(issue.message);
|
|
744
793
|
} catch {
|
|
745
794
|
}
|
|
746
795
|
}
|
|
747
796
|
function observeIngesterResponse(response) {
|
|
748
797
|
try {
|
|
749
|
-
if (!state.enabled) return;
|
|
798
|
+
if (!compat.state.enabled) return;
|
|
750
799
|
const fromHeader = headerInfo(response.headers);
|
|
751
800
|
if (fromHeader) {
|
|
752
|
-
if (state.info?.version !== fromHeader.version) {
|
|
801
|
+
if (compat.state.info?.version !== fromHeader.version) {
|
|
753
802
|
mergeInfo(fromHeader);
|
|
754
803
|
evaluateAndWarn();
|
|
755
804
|
}
|
|
756
805
|
return;
|
|
757
806
|
}
|
|
758
|
-
if (response.status === 404 && response.route && !state.info?.version) {
|
|
807
|
+
if (response.status === 404 && response.route && !compat.state.info?.version) {
|
|
759
808
|
mergeInfo({ version: null, legacy: true, routes: { [response.route]: false } });
|
|
760
809
|
evaluateAndWarn();
|
|
761
810
|
}
|
|
@@ -764,16 +813,16 @@ function observeIngesterResponse(response) {
|
|
|
764
813
|
}
|
|
765
814
|
function noteRelayRejection(eventTypes, status, headers) {
|
|
766
815
|
try {
|
|
767
|
-
if (!state.enabled || status !== 400 || headerInfo(headers)) return [];
|
|
816
|
+
if (!compat.state.enabled || status !== 400 || headerInfo(headers)) return [];
|
|
768
817
|
const named = [];
|
|
769
818
|
for (const id of featuresForBrowserEvents(eventTypes)) {
|
|
770
819
|
const feature = featureById(id);
|
|
771
820
|
const key = `${id}:relay_rejected`;
|
|
772
|
-
if (state.warned.has(key)) continue;
|
|
773
|
-
state.warned.add(key);
|
|
821
|
+
if (compat.state.warned.has(key)) continue;
|
|
822
|
+
compat.state.warned.add(key);
|
|
774
823
|
named.push(id);
|
|
775
824
|
try {
|
|
776
|
-
state.warn(
|
|
825
|
+
compat.state.warn(
|
|
777
826
|
`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
827
|
);
|
|
779
828
|
} catch {
|
|
@@ -799,6 +848,7 @@ export {
|
|
|
799
848
|
registerFlushTarget,
|
|
800
849
|
unregisterFlushTargets,
|
|
801
850
|
installAutterAutoFlush,
|
|
851
|
+
sharedSlot,
|
|
802
852
|
SDK_IDENTITY,
|
|
803
853
|
compatRequest,
|
|
804
854
|
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 _chunk4MVWIRBIcjs = require('./chunk-4MVWIRBI.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 = _chunk4MVWIRBIcjs.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
|
+
_chunk4MVWIRBIcjs.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
|
+
_chunk4MVWIRBIcjs.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 = _chunk4MVWIRBIcjs.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 = _chunk4MVWIRBIcjs.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
|
+
_chunk4MVWIRBIcjs.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) {
|
package/dist/cli.cjs
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-
|
|
7
|
+
var _chunk7OTD2YPTcjs = require('./chunk-7OTD2YPT.cjs');
|
|
8
|
+
require('./chunk-4MVWIRBI.cjs');
|
|
9
9
|
|
|
10
10
|
// src/cli.ts
|
|
11
11
|
var _child_process = require('child_process');
|
|
@@ -31,22 +31,22 @@ async function main(argv) {
|
|
|
31
31
|
return 64;
|
|
32
32
|
}
|
|
33
33
|
if (command !== "doctor") {
|
|
34
|
-
console.log(
|
|
34
|
+
console.log(_chunk7OTD2YPTcjs.DOCTOR_USAGE);
|
|
35
35
|
return command === void 0 || command === "--help" || command === "-h" ? 0 : 64;
|
|
36
36
|
}
|
|
37
|
-
const parsed =
|
|
37
|
+
const parsed = _chunk7OTD2YPTcjs.parseDoctorArgs.call(void 0, rest);
|
|
38
38
|
if ("help" in parsed) {
|
|
39
|
-
console.log(
|
|
39
|
+
console.log(_chunk7OTD2YPTcjs.DOCTOR_USAGE);
|
|
40
40
|
return 0;
|
|
41
41
|
}
|
|
42
42
|
if ("error" in parsed) {
|
|
43
43
|
console.error(`${parsed.error}
|
|
44
44
|
|
|
45
|
-
${
|
|
45
|
+
${_chunk7OTD2YPTcjs.DOCTOR_USAGE}`);
|
|
46
46
|
return 64;
|
|
47
47
|
}
|
|
48
|
-
const report = await
|
|
49
|
-
console.log(parsed.json ? JSON.stringify(report, null, 2) :
|
|
48
|
+
const report = await _chunk7OTD2YPTcjs.runDoctor.call(void 0, parsed);
|
|
49
|
+
console.log(parsed.json ? JSON.stringify(report, null, 2) : _chunk7OTD2YPTcjs.formatDoctorReport.call(void 0, report));
|
|
50
50
|
return report.exitCode;
|
|
51
51
|
}
|
|
52
52
|
main(process.argv.slice(2)).then(
|
package/dist/cli.js
CHANGED