@autter/runtime-node 1.9.0 → 1.9.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/dist/{chunk-BHYHORUD.cjs → chunk-3P573RHA.cjs} +1 -1
- package/dist/{chunk-HHKQ3UCH.js → chunk-D3PJ7TQ4.js} +18 -6
- package/dist/{chunk-YWTIKZSI.cjs → chunk-FV64SIRQ.cjs} +26 -14
- package/dist/{chunk-JSGGUWRD.js → chunk-FYMEBULO.js} +4 -3
- package/dist/{chunk-AN45KLWD.cjs → chunk-LYXQC4FI.cjs} +14 -13
- package/dist/{chunk-ZKM76SDP.js → chunk-VIP2EL47.js} +1 -1
- package/dist/cli.cjs +8 -8
- package/dist/cli.js +2 -2
- package/dist/index.cjs +269 -247
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +35 -13
- package/dist/{sinks-CLtQFPnn.d.ts → sinks-BfUoE96B.d.cts} +3 -1
- package/dist/{sinks-CLtQFPnn.d.cts → sinks-BfUoE96B.d.ts} +3 -1
- package/dist/testing.cjs +8 -8
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
var
|
|
54
|
+
var _chunkFV64SIRQcjs = require('./chunk-FV64SIRQ.cjs');
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
var
|
|
57
|
+
var _chunkLYXQC4FIcjs = require('./chunk-LYXQC4FI.cjs');
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
@@ -76,7 +76,7 @@ var _chunkAN45KLWDcjs = require('./chunk-AN45KLWD.cjs');
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
var
|
|
79
|
+
var _chunk3P573RHAcjs = require('./chunk-3P573RHA.cjs');
|
|
80
80
|
|
|
81
81
|
// src/relay.ts
|
|
82
82
|
var IpWindow = (_class = class {
|
|
@@ -336,7 +336,7 @@ function relayContext(raw, redactor) {
|
|
|
336
336
|
return Array.isArray(bounded) ? {} : { context: redactor(bounded) };
|
|
337
337
|
}
|
|
338
338
|
function relayBreadcrumbs(raw, redactor) {
|
|
339
|
-
const breadcrumbs =
|
|
339
|
+
const breadcrumbs = _chunkFV64SIRQcjs.sanitizeBreadcrumbs.call(void 0, raw, redactor);
|
|
340
340
|
return breadcrumbs ? { breadcrumbs } : {};
|
|
341
341
|
}
|
|
342
342
|
var DEBUG_ID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
@@ -353,10 +353,10 @@ function relayDebugIds(raw, redactor) {
|
|
|
353
353
|
return count ? { debugIds } : {};
|
|
354
354
|
}
|
|
355
355
|
function relayFingerprint(raw, redactor) {
|
|
356
|
-
const values =
|
|
356
|
+
const values = _chunkFV64SIRQcjs.fingerprintValues.call(void 0, raw, redactor.text);
|
|
357
357
|
return values ? { fingerprint: Array.isArray(raw) ? values : values[0] } : {};
|
|
358
358
|
}
|
|
359
|
-
var defaultRelayRedactor =
|
|
359
|
+
var defaultRelayRedactor = _chunkFV64SIRQcjs.makeRedactor.call(void 0, true);
|
|
360
360
|
function sanitizeBrowserPayload(raw, redactor = defaultRelayRedactor) {
|
|
361
361
|
if (typeof raw !== "object" || raw === null) return null;
|
|
362
362
|
const p = raw;
|
|
@@ -401,39 +401,61 @@ function sanitizeBrowserPayload(raw, redactor = defaultRelayRedactor) {
|
|
|
401
401
|
events
|
|
402
402
|
};
|
|
403
403
|
}
|
|
404
|
+
var FORWARD_ATTEMPTS = 3;
|
|
405
|
+
var FORWARD_MAX_WAIT_MS = 1e4;
|
|
404
406
|
function forward(payload, opts) {
|
|
405
407
|
const endpoint = (_nullishCoalesce(opts.endpoint, () => ( DEFAULT_ENDPOINT))).replace(/\/$/, "");
|
|
406
408
|
const url = `${endpoint}/v1/browser`;
|
|
407
409
|
const compat = opts.compatCheck !== false;
|
|
408
|
-
if (compat)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
410
|
+
if (compat) _chunk3P573RHAcjs.ensureCompatConfigured.call(void 0, endpoint);
|
|
411
|
+
const body = JSON.stringify(payload);
|
|
412
|
+
const attempt = async (n) => {
|
|
413
|
+
let response;
|
|
414
|
+
try {
|
|
415
|
+
response = await fetch(url, {
|
|
416
|
+
method: "POST",
|
|
417
|
+
headers: {
|
|
418
|
+
"content-type": "application/json",
|
|
419
|
+
authorization: `Bearer ${opts.apiKey}`
|
|
420
|
+
},
|
|
421
|
+
body,
|
|
422
|
+
signal: AbortSignal.timeout(1e4)
|
|
423
|
+
});
|
|
424
|
+
} catch (err) {
|
|
425
|
+
if (n >= FORWARD_ATTEMPTS) throw err;
|
|
426
|
+
await sleep(1e3 * 2 ** (n - 1));
|
|
427
|
+
return attempt(n + 1);
|
|
428
|
+
}
|
|
429
|
+
if ((response.status === 429 || response.status >= 500) && n < FORWARD_ATTEMPTS) {
|
|
430
|
+
const seconds = Number(response.headers.get("retry-after"));
|
|
431
|
+
await _optionalChain([response, 'access', _3 => _3.body, 'optionalAccess', _4 => _4.cancel, 'call', _5 => _5(), 'access', _6 => _6.catch, 'call', _7 => _7(() => {
|
|
432
|
+
})]);
|
|
433
|
+
await sleep(seconds > 0 ? Math.min(seconds * 1e3, FORWARD_MAX_WAIT_MS) : 1e3 * 2 ** (n - 1));
|
|
434
|
+
return attempt(n + 1);
|
|
435
|
+
}
|
|
418
436
|
if (!compat) return;
|
|
419
437
|
const types = new Set(
|
|
420
438
|
(_nullishCoalesce(payload.events, () => ( []))).map((e) => String(e.type))
|
|
421
439
|
);
|
|
422
|
-
|
|
423
|
-
for (const feature of
|
|
440
|
+
_chunk3P573RHAcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers });
|
|
441
|
+
for (const feature of _chunk3P573RHAcjs.featuresForBrowserEvents.call(void 0, types)) _chunk3P573RHAcjs.noteCompatFeature.call(void 0, feature);
|
|
424
442
|
if ((_nullishCoalesce(payload.events, () => ( []))).some((e) => e.traceId)) {
|
|
425
|
-
|
|
443
|
+
_chunk3P573RHAcjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
|
|
426
444
|
}
|
|
427
|
-
|
|
428
|
-
}
|
|
445
|
+
_chunk3P573RHAcjs.noteRelayRejection.call(void 0, types, response.status, response.headers);
|
|
446
|
+
};
|
|
447
|
+
void attempt(1).catch((err) => {
|
|
429
448
|
(_nullishCoalesce(opts.onError, () => ( ((e) => console.warn("autter relay forward failed:", e)))))(
|
|
430
449
|
err
|
|
431
450
|
);
|
|
432
451
|
});
|
|
433
452
|
}
|
|
453
|
+
function sleep(ms) {
|
|
454
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
455
|
+
}
|
|
434
456
|
function createBrowserRelayFetchHandler(opts) {
|
|
435
457
|
const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
|
|
436
|
-
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor :
|
|
458
|
+
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkFV64SIRQcjs.makeRedactor.call(void 0, opts.redact);
|
|
437
459
|
const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
|
|
438
460
|
return async (request) => {
|
|
439
461
|
if (request.method !== "POST") {
|
|
@@ -480,7 +502,7 @@ function createBrowserRelayFetchHandler(opts) {
|
|
|
480
502
|
}
|
|
481
503
|
function createBrowserRelayHandler(opts) {
|
|
482
504
|
const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
|
|
483
|
-
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor :
|
|
505
|
+
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkFV64SIRQcjs.makeRedactor.call(void 0, opts.redact);
|
|
484
506
|
const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
|
|
485
507
|
function respond(res, status, body) {
|
|
486
508
|
res.statusCode = status;
|
|
@@ -635,7 +657,7 @@ function makeUrlQueryPolicy(keepQueryParams = []) {
|
|
|
635
657
|
if (!name.includes("?") && !name.includes("#")) return name;
|
|
636
658
|
return name.split(" ").map((token) => {
|
|
637
659
|
if (!token.startsWith("/") && !SCHEME.test(token)) return token;
|
|
638
|
-
return _nullishCoalesce(_optionalChain([splitUrl, 'call',
|
|
660
|
+
return _nullishCoalesce(_optionalChain([splitUrl, 'call', _8 => _8(token), 'optionalAccess', _9 => _9.base]), () => ( token));
|
|
639
661
|
}).join(" ");
|
|
640
662
|
};
|
|
641
663
|
return {
|
|
@@ -770,7 +792,7 @@ var RedactingSpanExporter = class {
|
|
|
770
792
|
return this.inner.shutdown();
|
|
771
793
|
}
|
|
772
794
|
forceFlush() {
|
|
773
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
795
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _10 => _10.inner, 'access', _11 => _11.forceFlush, 'optionalCall', _12 => _12()]), () => ( Promise.resolve()));
|
|
774
796
|
}
|
|
775
797
|
};
|
|
776
798
|
var RedactingMetricExporter = class {
|
|
@@ -827,7 +849,7 @@ function startMemoryMetrics() {
|
|
|
827
849
|
[heapUsed, (result) => result.observe(process.memoryUsage().heapUsed)],
|
|
828
850
|
[heapLimit, (result) => result.observe(_v8.getHeapStatistics.call(void 0, ).heap_size_limit)],
|
|
829
851
|
[containerLimit, (result) => {
|
|
830
|
-
const constrained = _nullishCoalesce(_optionalChain([process, 'access',
|
|
852
|
+
const constrained = _nullishCoalesce(_optionalChain([process, 'access', _13 => _13.constrainedMemory, 'optionalCall', _14 => _14()]), () => ( 0));
|
|
831
853
|
if (constrained > 0) result.observe(constrained);
|
|
832
854
|
}],
|
|
833
855
|
[afterGc, (result) => {
|
|
@@ -878,19 +900,19 @@ function decide(rule, error, fallback) {
|
|
|
878
900
|
}
|
|
879
901
|
function expressRouteOf(req) {
|
|
880
902
|
const props = req;
|
|
881
|
-
const path = _optionalChain([props, 'optionalAccess',
|
|
903
|
+
const path = _optionalChain([props, 'optionalAccess', _15 => _15.route, 'optionalAccess', _16 => _16.path]);
|
|
882
904
|
if (typeof path !== "string" || path === "") return null;
|
|
883
|
-
const base = typeof _optionalChain([props, 'optionalAccess',
|
|
905
|
+
const base = typeof _optionalChain([props, 'optionalAccess', _17 => _17.baseUrl]) === "string" ? props.baseUrl : "";
|
|
884
906
|
const route = base + path;
|
|
885
907
|
return route.startsWith("/") ? route : null;
|
|
886
908
|
}
|
|
887
909
|
function defaultShouldCapture(error) {
|
|
888
|
-
return error instanceof
|
|
910
|
+
return error instanceof _chunkFV64SIRQcjs.RuntimeError || _chunkFV64SIRQcjs.errorCodeOf.call(void 0, error) !== void 0 || _chunkFV64SIRQcjs.responseStatusOf.call(void 0, error) >= 500;
|
|
889
911
|
}
|
|
890
912
|
function onRequestSpan(fn) {
|
|
891
913
|
const active = _api.context.active();
|
|
892
914
|
const metadata = _core.getRPCMetadata.call(void 0, active);
|
|
893
|
-
const span = _optionalChain([metadata, 'optionalAccess',
|
|
915
|
+
const span = _optionalChain([metadata, 'optionalAccess', _18 => _18.type]) === _core.RPCType.HTTP ? metadata.span : void 0;
|
|
894
916
|
if (!span || !span.isRecording() || _api.trace.getSpan(active) === span) {
|
|
895
917
|
fn();
|
|
896
918
|
return;
|
|
@@ -905,11 +927,11 @@ function captureAtBoundary(error, state, rule = void 0, attributes) {
|
|
|
905
927
|
wanted = false;
|
|
906
928
|
}
|
|
907
929
|
if (!wanted) return;
|
|
908
|
-
if (
|
|
909
|
-
|
|
930
|
+
if (_chunkFV64SIRQcjs.isCaptured.call(void 0, error)) return;
|
|
931
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
910
932
|
try {
|
|
911
933
|
const run = () => onRequestSpan(() => capturer(error, attributes));
|
|
912
|
-
if (state && !state.sealed)
|
|
934
|
+
if (state && !state.sealed) _chunkFV64SIRQcjs.local.run(state, run);
|
|
913
935
|
else run();
|
|
914
936
|
} catch (e17) {
|
|
915
937
|
}
|
|
@@ -919,7 +941,7 @@ function requestStateOf(req) {
|
|
|
919
941
|
return req[REQUEST_STATE];
|
|
920
942
|
}
|
|
921
943
|
function captureRequestError(error, attributes) {
|
|
922
|
-
if (
|
|
944
|
+
if (_chunkFV64SIRQcjs.isCaptured.call(void 0, error)) {
|
|
923
945
|
if (!attributes) return;
|
|
924
946
|
try {
|
|
925
947
|
onRequestSpan(() => annotator(attributes));
|
|
@@ -927,7 +949,7 @@ function captureRequestError(error, attributes) {
|
|
|
927
949
|
}
|
|
928
950
|
return;
|
|
929
951
|
}
|
|
930
|
-
captureAtBoundary(error,
|
|
952
|
+
captureAtBoundary(error, _chunkFV64SIRQcjs.currentOperation.call(void 0, ), true, attributes);
|
|
931
953
|
}
|
|
932
954
|
function bindEmitter(emitter, state) {
|
|
933
955
|
const target = emitter;
|
|
@@ -939,7 +961,7 @@ function bindEmitter(emitter, state) {
|
|
|
939
961
|
let wrapped = wrappers.get(listener);
|
|
940
962
|
if (!wrapped) {
|
|
941
963
|
wrapped = function(...args) {
|
|
942
|
-
return
|
|
964
|
+
return _chunkFV64SIRQcjs.local.run(
|
|
943
965
|
state,
|
|
944
966
|
() => listener.apply(this, args)
|
|
945
967
|
);
|
|
@@ -1006,7 +1028,7 @@ function pathOf(req) {
|
|
|
1006
1028
|
function finishRequest(state, input) {
|
|
1007
1029
|
if (state.sealed) return;
|
|
1008
1030
|
state.name = (_nullishCoalesce(input.name, () => ( `${input.method} ${input.route}`))).slice(0, 200);
|
|
1009
|
-
state.outcome =
|
|
1031
|
+
state.outcome = _chunkFV64SIRQcjs.requestOutcome.call(void 0, {
|
|
1010
1032
|
...state.explicitOutcome ? { explicit: state.outcome } : {},
|
|
1011
1033
|
...state.error !== void 0 ? { error: state.error } : {},
|
|
1012
1034
|
...state.errorThrown ? { thrown: true } : {},
|
|
@@ -1015,15 +1037,15 @@ function finishRequest(state, input) {
|
|
|
1015
1037
|
...state.degraded ? { degraded: true } : {}
|
|
1016
1038
|
});
|
|
1017
1039
|
const span = _api.trace.getActiveSpan();
|
|
1018
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1040
|
+
if (_optionalChain([span, 'optionalAccess', _19 => _19.isRecording, 'call', _20 => _20()])) span.setAttribute("autter.operation.outcome", state.outcome);
|
|
1019
1041
|
if (input.span) {
|
|
1020
1042
|
const remote = _api.trace.wrapSpanContext(input.span);
|
|
1021
1043
|
_api.context.with(
|
|
1022
1044
|
_api.trace.setSpan(_api.context.active(), remote),
|
|
1023
|
-
() =>
|
|
1045
|
+
() => _chunkFV64SIRQcjs.reportExplicitFailure.call(void 0, state)
|
|
1024
1046
|
);
|
|
1025
|
-
} else
|
|
1026
|
-
|
|
1047
|
+
} else _chunkFV64SIRQcjs.reportExplicitFailure.call(void 0, state);
|
|
1048
|
+
_chunkFV64SIRQcjs.emitSummary.call(void 0, state, {
|
|
1027
1049
|
http: {
|
|
1028
1050
|
"http.request.method": input.method,
|
|
1029
1051
|
"http.route": input.route,
|
|
@@ -1034,14 +1056,14 @@ function finishRequest(state, input) {
|
|
|
1034
1056
|
});
|
|
1035
1057
|
}
|
|
1036
1058
|
function beginNodeRequest(req, res, options, route) {
|
|
1037
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
1038
|
-
const requestId =
|
|
1059
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkFV64SIRQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1060
|
+
const requestId = _chunkFV64SIRQcjs.resolveRequestId.call(void 0,
|
|
1039
1061
|
options.trustRequestId === false ? void 0 : req.headers[header]
|
|
1040
1062
|
);
|
|
1041
1063
|
const method = (_nullishCoalesce(req.method, () => ( "GET"))).toUpperCase();
|
|
1042
1064
|
const path = pathOf(req);
|
|
1043
|
-
const state =
|
|
1044
|
-
name: `${method} ${
|
|
1065
|
+
const state = _chunkFV64SIRQcjs.createRequestState.call(void 0, {
|
|
1066
|
+
name: `${method} ${_chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, path)}`,
|
|
1045
1067
|
requestId,
|
|
1046
1068
|
req,
|
|
1047
1069
|
res
|
|
@@ -1053,19 +1075,19 @@ function beginNodeRequest(req, res, options, route) {
|
|
|
1053
1075
|
} catch (e20) {
|
|
1054
1076
|
}
|
|
1055
1077
|
const span = _api.trace.getActiveSpan();
|
|
1056
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1078
|
+
if (_optionalChain([span, 'optionalAccess', _21 => _21.isRecording, 'call', _22 => _22()]))
|
|
1057
1079
|
span.setAttributes({
|
|
1058
1080
|
"autter.request.id": requestId,
|
|
1059
1081
|
"autter.operation.kind": "request"
|
|
1060
1082
|
});
|
|
1061
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
1083
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _23 => _23.spanContext, 'call', _24 => _24()]);
|
|
1062
1084
|
bindEmitter(req, state);
|
|
1063
1085
|
bindEmitter(res, state);
|
|
1064
1086
|
let finished = false;
|
|
1065
1087
|
const done = () => {
|
|
1066
1088
|
finishRequest(state, {
|
|
1067
1089
|
method,
|
|
1068
|
-
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall',
|
|
1090
|
+
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _25 => _25()]), () => ( expressRouteOf(req))), () => ( _chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, path))),
|
|
1069
1091
|
status: res.statusCode,
|
|
1070
1092
|
aborted: !finished,
|
|
1071
1093
|
...spanContext ? { span: spanContext } : {}
|
|
@@ -1079,50 +1101,50 @@ function beginNodeRequest(req, res, options, route) {
|
|
|
1079
1101
|
return state;
|
|
1080
1102
|
}
|
|
1081
1103
|
function autterRequests(options = {}) {
|
|
1082
|
-
const ignored =
|
|
1104
|
+
const ignored = _chunkFV64SIRQcjs.compileIgnore.call(void 0, options.ignore);
|
|
1083
1105
|
return function autterRequestsMiddleware(req, res, next) {
|
|
1084
1106
|
if (req[REQUEST_STATE] || ignored(pathOf(req))) {
|
|
1085
1107
|
next();
|
|
1086
1108
|
return;
|
|
1087
1109
|
}
|
|
1088
1110
|
const state = beginNodeRequest(req, res, options);
|
|
1089
|
-
|
|
1111
|
+
_chunkFV64SIRQcjs.local.run(state, () => next());
|
|
1090
1112
|
};
|
|
1091
1113
|
}
|
|
1092
1114
|
function autterErrorResponse(options = {}) {
|
|
1093
1115
|
return function autterErrorResponseMiddleware(error, req, res, next) {
|
|
1094
1116
|
const state = req[REQUEST_STATE];
|
|
1095
|
-
if (state)
|
|
1117
|
+
if (state) _chunkFV64SIRQcjs.noteOperationError.call(void 0, error, true, state);
|
|
1096
1118
|
captureAtBoundary(error, state, options.capture);
|
|
1097
1119
|
if (res.headersSent) {
|
|
1098
1120
|
next(error);
|
|
1099
1121
|
return;
|
|
1100
1122
|
}
|
|
1101
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
1102
|
-
const inbound = _optionalChain([req, 'access',
|
|
1103
|
-
const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
1104
|
-
res.statusCode =
|
|
1123
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkFV64SIRQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1124
|
+
const inbound = _optionalChain([req, 'access', _26 => _26.headers, 'optionalAccess', _27 => _27[header]]);
|
|
1125
|
+
const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _28 => _28.requestId]), () => ( (typeof inbound === "string" ? inbound.slice(0, 128) : void 0)));
|
|
1126
|
+
res.statusCode = _chunkFV64SIRQcjs.responseStatusOf.call(void 0, error);
|
|
1105
1127
|
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
1106
|
-
res.end(JSON.stringify(
|
|
1128
|
+
res.end(JSON.stringify(_chunkFV64SIRQcjs.toClientError.call(void 0, error, requestId)));
|
|
1107
1129
|
};
|
|
1108
1130
|
}
|
|
1109
1131
|
var RESOURCE = /* @__PURE__ */ Symbol.for("autter.runtime.resource");
|
|
1110
1132
|
function autterFastify(fastify, options, done) {
|
|
1111
1133
|
const opts = _nullishCoalesce(options, () => ( {}));
|
|
1112
|
-
const header = (_nullishCoalesce(opts.requestIdHeader, () => (
|
|
1113
|
-
const ignored =
|
|
1134
|
+
const header = (_nullishCoalesce(opts.requestIdHeader, () => ( _chunkFV64SIRQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1135
|
+
const ignored = _chunkFV64SIRQcjs.compileIgnore.call(void 0, opts.ignore);
|
|
1114
1136
|
const stateOf = (request) => request[REQUEST_STATE];
|
|
1115
1137
|
fastify.addHook("onRequest", ((request, reply, next) => {
|
|
1116
1138
|
if (ignored(request.url) || request.raw[REQUEST_STATE]) {
|
|
1117
1139
|
next();
|
|
1118
1140
|
return;
|
|
1119
1141
|
}
|
|
1120
|
-
const requestId =
|
|
1142
|
+
const requestId = _chunkFV64SIRQcjs.resolveRequestId.call(void 0,
|
|
1121
1143
|
opts.trustRequestId === false ? void 0 : request.headers[header]
|
|
1122
1144
|
);
|
|
1123
1145
|
const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
|
|
1124
|
-
const state =
|
|
1125
|
-
name: `${method} ${
|
|
1146
|
+
const state = _chunkFV64SIRQcjs.createRequestState.call(void 0, {
|
|
1147
|
+
name: `${method} ${_chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, request.url)}`,
|
|
1126
1148
|
requestId,
|
|
1127
1149
|
req: request.raw,
|
|
1128
1150
|
res: reply.raw
|
|
@@ -1131,18 +1153,18 @@ function autterFastify(fastify, options, done) {
|
|
|
1131
1153
|
request.raw[REQUEST_STATE] = state;
|
|
1132
1154
|
reply.header(header, requestId);
|
|
1133
1155
|
const span = _api.trace.getActiveSpan();
|
|
1134
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1156
|
+
if (_optionalChain([span, 'optionalAccess', _29 => _29.isRecording, 'call', _30 => _30()]))
|
|
1135
1157
|
span.setAttributes({
|
|
1136
1158
|
"autter.request.id": requestId,
|
|
1137
1159
|
"autter.operation.kind": "request"
|
|
1138
1160
|
});
|
|
1139
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
1161
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _31 => _31.spanContext, 'call', _32 => _32()]);
|
|
1140
1162
|
bindEmitter(request.raw, state);
|
|
1141
1163
|
bindEmitter(reply.raw, state);
|
|
1142
1164
|
let finished = false;
|
|
1143
1165
|
const finish = (aborted) => finishRequest(state, {
|
|
1144
1166
|
method,
|
|
1145
|
-
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access',
|
|
1167
|
+
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _33 => _33.routeOptions, 'optionalAccess', _34 => _34.url]), () => ( request.routerPath)), () => ( _chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, request.url))),
|
|
1146
1168
|
status: reply.raw.statusCode || reply.statusCode,
|
|
1147
1169
|
aborted,
|
|
1148
1170
|
...spanContext ? { span: spanContext } : {}
|
|
@@ -1152,7 +1174,7 @@ function autterFastify(fastify, options, done) {
|
|
|
1152
1174
|
finish(false);
|
|
1153
1175
|
});
|
|
1154
1176
|
reply.raw.once("close", () => finish(!finished));
|
|
1155
|
-
|
|
1177
|
+
_chunkFV64SIRQcjs.local.run(state, () => {
|
|
1156
1178
|
request[RESOURCE] = new (0, _async_hooks.AsyncResource)("autter-request");
|
|
1157
1179
|
next();
|
|
1158
1180
|
});
|
|
@@ -1174,7 +1196,7 @@ function autterFastify(fastify, options, done) {
|
|
|
1174
1196
|
}));
|
|
1175
1197
|
fastify.addHook("onError", ((request, _reply, error, next) => {
|
|
1176
1198
|
const state = stateOf(request);
|
|
1177
|
-
if (state)
|
|
1199
|
+
if (state) _chunkFV64SIRQcjs.noteOperationError.call(void 0, error, true, state);
|
|
1178
1200
|
captureAtBoundary(error, state);
|
|
1179
1201
|
next();
|
|
1180
1202
|
}));
|
|
@@ -1205,8 +1227,8 @@ function withHeaders(response, header, requestId) {
|
|
|
1205
1227
|
}
|
|
1206
1228
|
}
|
|
1207
1229
|
function withRuntimeRequest(handler, options = {}) {
|
|
1208
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
1209
|
-
const ignored =
|
|
1230
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkFV64SIRQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1231
|
+
const ignored = _chunkFV64SIRQcjs.compileIgnore.call(void 0, options.ignore);
|
|
1210
1232
|
return async (request, ...rest) => {
|
|
1211
1233
|
let pathname = "/";
|
|
1212
1234
|
try {
|
|
@@ -1214,36 +1236,36 @@ function withRuntimeRequest(handler, options = {}) {
|
|
|
1214
1236
|
} catch (e24) {
|
|
1215
1237
|
}
|
|
1216
1238
|
if (ignored(pathname)) return handler(request, ...rest);
|
|
1217
|
-
const requestId =
|
|
1239
|
+
const requestId = _chunkFV64SIRQcjs.resolveRequestId.call(void 0,
|
|
1218
1240
|
options.trustRequestId === false ? void 0 : request.headers.get(header)
|
|
1219
1241
|
);
|
|
1220
1242
|
const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
|
|
1221
|
-
const route = _nullishCoalesce(options.route, () => (
|
|
1222
|
-
const state =
|
|
1243
|
+
const route = _nullishCoalesce(options.route, () => ( _chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, pathname)));
|
|
1244
|
+
const state = _chunkFV64SIRQcjs.createRequestState.call(void 0, {
|
|
1223
1245
|
name: `${method} ${_nullishCoalesce(options.name, () => ( route))}`,
|
|
1224
1246
|
requestId,
|
|
1225
1247
|
req: request
|
|
1226
1248
|
});
|
|
1227
1249
|
const span = _api.trace.getActiveSpan();
|
|
1228
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1250
|
+
if (_optionalChain([span, 'optionalAccess', _35 => _35.isRecording, 'call', _36 => _36()]))
|
|
1229
1251
|
span.setAttributes({
|
|
1230
1252
|
"autter.request.id": requestId,
|
|
1231
1253
|
"autter.operation.kind": "request"
|
|
1232
1254
|
});
|
|
1233
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
1255
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _37 => _37.spanContext, 'call', _38 => _38()]);
|
|
1234
1256
|
let status = 500;
|
|
1235
1257
|
try {
|
|
1236
|
-
const response = await
|
|
1258
|
+
const response = await _chunkFV64SIRQcjs.local.run(state, async () => {
|
|
1237
1259
|
try {
|
|
1238
1260
|
return await handler(request, ...rest);
|
|
1239
1261
|
} catch (error) {
|
|
1240
1262
|
if (decide(options.capture, error, true)) {
|
|
1241
|
-
|
|
1263
|
+
_chunkFV64SIRQcjs.noteOperationError.call(void 0, error, true, state);
|
|
1242
1264
|
captureAtBoundary(error, state, true);
|
|
1243
1265
|
}
|
|
1244
1266
|
if (!decide(options.errorResponse, error, false)) throw error;
|
|
1245
|
-
return new Response(JSON.stringify(
|
|
1246
|
-
status:
|
|
1267
|
+
return new Response(JSON.stringify(_chunkFV64SIRQcjs.toClientError.call(void 0, error, requestId)), {
|
|
1268
|
+
status: _chunkFV64SIRQcjs.responseStatusOf.call(void 0, error),
|
|
1247
1269
|
headers: { "content-type": "application/json; charset=utf-8" }
|
|
1248
1270
|
});
|
|
1249
1271
|
}
|
|
@@ -1251,7 +1273,7 @@ function withRuntimeRequest(handler, options = {}) {
|
|
|
1251
1273
|
status = response.status;
|
|
1252
1274
|
return withHeaders(response, header, requestId);
|
|
1253
1275
|
} finally {
|
|
1254
|
-
const aborted = _optionalChain([request, 'access',
|
|
1276
|
+
const aborted = _optionalChain([request, 'access', _39 => _39.signal, 'optionalAccess', _40 => _40.aborted]) === true;
|
|
1255
1277
|
finishRequest(state, {
|
|
1256
1278
|
method,
|
|
1257
1279
|
route,
|
|
@@ -1262,7 +1284,7 @@ function withRuntimeRequest(handler, options = {}) {
|
|
|
1262
1284
|
});
|
|
1263
1285
|
if (options.waitUntil) {
|
|
1264
1286
|
try {
|
|
1265
|
-
options.waitUntil(
|
|
1287
|
+
options.waitUntil(_chunkFV64SIRQcjs.flushRuntimeLogs.call(void 0, ).catch(() => {
|
|
1266
1288
|
}));
|
|
1267
1289
|
} catch (e25) {
|
|
1268
1290
|
}
|
|
@@ -1274,7 +1296,7 @@ function startHookRequest(res) {
|
|
|
1274
1296
|
const req = res.req;
|
|
1275
1297
|
if (!req || req[REQUEST_STATE]) return;
|
|
1276
1298
|
const state = beginNodeRequest(req, res, {});
|
|
1277
|
-
|
|
1299
|
+
_chunkFV64SIRQcjs.local.enterWith(state);
|
|
1278
1300
|
}
|
|
1279
1301
|
|
|
1280
1302
|
// src/unhandled-rejections.ts
|
|
@@ -1300,7 +1322,7 @@ var recorded = /* @__PURE__ */ new WeakSet();
|
|
|
1300
1322
|
function markRecorded(reason) {
|
|
1301
1323
|
if (!reason || typeof reason !== "object") return;
|
|
1302
1324
|
recorded.add(reason);
|
|
1303
|
-
_optionalChain([setImmediate, 'call',
|
|
1325
|
+
_optionalChain([setImmediate, 'call', _41 => _41(() => recorded.delete(reason)), 'access', _42 => _42.unref, 'optionalCall', _43 => _43()]);
|
|
1304
1326
|
}
|
|
1305
1327
|
function recordedAsRejection(error) {
|
|
1306
1328
|
return !!error && typeof error === "object" && recorded.has(error);
|
|
@@ -1340,7 +1362,7 @@ function describeReason(reason) {
|
|
|
1340
1362
|
}
|
|
1341
1363
|
try {
|
|
1342
1364
|
const proto = Object.getPrototypeOf(reason);
|
|
1343
|
-
const ctor = _optionalChain([proto, 'optionalAccess',
|
|
1365
|
+
const ctor = _optionalChain([proto, 'optionalAccess', _44 => _44.constructor]);
|
|
1344
1366
|
const name = typeof ctor === "function" ? ctor.name : "";
|
|
1345
1367
|
return name ? `#<${name}>` : "[object Object]";
|
|
1346
1368
|
} catch (e28) {
|
|
@@ -1354,7 +1376,7 @@ function toUncaught(reason, from) {
|
|
|
1354
1376
|
);
|
|
1355
1377
|
error.name = "UnhandledPromiseRejection";
|
|
1356
1378
|
error.code = "ERR_UNHANDLED_REJECTION";
|
|
1357
|
-
_optionalChain([Error, 'access',
|
|
1379
|
+
_optionalChain([Error, 'access', _45 => _45.captureStackTrace, 'optionalCall', _46 => _46(error, from)]);
|
|
1358
1380
|
return error;
|
|
1359
1381
|
}
|
|
1360
1382
|
var warningId = 0;
|
|
@@ -1408,9 +1430,9 @@ function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMod
|
|
|
1408
1430
|
var ours = /* @__PURE__ */ new WeakMap();
|
|
1409
1431
|
var RAW_PATH_SPAN_TYPES = /* @__PURE__ */ new Set(["BaseServer.renderToResponse"]);
|
|
1410
1432
|
function noteFrameworkRoute(parent, attributes) {
|
|
1411
|
-
const route = _optionalChain([attributes, 'optionalAccess',
|
|
1433
|
+
const route = _optionalChain([attributes, 'optionalAccess', _47 => _47["next.route"]]);
|
|
1412
1434
|
if (typeof route !== "string" || !route.startsWith("/")) return;
|
|
1413
|
-
if (RAW_PATH_SPAN_TYPES.has(String(_nullishCoalesce(_optionalChain([attributes, 'optionalAccess',
|
|
1435
|
+
if (RAW_PATH_SPAN_TYPES.has(String(_nullishCoalesce(_optionalChain([attributes, 'optionalAccess', _48 => _48["next.span_type"]]), () => ( ""))))) return;
|
|
1414
1436
|
const rpc = _core.getRPCMetadata.call(void 0, parent);
|
|
1415
1437
|
if (!rpc || rpc.type !== _core.RPCType.HTTP) return;
|
|
1416
1438
|
const mine = ours.get(rpc);
|
|
@@ -1438,10 +1460,10 @@ var RouteLabelSampler = class {
|
|
|
1438
1460
|
};
|
|
1439
1461
|
|
|
1440
1462
|
// src/server.ts
|
|
1441
|
-
var S =
|
|
1463
|
+
var S = _chunk3P573RHAcjs.sharedSlot.call(void 0, "server", () => ({
|
|
1442
1464
|
active: null,
|
|
1443
1465
|
alwaysOnProvider: null,
|
|
1444
|
-
redactor:
|
|
1466
|
+
redactor: _chunkFV64SIRQcjs.makeRedactor.call(void 0, true),
|
|
1445
1467
|
loggerOnlyCapture: null,
|
|
1446
1468
|
handled: null,
|
|
1447
1469
|
loggerOnlyHandled: null,
|
|
@@ -1543,7 +1565,7 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
|
|
|
1543
1565
|
this.retainErrors = retainErrors;
|
|
1544
1566
|
this.slowThresholdMs = slowThresholdMs;
|
|
1545
1567
|
this.sweeper = setInterval(() => this.sweep(), RETENTION_SWEEP_INTERVAL_MS);
|
|
1546
|
-
_optionalChain([this, 'access',
|
|
1568
|
+
_optionalChain([this, 'access', _49 => _49.sweeper, 'access', _50 => _50.unref, 'optionalCall', _51 => _51()]);
|
|
1547
1569
|
}
|
|
1548
1570
|
|
|
1549
1571
|
|
|
@@ -1574,7 +1596,7 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
|
|
|
1574
1596
|
}
|
|
1575
1597
|
/** Promote the active trace, if any — called on captured errors. */
|
|
1576
1598
|
retainActiveTrace() {
|
|
1577
|
-
const active = _optionalChain([_api.trace, 'access',
|
|
1599
|
+
const active = _optionalChain([_api.trace, 'access', _52 => _52.getActiveSpan, 'call', _53 => _53(), 'optionalAccess', _54 => _54.spanContext, 'call', _55 => _55()]);
|
|
1578
1600
|
if (!active || (active.traceFlags & _api.TraceFlags.SAMPLED) !== 0) return;
|
|
1579
1601
|
const entry = this.entryFor(active.traceId);
|
|
1580
1602
|
if (entry.retained) return;
|
|
@@ -1695,15 +1717,15 @@ async function runLlmSpan(tracer, info, fn) {
|
|
|
1695
1717
|
return result;
|
|
1696
1718
|
} catch (err) {
|
|
1697
1719
|
recordError(span, err);
|
|
1698
|
-
if (
|
|
1720
|
+
if (_chunkFV64SIRQcjs.isError.call(void 0, err)) span.setAttribute("error.type", err.name);
|
|
1699
1721
|
throw err;
|
|
1700
1722
|
} finally {
|
|
1701
1723
|
span.end();
|
|
1702
|
-
|
|
1724
|
+
_chunkFV64SIRQcjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
|
|
1703
1725
|
}
|
|
1704
1726
|
}
|
|
1705
1727
|
function recordLlmCall(tracer, call) {
|
|
1706
|
-
|
|
1728
|
+
_chunkFV64SIRQcjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
|
|
1707
1729
|
const durationMs = Math.max(0, _nullishCoalesce(call.durationMs, () => ( 0)));
|
|
1708
1730
|
const endTime = /* @__PURE__ */ new Date();
|
|
1709
1731
|
const startTime = new Date(endTime.getTime() - durationMs);
|
|
@@ -1717,7 +1739,7 @@ function recordLlmCall(tracer, call) {
|
|
|
1717
1739
|
);
|
|
1718
1740
|
if (call.error !== void 0 && call.error !== null) {
|
|
1719
1741
|
recordError(span, call.error);
|
|
1720
|
-
if (
|
|
1742
|
+
if (_chunkFV64SIRQcjs.isError.call(void 0, call.error)) {
|
|
1721
1743
|
span.setAttribute("error.type", call.error.name);
|
|
1722
1744
|
}
|
|
1723
1745
|
} else {
|
|
@@ -1728,7 +1750,7 @@ function recordLlmCall(tracer, call) {
|
|
|
1728
1750
|
async function runWithSpan(tracer, name, fn, attributes, links) {
|
|
1729
1751
|
const span = tracer.startSpan(name, {
|
|
1730
1752
|
attributes,
|
|
1731
|
-
..._optionalChain([links, 'optionalAccess',
|
|
1753
|
+
..._optionalChain([links, 'optionalAccess', _56 => _56.length]) ? { links } : {}
|
|
1732
1754
|
});
|
|
1733
1755
|
try {
|
|
1734
1756
|
const result = await _api.context.with(
|
|
@@ -1745,14 +1767,14 @@ async function runWithSpan(tracer, name, fn, attributes, links) {
|
|
|
1745
1767
|
}
|
|
1746
1768
|
}
|
|
1747
1769
|
function recordError(span, err) {
|
|
1748
|
-
const isErr =
|
|
1770
|
+
const isErr = _chunkFV64SIRQcjs.isError.call(void 0, err);
|
|
1749
1771
|
const message = S.redactor.text(isErr ? err.message : String(err));
|
|
1750
1772
|
if (isErr) {
|
|
1751
1773
|
span.addEvent("exception", {
|
|
1752
1774
|
"exception.type": err.name,
|
|
1753
1775
|
"exception.message": message,
|
|
1754
1776
|
...err.stack ? { "exception.stacktrace": S.redactor.text(err.stack) } : {},
|
|
1755
|
-
...
|
|
1777
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text, err)
|
|
1756
1778
|
});
|
|
1757
1779
|
}
|
|
1758
1780
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
|
|
@@ -1772,7 +1794,7 @@ var METRIC_ROUTE_ATTR = "autter.metric_has_route";
|
|
|
1772
1794
|
function captureRequestRoute(span, response) {
|
|
1773
1795
|
if (!(response instanceof _http.ServerResponse)) return;
|
|
1774
1796
|
const rpcMetadata = _core.getRPCMetadata.call(void 0, _api.context.active());
|
|
1775
|
-
if (_optionalChain([rpcMetadata, 'optionalAccess',
|
|
1797
|
+
if (_optionalChain([rpcMetadata, 'optionalAccess', _57 => _57.type]) !== _core.RPCType.HTTP) return;
|
|
1776
1798
|
let failed = false;
|
|
1777
1799
|
response.on(_events.errorMonitor, () => {
|
|
1778
1800
|
failed = true;
|
|
@@ -1790,8 +1812,8 @@ function captureRequestRoute(span, response) {
|
|
|
1790
1812
|
if (S.hookRequests) startHookRequest(response);
|
|
1791
1813
|
}
|
|
1792
1814
|
function structuredErrorAttributes(error) {
|
|
1793
|
-
const attrs = { ...
|
|
1794
|
-
const internal =
|
|
1815
|
+
const attrs = { ..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error, { causes: false }) };
|
|
1816
|
+
const internal = _chunkFV64SIRQcjs.errorInternal.call(void 0, error);
|
|
1795
1817
|
if (internal) {
|
|
1796
1818
|
try {
|
|
1797
1819
|
attrs["autter.error.internal"] = JSON.stringify(
|
|
@@ -1809,9 +1831,9 @@ function initAutterServer(options) {
|
|
|
1809
1831
|
""
|
|
1810
1832
|
);
|
|
1811
1833
|
const headers = { authorization: `Bearer ${options.apiKey}` };
|
|
1812
|
-
const redactor =
|
|
1834
|
+
const redactor = _chunkFV64SIRQcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
|
|
1813
1835
|
const queryPolicy = makeUrlQueryPolicy(options.keepQueryParams);
|
|
1814
|
-
const traceExporter = () => new (0,
|
|
1836
|
+
const traceExporter = () => new (0, _chunk3P573RHAcjs.CountingExporter)(
|
|
1815
1837
|
new RedactingSpanExporter(
|
|
1816
1838
|
new (0, _exportertraceotlphttp.OTLPTraceExporter)({ url: `${endpoint}/v1/traces`, headers }),
|
|
1817
1839
|
() => redactor,
|
|
@@ -1819,11 +1841,11 @@ function initAutterServer(options) {
|
|
|
1819
1841
|
)
|
|
1820
1842
|
);
|
|
1821
1843
|
const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
|
|
1822
|
-
if (
|
|
1823
|
-
|
|
1844
|
+
if (_chunk3P573RHAcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk3P573RHAcjs.setDebugMode.call(void 0, true);
|
|
1845
|
+
_chunk3P573RHAcjs.debugLog.call(void 0, `initialising service=${options.service} endpoint=${endpoint}`);
|
|
1824
1846
|
S.redactor = redactor;
|
|
1825
|
-
const distro = _nullishCoalesce(options.distro, () => (
|
|
1826
|
-
|
|
1847
|
+
const distro = _nullishCoalesce(options.distro, () => ( _chunk3P573RHAcjs.SDK_IDENTITY));
|
|
1848
|
+
_chunk3P573RHAcjs.configureCompatCheck.call(void 0, { endpoint, enabled: options.compatCheck !== false, sdk: distro });
|
|
1827
1849
|
const resource = new (0, _resources.Resource)({
|
|
1828
1850
|
[_semanticconventions.ATTR_SERVICE_NAME]: options.service,
|
|
1829
1851
|
"service.instance.id": (options.instanceId || process.env.AUTTER_RUNTIME_INSTANCE_ID || _crypto.randomUUID.call(void 0, )).slice(0, 128),
|
|
@@ -1844,7 +1866,7 @@ function initAutterServer(options) {
|
|
|
1844
1866
|
// its span-fed per-route counts.
|
|
1845
1867
|
"autter.metrics_routes": true
|
|
1846
1868
|
});
|
|
1847
|
-
const errorFilter =
|
|
1869
|
+
const errorFilter = _chunkFV64SIRQcjs.createErrorFilter.call(void 0, { ignoreErrors: options.ignoreErrors, sampleRate: options.sampleRate });
|
|
1848
1870
|
const rootSampler = new (0, _sdktracebase.TraceIdRatioBasedSampler)(_nullishCoalesce(options.traceSampleRate, () => ( 0.01)));
|
|
1849
1871
|
const headSampler = new (0, _sdktracebase.ParentBasedSampler)({
|
|
1850
1872
|
root: rootSampler,
|
|
@@ -1906,9 +1928,9 @@ function initAutterServer(options) {
|
|
|
1906
1928
|
sdk.start();
|
|
1907
1929
|
patchLoadedHttpModules();
|
|
1908
1930
|
const stopMemoryMetrics = options.memoryMetrics === false ? null : startMemoryMetrics();
|
|
1909
|
-
|
|
1910
|
-
if (stopMemoryMetrics)
|
|
1911
|
-
if (options.llmTracing !== false)
|
|
1931
|
+
_chunk3P573RHAcjs.noteCompatFeature.call(void 0, "endpoint_latency");
|
|
1932
|
+
if (stopMemoryMetrics) _chunk3P573RHAcjs.noteCompatFeature.call(void 0, "memory_metrics");
|
|
1933
|
+
if (options.llmTracing !== false) _chunk3P573RHAcjs.noteCompatFeature.call(void 0, "llm_calls");
|
|
1912
1934
|
const alwaysOnProvider = new (0, _sdktracebase.BasicTracerProvider)({
|
|
1913
1935
|
resource,
|
|
1914
1936
|
sampler: new (0, _sdktracebase.AlwaysOnSampler)(),
|
|
@@ -1920,44 +1942,44 @@ function initAutterServer(options) {
|
|
|
1920
1942
|
const processTracer = alwaysOnProvider.getTracer("autter-processes");
|
|
1921
1943
|
const llmTracer = alwaysOnProvider.getTracer("autter-llm");
|
|
1922
1944
|
function captureException2(error, attributes) {
|
|
1923
|
-
const isErrValue =
|
|
1945
|
+
const isErrValue = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
1924
1946
|
const reported = errorFilter({
|
|
1925
1947
|
type: isErrValue ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
|
|
1926
1948
|
message: isErrValue ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
|
|
1927
|
-
crash: _optionalChain([attributes, 'optionalAccess',
|
|
1949
|
+
crash: _optionalChain([attributes, 'optionalAccess', _58 => _58["autter.unhandled"]]) === true || _optionalChain([attributes, 'optionalAccess', _59 => _59["autter.unhandled_rejection"]]) === true
|
|
1928
1950
|
});
|
|
1929
1951
|
if (!reported) {
|
|
1930
|
-
|
|
1952
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
1931
1953
|
return;
|
|
1932
1954
|
}
|
|
1933
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
1934
|
-
|
|
1935
|
-
const isErr =
|
|
1955
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _60 => _60.retainActiveTrace, 'call', _61 => _61()]);
|
|
1956
|
+
_chunk3P573RHAcjs.telemetryStats.markCaptured();
|
|
1957
|
+
const isErr = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
1936
1958
|
const message = redactor.text(isErr ? error.message : String(error));
|
|
1937
1959
|
const stackText = isErr && error.stack ? redactor.text(error.stack) : "";
|
|
1938
|
-
const split =
|
|
1939
|
-
const fingerprint =
|
|
1940
|
-
if (fingerprint["autter.fingerprint"])
|
|
1960
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
1961
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
|
|
1962
|
+
if (fingerprint["autter.fingerprint"]) _chunk3P573RHAcjs.noteCompatFeature.call(void 0, "fingerprint_override");
|
|
1941
1963
|
const redacted = redactor(split.attributes);
|
|
1942
1964
|
const activeSpan = _api.trace.getActiveSpan();
|
|
1943
|
-
const reuseActive = _optionalChain([activeSpan, 'optionalAccess',
|
|
1965
|
+
const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _62 => _62.isRecording, 'call', _63 => _63()]) === true;
|
|
1944
1966
|
const span = reuseActive ? activeSpan : errorTracer.startSpan(isErr ? error.name : "Error");
|
|
1945
1967
|
const structured = structuredErrorAttributes(error);
|
|
1946
|
-
const causes =
|
|
1968
|
+
const causes = _chunkFV64SIRQcjs.errorAttributes.call(void 0, error);
|
|
1947
1969
|
const declared = {
|
|
1948
1970
|
...Object.fromEntries(Object.entries(causes).filter(([key]) => key !== "autter.error.internal")),
|
|
1949
1971
|
...fingerprint
|
|
1950
1972
|
};
|
|
1951
|
-
const requestId = _optionalChain([
|
|
1973
|
+
const requestId = _optionalChain([_chunkFV64SIRQcjs.currentOperation.call(void 0, ), 'optionalAccess', _64 => _64.requestId]);
|
|
1952
1974
|
span.setAttributes({
|
|
1953
1975
|
"autter.severity": "error",
|
|
1954
1976
|
...redacted,
|
|
1955
1977
|
...structured,
|
|
1956
1978
|
...requestId ? { "autter.request.id": requestId } : {}
|
|
1957
1979
|
});
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1980
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
1981
|
+
_chunkFV64SIRQcjs.noteOperationError.call(void 0, error);
|
|
1982
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
1961
1983
|
if (isErr && stackText) {
|
|
1962
1984
|
span.addEvent("exception", {
|
|
1963
1985
|
"exception.type": error.name,
|
|
@@ -1965,17 +1987,17 @@ function initAutterServer(options) {
|
|
|
1965
1987
|
"exception.stacktrace": stackText,
|
|
1966
1988
|
...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
|
|
1967
1989
|
...declared,
|
|
1968
|
-
...
|
|
1990
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
|
|
1969
1991
|
});
|
|
1970
1992
|
} else {
|
|
1971
|
-
const stack = _optionalChain([new Error(), 'access',
|
|
1993
|
+
const stack = _optionalChain([new Error(), 'access', _65 => _65.stack, 'optionalAccess', _66 => _66.split, 'call', _67 => _67("\n"), 'access', _68 => _68.filter, 'call', _69 => _69((line, i) => i === 0 || !line.includes("captureException")), 'access', _70 => _70.join, 'call', _71 => _71("\n")]);
|
|
1972
1994
|
span.addEvent("exception", {
|
|
1973
1995
|
"exception.type": isErr ? error.name : "Error",
|
|
1974
1996
|
"exception.message": message,
|
|
1975
1997
|
...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
|
|
1976
1998
|
...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
|
|
1977
1999
|
...declared,
|
|
1978
|
-
...
|
|
2000
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
|
|
1979
2001
|
});
|
|
1980
2002
|
}
|
|
1981
2003
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
|
|
@@ -1984,10 +2006,10 @@ function initAutterServer(options) {
|
|
|
1984
2006
|
function captureMessage2(message, severity = "warning", attributes) {
|
|
1985
2007
|
if (!errorFilter({ type: "Message", message: String(message), severity })) return;
|
|
1986
2008
|
if (severity === "error" || severity === "fatal") {
|
|
1987
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
2009
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _72 => _72.retainActiveTrace, 'call', _73 => _73()]);
|
|
1988
2010
|
}
|
|
1989
|
-
|
|
1990
|
-
const stack = _optionalChain([new Error(), 'access',
|
|
2011
|
+
_chunk3P573RHAcjs.telemetryStats.markCaptured();
|
|
2012
|
+
const stack = _optionalChain([new Error(), 'access', _74 => _74.stack, 'optionalAccess', _75 => _75.split, 'call', _76 => _76("\n"), 'access', _77 => _77.filter, 'call', _78 => _78((line, i) => i === 0 || !line.includes("captureMessage")), 'access', _79 => _79.join, 'call', _80 => _80("\n")]);
|
|
1991
2013
|
const safeMessage = redactor.text(message);
|
|
1992
2014
|
const span = errorTracer.startSpan("Message", {
|
|
1993
2015
|
attributes: { "autter.severity": severity, ...redactor(attributes) }
|
|
@@ -1997,17 +2019,17 @@ function initAutterServer(options) {
|
|
|
1997
2019
|
"exception.message": safeMessage,
|
|
1998
2020
|
...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
|
|
1999
2021
|
"autter.severity": severity,
|
|
2000
|
-
...
|
|
2022
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, redactor.text)
|
|
2001
2023
|
});
|
|
2002
2024
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
|
|
2003
2025
|
span.end();
|
|
2004
2026
|
}
|
|
2005
2027
|
function reportOutcome2(name, message, attributes) {
|
|
2006
2028
|
if (!errorFilter({ type: "OutcomeFailure", message: `${name}: ${message}` })) return;
|
|
2007
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
2008
|
-
|
|
2029
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _81 => _81.retainActiveTrace, 'call', _82 => _82()]);
|
|
2030
|
+
_chunk3P573RHAcjs.telemetryStats.markCaptured();
|
|
2009
2031
|
const activeSpan = _api.trace.getActiveSpan();
|
|
2010
|
-
const reuseActive = _optionalChain([activeSpan, 'optionalAccess',
|
|
2032
|
+
const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _83 => _83.isRecording, 'call', _84 => _84()]) === true;
|
|
2011
2033
|
const span = reuseActive ? activeSpan : errorTracer.startSpan("OutcomeFailure");
|
|
2012
2034
|
const safeOutcome = redactor({ "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
|
|
2013
2035
|
const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
|
|
@@ -2022,37 +2044,37 @@ function initAutterServer(options) {
|
|
|
2022
2044
|
if (!reuseActive) span.end();
|
|
2023
2045
|
}
|
|
2024
2046
|
function captureHandled(error, attributes, severity) {
|
|
2025
|
-
const isErr =
|
|
2047
|
+
const isErr = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
2026
2048
|
if (!errorFilter({
|
|
2027
2049
|
type: isErr ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
|
|
2028
2050
|
message: isErr ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
|
|
2029
2051
|
severity
|
|
2030
2052
|
})) return;
|
|
2031
|
-
if (severity === "error") _optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
2032
|
-
|
|
2053
|
+
if (severity === "error") _optionalChain([errorTraceBuffer, 'optionalAccess', _85 => _85.retainActiveTrace, 'call', _86 => _86()]);
|
|
2054
|
+
_chunk3P573RHAcjs.telemetryStats.markCaptured();
|
|
2033
2055
|
const message = redactor.text(isErr ? error.message : String(error));
|
|
2034
|
-
const stack = isErr && error.stack ? error.stack : _optionalChain([new Error(), 'access',
|
|
2035
|
-
const split =
|
|
2036
|
-
const fingerprint =
|
|
2056
|
+
const stack = isErr && error.stack ? error.stack : _optionalChain([new Error(), 'access', _87 => _87.stack, 'optionalAccess', _88 => _88.split, 'call', _89 => _89("\n"), 'access', _90 => _90.filter, 'call', _91 => _91((line, i) => i === 0 || !/captureHandled|report(?:Degraded|LoggedError)/.test(line)), 'access', _92 => _92.join, 'call', _93 => _93("\n")]);
|
|
2057
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2058
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
|
|
2037
2059
|
const redacted = redactor(split.attributes);
|
|
2038
2060
|
const activeSpan = _api.trace.getActiveSpan();
|
|
2039
|
-
const reuseActive = _optionalChain([activeSpan, 'optionalAccess',
|
|
2061
|
+
const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _94 => _94.isRecording, 'call', _95 => _95()]) === true;
|
|
2040
2062
|
const span = reuseActive ? activeSpan : errorTracer.startSpan(isErr ? error.name : "Error");
|
|
2041
|
-
|
|
2042
|
-
|
|
2063
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2064
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint, "autter.severity": severity });
|
|
2043
2065
|
span.addEvent("exception", {
|
|
2044
2066
|
...redacted,
|
|
2045
2067
|
"exception.type": isErr ? error.name : "Error",
|
|
2046
2068
|
"exception.message": message,
|
|
2047
2069
|
...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
|
|
2048
2070
|
"autter.severity": severity,
|
|
2049
|
-
...
|
|
2071
|
+
..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error),
|
|
2050
2072
|
...fingerprint,
|
|
2051
|
-
...
|
|
2073
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
|
|
2052
2074
|
});
|
|
2053
2075
|
if (!reuseActive) span.end();
|
|
2054
2076
|
}
|
|
2055
|
-
|
|
2077
|
+
_chunkFV64SIRQcjs.configureRuntimeLogger.call(void 0, {
|
|
2056
2078
|
endpoint,
|
|
2057
2079
|
apiKey: options.apiKey,
|
|
2058
2080
|
service: options.service,
|
|
@@ -2064,9 +2086,9 @@ function initAutterServer(options) {
|
|
|
2064
2086
|
run: (name, fn, attributes, links) => runWithSpan(processTracer, name, fn, redactor(attributes), links),
|
|
2065
2087
|
reportOutcome: reportOutcome2
|
|
2066
2088
|
});
|
|
2067
|
-
S.hookRequests = _optionalChain([options, 'access',
|
|
2089
|
+
S.hookRequests = _optionalChain([options, 'access', _96 => _96.logging, 'optionalAccess', _97 => _97.requests]) === true;
|
|
2068
2090
|
S.handled = captureHandled;
|
|
2069
|
-
|
|
2091
|
+
_chunkFV64SIRQcjs.startLoggedErrorCapture.call(void 0, options.captureLoggedErrors);
|
|
2070
2092
|
let onCrash = null;
|
|
2071
2093
|
let uninstallRejections = null;
|
|
2072
2094
|
if (options.captureGlobalErrors !== false) {
|
|
@@ -2086,7 +2108,7 @@ function initAutterServer(options) {
|
|
|
2086
2108
|
const flushTarget = {
|
|
2087
2109
|
forceFlush: async () => {
|
|
2088
2110
|
const results = await Promise.allSettled([
|
|
2089
|
-
|
|
2111
|
+
_chunkFV64SIRQcjs.flushRuntimeLogs.call(void 0, ),
|
|
2090
2112
|
Promise.resolve().then(() => alwaysOnProvider.forceFlush()),
|
|
2091
2113
|
Promise.resolve().then(() => mainSpanProcessor.forceFlush()),
|
|
2092
2114
|
...errorTraceBuffer ? [Promise.resolve().then(() => errorTraceBuffer.forceFlush())] : [],
|
|
@@ -2100,10 +2122,10 @@ function initAutterServer(options) {
|
|
|
2100
2122
|
}
|
|
2101
2123
|
}
|
|
2102
2124
|
};
|
|
2103
|
-
|
|
2125
|
+
_chunk3P573RHAcjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
|
|
2104
2126
|
let autoFlushHandle = null;
|
|
2105
2127
|
if (options.autoFlush !== false) {
|
|
2106
|
-
autoFlushHandle =
|
|
2128
|
+
autoFlushHandle = _chunk3P573RHAcjs.installAutterAutoFlush.call(void 0, );
|
|
2107
2129
|
}
|
|
2108
2130
|
const server = {
|
|
2109
2131
|
captureException: captureException2,
|
|
@@ -2113,24 +2135,24 @@ function initAutterServer(options) {
|
|
|
2113
2135
|
withLlmCall: (info, fn) => runLlmSpan(llmTracer, info, fn),
|
|
2114
2136
|
trackLlmCall: (call) => recordLlmCall(llmTracer, call),
|
|
2115
2137
|
shutdown: async () => {
|
|
2116
|
-
if (S.active === server)
|
|
2117
|
-
const logShutdown = await Promise.allSettled([
|
|
2138
|
+
if (S.active === server) _chunkFV64SIRQcjs.stopLoggedErrorCapture.call(void 0, );
|
|
2139
|
+
const logShutdown = await Promise.allSettled([_chunkFV64SIRQcjs.shutdownRuntimeLogger.call(void 0, )]);
|
|
2118
2140
|
if (onCrash) process.off("uncaughtExceptionMonitor", onCrash);
|
|
2119
|
-
_optionalChain([uninstallRejections, 'optionalCall',
|
|
2120
|
-
_optionalChain([stopMemoryMetrics, 'optionalCall',
|
|
2141
|
+
_optionalChain([uninstallRejections, 'optionalCall', _98 => _98()]);
|
|
2142
|
+
_optionalChain([stopMemoryMetrics, 'optionalCall', _99 => _99()]);
|
|
2121
2143
|
if (S.active === server) {
|
|
2122
2144
|
S.active = null;
|
|
2123
2145
|
S.alwaysOnProvider = null;
|
|
2124
2146
|
S.handled = null;
|
|
2125
2147
|
S.hookRequests = false;
|
|
2126
|
-
S.redactor =
|
|
2148
|
+
S.redactor = _chunkFV64SIRQcjs.makeRedactor.call(void 0, true);
|
|
2127
2149
|
}
|
|
2128
|
-
_optionalChain([autoFlushHandle, 'optionalAccess',
|
|
2150
|
+
_optionalChain([autoFlushHandle, 'optionalAccess', _100 => _100.dispose, 'call', _101 => _101()]);
|
|
2129
2151
|
autoFlushHandle = null;
|
|
2130
|
-
|
|
2131
|
-
|
|
2152
|
+
_chunk3P573RHAcjs.unregisterFlushTargets.call(void 0, );
|
|
2153
|
+
_chunk3P573RHAcjs.telemetryStats.markAllFlushed();
|
|
2132
2154
|
await Promise.allSettled([alwaysOnProvider.shutdown(), sdk.shutdown()]);
|
|
2133
|
-
if (_optionalChain([logShutdown, 'access',
|
|
2155
|
+
if (_optionalChain([logShutdown, 'access', _102 => _102[0], 'optionalAccess', _103 => _103.status]) === "rejected") throw logShutdown[0].reason;
|
|
2134
2156
|
}
|
|
2135
2157
|
};
|
|
2136
2158
|
S.active = server;
|
|
@@ -2146,12 +2168,12 @@ function captureException(error, attributes) {
|
|
|
2146
2168
|
S.loggerOnlyCapture(error, attributes);
|
|
2147
2169
|
return;
|
|
2148
2170
|
}
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
const split =
|
|
2152
|
-
const fingerprint =
|
|
2153
|
-
|
|
2154
|
-
const span = _api.trace.getTracer("autter-errors").startSpan(
|
|
2171
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2172
|
+
_chunkFV64SIRQcjs.noteOperationError.call(void 0, error);
|
|
2173
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2174
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text);
|
|
2175
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...split.attributes, ...fingerprint });
|
|
2176
|
+
const span = _api.trace.getTracer("autter-errors").startSpan(_chunkFV64SIRQcjs.isError.call(void 0, error) ? error.name : "Error", {
|
|
2155
2177
|
attributes: { ...S.redactor(split.attributes), ...fingerprint }
|
|
2156
2178
|
});
|
|
2157
2179
|
recordError(span, error);
|
|
@@ -2163,25 +2185,25 @@ function setLoggerOnlyCapture(fn, handled = null) {
|
|
|
2163
2185
|
}
|
|
2164
2186
|
function captureHandledError(error, attributes, severity) {
|
|
2165
2187
|
if (S.active) {
|
|
2166
|
-
_optionalChain([S, 'access',
|
|
2188
|
+
_optionalChain([S, 'access', _104 => _104.handled, 'optionalCall', _105 => _105(error, attributes, severity)]);
|
|
2167
2189
|
return;
|
|
2168
2190
|
}
|
|
2169
2191
|
if (S.loggerOnlyHandled) {
|
|
2170
2192
|
S.loggerOnlyHandled(error, attributes, severity);
|
|
2171
2193
|
return;
|
|
2172
2194
|
}
|
|
2173
|
-
|
|
2174
|
-
const split =
|
|
2175
|
-
|
|
2176
|
-
const span = _api.trace.getTracer("autter-errors").startSpan(
|
|
2195
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2196
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2197
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...split.attributes, "autter.severity": severity });
|
|
2198
|
+
const span = _api.trace.getTracer("autter-errors").startSpan(_chunkFV64SIRQcjs.isError.call(void 0, error) ? error.name : "Error");
|
|
2177
2199
|
span.addEvent("exception", {
|
|
2178
2200
|
...S.redactor(split.attributes),
|
|
2179
|
-
"exception.type":
|
|
2180
|
-
"exception.message": S.redactor.text(
|
|
2181
|
-
...
|
|
2201
|
+
"exception.type": _chunkFV64SIRQcjs.isError.call(void 0, error) ? error.name : "Error",
|
|
2202
|
+
"exception.message": S.redactor.text(_chunkFV64SIRQcjs.isError.call(void 0, error) ? error.message : String(error)),
|
|
2203
|
+
..._chunkFV64SIRQcjs.isError.call(void 0, error) && error.stack ? { "exception.stacktrace": S.redactor.text(error.stack) } : {},
|
|
2182
2204
|
"autter.severity": severity,
|
|
2183
|
-
...
|
|
2184
|
-
...
|
|
2205
|
+
..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error),
|
|
2206
|
+
..._chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text)
|
|
2185
2207
|
});
|
|
2186
2208
|
span.end();
|
|
2187
2209
|
}
|
|
@@ -2189,10 +2211,10 @@ function serverActive() {
|
|
|
2189
2211
|
return S.active !== null;
|
|
2190
2212
|
}
|
|
2191
2213
|
setRequestExceptionCapturer((error, attributes) => captureException(error, attributes));
|
|
2192
|
-
|
|
2214
|
+
_chunkFV64SIRQcjs.setHandledCapture.call(void 0, captureHandledError);
|
|
2193
2215
|
setRequestSpanAnnotator((attributes) => {
|
|
2194
2216
|
const span = _api.trace.getActiveSpan();
|
|
2195
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
2217
|
+
if (_optionalChain([span, 'optionalAccess', _106 => _106.isRecording, 'call', _107 => _107()])) span.setAttributes(S.redactor(_chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes).attributes));
|
|
2196
2218
|
});
|
|
2197
2219
|
function withProcessSpan(name, fn, attributes) {
|
|
2198
2220
|
if (S.active) return S.active.withProcessSpan(name, fn, attributes);
|
|
@@ -2227,7 +2249,7 @@ function captureMessage(message, severity = "warning", attributes) {
|
|
|
2227
2249
|
"exception.type": "Message",
|
|
2228
2250
|
"exception.message": safeMessage,
|
|
2229
2251
|
"autter.severity": severity,
|
|
2230
|
-
...
|
|
2252
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text)
|
|
2231
2253
|
});
|
|
2232
2254
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
|
|
2233
2255
|
span.end();
|
|
@@ -2235,11 +2257,11 @@ function captureMessage(message, severity = "warning", attributes) {
|
|
|
2235
2257
|
function reportOutcome(name, message, attributes) {
|
|
2236
2258
|
if (S.active) return S.active.reportOutcome(name, message, attributes);
|
|
2237
2259
|
const span = _api.trace.getTracer("autter-outcomes").startSpan("OutcomeFailure");
|
|
2238
|
-
const safeOutcome =
|
|
2260
|
+
const safeOutcome = _chunkFV64SIRQcjs.redactAttributes.call(void 0, { "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
|
|
2239
2261
|
const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
|
|
2240
2262
|
const safeMessage = String(_nullishCoalesce(safeOutcome["autter.outcome.message"], () => ( "failed")));
|
|
2241
2263
|
span.addEvent("autter.outcome", {
|
|
2242
|
-
...
|
|
2264
|
+
..._chunkFV64SIRQcjs.redactAttributes.call(void 0, attributes),
|
|
2243
2265
|
"autter.outcome.status": "error",
|
|
2244
2266
|
"autter.outcome.name": safeName,
|
|
2245
2267
|
"autter.outcome.message": safeMessage
|
|
@@ -2248,7 +2270,7 @@ function reportOutcome(name, message, attributes) {
|
|
|
2248
2270
|
span.end();
|
|
2249
2271
|
}
|
|
2250
2272
|
function makeSafeCapture(options) {
|
|
2251
|
-
const clean = (attributes) => attributes ? { ...
|
|
2273
|
+
const clean = (attributes) => attributes ? { ..._chunkFV64SIRQcjs.redactAttributes.call(void 0, attributes, options) } : void 0;
|
|
2252
2274
|
return {
|
|
2253
2275
|
captureException: (error, attributes) => captureException(error, clean(attributes)),
|
|
2254
2276
|
captureMessage: (message, severity, attributes) => captureMessage(message, _nullishCoalesce(severity, () => ( "warning")), clean(attributes))
|
|
@@ -2275,7 +2297,7 @@ async function emitLlmSelftestTrace() {
|
|
|
2275
2297
|
attributes: { "autter.selftest": true }
|
|
2276
2298
|
},
|
|
2277
2299
|
(llm) => {
|
|
2278
|
-
traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access',
|
|
2300
|
+
traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access', _108 => _108.getActiveSpan, 'call', _109 => _109(), 'optionalAccess', _110 => _110.spanContext, 'call', _111 => _111(), 'access', _112 => _112.traceId]), () => ( ""));
|
|
2279
2301
|
llm.setUsage({ inputTokens: 1, outputTokens: 1 });
|
|
2280
2302
|
llm.setCost(0);
|
|
2281
2303
|
}
|
|
@@ -2303,7 +2325,7 @@ var CALL_METHODS = /* @__PURE__ */ new Set([
|
|
|
2303
2325
|
// openai beta structured outputs
|
|
2304
2326
|
]);
|
|
2305
2327
|
function detectProvider(client) {
|
|
2306
|
-
const name = _nullishCoalesce(_optionalChain([client, 'access',
|
|
2328
|
+
const name = _nullishCoalesce(_optionalChain([client, 'access', _113 => _113.constructor, 'optionalAccess', _114 => _114.name, 'optionalAccess', _115 => _115.toLowerCase, 'call', _116 => _116()]), () => ( ""));
|
|
2307
2329
|
for (const known of ["openai", "anthropic", "mistral", "groq", "cohere"]) {
|
|
2308
2330
|
if (name.includes(known)) return known;
|
|
2309
2331
|
}
|
|
@@ -2311,7 +2333,7 @@ function detectProvider(client) {
|
|
|
2311
2333
|
const baseUrl = String(
|
|
2312
2334
|
_nullishCoalesce(_nullishCoalesce(client.baseURL, () => ( client.baseUrl)), () => ( ""))
|
|
2313
2335
|
);
|
|
2314
|
-
const host = _nullishCoalesce(_optionalChain([baseUrl, 'access',
|
|
2336
|
+
const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _117 => _117.match, 'call', _118 => _118(/https?:\/\/([^/]+)/), 'optionalAccess', _119 => _119[1]]), () => ( ""));
|
|
2315
2337
|
if (host.includes("openai")) return "openai";
|
|
2316
2338
|
if (host.includes("anthropic")) return "anthropic";
|
|
2317
2339
|
if (host.includes("googleapis")) return "google";
|
|
@@ -2321,13 +2343,13 @@ function detectProvider(client) {
|
|
|
2321
2343
|
}
|
|
2322
2344
|
function extractUsage(result) {
|
|
2323
2345
|
const r = result;
|
|
2324
|
-
const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
2325
|
-
const meta = _optionalChain([r, 'optionalAccess',
|
|
2326
|
-
const details = _optionalChain([usage, 'optionalAccess',
|
|
2327
|
-
const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
2328
|
-
const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
2329
|
-
const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
2330
|
-
const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
2346
|
+
const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.usage]), () => ( _optionalChain([r, 'optionalAccess', _121 => _121.message, 'optionalAccess', _122 => _122.usage])));
|
|
2347
|
+
const meta = _optionalChain([r, 'optionalAccess', _123 => _123.usageMetadata]);
|
|
2348
|
+
const details = _optionalChain([usage, 'optionalAccess', _124 => _124.prompt_tokens_details]);
|
|
2349
|
+
const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _125 => _125.cache_read_input_tokens]), () => ( (typeof _optionalChain([details, 'optionalAccess', _126 => _126.cached_tokens]) === "number" ? details.cached_tokens : void 0))), () => ( _optionalChain([meta, 'optionalAccess', _127 => _127.cachedContentTokenCount])));
|
|
2350
|
+
const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _128 => _128.prompt_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _129 => _129.input_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _130 => _130.promptTokenCount]))), () => ( void 0));
|
|
2351
|
+
const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _131 => _131.completion_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _132 => _132.output_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _133 => _133.candidatesTokenCount]))), () => ( void 0));
|
|
2352
|
+
const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _134 => _134.model]), () => ( _optionalChain([r, 'optionalAccess', _135 => _135.modelVersion])));
|
|
2331
2353
|
return {
|
|
2332
2354
|
inputTokens: typeof input === "number" ? input : void 0,
|
|
2333
2355
|
outputTokens: typeof output === "number" ? output : void 0,
|
|
@@ -2336,7 +2358,7 @@ function extractUsage(result) {
|
|
|
2336
2358
|
};
|
|
2337
2359
|
}
|
|
2338
2360
|
function rollUp(model, usage) {
|
|
2339
|
-
|
|
2361
|
+
_chunkFV64SIRQcjs.recordOperationAiUsage.call(void 0, {
|
|
2340
2362
|
model: _nullishCoalesce(usage.responseModel, () => ( model)),
|
|
2341
2363
|
...usage.inputTokens !== void 0 ? { inputTokens: usage.inputTokens } : {},
|
|
2342
2364
|
...usage.outputTokens !== void 0 ? { outputTokens: usage.outputTokens } : {},
|
|
@@ -2420,10 +2442,10 @@ function wrapStream(stream, span, model) {
|
|
|
2420
2442
|
});
|
|
2421
2443
|
}
|
|
2422
2444
|
function instrumentLlmClient(client, options) {
|
|
2423
|
-
const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2445
|
+
const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _136 => _136.provider]), () => ( detectProvider(client)))).toLowerCase();
|
|
2424
2446
|
const proxied = /* @__PURE__ */ new WeakMap();
|
|
2425
2447
|
function resolveUserId() {
|
|
2426
|
-
return typeof _optionalChain([options, 'optionalAccess',
|
|
2448
|
+
return typeof _optionalChain([options, 'optionalAccess', _137 => _137.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _138 => _138.userId]);
|
|
2427
2449
|
}
|
|
2428
2450
|
function traceCall(fn, self, callPath, args) {
|
|
2429
2451
|
const request = args[0];
|
|
@@ -2437,7 +2459,7 @@ function instrumentLlmClient(client, options) {
|
|
|
2437
2459
|
"gen_ai.system": provider,
|
|
2438
2460
|
"gen_ai.request.model": request.model,
|
|
2439
2461
|
...userId ? { "autter.user_id": userId } : {},
|
|
2440
|
-
...redactWithActive(_optionalChain([options, 'optionalAccess',
|
|
2462
|
+
...redactWithActive(_optionalChain([options, 'optionalAccess', _139 => _139.attributes]))
|
|
2441
2463
|
}
|
|
2442
2464
|
});
|
|
2443
2465
|
let result;
|
|
@@ -2561,7 +2583,7 @@ ${frames.join("\n")}`;
|
|
|
2561
2583
|
function recordBoundaryError(error, req, rule) {
|
|
2562
2584
|
try {
|
|
2563
2585
|
const state = requestStateOf(req);
|
|
2564
|
-
if (state)
|
|
2586
|
+
if (state) _chunkFV64SIRQcjs.noteOperationError.call(void 0, error, false, state);
|
|
2565
2587
|
captureAtBoundary(error, state, rule);
|
|
2566
2588
|
} catch (e34) {
|
|
2567
2589
|
}
|
|
@@ -2573,12 +2595,12 @@ function autterErrorHandler(options = {}) {
|
|
|
2573
2595
|
};
|
|
2574
2596
|
}
|
|
2575
2597
|
function autterFastifyErrors(fastify, options, done) {
|
|
2576
|
-
const rule = _optionalChain([options, 'optionalAccess',
|
|
2598
|
+
const rule = _optionalChain([options, 'optionalAccess', _140 => _140.capture]);
|
|
2577
2599
|
fastify.addHook("onError", ((request, _reply, error, next) => {
|
|
2578
|
-
recordBoundaryError(error, _optionalChain([request, 'optionalAccess',
|
|
2600
|
+
recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _141 => _141.raw]), rule);
|
|
2579
2601
|
next();
|
|
2580
2602
|
}));
|
|
2581
|
-
_optionalChain([done, 'optionalCall',
|
|
2603
|
+
_optionalChain([done, 'optionalCall', _142 => _142()]);
|
|
2582
2604
|
}
|
|
2583
2605
|
autterFastifyErrors[/* @__PURE__ */ Symbol.for("skip-override")] = true;
|
|
2584
2606
|
autterFastifyErrors[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "autter-runtime-errors";
|
|
@@ -2587,7 +2609,7 @@ function autterKoa(options = {}) {
|
|
|
2587
2609
|
try {
|
|
2588
2610
|
await next();
|
|
2589
2611
|
} catch (error) {
|
|
2590
|
-
recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess',
|
|
2612
|
+
recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _143 => _143.req]), options.capture);
|
|
2591
2613
|
throw error;
|
|
2592
2614
|
}
|
|
2593
2615
|
};
|
|
@@ -2598,7 +2620,7 @@ function autterKoa(options = {}) {
|
|
|
2598
2620
|
|
|
2599
2621
|
|
|
2600
2622
|
|
|
2601
|
-
var L =
|
|
2623
|
+
var L = _chunk3P573RHAcjs.sharedSlot.call(void 0, "logging", () => ({ active: null }));
|
|
2602
2624
|
function initAutterLogging(options) {
|
|
2603
2625
|
if (L.active) return L.active;
|
|
2604
2626
|
if (serverActive()) {
|
|
@@ -2607,37 +2629,37 @@ function initAutterLogging(options) {
|
|
|
2607
2629
|
);
|
|
2608
2630
|
return {
|
|
2609
2631
|
captureException,
|
|
2610
|
-
flush:
|
|
2632
|
+
flush: _chunkFV64SIRQcjs.flushRuntimeLogs,
|
|
2611
2633
|
shutdown: async () => {
|
|
2612
2634
|
}
|
|
2613
2635
|
};
|
|
2614
2636
|
}
|
|
2615
|
-
if (
|
|
2637
|
+
if (_chunk3P573RHAcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk3P573RHAcjs.setDebugMode.call(void 0, true);
|
|
2616
2638
|
const endpoint = (_nullishCoalesce(options.endpoint, () => ( "https://otlp.autter.dev"))).replace(/\/$/, "");
|
|
2617
2639
|
const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
|
|
2618
|
-
const redact =
|
|
2640
|
+
const redact = _chunkFV64SIRQcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
|
|
2619
2641
|
const mode = _nullishCoalesce(options.exceptions, () => ( "auto"));
|
|
2620
|
-
|
|
2621
|
-
const errorFilter =
|
|
2642
|
+
_chunk3P573RHAcjs.debugLog.call(void 0, `initialising logger-only service=${options.service} endpoint=${endpoint}`);
|
|
2643
|
+
const errorFilter = _chunkFV64SIRQcjs.createErrorFilter.call(void 0, { ignoreErrors: options.ignoreErrors, sampleRate: options.sampleRate });
|
|
2622
2644
|
function captureException2(error, attributes) {
|
|
2623
|
-
|
|
2624
|
-
const isErrValue =
|
|
2645
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2646
|
+
const isErrValue = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
2625
2647
|
const reported = errorFilter({
|
|
2626
2648
|
type: isErrValue ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
|
|
2627
2649
|
message: isErrValue ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
|
|
2628
|
-
crash: _optionalChain([attributes, 'optionalAccess',
|
|
2650
|
+
crash: _optionalChain([attributes, 'optionalAccess', _144 => _144["autter.unhandled"]]) === true || _optionalChain([attributes, 'optionalAccess', _145 => _145["autter.unhandled_rejection"]]) === true
|
|
2629
2651
|
});
|
|
2630
2652
|
if (!reported) return;
|
|
2631
|
-
const split =
|
|
2632
|
-
const fingerprint =
|
|
2653
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2654
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
|
|
2633
2655
|
const redacted = redact(split.attributes);
|
|
2634
2656
|
const span = _api.trace.getActiveSpan();
|
|
2635
|
-
if (mode === "auto" && _optionalChain([span, 'optionalAccess',
|
|
2636
|
-
|
|
2637
|
-
|
|
2657
|
+
if (mode === "auto" && _optionalChain([span, 'optionalAccess', _146 => _146.isRecording, 'call', _147 => _147()])) {
|
|
2658
|
+
_chunkFV64SIRQcjs.noteOperationError.call(void 0, error);
|
|
2659
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2638
2660
|
span.setAttributes({ "autter.severity": "error", ...redacted, ...structuredErrorAttributes(error) });
|
|
2639
|
-
const declared = { ...
|
|
2640
|
-
if (
|
|
2661
|
+
const declared = { ..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error), ...fingerprint };
|
|
2662
|
+
if (_chunkFV64SIRQcjs.isError.call(void 0, error)) {
|
|
2641
2663
|
span.addEvent("exception", {
|
|
2642
2664
|
"exception.type": error.name,
|
|
2643
2665
|
"exception.message": error.message,
|
|
@@ -2653,42 +2675,42 @@ function initAutterLogging(options) {
|
|
|
2653
2675
|
}
|
|
2654
2676
|
span.setStatus({
|
|
2655
2677
|
code: _api.SpanStatusCode.ERROR,
|
|
2656
|
-
message:
|
|
2678
|
+
message: _chunkFV64SIRQcjs.isError.call(void 0, error) ? error.message : String(error)
|
|
2657
2679
|
});
|
|
2658
2680
|
return;
|
|
2659
2681
|
}
|
|
2660
|
-
|
|
2661
|
-
|
|
2682
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2683
|
+
_chunkFV64SIRQcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2662
2684
|
}
|
|
2663
2685
|
function captureHandled(error, attributes, severity) {
|
|
2664
|
-
|
|
2665
|
-
const isErrValue =
|
|
2686
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2687
|
+
const isErrValue = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
2666
2688
|
if (!errorFilter({
|
|
2667
2689
|
type: isErrValue ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
|
|
2668
2690
|
message: isErrValue ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
|
|
2669
2691
|
severity
|
|
2670
2692
|
})) return;
|
|
2671
|
-
const split =
|
|
2672
|
-
const fingerprint =
|
|
2693
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2694
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
|
|
2673
2695
|
const redacted = redact(split.attributes);
|
|
2674
|
-
|
|
2696
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint, "autter.severity": severity });
|
|
2675
2697
|
const span = _api.trace.getActiveSpan();
|
|
2676
|
-
if (mode === "auto" && _optionalChain([span, 'optionalAccess',
|
|
2698
|
+
if (mode === "auto" && _optionalChain([span, 'optionalAccess', _148 => _148.isRecording, 'call', _149 => _149()])) {
|
|
2677
2699
|
span.addEvent("exception", {
|
|
2678
2700
|
...redacted,
|
|
2679
2701
|
"exception.type": isErrValue ? error.name : "Error",
|
|
2680
2702
|
"exception.message": redact.text(isErrValue ? error.message : String(error)),
|
|
2681
2703
|
...isErrValue && error.stack ? { "exception.stacktrace": redact.text(error.stack) } : {},
|
|
2682
2704
|
"autter.severity": severity,
|
|
2683
|
-
...
|
|
2705
|
+
..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error),
|
|
2684
2706
|
...fingerprint
|
|
2685
2707
|
});
|
|
2686
2708
|
return;
|
|
2687
2709
|
}
|
|
2688
|
-
|
|
2710
|
+
_chunkFV64SIRQcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint }, severity);
|
|
2689
2711
|
}
|
|
2690
2712
|
const captured = /* @__PURE__ */ new WeakSet();
|
|
2691
|
-
|
|
2713
|
+
_chunkFV64SIRQcjs.configureRuntimeLogger.call(void 0, {
|
|
2692
2714
|
endpoint,
|
|
2693
2715
|
apiKey: _nullishCoalesce(options.apiKey, () => ( "")),
|
|
2694
2716
|
service: options.service,
|
|
@@ -2697,7 +2719,7 @@ function initAutterLogging(options) {
|
|
|
2697
2719
|
...options.logging ? { options: options.logging } : {},
|
|
2698
2720
|
redact,
|
|
2699
2721
|
reportOutcome: (name, message, attributes) => {
|
|
2700
|
-
|
|
2722
|
+
_chunkFV64SIRQcjs.runtimeLogger.error(message, {
|
|
2701
2723
|
...attributes,
|
|
2702
2724
|
"autter.outcome.name": name.slice(0, 200),
|
|
2703
2725
|
"autter.outcome.message": message.slice(0, 1e3)
|
|
@@ -2712,7 +2734,7 @@ function initAutterLogging(options) {
|
|
|
2712
2734
|
}
|
|
2713
2735
|
});
|
|
2714
2736
|
setLoggerOnlyCapture(captureException2, captureHandled);
|
|
2715
|
-
|
|
2737
|
+
_chunkFV64SIRQcjs.startLoggedErrorCapture.call(void 0, options.captureLoggedErrors);
|
|
2716
2738
|
const onCrash = (error) => {
|
|
2717
2739
|
if (recordedAsRejection(error)) return;
|
|
2718
2740
|
captureException2(error, { "autter.unhandled": true });
|
|
@@ -2725,22 +2747,22 @@ function initAutterLogging(options) {
|
|
|
2725
2747
|
(reason) => captureException2(reason, { "autter.unhandled_rejection": true })
|
|
2726
2748
|
);
|
|
2727
2749
|
}
|
|
2728
|
-
|
|
2729
|
-
let autoFlushHandle = options.autoFlush === false ? null :
|
|
2750
|
+
_chunk3P573RHAcjs.registerFlushTarget.call(void 0, "logging", { forceFlush: () => _chunkFV64SIRQcjs.flushRuntimeLogs.call(void 0, ) });
|
|
2751
|
+
let autoFlushHandle = options.autoFlush === false ? null : _chunk3P573RHAcjs.installAutterAutoFlush.call(void 0, );
|
|
2730
2752
|
const handle = {
|
|
2731
2753
|
captureException: captureException2,
|
|
2732
|
-
flush:
|
|
2754
|
+
flush: _chunkFV64SIRQcjs.flushRuntimeLogs,
|
|
2733
2755
|
shutdown: async () => {
|
|
2734
|
-
if (L.active === handle)
|
|
2756
|
+
if (L.active === handle) _chunkFV64SIRQcjs.stopLoggedErrorCapture.call(void 0, );
|
|
2735
2757
|
process.off("uncaughtExceptionMonitor", onCrash);
|
|
2736
|
-
_optionalChain([uninstallRejections, 'optionalCall',
|
|
2758
|
+
_optionalChain([uninstallRejections, 'optionalCall', _150 => _150()]);
|
|
2737
2759
|
uninstallRejections = null;
|
|
2738
2760
|
setLoggerOnlyCapture(null);
|
|
2739
|
-
_optionalChain([autoFlushHandle, 'optionalAccess',
|
|
2761
|
+
_optionalChain([autoFlushHandle, 'optionalAccess', _151 => _151.dispose, 'call', _152 => _152()]);
|
|
2740
2762
|
autoFlushHandle = null;
|
|
2741
|
-
|
|
2763
|
+
_chunk3P573RHAcjs.unregisterFlushTargets.call(void 0, );
|
|
2742
2764
|
if (L.active === handle) L.active = null;
|
|
2743
|
-
await
|
|
2765
|
+
await _chunkFV64SIRQcjs.shutdownRuntimeLogger.call(void 0, );
|
|
2744
2766
|
}
|
|
2745
2767
|
};
|
|
2746
2768
|
L.active = handle;
|
|
@@ -2749,7 +2771,7 @@ function initAutterLogging(options) {
|
|
|
2749
2771
|
|
|
2750
2772
|
// src/enrichers.ts
|
|
2751
2773
|
function headerOf(req, name) {
|
|
2752
|
-
const headers = _optionalChain([req, 'optionalAccess',
|
|
2774
|
+
const headers = _optionalChain([req, 'optionalAccess', _153 => _153.headers]);
|
|
2753
2775
|
if (!headers) return void 0;
|
|
2754
2776
|
if (typeof headers.get === "function") {
|
|
2755
2777
|
return _nullishCoalesce(headers.get(name), () => ( void 0));
|
|
@@ -2762,7 +2784,7 @@ function enrichUserAgent() {
|
|
|
2762
2784
|
return (event, { req }) => {
|
|
2763
2785
|
const ua = headerOf(req, "user-agent");
|
|
2764
2786
|
if (!ua) return;
|
|
2765
|
-
const info =
|
|
2787
|
+
const info = _chunkFV64SIRQcjs.parseUserAgent.call(void 0, ua);
|
|
2766
2788
|
if (info.browser) event.attributes["user_agent.browser"] = info.browser;
|
|
2767
2789
|
if (info.os) event.attributes["user_agent.os"] = info.os;
|
|
2768
2790
|
event.attributes["user_agent.device"] = info.device;
|
|
@@ -2774,7 +2796,7 @@ function enrichRequestSize() {
|
|
|
2774
2796
|
const request = Number(headerOf(req, "content-length"));
|
|
2775
2797
|
if (Number.isFinite(request) && request >= 0)
|
|
2776
2798
|
event.attributes["http.request.body.size"] = request;
|
|
2777
|
-
const raw = _optionalChain([res, 'optionalAccess',
|
|
2799
|
+
const raw = _optionalChain([res, 'optionalAccess', _154 => _154.getHeader, 'optionalCall', _155 => _155(
|
|
2778
2800
|
"content-length"
|
|
2779
2801
|
)]);
|
|
2780
2802
|
const response = Number(raw);
|
|
@@ -2792,7 +2814,7 @@ var COUNTRY_HEADERS = [
|
|
|
2792
2814
|
function enrichEdgeGeo() {
|
|
2793
2815
|
return (event, { req }) => {
|
|
2794
2816
|
for (const name of COUNTRY_HEADERS) {
|
|
2795
|
-
const value = _optionalChain([headerOf, 'call',
|
|
2817
|
+
const value = _optionalChain([headerOf, 'call', _156 => _156(req, name), 'optionalAccess', _157 => _157.trim, 'call', _158 => _158(), 'access', _159 => _159.toUpperCase, 'call', _160 => _160()]);
|
|
2796
2818
|
if (value && /^[A-Z]{2}$/.test(value) && value !== "XX" && value !== "T1") {
|
|
2797
2819
|
event.attributes["geo.country.iso_code"] = value;
|
|
2798
2820
|
return;
|
|
@@ -2826,9 +2848,9 @@ var COMMIT_VARS = [
|
|
|
2826
2848
|
"SOURCE_VERSION"
|
|
2827
2849
|
];
|
|
2828
2850
|
function enrichDeployment(env = process.env) {
|
|
2829
|
-
const pick = (names) => names.map((name) => _optionalChain([env, 'access',
|
|
2830
|
-
const region = _optionalChain([pick, 'call',
|
|
2831
|
-
const commit = _optionalChain([pick, 'call',
|
|
2851
|
+
const pick = (names) => names.map((name) => _optionalChain([env, 'access', _161 => _161[name], 'optionalAccess', _162 => _162.trim, 'call', _163 => _163()])).find((value) => value);
|
|
2852
|
+
const region = _optionalChain([pick, 'call', _164 => _164(REGION_VARS), 'optionalAccess', _165 => _165.slice, 'call', _166 => _166(0, 64)]);
|
|
2853
|
+
const commit = _optionalChain([pick, 'call', _167 => _167(COMMIT_VARS), 'optionalAccess', _168 => _168.slice, 'call', _169 => _169(0, 64)]);
|
|
2832
2854
|
return (event) => {
|
|
2833
2855
|
if (region) event.attributes["deployment.region"] = region;
|
|
2834
2856
|
if (commit) event.attributes["deployment.commit"] = commit;
|
|
@@ -2889,4 +2911,4 @@ function enrichDeployment(env = process.env) {
|
|
|
2889
2911
|
|
|
2890
2912
|
|
|
2891
2913
|
|
|
2892
|
-
exports.CODE_PATTERN =
|
|
2914
|
+
exports.CODE_PATTERN = _chunkFV64SIRQcjs.CODE_PATTERN; exports.COMPAT_MANIFEST = _chunk3P573RHAcjs.COMPAT_MANIFEST; exports.INGESTER_VERSION_HEADER = _chunk3P573RHAcjs.INGESTER_VERSION_HEADER; exports.RuntimeError = _chunkFV64SIRQcjs.RuntimeError; exports.SDK_IDENTITY = _chunk3P573RHAcjs.SDK_IDENTITY; exports.addBreadcrumb = _chunkFV64SIRQcjs.addBreadcrumb; exports.autterErrorHandler = autterErrorHandler; exports.autterErrorResponse = autterErrorResponse; exports.autterFastify = autterFastify; exports.autterFastifyErrors = autterFastifyErrors; exports.autterKoa = autterKoa; exports.autterRequests = autterRequests; exports.captureException = captureException; exports.captureMessage = captureMessage; exports.captureRequestError = captureRequestError; exports.consoleSink = _chunkFV64SIRQcjs.consoleSink; exports.createBrowserRelayFetchHandler = createBrowserRelayFetchHandler; exports.createBrowserRelayHandler = createBrowserRelayHandler; exports.createRuntimeLogger = _chunkFV64SIRQcjs.createRuntimeLogger; exports.defineRuntimeErrors = _chunkFV64SIRQcjs.defineRuntimeErrors; exports.emitLlmSelftestTrace = emitLlmSelftestTrace; exports.enrichDeployment = enrichDeployment; exports.enrichEdgeGeo = enrichEdgeGeo; exports.enrichRequestSize = enrichRequestSize; exports.enrichUserAgent = enrichUserAgent; exports.errorAttributes = _chunkFV64SIRQcjs.errorAttributes; exports.evaluateCompat = _chunk3P573RHAcjs.evaluateCompat; exports.fetchIngesterCompat = _chunk3P573RHAcjs.fetchIngesterCompat; exports.fileSink = _chunkFV64SIRQcjs.fileSink; exports.flushRuntimeLogs = _chunkFV64SIRQcjs.flushRuntimeLogs; exports.initAutterLogging = initAutterLogging; exports.initAutterServer = initAutterServer; exports.installAutterAutoFlush = _chunk3P573RHAcjs.installAutterAutoFlush; exports.instrumentLlmClient = instrumentLlmClient; exports.isRuntimeErrorLike = _chunkFV64SIRQcjs.isRuntimeErrorLike; exports.makeSafeCapture = makeSafeCapture; exports.otlpSink = _chunkFV64SIRQcjs.otlpSink; exports.redactAttributes = _chunkFV64SIRQcjs.redactAttributes; exports.redactText = _chunkFV64SIRQcjs.redactText; exports.reportOutcome = reportOutcome; exports.runDoctor = _chunkLYXQC4FIcjs.runDoctor; exports.runInBackground = _chunkFV64SIRQcjs.runInBackground; exports.runtimeContext = _chunkFV64SIRQcjs.runtimeContext; exports.runtimeLogStats = _chunkFV64SIRQcjs.runtimeLogStats; exports.runtimeLogger = _chunkFV64SIRQcjs.runtimeLogger; exports.sanitizeBrowserPayload = sanitizeBrowserPayload; exports.startCaughtExceptionSampler = startCaughtExceptionSampler; exports.toClientError = _chunkFV64SIRQcjs.toClientError; exports.trackLlmCall = trackLlmCall; exports.unhandledRejectionsMode = unhandledRejectionsMode; exports.withLlmCall = withLlmCall; exports.withProcessSpan = withProcessSpan; exports.withRuntimeOperation = _chunkFV64SIRQcjs.withRuntimeOperation; exports.withRuntimeRequest = withRuntimeRequest;
|