@autter/runtime-node 1.5.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 +139 -1
- package/dist/{chunk-GI47WGRR.cjs → chunk-4MVWIRBI.cjs} +120 -39
- package/dist/{chunk-3TJHUCZ6.js → chunk-5KISVAVB.js} +326 -54
- package/dist/{chunk-L6SRL65J.cjs → chunk-7OTD2YPT.cjs} +11 -11
- package/dist/{chunk-L7HWKMCZ.js → chunk-HRDELHZP.js} +112 -31
- package/dist/{chunk-ZS4WQJQR.js → chunk-L5ENELB2.js} +1 -1
- package/dist/{chunk-P4VRTFAV.cjs → chunk-UXTIMS3G.cjs} +353 -81
- package/dist/cli.cjs +29 -9
- package/dist/cli.js +22 -2
- package/dist/index.cjs +668 -272
- package/dist/index.d.cts +160 -7
- package/dist/index.d.ts +160 -7
- package/dist/index.js +529 -133
- package/dist/{sinks-RFV76lF1.d.cts → sinks-CPGDyfU8.d.cts} +29 -1
- package/dist/{sinks-RFV76lF1.d.ts → sinks-CPGDyfU8.d.ts} +29 -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 +3 -1
package/dist/index.cjs
CHANGED
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
var _chunkP4VRTFAVcjs = require('./chunk-P4VRTFAV.cjs');
|
|
42
41
|
|
|
43
42
|
|
|
44
|
-
var _chunkL6SRL65Jcjs = require('./chunk-L6SRL65J.cjs');
|
|
45
43
|
|
|
46
44
|
|
|
47
45
|
|
|
48
46
|
|
|
49
47
|
|
|
48
|
+
var _chunkUXTIMS3Gcjs = require('./chunk-UXTIMS3G.cjs');
|
|
50
49
|
|
|
51
50
|
|
|
51
|
+
var _chunk7OTD2YPTcjs = require('./chunk-7OTD2YPT.cjs');
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
@@ -62,7 +62,15 @@ var _chunkL6SRL65Jcjs = require('./chunk-L6SRL65J.cjs');
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
var _chunk4MVWIRBIcjs = require('./chunk-4MVWIRBI.cjs');
|
|
66
74
|
|
|
67
75
|
// src/relay.ts
|
|
68
76
|
var IpWindow = (_class = class {
|
|
@@ -102,6 +110,7 @@ var EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
102
110
|
"timing"
|
|
103
111
|
]);
|
|
104
112
|
var SEVERITIES = /* @__PURE__ */ new Set(["fatal", "error", "warning", "info"]);
|
|
113
|
+
var TRACE_ID = /^(?!0{32})[0-9a-f]{32}$/;
|
|
105
114
|
var CONTEXT_MAX_DEPTH = 6;
|
|
106
115
|
var CONTEXT_MAX_NODES = 256;
|
|
107
116
|
var CONTEXT_MAX_STRING = 4e3;
|
|
@@ -214,7 +223,28 @@ function relayContext(raw, redactor) {
|
|
|
214
223
|
const bounded = boundContext(raw);
|
|
215
224
|
return Array.isArray(bounded) ? {} : { context: redactor(bounded) };
|
|
216
225
|
}
|
|
217
|
-
|
|
226
|
+
function relayBreadcrumbs(raw, redactor) {
|
|
227
|
+
const breadcrumbs = _chunkUXTIMS3Gcjs.sanitizeBreadcrumbs.call(void 0, raw, redactor);
|
|
228
|
+
return breadcrumbs ? { breadcrumbs } : {};
|
|
229
|
+
}
|
|
230
|
+
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}$/;
|
|
231
|
+
function relayDebugIds(raw, redactor) {
|
|
232
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {};
|
|
233
|
+
const debugIds = {};
|
|
234
|
+
let count = 0;
|
|
235
|
+
for (const [url, id] of Object.entries(raw)) {
|
|
236
|
+
if (count >= 50) break;
|
|
237
|
+
if (typeof id !== "string" || !DEBUG_ID_RE.test(id) || url.length > 1e3) continue;
|
|
238
|
+
debugIds[redactor.text(url.split(/[?#]/)[0])] = id.toLowerCase();
|
|
239
|
+
count++;
|
|
240
|
+
}
|
|
241
|
+
return count ? { debugIds } : {};
|
|
242
|
+
}
|
|
243
|
+
function relayFingerprint(raw, redactor) {
|
|
244
|
+
const values = _chunkUXTIMS3Gcjs.fingerprintValues.call(void 0, raw, redactor.text);
|
|
245
|
+
return values ? { fingerprint: Array.isArray(raw) ? values : values[0] } : {};
|
|
246
|
+
}
|
|
247
|
+
var defaultRelayRedactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true);
|
|
218
248
|
function sanitizeBrowserPayload(raw, redactor = defaultRelayRedactor) {
|
|
219
249
|
if (typeof raw !== "object" || raw === null) return null;
|
|
220
250
|
const p = raw;
|
|
@@ -241,7 +271,11 @@ function sanitizeBrowserPayload(raw, redactor = defaultRelayRedactor) {
|
|
|
241
271
|
...typeof e.line === "number" ? { line: e.line } : {},
|
|
242
272
|
...typeof e.column === "number" ? { column: e.column } : {},
|
|
243
273
|
...typeof e.route === "string" ? { route: e.route.split("?")[0].slice(0, 1e3) } : {},
|
|
244
|
-
...typeof e.context === "object" && e.context !== null ? relayContext(e.context, redactor) : {}
|
|
274
|
+
...typeof e.context === "object" && e.context !== null ? relayContext(e.context, redactor) : {},
|
|
275
|
+
...relayBreadcrumbs(e.breadcrumbs, redactor),
|
|
276
|
+
...relayDebugIds(e.debugIds, redactor),
|
|
277
|
+
...relayFingerprint(e.fingerprint, redactor),
|
|
278
|
+
...typeof e.traceId === "string" && TRACE_ID.test(e.traceId) ? { traceId: e.traceId } : {}
|
|
245
279
|
});
|
|
246
280
|
}
|
|
247
281
|
return {
|
|
@@ -259,7 +293,7 @@ function forward(payload, opts) {
|
|
|
259
293
|
const endpoint = (_nullishCoalesce(opts.endpoint, () => ( DEFAULT_ENDPOINT))).replace(/\/$/, "");
|
|
260
294
|
const url = `${endpoint}/v1/browser`;
|
|
261
295
|
const compat = opts.compatCheck !== false;
|
|
262
|
-
if (compat)
|
|
296
|
+
if (compat) _chunk4MVWIRBIcjs.ensureCompatConfigured.call(void 0, endpoint);
|
|
263
297
|
void fetch(url, {
|
|
264
298
|
method: "POST",
|
|
265
299
|
headers: {
|
|
@@ -273,9 +307,12 @@ function forward(payload, opts) {
|
|
|
273
307
|
const types = new Set(
|
|
274
308
|
(_nullishCoalesce(payload.events, () => ( []))).map((e) => String(e.type))
|
|
275
309
|
);
|
|
276
|
-
|
|
277
|
-
for (const feature of
|
|
278
|
-
|
|
310
|
+
_chunk4MVWIRBIcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers });
|
|
311
|
+
for (const feature of _chunk4MVWIRBIcjs.featuresForBrowserEvents.call(void 0, types)) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, feature);
|
|
312
|
+
if ((_nullishCoalesce(payload.events, () => ( []))).some((e) => e.traceId)) {
|
|
313
|
+
_chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
|
|
314
|
+
}
|
|
315
|
+
_chunk4MVWIRBIcjs.noteRelayRejection.call(void 0, types, response.status, response.headers);
|
|
279
316
|
}).catch((err) => {
|
|
280
317
|
(_nullishCoalesce(opts.onError, () => ( ((e) => console.warn("autter relay forward failed:", e)))))(
|
|
281
318
|
err
|
|
@@ -284,7 +321,7 @@ function forward(payload, opts) {
|
|
|
284
321
|
}
|
|
285
322
|
function createBrowserRelayFetchHandler(opts) {
|
|
286
323
|
const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
|
|
287
|
-
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor :
|
|
324
|
+
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, opts.redact);
|
|
288
325
|
const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
|
|
289
326
|
return async (request) => {
|
|
290
327
|
if (request.method !== "POST") {
|
|
@@ -331,7 +368,7 @@ function createBrowserRelayFetchHandler(opts) {
|
|
|
331
368
|
}
|
|
332
369
|
function createBrowserRelayHandler(opts) {
|
|
333
370
|
const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
|
|
334
|
-
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor :
|
|
371
|
+
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, opts.redact);
|
|
335
372
|
const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
|
|
336
373
|
function respond(res, status, body) {
|
|
337
374
|
res.statusCode = status;
|
|
@@ -442,6 +479,89 @@ var _semanticconventions = require('@opentelemetry/semantic-conventions');
|
|
|
442
479
|
|
|
443
480
|
|
|
444
481
|
|
|
482
|
+
|
|
483
|
+
// src/url-query.ts
|
|
484
|
+
var URL_KEYS = ["http.target", "http.url", "url.full", "url.original", "url.path"];
|
|
485
|
+
var QUERY_KEY = "url.query";
|
|
486
|
+
var NAME_KEYS = ["next.span_name"];
|
|
487
|
+
var MASK = "[redacted]";
|
|
488
|
+
var SCHEME = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
489
|
+
function splitUrl(value) {
|
|
490
|
+
const from = SCHEME.test(value) ? value.indexOf("://") + 3 : 0;
|
|
491
|
+
const question = value.indexOf("?", from);
|
|
492
|
+
const hash = value.indexOf("#", from);
|
|
493
|
+
const at = question < 0 ? hash : hash < 0 ? question : Math.min(question, hash);
|
|
494
|
+
if (at < 0) return null;
|
|
495
|
+
const query = at === question ? value.slice(at + 1, hash > at ? hash : void 0) : null;
|
|
496
|
+
return { base: value.slice(0, at), query };
|
|
497
|
+
}
|
|
498
|
+
function decodeName(raw) {
|
|
499
|
+
try {
|
|
500
|
+
return decodeURIComponent(raw.replace(/\+/g, " "));
|
|
501
|
+
} catch (e12) {
|
|
502
|
+
return raw;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function makeUrlQueryPolicy(keepQueryParams = []) {
|
|
506
|
+
const keep = new Set(keepQueryParams.filter((name) => typeof name === "string"));
|
|
507
|
+
const maskQuery = (query) => {
|
|
508
|
+
const out = [];
|
|
509
|
+
for (const part of query.split("&")) {
|
|
510
|
+
if (!part) continue;
|
|
511
|
+
const eq = part.indexOf("=");
|
|
512
|
+
const name = eq < 0 ? part : part.slice(0, eq);
|
|
513
|
+
if (keep.size && keep.has(decodeName(name))) out.push(part);
|
|
514
|
+
else if (eq < 0) out.push(MASK);
|
|
515
|
+
else out.push(eq === part.length - 1 ? part : `${name}=${MASK}`);
|
|
516
|
+
}
|
|
517
|
+
return out.join("&");
|
|
518
|
+
};
|
|
519
|
+
const stripName = (name) => {
|
|
520
|
+
if (!name.includes("?") && !name.includes("#")) return name;
|
|
521
|
+
return name.split(" ").map((token) => {
|
|
522
|
+
if (!token.startsWith("/") && !SCHEME.test(token)) return token;
|
|
523
|
+
return _nullishCoalesce(_optionalChain([splitUrl, 'call', _3 => _3(token), 'optionalAccess', _4 => _4.base]), () => ( token));
|
|
524
|
+
}).join(" ");
|
|
525
|
+
};
|
|
526
|
+
return {
|
|
527
|
+
attributes(attributes) {
|
|
528
|
+
let out = null;
|
|
529
|
+
const set = (key, value) => {
|
|
530
|
+
out ??= { ...attributes };
|
|
531
|
+
out[key] = value;
|
|
532
|
+
};
|
|
533
|
+
let dropped = null;
|
|
534
|
+
for (const key of URL_KEYS) {
|
|
535
|
+
const value = attributes[key];
|
|
536
|
+
if (typeof value !== "string") continue;
|
|
537
|
+
const split = splitUrl(value);
|
|
538
|
+
if (!split) continue;
|
|
539
|
+
set(key, split.base);
|
|
540
|
+
if (split.query) dropped ??= split.query;
|
|
541
|
+
}
|
|
542
|
+
for (const key of NAME_KEYS) {
|
|
543
|
+
const value = attributes[key];
|
|
544
|
+
if (typeof value !== "string") continue;
|
|
545
|
+
const stripped = stripName(value);
|
|
546
|
+
if (stripped !== value) set(key, stripped);
|
|
547
|
+
}
|
|
548
|
+
const current = attributes[QUERY_KEY];
|
|
549
|
+
if (typeof current === "string") {
|
|
550
|
+
const masked = maskQuery(current.startsWith("?") ? current.slice(1) : current);
|
|
551
|
+
if (masked !== current) set(QUERY_KEY, masked);
|
|
552
|
+
} else if (current !== void 0) {
|
|
553
|
+
set(QUERY_KEY, MASK);
|
|
554
|
+
} else if (dropped !== null) {
|
|
555
|
+
const masked = maskQuery(dropped);
|
|
556
|
+
if (masked) set(QUERY_KEY, masked);
|
|
557
|
+
}
|
|
558
|
+
return _nullishCoalesce(out, () => ( attributes));
|
|
559
|
+
},
|
|
560
|
+
name: stripName
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// src/redact-exporter.ts
|
|
445
565
|
var scrubbedResources = /* @__PURE__ */ new WeakMap();
|
|
446
566
|
function redactResource(resource, redactor) {
|
|
447
567
|
const cached = scrubbedResources.get(resource);
|
|
@@ -450,17 +570,41 @@ function redactResource(resource, redactor) {
|
|
|
450
570
|
scrubbedResources.set(resource, scrubbed);
|
|
451
571
|
return scrubbed;
|
|
452
572
|
}
|
|
453
|
-
|
|
454
|
-
|
|
573
|
+
var DEFAULT_QUERY_POLICY = makeUrlQueryPolicy();
|
|
574
|
+
function stripQueries(span, query) {
|
|
575
|
+
const name = query.name(span.name);
|
|
576
|
+
const attributes = query.attributes(span.attributes);
|
|
577
|
+
if (name === span.name && attributes === span.attributes) return span;
|
|
578
|
+
return wrap(span, { name, attributes });
|
|
579
|
+
}
|
|
580
|
+
function wrap(span, fields) {
|
|
455
581
|
return {
|
|
456
|
-
name:
|
|
582
|
+
name: fields.name,
|
|
457
583
|
kind: span.kind,
|
|
458
584
|
spanContext: () => span.spanContext(),
|
|
459
585
|
parentSpanId: span.parentSpanId,
|
|
460
586
|
startTime: span.startTime,
|
|
461
587
|
endTime: span.endTime,
|
|
588
|
+
status: _nullishCoalesce(fields.status, () => ( span.status)),
|
|
589
|
+
attributes: fields.attributes,
|
|
590
|
+
links: _nullishCoalesce(fields.links, () => ( span.links)),
|
|
591
|
+
events: _nullishCoalesce(fields.events, () => ( span.events)),
|
|
592
|
+
duration: span.duration,
|
|
593
|
+
ended: span.ended,
|
|
594
|
+
resource: _nullishCoalesce(fields.resource, () => ( span.resource)),
|
|
595
|
+
instrumentationLibrary: span.instrumentationLibrary,
|
|
596
|
+
droppedAttributesCount: span.droppedAttributesCount,
|
|
597
|
+
droppedEventsCount: span.droppedEventsCount,
|
|
598
|
+
droppedLinksCount: span.droppedLinksCount
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
function redactSpan(span, redactor, query = DEFAULT_QUERY_POLICY) {
|
|
602
|
+
if (!redactor.enabled) return stripQueries(span, query);
|
|
603
|
+
const status = span.status.message ? { ...span.status, message: redactor.text(span.status.message) } : span.status;
|
|
604
|
+
return wrap(span, {
|
|
605
|
+
name: query.name(redactor.text(span.name)),
|
|
462
606
|
status,
|
|
463
|
-
attributes: redactor.exported(span.attributes),
|
|
607
|
+
attributes: query.attributes(redactor.exported(span.attributes)),
|
|
464
608
|
links: span.links.map(
|
|
465
609
|
(link) => link.attributes ? { ...link, attributes: redactor.exported(link.attributes) } : link
|
|
466
610
|
),
|
|
@@ -469,34 +613,27 @@ function redactSpan(span, redactor) {
|
|
|
469
613
|
name: redactor.text(event.name),
|
|
470
614
|
...event.attributes ? { attributes: redactor.exported(event.attributes) } : {}
|
|
471
615
|
})),
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
resource: redactResource(span.resource, redactor),
|
|
475
|
-
instrumentationLibrary: span.instrumentationLibrary,
|
|
476
|
-
droppedAttributesCount: span.droppedAttributesCount,
|
|
477
|
-
droppedEventsCount: span.droppedEventsCount,
|
|
478
|
-
droppedLinksCount: span.droppedLinksCount
|
|
479
|
-
};
|
|
616
|
+
resource: redactResource(span.resource, redactor)
|
|
617
|
+
});
|
|
480
618
|
}
|
|
481
619
|
var RedactingSpanExporter = class {
|
|
482
|
-
constructor(inner, redactor) {
|
|
620
|
+
constructor(inner, redactor, query = DEFAULT_QUERY_POLICY) {
|
|
483
621
|
this.inner = inner;
|
|
484
622
|
this.redactor = redactor;
|
|
623
|
+
this.query = query;
|
|
485
624
|
}
|
|
486
625
|
|
|
487
626
|
|
|
627
|
+
|
|
488
628
|
export(spans, resultCallback) {
|
|
489
629
|
const redactor = this.redactor();
|
|
490
|
-
|
|
630
|
+
const scrubbed = [];
|
|
491
631
|
let failed = 0;
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
} catch (e12) {
|
|
498
|
-
failed++;
|
|
499
|
-
}
|
|
632
|
+
for (const span of spans) {
|
|
633
|
+
try {
|
|
634
|
+
scrubbed.push(redactSpan(span, redactor, this.query));
|
|
635
|
+
} catch (e13) {
|
|
636
|
+
failed++;
|
|
500
637
|
}
|
|
501
638
|
}
|
|
502
639
|
if (!failed) {
|
|
@@ -518,7 +655,7 @@ var RedactingSpanExporter = class {
|
|
|
518
655
|
return this.inner.shutdown();
|
|
519
656
|
}
|
|
520
657
|
forceFlush() {
|
|
521
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
658
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _5 => _5.inner, 'access', _6 => _6.forceFlush, 'optionalCall', _7 => _7()]), () => ( Promise.resolve()));
|
|
522
659
|
}
|
|
523
660
|
};
|
|
524
661
|
var RedactingMetricExporter = class {
|
|
@@ -575,7 +712,7 @@ function startMemoryMetrics() {
|
|
|
575
712
|
[heapUsed, (result) => result.observe(process.memoryUsage().heapUsed)],
|
|
576
713
|
[heapLimit, (result) => result.observe(_v8.getHeapStatistics.call(void 0, ).heap_size_limit)],
|
|
577
714
|
[containerLimit, (result) => {
|
|
578
|
-
const constrained = _nullishCoalesce(_optionalChain([process, 'access',
|
|
715
|
+
const constrained = _nullishCoalesce(_optionalChain([process, 'access', _8 => _8.constrainedMemory, 'optionalCall', _9 => _9()]), () => ( 0));
|
|
579
716
|
if (constrained > 0) result.observe(constrained);
|
|
580
717
|
}],
|
|
581
718
|
[afterGc, (result) => {
|
|
@@ -602,50 +739,87 @@ function startMemoryMetrics() {
|
|
|
602
739
|
// src/requests.ts
|
|
603
740
|
var _async_hooks = require('async_hooks');
|
|
604
741
|
|
|
742
|
+
|
|
605
743
|
var REQUEST_STATE = /* @__PURE__ */ Symbol.for("autter.runtime.request");
|
|
606
744
|
var BOUND = /* @__PURE__ */ Symbol.for("autter.runtime.bound");
|
|
607
|
-
var CAPTURED = /* @__PURE__ */ new WeakSet();
|
|
745
|
+
var CAPTURED = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "requests", () => ({ captured: /* @__PURE__ */ new WeakSet() })).captured;
|
|
608
746
|
var capturer = () => {
|
|
609
747
|
};
|
|
610
748
|
function setRequestExceptionCapturer(fn) {
|
|
611
749
|
capturer = fn;
|
|
612
750
|
}
|
|
751
|
+
var annotator = () => {
|
|
752
|
+
};
|
|
753
|
+
function setRequestSpanAnnotator(fn) {
|
|
754
|
+
annotator = fn;
|
|
755
|
+
}
|
|
613
756
|
function markCaptured(error) {
|
|
614
757
|
if (error && typeof error === "object") CAPTURED.add(error);
|
|
615
758
|
}
|
|
616
759
|
function expressRouteOf(req) {
|
|
617
760
|
const props = req;
|
|
618
|
-
const path = _optionalChain([props, 'optionalAccess',
|
|
761
|
+
const path = _optionalChain([props, 'optionalAccess', _10 => _10.route, 'optionalAccess', _11 => _11.path]);
|
|
619
762
|
if (typeof path !== "string" || path === "") return null;
|
|
620
|
-
const base = typeof _optionalChain([props, 'optionalAccess',
|
|
763
|
+
const base = typeof _optionalChain([props, 'optionalAccess', _12 => _12.baseUrl]) === "string" ? props.baseUrl : "";
|
|
621
764
|
const route = base + path;
|
|
622
765
|
return route.startsWith("/") ? route : null;
|
|
623
766
|
}
|
|
624
767
|
function defaultShouldCapture(error) {
|
|
625
|
-
return error instanceof
|
|
768
|
+
return error instanceof _chunkUXTIMS3Gcjs.RuntimeError || _chunkUXTIMS3Gcjs.errorCodeOf.call(void 0, error) !== void 0 || _chunkUXTIMS3Gcjs.responseStatusOf.call(void 0, error) >= 500;
|
|
769
|
+
}
|
|
770
|
+
function onRequestSpan(fn) {
|
|
771
|
+
const active = _api.context.active();
|
|
772
|
+
const metadata = _core.getRPCMetadata.call(void 0, active);
|
|
773
|
+
const span = _optionalChain([metadata, 'optionalAccess', _13 => _13.type]) === _core.RPCType.HTTP ? metadata.span : void 0;
|
|
774
|
+
if (!span || !span.isRecording() || _api.trace.getSpan(active) === span) {
|
|
775
|
+
fn();
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
_api.context.with(_api.trace.setSpan(active, span), fn);
|
|
626
779
|
}
|
|
627
|
-
function captureAtBoundary(error, state, rule = void 0) {
|
|
628
|
-
|
|
780
|
+
function captureAtBoundary(error, state, rule = void 0, attributes) {
|
|
781
|
+
let wanted;
|
|
782
|
+
try {
|
|
783
|
+
wanted = typeof rule === "function" ? rule(error) : rule === void 0 ? defaultShouldCapture(error) : rule;
|
|
784
|
+
} catch (e14) {
|
|
785
|
+
wanted = false;
|
|
786
|
+
}
|
|
629
787
|
if (!wanted) return;
|
|
630
788
|
if (error && typeof error === "object" && CAPTURED.has(error)) return;
|
|
631
789
|
markCaptured(error);
|
|
632
790
|
try {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
791
|
+
const run = () => onRequestSpan(() => capturer(error, attributes));
|
|
792
|
+
if (state && !state.sealed) _chunkUXTIMS3Gcjs.local.run(state, run);
|
|
793
|
+
else run();
|
|
794
|
+
} catch (e15) {
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
function requestStateOf(req) {
|
|
798
|
+
if (!req || typeof req !== "object") return void 0;
|
|
799
|
+
return req[REQUEST_STATE];
|
|
800
|
+
}
|
|
801
|
+
function captureRequestError(error, attributes) {
|
|
802
|
+
if (error && typeof error === "object" && CAPTURED.has(error)) {
|
|
803
|
+
if (!attributes) return;
|
|
804
|
+
try {
|
|
805
|
+
onRequestSpan(() => annotator(attributes));
|
|
806
|
+
} catch (e16) {
|
|
807
|
+
}
|
|
808
|
+
return;
|
|
636
809
|
}
|
|
810
|
+
captureAtBoundary(error, _chunkUXTIMS3Gcjs.currentOperation.call(void 0, ), true, attributes);
|
|
637
811
|
}
|
|
638
812
|
function bindEmitter(emitter, state) {
|
|
639
813
|
const target = emitter;
|
|
640
814
|
if (!target || typeof target !== "object" || target[BOUND]) return;
|
|
641
815
|
target[BOUND] = true;
|
|
642
816
|
const wrappers = /* @__PURE__ */ new WeakMap();
|
|
643
|
-
const
|
|
817
|
+
const wrap2 = (listener) => {
|
|
644
818
|
if (typeof listener !== "function") return listener;
|
|
645
819
|
let wrapped = wrappers.get(listener);
|
|
646
820
|
if (!wrapped) {
|
|
647
821
|
wrapped = function(...args) {
|
|
648
|
-
return
|
|
822
|
+
return _chunkUXTIMS3Gcjs.local.run(
|
|
649
823
|
state,
|
|
650
824
|
() => listener.apply(this, args)
|
|
651
825
|
);
|
|
@@ -664,7 +838,7 @@ function bindEmitter(emitter, state) {
|
|
|
664
838
|
const original = target[method];
|
|
665
839
|
if (typeof original !== "function") continue;
|
|
666
840
|
target[method] = function(event, listener) {
|
|
667
|
-
return original.call(this, event,
|
|
841
|
+
return original.call(this, event, wrap2(listener));
|
|
668
842
|
};
|
|
669
843
|
}
|
|
670
844
|
for (const method of ["removeListener", "off"]) {
|
|
@@ -700,7 +874,7 @@ function exposeOnCors(res, header) {
|
|
|
700
874
|
if (value && key && inline) inline[key] = value;
|
|
701
875
|
else if (value) res.setHeader("access-control-expose-headers", value);
|
|
702
876
|
}
|
|
703
|
-
} catch (
|
|
877
|
+
} catch (e17) {
|
|
704
878
|
}
|
|
705
879
|
return original.apply(this, args);
|
|
706
880
|
};
|
|
@@ -712,7 +886,7 @@ function pathOf(req) {
|
|
|
712
886
|
function finishRequest(state, input) {
|
|
713
887
|
if (state.sealed) return;
|
|
714
888
|
state.name = (_nullishCoalesce(input.name, () => ( `${input.method} ${input.route}`))).slice(0, 200);
|
|
715
|
-
state.outcome =
|
|
889
|
+
state.outcome = _chunkUXTIMS3Gcjs.requestOutcome.call(void 0, {
|
|
716
890
|
...state.explicitOutcome ? { explicit: state.outcome } : {},
|
|
717
891
|
...state.error !== void 0 ? { error: state.error } : {},
|
|
718
892
|
...state.errorThrown ? { thrown: true } : {},
|
|
@@ -720,15 +894,15 @@ function finishRequest(state, input) {
|
|
|
720
894
|
aborted: input.aborted
|
|
721
895
|
});
|
|
722
896
|
const span = _api.trace.getActiveSpan();
|
|
723
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
897
|
+
if (_optionalChain([span, 'optionalAccess', _14 => _14.isRecording, 'call', _15 => _15()])) span.setAttribute("autter.operation.outcome", state.outcome);
|
|
724
898
|
if (input.span) {
|
|
725
899
|
const remote = _api.trace.wrapSpanContext(input.span);
|
|
726
900
|
_api.context.with(
|
|
727
901
|
_api.trace.setSpan(_api.context.active(), remote),
|
|
728
|
-
() =>
|
|
902
|
+
() => _chunkUXTIMS3Gcjs.reportExplicitFailure.call(void 0, state)
|
|
729
903
|
);
|
|
730
|
-
} else
|
|
731
|
-
|
|
904
|
+
} else _chunkUXTIMS3Gcjs.reportExplicitFailure.call(void 0, state);
|
|
905
|
+
_chunkUXTIMS3Gcjs.emitSummary.call(void 0, state, {
|
|
732
906
|
http: {
|
|
733
907
|
"http.request.method": input.method,
|
|
734
908
|
"http.route": input.route,
|
|
@@ -739,14 +913,14 @@ function finishRequest(state, input) {
|
|
|
739
913
|
});
|
|
740
914
|
}
|
|
741
915
|
function beginNodeRequest(req, res, options, route) {
|
|
742
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
743
|
-
const requestId =
|
|
916
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
917
|
+
const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
|
|
744
918
|
options.trustRequestId === false ? void 0 : req.headers[header]
|
|
745
919
|
);
|
|
746
920
|
const method = (_nullishCoalesce(req.method, () => ( "GET"))).toUpperCase();
|
|
747
921
|
const path = pathOf(req);
|
|
748
|
-
const state =
|
|
749
|
-
name: `${method} ${
|
|
922
|
+
const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
|
|
923
|
+
name: `${method} ${_chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, path)}`,
|
|
750
924
|
requestId,
|
|
751
925
|
req,
|
|
752
926
|
res
|
|
@@ -755,22 +929,22 @@ function beginNodeRequest(req, res, options, route) {
|
|
|
755
929
|
try {
|
|
756
930
|
if (!res.headersSent) res.setHeader(header, requestId);
|
|
757
931
|
exposeOnCors(res, header);
|
|
758
|
-
} catch (
|
|
932
|
+
} catch (e18) {
|
|
759
933
|
}
|
|
760
934
|
const span = _api.trace.getActiveSpan();
|
|
761
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
935
|
+
if (_optionalChain([span, 'optionalAccess', _16 => _16.isRecording, 'call', _17 => _17()]))
|
|
762
936
|
span.setAttributes({
|
|
763
937
|
"autter.request.id": requestId,
|
|
764
938
|
"autter.operation.kind": "request"
|
|
765
939
|
});
|
|
766
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
940
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _18 => _18.spanContext, 'call', _19 => _19()]);
|
|
767
941
|
bindEmitter(req, state);
|
|
768
942
|
bindEmitter(res, state);
|
|
769
943
|
let finished = false;
|
|
770
944
|
const done = () => {
|
|
771
945
|
finishRequest(state, {
|
|
772
946
|
method,
|
|
773
|
-
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall',
|
|
947
|
+
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _20 => _20()]), () => ( expressRouteOf(req))), () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, path))),
|
|
774
948
|
status: res.statusCode,
|
|
775
949
|
aborted: !finished,
|
|
776
950
|
...spanContext ? { span: spanContext } : {}
|
|
@@ -784,50 +958,50 @@ function beginNodeRequest(req, res, options, route) {
|
|
|
784
958
|
return state;
|
|
785
959
|
}
|
|
786
960
|
function autterRequests(options = {}) {
|
|
787
|
-
const ignored =
|
|
961
|
+
const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, options.ignore);
|
|
788
962
|
return function autterRequestsMiddleware(req, res, next) {
|
|
789
963
|
if (req[REQUEST_STATE] || ignored(pathOf(req))) {
|
|
790
964
|
next();
|
|
791
965
|
return;
|
|
792
966
|
}
|
|
793
967
|
const state = beginNodeRequest(req, res, options);
|
|
794
|
-
|
|
968
|
+
_chunkUXTIMS3Gcjs.local.run(state, () => next());
|
|
795
969
|
};
|
|
796
970
|
}
|
|
797
971
|
function autterErrorResponse(options = {}) {
|
|
798
972
|
return function autterErrorResponseMiddleware(error, req, res, next) {
|
|
799
973
|
const state = req[REQUEST_STATE];
|
|
800
|
-
if (state)
|
|
974
|
+
if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
|
|
801
975
|
captureAtBoundary(error, state, options.capture);
|
|
802
976
|
if (res.headersSent) {
|
|
803
977
|
next(error);
|
|
804
978
|
return;
|
|
805
979
|
}
|
|
806
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
807
|
-
const inbound = _optionalChain([req, 'access',
|
|
808
|
-
const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
809
|
-
res.statusCode =
|
|
980
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
981
|
+
const inbound = _optionalChain([req, 'access', _21 => _21.headers, 'optionalAccess', _22 => _22[header]]);
|
|
982
|
+
const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _23 => _23.requestId]), () => ( (typeof inbound === "string" ? inbound.slice(0, 128) : void 0)));
|
|
983
|
+
res.statusCode = _chunkUXTIMS3Gcjs.responseStatusOf.call(void 0, error);
|
|
810
984
|
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
811
|
-
res.end(JSON.stringify(
|
|
985
|
+
res.end(JSON.stringify(_chunkUXTIMS3Gcjs.toClientError.call(void 0, error, requestId)));
|
|
812
986
|
};
|
|
813
987
|
}
|
|
814
988
|
var RESOURCE = /* @__PURE__ */ Symbol.for("autter.runtime.resource");
|
|
815
989
|
function autterFastify(fastify, options, done) {
|
|
816
990
|
const opts = _nullishCoalesce(options, () => ( {}));
|
|
817
|
-
const header = (_nullishCoalesce(opts.requestIdHeader, () => (
|
|
818
|
-
const ignored =
|
|
991
|
+
const header = (_nullishCoalesce(opts.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
992
|
+
const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, opts.ignore);
|
|
819
993
|
const stateOf = (request) => request[REQUEST_STATE];
|
|
820
994
|
fastify.addHook("onRequest", ((request, reply, next) => {
|
|
821
995
|
if (ignored(request.url) || request.raw[REQUEST_STATE]) {
|
|
822
996
|
next();
|
|
823
997
|
return;
|
|
824
998
|
}
|
|
825
|
-
const requestId =
|
|
999
|
+
const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
|
|
826
1000
|
opts.trustRequestId === false ? void 0 : request.headers[header]
|
|
827
1001
|
);
|
|
828
1002
|
const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
|
|
829
|
-
const state =
|
|
830
|
-
name: `${method} ${
|
|
1003
|
+
const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
|
|
1004
|
+
name: `${method} ${_chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, request.url)}`,
|
|
831
1005
|
requestId,
|
|
832
1006
|
req: request.raw,
|
|
833
1007
|
res: reply.raw
|
|
@@ -836,18 +1010,18 @@ function autterFastify(fastify, options, done) {
|
|
|
836
1010
|
request.raw[REQUEST_STATE] = state;
|
|
837
1011
|
reply.header(header, requestId);
|
|
838
1012
|
const span = _api.trace.getActiveSpan();
|
|
839
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1013
|
+
if (_optionalChain([span, 'optionalAccess', _24 => _24.isRecording, 'call', _25 => _25()]))
|
|
840
1014
|
span.setAttributes({
|
|
841
1015
|
"autter.request.id": requestId,
|
|
842
1016
|
"autter.operation.kind": "request"
|
|
843
1017
|
});
|
|
844
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
1018
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _26 => _26.spanContext, 'call', _27 => _27()]);
|
|
845
1019
|
bindEmitter(request.raw, state);
|
|
846
1020
|
bindEmitter(reply.raw, state);
|
|
847
1021
|
let finished = false;
|
|
848
1022
|
const finish = (aborted) => finishRequest(state, {
|
|
849
1023
|
method,
|
|
850
|
-
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access',
|
|
1024
|
+
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _28 => _28.routeOptions, 'optionalAccess', _29 => _29.url]), () => ( request.routerPath)), () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, request.url))),
|
|
851
1025
|
status: reply.raw.statusCode || reply.statusCode,
|
|
852
1026
|
aborted,
|
|
853
1027
|
...spanContext ? { span: spanContext } : {}
|
|
@@ -857,7 +1031,7 @@ function autterFastify(fastify, options, done) {
|
|
|
857
1031
|
finish(false);
|
|
858
1032
|
});
|
|
859
1033
|
reply.raw.once("close", () => finish(!finished));
|
|
860
|
-
|
|
1034
|
+
_chunkUXTIMS3Gcjs.local.run(state, () => {
|
|
861
1035
|
request[RESOURCE] = new (0, _async_hooks.AsyncResource)("autter-request");
|
|
862
1036
|
next();
|
|
863
1037
|
});
|
|
@@ -873,13 +1047,13 @@ function autterFastify(fastify, options, done) {
|
|
|
873
1047
|
const value = exposeHeaderValue(reply.getHeader("access-control-expose-headers"), header);
|
|
874
1048
|
if (value) reply.header("access-control-expose-headers", value);
|
|
875
1049
|
}
|
|
876
|
-
} catch (
|
|
1050
|
+
} catch (e19) {
|
|
877
1051
|
}
|
|
878
1052
|
next(null, payload);
|
|
879
1053
|
}));
|
|
880
1054
|
fastify.addHook("onError", ((request, _reply, error, next) => {
|
|
881
1055
|
const state = stateOf(request);
|
|
882
|
-
if (state)
|
|
1056
|
+
if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
|
|
883
1057
|
captureAtBoundary(error, state);
|
|
884
1058
|
next();
|
|
885
1059
|
}));
|
|
@@ -901,48 +1075,48 @@ function withHeaders(response, header, requestId) {
|
|
|
901
1075
|
};
|
|
902
1076
|
try {
|
|
903
1077
|
return apply(response);
|
|
904
|
-
} catch (
|
|
1078
|
+
} catch (e20) {
|
|
905
1079
|
try {
|
|
906
1080
|
return apply(new Response(response.body, response));
|
|
907
|
-
} catch (
|
|
1081
|
+
} catch (e21) {
|
|
908
1082
|
return response;
|
|
909
1083
|
}
|
|
910
1084
|
}
|
|
911
1085
|
}
|
|
912
1086
|
function withRuntimeRequest(handler, options = {}) {
|
|
913
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
914
|
-
const ignored =
|
|
1087
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkUXTIMS3Gcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1088
|
+
const ignored = _chunkUXTIMS3Gcjs.compileIgnore.call(void 0, options.ignore);
|
|
915
1089
|
return async (request, ...rest) => {
|
|
916
1090
|
let pathname = "/";
|
|
917
1091
|
try {
|
|
918
1092
|
pathname = new URL(request.url, "http://localhost").pathname;
|
|
919
|
-
} catch (
|
|
1093
|
+
} catch (e22) {
|
|
920
1094
|
}
|
|
921
1095
|
if (ignored(pathname)) return handler(request, ...rest);
|
|
922
|
-
const requestId =
|
|
1096
|
+
const requestId = _chunkUXTIMS3Gcjs.resolveRequestId.call(void 0,
|
|
923
1097
|
options.trustRequestId === false ? void 0 : request.headers.get(header)
|
|
924
1098
|
);
|
|
925
1099
|
const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
|
|
926
|
-
const route = _nullishCoalesce(options.route, () => (
|
|
927
|
-
const state =
|
|
1100
|
+
const route = _nullishCoalesce(options.route, () => ( _chunkUXTIMS3Gcjs.normalizeRoutePath.call(void 0, pathname)));
|
|
1101
|
+
const state = _chunkUXTIMS3Gcjs.createRequestState.call(void 0, {
|
|
928
1102
|
name: `${method} ${_nullishCoalesce(options.name, () => ( route))}`,
|
|
929
1103
|
requestId,
|
|
930
1104
|
req: request
|
|
931
1105
|
});
|
|
932
1106
|
const span = _api.trace.getActiveSpan();
|
|
933
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1107
|
+
if (_optionalChain([span, 'optionalAccess', _30 => _30.isRecording, 'call', _31 => _31()]))
|
|
934
1108
|
span.setAttributes({
|
|
935
1109
|
"autter.request.id": requestId,
|
|
936
1110
|
"autter.operation.kind": "request"
|
|
937
1111
|
});
|
|
938
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
1112
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _32 => _32.spanContext, 'call', _33 => _33()]);
|
|
939
1113
|
let status = 500;
|
|
940
1114
|
try {
|
|
941
|
-
const response = await
|
|
1115
|
+
const response = await _chunkUXTIMS3Gcjs.local.run(state, async () => {
|
|
942
1116
|
try {
|
|
943
1117
|
return await handler(request, ...rest);
|
|
944
1118
|
} catch (error) {
|
|
945
|
-
|
|
1119
|
+
_chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, true, state);
|
|
946
1120
|
captureAtBoundary(error, state, true);
|
|
947
1121
|
throw error;
|
|
948
1122
|
}
|
|
@@ -950,7 +1124,7 @@ function withRuntimeRequest(handler, options = {}) {
|
|
|
950
1124
|
status = response.status;
|
|
951
1125
|
return withHeaders(response, header, requestId);
|
|
952
1126
|
} finally {
|
|
953
|
-
const aborted = _optionalChain([request, 'access',
|
|
1127
|
+
const aborted = _optionalChain([request, 'access', _34 => _34.signal, 'optionalAccess', _35 => _35.aborted]) === true;
|
|
954
1128
|
finishRequest(state, {
|
|
955
1129
|
method,
|
|
956
1130
|
route,
|
|
@@ -961,9 +1135,9 @@ function withRuntimeRequest(handler, options = {}) {
|
|
|
961
1135
|
});
|
|
962
1136
|
if (options.waitUntil) {
|
|
963
1137
|
try {
|
|
964
|
-
options.waitUntil(
|
|
1138
|
+
options.waitUntil(_chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ).catch(() => {
|
|
965
1139
|
}));
|
|
966
|
-
} catch (
|
|
1140
|
+
} catch (e23) {
|
|
967
1141
|
}
|
|
968
1142
|
}
|
|
969
1143
|
}
|
|
@@ -973,10 +1147,143 @@ function startHookRequest(res) {
|
|
|
973
1147
|
const req = res.req;
|
|
974
1148
|
if (!req || req[REQUEST_STATE]) return;
|
|
975
1149
|
const state = beginNodeRequest(req, res, {});
|
|
976
|
-
|
|
1150
|
+
_chunkUXTIMS3Gcjs.local.enterWith(state);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
// src/unhandled-rejections.ts
|
|
1154
|
+
var MODES = /* @__PURE__ */ new Set([
|
|
1155
|
+
"throw",
|
|
1156
|
+
"strict",
|
|
1157
|
+
"warn",
|
|
1158
|
+
"warn-with-error-code",
|
|
1159
|
+
"none"
|
|
1160
|
+
]);
|
|
1161
|
+
var LISTENER_MARK = /* @__PURE__ */ Symbol.for("autter.runtime.unhandledRejection.listener");
|
|
1162
|
+
var HANDLED_KEY = /* @__PURE__ */ Symbol.for("autter.runtime.unhandledRejection.handled");
|
|
1163
|
+
function handledPromises() {
|
|
1164
|
+
const registry = globalThis;
|
|
1165
|
+
let set = registry[HANDLED_KEY];
|
|
1166
|
+
if (!set) {
|
|
1167
|
+
set = /* @__PURE__ */ new WeakSet();
|
|
1168
|
+
registry[HANDLED_KEY] = set;
|
|
1169
|
+
}
|
|
1170
|
+
return set;
|
|
1171
|
+
}
|
|
1172
|
+
var recorded = /* @__PURE__ */ new WeakSet();
|
|
1173
|
+
function markRecorded(reason) {
|
|
1174
|
+
if (!reason || typeof reason !== "object") return;
|
|
1175
|
+
recorded.add(reason);
|
|
1176
|
+
_optionalChain([setImmediate, 'call', _36 => _36(() => recorded.delete(reason)), 'access', _37 => _37.unref, 'optionalCall', _38 => _38()]);
|
|
1177
|
+
}
|
|
1178
|
+
function recordedAsRejection(error) {
|
|
1179
|
+
return !!error && typeof error === "object" && recorded.has(error);
|
|
1180
|
+
}
|
|
1181
|
+
function splitOptions(value) {
|
|
1182
|
+
return value ? value.split(/\s+/).filter(Boolean) : [];
|
|
1183
|
+
}
|
|
1184
|
+
function unhandledRejectionsMode(execArgv = process.execArgv, nodeOptions = process.env.NODE_OPTIONS) {
|
|
1185
|
+
const args = [...splitOptions(nodeOptions), ...execArgv];
|
|
1186
|
+
let mode = "throw";
|
|
1187
|
+
for (let i = 0; i < args.length; i++) {
|
|
1188
|
+
const arg = _nullishCoalesce(args[i], () => ( ""));
|
|
1189
|
+
if (!arg.startsWith("--")) continue;
|
|
1190
|
+
const eq = arg.indexOf("=");
|
|
1191
|
+
const name = (eq < 0 ? arg : arg.slice(0, eq)).replace(/_/g, "-");
|
|
1192
|
+
if (name !== "--unhandled-rejections") continue;
|
|
1193
|
+
const value = eq < 0 ? args[++i] : arg.slice(eq + 1);
|
|
1194
|
+
if (value && MODES.has(value))
|
|
1195
|
+
mode = value;
|
|
1196
|
+
}
|
|
1197
|
+
return mode;
|
|
1198
|
+
}
|
|
1199
|
+
function isErrorLike(value) {
|
|
1200
|
+
try {
|
|
1201
|
+
return typeof value === "object" && value !== null && Object.prototype.hasOwnProperty.call(value, "stack");
|
|
1202
|
+
} catch (e24) {
|
|
1203
|
+
return false;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
function describeReason(reason) {
|
|
1207
|
+
if (typeof reason !== "object" && typeof reason !== "function" || reason === null) {
|
|
1208
|
+
try {
|
|
1209
|
+
return String(reason);
|
|
1210
|
+
} catch (e25) {
|
|
1211
|
+
return typeof reason;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
try {
|
|
1215
|
+
const proto = Object.getPrototypeOf(reason);
|
|
1216
|
+
const ctor = _optionalChain([proto, 'optionalAccess', _39 => _39.constructor]);
|
|
1217
|
+
const name = typeof ctor === "function" ? ctor.name : "";
|
|
1218
|
+
return name ? `#<${name}>` : "[object Object]";
|
|
1219
|
+
} catch (e26) {
|
|
1220
|
+
return "[object Object]";
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
function toUncaught(reason, from) {
|
|
1224
|
+
if (isErrorLike(reason)) return reason;
|
|
1225
|
+
const error = new Error(
|
|
1226
|
+
`This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "${describeReason(reason)}".`
|
|
1227
|
+
);
|
|
1228
|
+
error.name = "UnhandledPromiseRejection";
|
|
1229
|
+
error.code = "ERR_UNHANDLED_REJECTION";
|
|
1230
|
+
_optionalChain([Error, 'access', _40 => _40.captureStackTrace, 'optionalCall', _41 => _41(error, from)]);
|
|
1231
|
+
return error;
|
|
1232
|
+
}
|
|
1233
|
+
var warningId = 0;
|
|
1234
|
+
function emitNodeWarning(reason) {
|
|
1235
|
+
try {
|
|
1236
|
+
const text = isErrorLike(reason) ? String(reason.stack) : describeReason(reason);
|
|
1237
|
+
process.emitWarning(text, "UnhandledPromiseRejectionWarning");
|
|
1238
|
+
process.emitWarning(
|
|
1239
|
+
`Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag \`--unhandled-rejections=strict\` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: ${++warningId})`,
|
|
1240
|
+
"UnhandledPromiseRejectionWarning"
|
|
1241
|
+
);
|
|
1242
|
+
} catch (e27) {
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMode()) {
|
|
1246
|
+
if (mode === "strict") return () => {
|
|
1247
|
+
};
|
|
1248
|
+
const listener = (reason, promise) => {
|
|
1249
|
+
try {
|
|
1250
|
+
if (promise && typeof promise === "object") {
|
|
1251
|
+
const handled = handledPromises();
|
|
1252
|
+
if (handled.has(promise)) return;
|
|
1253
|
+
handled.add(promise);
|
|
1254
|
+
}
|
|
1255
|
+
const alone = process.listeners("unhandledRejection").every((fn) => fn[LISTENER_MARK] === true);
|
|
1256
|
+
if (alone && mode === "throw") {
|
|
1257
|
+
const error = toUncaught(reason, listener);
|
|
1258
|
+
process.nextTick(() => {
|
|
1259
|
+
throw error;
|
|
1260
|
+
});
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
if (alone && mode === "warn-with-error-code") {
|
|
1264
|
+
emitNodeWarning(reason);
|
|
1265
|
+
process.exitCode = 1;
|
|
1266
|
+
}
|
|
1267
|
+
markRecorded(reason);
|
|
1268
|
+
capture(reason);
|
|
1269
|
+
} catch (e28) {
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
listener[LISTENER_MARK] = true;
|
|
1273
|
+
process.on("unhandledRejection", listener);
|
|
1274
|
+
return () => {
|
|
1275
|
+
process.off("unhandledRejection", listener);
|
|
1276
|
+
};
|
|
977
1277
|
}
|
|
978
1278
|
|
|
979
1279
|
// src/server.ts
|
|
1280
|
+
var S = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "server", () => ({
|
|
1281
|
+
active: null,
|
|
1282
|
+
alwaysOnProvider: null,
|
|
1283
|
+
redactor: _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true),
|
|
1284
|
+
loggerOnlyCapture: null,
|
|
1285
|
+
hookRequests: false
|
|
1286
|
+
}));
|
|
980
1287
|
var LLM_MARKER_ATTRIBUTES = [
|
|
981
1288
|
"gen_ai.operation.name",
|
|
982
1289
|
"gen_ai.system",
|
|
@@ -1073,7 +1380,7 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
|
|
|
1073
1380
|
this.retainErrors = retainErrors;
|
|
1074
1381
|
this.slowThresholdMs = slowThresholdMs;
|
|
1075
1382
|
this.sweeper = setInterval(() => this.sweep(), RETENTION_SWEEP_INTERVAL_MS);
|
|
1076
|
-
_optionalChain([this, 'access',
|
|
1383
|
+
_optionalChain([this, 'access', _42 => _42.sweeper, 'access', _43 => _43.unref, 'optionalCall', _44 => _44()]);
|
|
1077
1384
|
}
|
|
1078
1385
|
|
|
1079
1386
|
|
|
@@ -1104,9 +1411,9 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
|
|
|
1104
1411
|
}
|
|
1105
1412
|
/** Promote the active trace, if any — called on captured errors. */
|
|
1106
1413
|
retainActiveTrace() {
|
|
1107
|
-
const
|
|
1108
|
-
if (!
|
|
1109
|
-
const entry = this.entryFor(
|
|
1414
|
+
const active = _optionalChain([_api.trace, 'access', _45 => _45.getActiveSpan, 'call', _46 => _46(), 'optionalAccess', _47 => _47.spanContext, 'call', _48 => _48()]);
|
|
1415
|
+
if (!active || (active.traceFlags & _api.TraceFlags.SAMPLED) !== 0) return;
|
|
1416
|
+
const entry = this.entryFor(active.traceId);
|
|
1110
1417
|
if (entry.retained) return;
|
|
1111
1418
|
entry.retained = true;
|
|
1112
1419
|
this.flush(entry);
|
|
@@ -1173,7 +1480,7 @@ function llmBaseAttributes(info) {
|
|
|
1173
1480
|
...info.sessionId ? { "autter.session_id": info.sessionId } : {},
|
|
1174
1481
|
// Caller-supplied extras go through redaction like every other
|
|
1175
1482
|
// custom attribute family (prompts can contain emails/keys).
|
|
1176
|
-
...info.attributes ?
|
|
1483
|
+
...info.attributes ? S.redactor(info.attributes) : {}
|
|
1177
1484
|
};
|
|
1178
1485
|
}
|
|
1179
1486
|
function usageAttributes(usage) {
|
|
@@ -1214,7 +1521,7 @@ async function runLlmSpan(tracer, info, fn) {
|
|
|
1214
1521
|
},
|
|
1215
1522
|
setResponseModel,
|
|
1216
1523
|
setModel: setResponseModel,
|
|
1217
|
-
setAttributes: (attributes) => span.setAttributes(
|
|
1524
|
+
setAttributes: (attributes) => span.setAttributes(S.redactor(attributes))
|
|
1218
1525
|
};
|
|
1219
1526
|
try {
|
|
1220
1527
|
const result = await _api.context.with(
|
|
@@ -1225,15 +1532,15 @@ async function runLlmSpan(tracer, info, fn) {
|
|
|
1225
1532
|
return result;
|
|
1226
1533
|
} catch (err) {
|
|
1227
1534
|
recordError(span, err);
|
|
1228
|
-
if (
|
|
1535
|
+
if (_chunkUXTIMS3Gcjs.isError.call(void 0, err)) span.setAttribute("error.type", err.name);
|
|
1229
1536
|
throw err;
|
|
1230
1537
|
} finally {
|
|
1231
1538
|
span.end();
|
|
1232
|
-
|
|
1539
|
+
_chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
|
|
1233
1540
|
}
|
|
1234
1541
|
}
|
|
1235
1542
|
function recordLlmCall(tracer, call) {
|
|
1236
|
-
|
|
1543
|
+
_chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
|
|
1237
1544
|
const durationMs = Math.max(0, _nullishCoalesce(call.durationMs, () => ( 0)));
|
|
1238
1545
|
const endTime = /* @__PURE__ */ new Date();
|
|
1239
1546
|
const startTime = new Date(endTime.getTime() - durationMs);
|
|
@@ -1247,7 +1554,7 @@ function recordLlmCall(tracer, call) {
|
|
|
1247
1554
|
);
|
|
1248
1555
|
if (call.error !== void 0 && call.error !== null) {
|
|
1249
1556
|
recordError(span, call.error);
|
|
1250
|
-
if (call.error
|
|
1557
|
+
if (_chunkUXTIMS3Gcjs.isError.call(void 0, call.error)) {
|
|
1251
1558
|
span.setAttribute("error.type", call.error.name);
|
|
1252
1559
|
}
|
|
1253
1560
|
} else {
|
|
@@ -1258,7 +1565,7 @@ function recordLlmCall(tracer, call) {
|
|
|
1258
1565
|
async function runWithSpan(tracer, name, fn, attributes, links) {
|
|
1259
1566
|
const span = tracer.startSpan(name, {
|
|
1260
1567
|
attributes,
|
|
1261
|
-
..._optionalChain([links, 'optionalAccess',
|
|
1568
|
+
..._optionalChain([links, 'optionalAccess', _49 => _49.length]) ? { links } : {}
|
|
1262
1569
|
});
|
|
1263
1570
|
try {
|
|
1264
1571
|
const result = await _api.context.with(
|
|
@@ -1275,24 +1582,25 @@ async function runWithSpan(tracer, name, fn, attributes, links) {
|
|
|
1275
1582
|
}
|
|
1276
1583
|
}
|
|
1277
1584
|
function recordError(span, err) {
|
|
1278
|
-
const
|
|
1279
|
-
const message =
|
|
1280
|
-
if (
|
|
1585
|
+
const isErr = _chunkUXTIMS3Gcjs.isError.call(void 0, err);
|
|
1586
|
+
const message = S.redactor.text(isErr ? err.message : String(err));
|
|
1587
|
+
if (isErr) {
|
|
1281
1588
|
span.addEvent("exception", {
|
|
1282
1589
|
"exception.type": err.name,
|
|
1283
1590
|
"exception.message": message,
|
|
1284
|
-
...err.stack ? { "exception.stacktrace":
|
|
1591
|
+
...err.stack ? { "exception.stacktrace": S.redactor.text(err.stack) } : {},
|
|
1592
|
+
..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text, err)
|
|
1285
1593
|
});
|
|
1286
1594
|
}
|
|
1287
1595
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
|
|
1288
1596
|
}
|
|
1289
1597
|
function redactWithActive(attributes) {
|
|
1290
|
-
return
|
|
1598
|
+
return S.redactor(attributes);
|
|
1291
1599
|
}
|
|
1292
1600
|
function captureExpressRoute(_span, response) {
|
|
1293
1601
|
if (!(response instanceof _http.ServerResponse)) return;
|
|
1294
1602
|
const rpcMetadata = _core.getRPCMetadata.call(void 0, _api.context.active());
|
|
1295
|
-
if (_optionalChain([rpcMetadata, 'optionalAccess',
|
|
1603
|
+
if (_optionalChain([rpcMetadata, 'optionalAccess', _50 => _50.type]) !== _core.RPCType.HTTP) return;
|
|
1296
1604
|
const setRoute = () => {
|
|
1297
1605
|
if (rpcMetadata.route) return;
|
|
1298
1606
|
const route = expressRouteOf(response.req);
|
|
@@ -1300,44 +1608,43 @@ function captureExpressRoute(_span, response) {
|
|
|
1300
1608
|
};
|
|
1301
1609
|
response.prependListener("finish", setRoute);
|
|
1302
1610
|
response.prependListener("close", setRoute);
|
|
1303
|
-
if (hookRequests) startHookRequest(response);
|
|
1611
|
+
if (S.hookRequests) startHookRequest(response);
|
|
1304
1612
|
}
|
|
1305
|
-
var hookRequests = false;
|
|
1306
1613
|
function structuredErrorAttributes(error) {
|
|
1307
|
-
const attrs = { ...
|
|
1308
|
-
const internal =
|
|
1614
|
+
const attrs = { ..._chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error, { causes: false }) };
|
|
1615
|
+
const internal = _chunkUXTIMS3Gcjs.errorInternal.call(void 0, error);
|
|
1309
1616
|
if (internal) {
|
|
1310
1617
|
try {
|
|
1311
1618
|
attrs["autter.error.internal"] = JSON.stringify(
|
|
1312
|
-
|
|
1619
|
+
S.redactor(internal)
|
|
1313
1620
|
).slice(0, 4e3);
|
|
1314
|
-
} catch (
|
|
1621
|
+
} catch (e29) {
|
|
1315
1622
|
}
|
|
1316
1623
|
}
|
|
1317
1624
|
return attrs;
|
|
1318
1625
|
}
|
|
1319
|
-
var active = null;
|
|
1320
|
-
var activeAlwaysOnProvider = null;
|
|
1321
|
-
var activeRedactor = _chunkP4VRTFAVcjs.makeRedactor.call(void 0, true);
|
|
1322
1626
|
function initAutterServer(options) {
|
|
1323
|
-
if (active) return active;
|
|
1627
|
+
if (S.active) return S.active;
|
|
1324
1628
|
const endpoint = (_nullishCoalesce(options.endpoint, () => ( "https://otlp.autter.dev"))).replace(
|
|
1325
1629
|
/\/$/,
|
|
1326
1630
|
""
|
|
1327
1631
|
);
|
|
1328
1632
|
const headers = { authorization: `Bearer ${options.apiKey}` };
|
|
1329
|
-
const
|
|
1633
|
+
const redactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
|
|
1634
|
+
const queryPolicy = makeUrlQueryPolicy(options.keepQueryParams);
|
|
1635
|
+
const traceExporter = () => new (0, _chunk4MVWIRBIcjs.CountingExporter)(
|
|
1330
1636
|
new RedactingSpanExporter(
|
|
1331
1637
|
new (0, _exportertraceotlphttp.OTLPTraceExporter)({ url: `${endpoint}/v1/traces`, headers }),
|
|
1332
|
-
() =>
|
|
1638
|
+
() => redactor,
|
|
1639
|
+
queryPolicy
|
|
1333
1640
|
)
|
|
1334
1641
|
);
|
|
1335
1642
|
const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
|
|
1336
|
-
if (
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
const distro = _nullishCoalesce(options.distro, () => (
|
|
1340
|
-
|
|
1643
|
+
if (_chunk4MVWIRBIcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk4MVWIRBIcjs.setDebugMode.call(void 0, true);
|
|
1644
|
+
_chunk4MVWIRBIcjs.debugLog.call(void 0, `initialising service=${options.service} endpoint=${endpoint}`);
|
|
1645
|
+
S.redactor = redactor;
|
|
1646
|
+
const distro = _nullishCoalesce(options.distro, () => ( _chunk4MVWIRBIcjs.SDK_IDENTITY));
|
|
1647
|
+
_chunk4MVWIRBIcjs.configureCompatCheck.call(void 0, { endpoint, enabled: options.compatCheck !== false, sdk: distro });
|
|
1341
1648
|
const resource = new (0, _resources.Resource)({
|
|
1342
1649
|
[_semanticconventions.ATTR_SERVICE_NAME]: options.service,
|
|
1343
1650
|
"service.instance.id": (options.instanceId || process.env.AUTTER_RUNTIME_INSTANCE_ID || _crypto.randomUUID.call(void 0, )).slice(0, 128),
|
|
@@ -1352,8 +1659,15 @@ function initAutterServer(options) {
|
|
|
1352
1659
|
// would double-count every sampled request).
|
|
1353
1660
|
"autter.metrics_wired": true
|
|
1354
1661
|
});
|
|
1662
|
+
const rootSampler = new (0, _sdktracebase.TraceIdRatioBasedSampler)(_nullishCoalesce(options.traceSampleRate, () => ( 0.01)));
|
|
1355
1663
|
const headSampler = new (0, _sdktracebase.ParentBasedSampler)({
|
|
1356
|
-
root:
|
|
1664
|
+
root: rootSampler,
|
|
1665
|
+
// Browsers (runtime-browser's traceparent) send unsampled parents: they
|
|
1666
|
+
// make no sampling decision. Apply this service's own rate to such
|
|
1667
|
+
// requests instead of never head-sampling them. The ratio sampler is
|
|
1668
|
+
// deterministic by trace id, so services sharing a rate still agree
|
|
1669
|
+
// with an upstream service that chose not to sample.
|
|
1670
|
+
remoteParentNotSampled: rootSampler
|
|
1357
1671
|
});
|
|
1358
1672
|
const retainOnError = options.retainTracesOnError !== false;
|
|
1359
1673
|
const slowThresholdMs = Number.isFinite(options.retainTracesAboveMs) ? Math.max(0, options.retainTracesAboveMs) : 0;
|
|
@@ -1377,7 +1691,7 @@ function initAutterServer(options) {
|
|
|
1377
1691
|
// 60 s export.
|
|
1378
1692
|
temporalityPreference: _exportermetricsotlphttp.AggregationTemporalityPreference.DELTA
|
|
1379
1693
|
}),
|
|
1380
|
-
() =>
|
|
1694
|
+
() => redactor
|
|
1381
1695
|
),
|
|
1382
1696
|
exportIntervalMillis: _nullishCoalesce(options.metricIntervalMs, () => ( 6e4))
|
|
1383
1697
|
});
|
|
@@ -1404,9 +1718,9 @@ function initAutterServer(options) {
|
|
|
1404
1718
|
});
|
|
1405
1719
|
sdk.start();
|
|
1406
1720
|
const stopMemoryMetrics = options.memoryMetrics === false ? null : startMemoryMetrics();
|
|
1407
|
-
|
|
1408
|
-
if (stopMemoryMetrics)
|
|
1409
|
-
if (options.llmTracing !== false)
|
|
1721
|
+
_chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "endpoint_latency");
|
|
1722
|
+
if (stopMemoryMetrics) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "memory_metrics");
|
|
1723
|
+
if (options.llmTracing !== false) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "llm_calls");
|
|
1410
1724
|
const alwaysOnProvider = new (0, _sdktracebase.BasicTracerProvider)({
|
|
1411
1725
|
resource,
|
|
1412
1726
|
sampler: new (0, _sdktracebase.AlwaysOnSampler)(),
|
|
@@ -1418,21 +1732,25 @@ function initAutterServer(options) {
|
|
|
1418
1732
|
const processTracer = alwaysOnProvider.getTracer("autter-processes");
|
|
1419
1733
|
const llmTracer = alwaysOnProvider.getTracer("autter-llm");
|
|
1420
1734
|
function captureException2(error, attributes) {
|
|
1421
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
1422
|
-
|
|
1423
|
-
const
|
|
1424
|
-
const message =
|
|
1425
|
-
const stackText =
|
|
1426
|
-
const
|
|
1735
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _51 => _51.retainActiveTrace, 'call', _52 => _52()]);
|
|
1736
|
+
_chunk4MVWIRBIcjs.telemetryStats.markCaptured();
|
|
1737
|
+
const isErr = _chunkUXTIMS3Gcjs.isError.call(void 0, error);
|
|
1738
|
+
const message = redactor.text(isErr ? error.message : String(error));
|
|
1739
|
+
const stackText = isErr && error.stack ? redactor.text(error.stack) : "";
|
|
1740
|
+
const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
|
|
1741
|
+
const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
|
|
1742
|
+
if (fingerprint["autter.fingerprint"]) _chunk4MVWIRBIcjs.noteCompatFeature.call(void 0, "fingerprint_override");
|
|
1743
|
+
const redacted = redactor(split.attributes);
|
|
1427
1744
|
const activeSpan = _api.trace.getActiveSpan();
|
|
1428
|
-
const reuseActive = _optionalChain([activeSpan, 'optionalAccess',
|
|
1429
|
-
const span = reuseActive ? activeSpan : errorTracer.startSpan(
|
|
1745
|
+
const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _53 => _53.isRecording, 'call', _54 => _54()]) === true;
|
|
1746
|
+
const span = reuseActive ? activeSpan : errorTracer.startSpan(isErr ? error.name : "Error");
|
|
1430
1747
|
const structured = structuredErrorAttributes(error);
|
|
1431
|
-
const causes =
|
|
1432
|
-
const declared =
|
|
1433
|
-
Object.entries(causes).filter(([key]) => key !== "autter.error.internal")
|
|
1434
|
-
|
|
1435
|
-
|
|
1748
|
+
const causes = _chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error);
|
|
1749
|
+
const declared = {
|
|
1750
|
+
...Object.fromEntries(Object.entries(causes).filter(([key]) => key !== "autter.error.internal")),
|
|
1751
|
+
...fingerprint
|
|
1752
|
+
};
|
|
1753
|
+
const requestId = _optionalChain([_chunkUXTIMS3Gcjs.currentOperation.call(void 0, ), 'optionalAccess', _55 => _55.requestId]);
|
|
1436
1754
|
span.setAttributes({
|
|
1437
1755
|
"autter.severity": "error",
|
|
1438
1756
|
...redacted,
|
|
@@ -1440,24 +1758,26 @@ function initAutterServer(options) {
|
|
|
1440
1758
|
...requestId ? { "autter.request.id": requestId } : {}
|
|
1441
1759
|
});
|
|
1442
1760
|
markCaptured(error);
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
if (
|
|
1761
|
+
_chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
|
|
1762
|
+
_chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
1763
|
+
if (isErr && stackText) {
|
|
1446
1764
|
span.addEvent("exception", {
|
|
1447
1765
|
"exception.type": error.name,
|
|
1448
1766
|
"exception.message": message,
|
|
1449
1767
|
"exception.stacktrace": stackText,
|
|
1450
1768
|
...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
|
|
1451
|
-
...declared
|
|
1769
|
+
...declared,
|
|
1770
|
+
..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
|
|
1452
1771
|
});
|
|
1453
1772
|
} else {
|
|
1454
|
-
const stack = _optionalChain([new Error(), 'access',
|
|
1773
|
+
const stack = _optionalChain([new Error(), 'access', _56 => _56.stack, 'optionalAccess', _57 => _57.split, 'call', _58 => _58("\n"), 'access', _59 => _59.filter, 'call', _60 => _60((line, i) => i === 0 || !line.includes("captureException")), 'access', _61 => _61.join, 'call', _62 => _62("\n")]);
|
|
1455
1774
|
span.addEvent("exception", {
|
|
1456
|
-
"exception.type":
|
|
1775
|
+
"exception.type": isErr ? error.name : "Error",
|
|
1457
1776
|
"exception.message": message,
|
|
1458
|
-
...stack ? { "exception.stacktrace":
|
|
1777
|
+
...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
|
|
1459
1778
|
...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
|
|
1460
|
-
...declared
|
|
1779
|
+
...declared,
|
|
1780
|
+
..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
|
|
1461
1781
|
});
|
|
1462
1782
|
}
|
|
1463
1783
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
|
|
@@ -1465,34 +1785,35 @@ function initAutterServer(options) {
|
|
|
1465
1785
|
}
|
|
1466
1786
|
function captureMessage2(message, severity = "warning", attributes) {
|
|
1467
1787
|
if (severity === "error" || severity === "fatal") {
|
|
1468
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
1788
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _63 => _63.retainActiveTrace, 'call', _64 => _64()]);
|
|
1469
1789
|
}
|
|
1470
|
-
|
|
1471
|
-
const stack = _optionalChain([new Error(), 'access',
|
|
1472
|
-
const safeMessage =
|
|
1790
|
+
_chunk4MVWIRBIcjs.telemetryStats.markCaptured();
|
|
1791
|
+
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("captureMessage")), 'access', _70 => _70.join, 'call', _71 => _71("\n")]);
|
|
1792
|
+
const safeMessage = redactor.text(message);
|
|
1473
1793
|
const span = errorTracer.startSpan("Message", {
|
|
1474
|
-
attributes: { "autter.severity": severity, ...
|
|
1794
|
+
attributes: { "autter.severity": severity, ...redactor(attributes) }
|
|
1475
1795
|
});
|
|
1476
1796
|
span.addEvent("exception", {
|
|
1477
1797
|
"exception.type": "Message",
|
|
1478
1798
|
"exception.message": safeMessage,
|
|
1479
|
-
...stack ? { "exception.stacktrace":
|
|
1480
|
-
"autter.severity": severity
|
|
1799
|
+
...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
|
|
1800
|
+
"autter.severity": severity,
|
|
1801
|
+
..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, redactor.text)
|
|
1481
1802
|
});
|
|
1482
1803
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
|
|
1483
1804
|
span.end();
|
|
1484
1805
|
}
|
|
1485
1806
|
function reportOutcome2(name, message, attributes) {
|
|
1486
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
1487
|
-
|
|
1807
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _72 => _72.retainActiveTrace, 'call', _73 => _73()]);
|
|
1808
|
+
_chunk4MVWIRBIcjs.telemetryStats.markCaptured();
|
|
1488
1809
|
const activeSpan = _api.trace.getActiveSpan();
|
|
1489
|
-
const reuseActive = _optionalChain([activeSpan, 'optionalAccess',
|
|
1810
|
+
const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _74 => _74.isRecording, 'call', _75 => _75()]) === true;
|
|
1490
1811
|
const span = reuseActive ? activeSpan : errorTracer.startSpan("OutcomeFailure");
|
|
1491
|
-
const safeOutcome =
|
|
1812
|
+
const safeOutcome = redactor({ "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
|
|
1492
1813
|
const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
|
|
1493
1814
|
const safeMessage = String(_nullishCoalesce(safeOutcome["autter.outcome.message"], () => ( "failed")));
|
|
1494
1815
|
span.addEvent("autter.outcome", {
|
|
1495
|
-
...
|
|
1816
|
+
...redactor(attributes),
|
|
1496
1817
|
"autter.outcome.status": "error",
|
|
1497
1818
|
"autter.outcome.name": safeName,
|
|
1498
1819
|
"autter.outcome.message": safeMessage
|
|
@@ -1500,7 +1821,7 @@ function initAutterServer(options) {
|
|
|
1500
1821
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
|
|
1501
1822
|
if (!reuseActive) span.end();
|
|
1502
1823
|
}
|
|
1503
|
-
|
|
1824
|
+
_chunkUXTIMS3Gcjs.configureRuntimeLogger.call(void 0, {
|
|
1504
1825
|
endpoint,
|
|
1505
1826
|
apiKey: options.apiKey,
|
|
1506
1827
|
service: options.service,
|
|
@@ -1508,22 +1829,31 @@ function initAutterServer(options) {
|
|
|
1508
1829
|
distro,
|
|
1509
1830
|
release: options.release,
|
|
1510
1831
|
options: options.logging,
|
|
1511
|
-
redact:
|
|
1512
|
-
run: (name, fn, attributes, links) => runWithSpan(processTracer, name, fn,
|
|
1832
|
+
redact: redactor,
|
|
1833
|
+
run: (name, fn, attributes, links) => runWithSpan(processTracer, name, fn, redactor(attributes), links),
|
|
1513
1834
|
reportOutcome: reportOutcome2
|
|
1514
1835
|
});
|
|
1515
|
-
hookRequests = _optionalChain([options, 'access',
|
|
1836
|
+
S.hookRequests = _optionalChain([options, 'access', _76 => _76.logging, 'optionalAccess', _77 => _77.requests]) === true;
|
|
1837
|
+
let onCrash = null;
|
|
1838
|
+
let uninstallRejections = null;
|
|
1516
1839
|
if (options.captureGlobalErrors !== false) {
|
|
1517
|
-
|
|
1840
|
+
onCrash = (err) => {
|
|
1841
|
+
if (recordedAsRejection(err)) return;
|
|
1518
1842
|
captureException2(err, { "autter.unhandled": true });
|
|
1519
1843
|
if (options.autoFlush === false) void Promise.resolve(flushTarget.forceFlush()).catch(() => {
|
|
1520
1844
|
});
|
|
1521
|
-
}
|
|
1845
|
+
};
|
|
1846
|
+
process.on("uncaughtExceptionMonitor", onCrash);
|
|
1847
|
+
if (options.captureUnhandledRejections !== false) {
|
|
1848
|
+
uninstallRejections = installUnhandledRejectionCapture(
|
|
1849
|
+
(reason) => captureException2(reason, { "autter.unhandled_rejection": true })
|
|
1850
|
+
);
|
|
1851
|
+
}
|
|
1522
1852
|
}
|
|
1523
1853
|
const flushTarget = {
|
|
1524
1854
|
forceFlush: async () => {
|
|
1525
1855
|
const results = await Promise.allSettled([
|
|
1526
|
-
|
|
1856
|
+
_chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ),
|
|
1527
1857
|
Promise.resolve().then(() => alwaysOnProvider.forceFlush()),
|
|
1528
1858
|
Promise.resolve().then(() => mainSpanProcessor.forceFlush()),
|
|
1529
1859
|
...errorTraceBuffer ? [Promise.resolve().then(() => errorTraceBuffer.forceFlush())] : [],
|
|
@@ -1537,107 +1867,118 @@ function initAutterServer(options) {
|
|
|
1537
1867
|
}
|
|
1538
1868
|
}
|
|
1539
1869
|
};
|
|
1540
|
-
|
|
1870
|
+
_chunk4MVWIRBIcjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
|
|
1541
1871
|
let autoFlushHandle = null;
|
|
1542
1872
|
if (options.autoFlush !== false) {
|
|
1543
|
-
autoFlushHandle =
|
|
1873
|
+
autoFlushHandle = _chunk4MVWIRBIcjs.installAutterAutoFlush.call(void 0, );
|
|
1544
1874
|
}
|
|
1545
1875
|
const server = {
|
|
1546
1876
|
captureException: captureException2,
|
|
1547
1877
|
captureMessage: captureMessage2,
|
|
1548
1878
|
reportOutcome: reportOutcome2,
|
|
1549
|
-
withProcessSpan: (name, fn, attributes) => runWithSpan(processTracer, name, fn,
|
|
1879
|
+
withProcessSpan: (name, fn, attributes) => runWithSpan(processTracer, name, fn, redactor(attributes)),
|
|
1550
1880
|
withLlmCall: (info, fn) => runLlmSpan(llmTracer, info, fn),
|
|
1551
1881
|
trackLlmCall: (call) => recordLlmCall(llmTracer, call),
|
|
1552
1882
|
shutdown: async () => {
|
|
1553
|
-
const logShutdown = await Promise.allSettled([
|
|
1554
|
-
|
|
1555
|
-
_optionalChain([
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1883
|
+
const logShutdown = await Promise.allSettled([_chunkUXTIMS3Gcjs.shutdownRuntimeLogger.call(void 0, )]);
|
|
1884
|
+
if (onCrash) process.off("uncaughtExceptionMonitor", onCrash);
|
|
1885
|
+
_optionalChain([uninstallRejections, 'optionalCall', _78 => _78()]);
|
|
1886
|
+
_optionalChain([stopMemoryMetrics, 'optionalCall', _79 => _79()]);
|
|
1887
|
+
if (S.active === server) {
|
|
1888
|
+
S.active = null;
|
|
1889
|
+
S.alwaysOnProvider = null;
|
|
1890
|
+
S.hookRequests = false;
|
|
1891
|
+
S.redactor = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, true);
|
|
1892
|
+
}
|
|
1893
|
+
_optionalChain([autoFlushHandle, 'optionalAccess', _80 => _80.dispose, 'call', _81 => _81()]);
|
|
1559
1894
|
autoFlushHandle = null;
|
|
1560
|
-
|
|
1561
|
-
|
|
1895
|
+
_chunk4MVWIRBIcjs.unregisterFlushTargets.call(void 0, );
|
|
1896
|
+
_chunk4MVWIRBIcjs.telemetryStats.markAllFlushed();
|
|
1562
1897
|
await Promise.allSettled([alwaysOnProvider.shutdown(), sdk.shutdown()]);
|
|
1563
|
-
if (_optionalChain([logShutdown, 'access',
|
|
1898
|
+
if (_optionalChain([logShutdown, 'access', _82 => _82[0], 'optionalAccess', _83 => _83.status]) === "rejected") throw logShutdown[0].reason;
|
|
1564
1899
|
}
|
|
1565
1900
|
};
|
|
1566
|
-
active = server;
|
|
1567
|
-
|
|
1901
|
+
S.active = server;
|
|
1902
|
+
S.alwaysOnProvider = alwaysOnProvider;
|
|
1568
1903
|
return server;
|
|
1569
1904
|
}
|
|
1570
1905
|
function captureException(error, attributes) {
|
|
1571
|
-
if (active) {
|
|
1572
|
-
active.captureException(error, attributes);
|
|
1906
|
+
if (S.active) {
|
|
1907
|
+
S.active.captureException(error, attributes);
|
|
1573
1908
|
return;
|
|
1574
1909
|
}
|
|
1575
|
-
if (loggerOnlyCapture) {
|
|
1576
|
-
loggerOnlyCapture(error, attributes);
|
|
1910
|
+
if (S.loggerOnlyCapture) {
|
|
1911
|
+
S.loggerOnlyCapture(error, attributes);
|
|
1577
1912
|
return;
|
|
1578
1913
|
}
|
|
1579
1914
|
markCaptured(error);
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1915
|
+
_chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
|
|
1916
|
+
const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
|
|
1917
|
+
const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text);
|
|
1918
|
+
_chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...split.attributes, ...fingerprint });
|
|
1919
|
+
const span = _api.trace.getTracer("autter-errors").startSpan(_chunkUXTIMS3Gcjs.isError.call(void 0, error) ? error.name : "Error", {
|
|
1920
|
+
attributes: { ...S.redactor(split.attributes), ...fingerprint }
|
|
1584
1921
|
});
|
|
1585
1922
|
recordError(span, error);
|
|
1586
1923
|
span.end();
|
|
1587
1924
|
}
|
|
1588
|
-
var loggerOnlyCapture = null;
|
|
1589
1925
|
function setLoggerOnlyCapture(fn) {
|
|
1590
|
-
loggerOnlyCapture = fn;
|
|
1926
|
+
S.loggerOnlyCapture = fn;
|
|
1591
1927
|
}
|
|
1592
1928
|
function serverActive() {
|
|
1593
|
-
return active !== null;
|
|
1929
|
+
return S.active !== null;
|
|
1594
1930
|
}
|
|
1595
|
-
setRequestExceptionCapturer((error) => captureException(error));
|
|
1931
|
+
setRequestExceptionCapturer((error, attributes) => captureException(error, attributes));
|
|
1932
|
+
setRequestSpanAnnotator((attributes) => {
|
|
1933
|
+
const span = _api.trace.getActiveSpan();
|
|
1934
|
+
if (_optionalChain([span, 'optionalAccess', _84 => _84.isRecording, 'call', _85 => _85()])) span.setAttributes(S.redactor(_chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes).attributes));
|
|
1935
|
+
});
|
|
1596
1936
|
function withProcessSpan(name, fn, attributes) {
|
|
1597
|
-
if (active) return active.withProcessSpan(name, fn, attributes);
|
|
1937
|
+
if (S.active) return S.active.withProcessSpan(name, fn, attributes);
|
|
1598
1938
|
return runWithSpan(
|
|
1599
1939
|
_api.trace.getTracer("autter-processes"),
|
|
1600
1940
|
name,
|
|
1601
1941
|
fn,
|
|
1602
|
-
|
|
1942
|
+
S.redactor(attributes)
|
|
1603
1943
|
);
|
|
1604
1944
|
}
|
|
1605
1945
|
function withLlmCall(info, fn) {
|
|
1606
|
-
if (active) return active.withLlmCall(info, fn);
|
|
1946
|
+
if (S.active) return S.active.withLlmCall(info, fn);
|
|
1607
1947
|
return runLlmSpan(_api.trace.getTracer("autter-llm"), info, fn);
|
|
1608
1948
|
}
|
|
1609
1949
|
function trackLlmCall(call) {
|
|
1610
|
-
if (active) {
|
|
1611
|
-
active.trackLlmCall(call);
|
|
1950
|
+
if (S.active) {
|
|
1951
|
+
S.active.trackLlmCall(call);
|
|
1612
1952
|
return;
|
|
1613
1953
|
}
|
|
1614
1954
|
recordLlmCall(_api.trace.getTracer("autter-llm"), call);
|
|
1615
1955
|
}
|
|
1616
1956
|
function captureMessage(message, severity = "warning", attributes) {
|
|
1617
|
-
if (active) {
|
|
1618
|
-
active.captureMessage(message, severity, attributes);
|
|
1957
|
+
if (S.active) {
|
|
1958
|
+
S.active.captureMessage(message, severity, attributes);
|
|
1619
1959
|
return;
|
|
1620
1960
|
}
|
|
1621
|
-
const safeMessage =
|
|
1961
|
+
const safeMessage = S.redactor.text(message);
|
|
1622
1962
|
const span = _api.trace.getTracer("autter-errors").startSpan("Message", {
|
|
1623
|
-
attributes: { "autter.severity": severity, ...
|
|
1963
|
+
attributes: { "autter.severity": severity, ...S.redactor(attributes) }
|
|
1624
1964
|
});
|
|
1625
1965
|
span.addEvent("exception", {
|
|
1626
1966
|
"exception.type": "Message",
|
|
1627
1967
|
"exception.message": safeMessage,
|
|
1628
|
-
"autter.severity": severity
|
|
1968
|
+
"autter.severity": severity,
|
|
1969
|
+
..._chunkUXTIMS3Gcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text)
|
|
1629
1970
|
});
|
|
1630
1971
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
|
|
1631
1972
|
span.end();
|
|
1632
1973
|
}
|
|
1633
1974
|
function reportOutcome(name, message, attributes) {
|
|
1634
|
-
if (active) return active.reportOutcome(name, message, attributes);
|
|
1975
|
+
if (S.active) return S.active.reportOutcome(name, message, attributes);
|
|
1635
1976
|
const span = _api.trace.getTracer("autter-outcomes").startSpan("OutcomeFailure");
|
|
1636
|
-
const safeOutcome =
|
|
1977
|
+
const safeOutcome = _chunkUXTIMS3Gcjs.redactAttributes.call(void 0, { "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
|
|
1637
1978
|
const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
|
|
1638
1979
|
const safeMessage = String(_nullishCoalesce(safeOutcome["autter.outcome.message"], () => ( "failed")));
|
|
1639
1980
|
span.addEvent("autter.outcome", {
|
|
1640
|
-
...
|
|
1981
|
+
..._chunkUXTIMS3Gcjs.redactAttributes.call(void 0, attributes),
|
|
1641
1982
|
"autter.outcome.status": "error",
|
|
1642
1983
|
"autter.outcome.name": safeName,
|
|
1643
1984
|
"autter.outcome.message": safeMessage
|
|
@@ -1646,20 +1987,20 @@ function reportOutcome(name, message, attributes) {
|
|
|
1646
1987
|
span.end();
|
|
1647
1988
|
}
|
|
1648
1989
|
function makeSafeCapture(options) {
|
|
1649
|
-
const clean = (attributes) => attributes ? { ...
|
|
1990
|
+
const clean = (attributes) => attributes ? { ..._chunkUXTIMS3Gcjs.redactAttributes.call(void 0, attributes, options) } : void 0;
|
|
1650
1991
|
return {
|
|
1651
1992
|
captureException: (error, attributes) => captureException(error, clean(attributes)),
|
|
1652
1993
|
captureMessage: (message, severity, attributes) => captureMessage(message, _nullishCoalesce(severity, () => ( "warning")), clean(attributes))
|
|
1653
1994
|
};
|
|
1654
1995
|
}
|
|
1655
1996
|
function alwaysOnTracer(name) {
|
|
1656
|
-
return
|
|
1997
|
+
return S.alwaysOnProvider ? S.alwaysOnProvider.getTracer(name) : _api.trace.getTracer(name);
|
|
1657
1998
|
}
|
|
1658
1999
|
function autterLlmTracer() {
|
|
1659
2000
|
return alwaysOnTracer("autter-llm");
|
|
1660
2001
|
}
|
|
1661
2002
|
async function emitLlmSelftestTrace() {
|
|
1662
|
-
const provider =
|
|
2003
|
+
const provider = S.alwaysOnProvider;
|
|
1663
2004
|
if (!provider) {
|
|
1664
2005
|
throw new Error(
|
|
1665
2006
|
"emitLlmSelftestTrace() requires initAutterServer() to have been called"
|
|
@@ -1673,7 +2014,7 @@ async function emitLlmSelftestTrace() {
|
|
|
1673
2014
|
attributes: { "autter.selftest": true }
|
|
1674
2015
|
},
|
|
1675
2016
|
(llm) => {
|
|
1676
|
-
traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access',
|
|
2017
|
+
traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access', _86 => _86.getActiveSpan, 'call', _87 => _87(), 'optionalAccess', _88 => _88.spanContext, 'call', _89 => _89(), 'access', _90 => _90.traceId]), () => ( ""));
|
|
1677
2018
|
llm.setUsage({ inputTokens: 1, outputTokens: 1 });
|
|
1678
2019
|
llm.setCost(0);
|
|
1679
2020
|
}
|
|
@@ -1701,7 +2042,7 @@ var CALL_METHODS = /* @__PURE__ */ new Set([
|
|
|
1701
2042
|
// openai beta structured outputs
|
|
1702
2043
|
]);
|
|
1703
2044
|
function detectProvider(client) {
|
|
1704
|
-
const name = _nullishCoalesce(_optionalChain([client, 'access',
|
|
2045
|
+
const name = _nullishCoalesce(_optionalChain([client, 'access', _91 => _91.constructor, 'optionalAccess', _92 => _92.name, 'optionalAccess', _93 => _93.toLowerCase, 'call', _94 => _94()]), () => ( ""));
|
|
1705
2046
|
for (const known of ["openai", "anthropic", "mistral", "groq", "cohere"]) {
|
|
1706
2047
|
if (name.includes(known)) return known;
|
|
1707
2048
|
}
|
|
@@ -1709,7 +2050,7 @@ function detectProvider(client) {
|
|
|
1709
2050
|
const baseUrl = String(
|
|
1710
2051
|
_nullishCoalesce(_nullishCoalesce(client.baseURL, () => ( client.baseUrl)), () => ( ""))
|
|
1711
2052
|
);
|
|
1712
|
-
const host = _nullishCoalesce(_optionalChain([baseUrl, 'access',
|
|
2053
|
+
const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _95 => _95.match, 'call', _96 => _96(/https?:\/\/([^/]+)/), 'optionalAccess', _97 => _97[1]]), () => ( ""));
|
|
1713
2054
|
if (host.includes("openai")) return "openai";
|
|
1714
2055
|
if (host.includes("anthropic")) return "anthropic";
|
|
1715
2056
|
if (host.includes("googleapis")) return "google";
|
|
@@ -1719,13 +2060,13 @@ function detectProvider(client) {
|
|
|
1719
2060
|
}
|
|
1720
2061
|
function extractUsage(result) {
|
|
1721
2062
|
const r = result;
|
|
1722
|
-
const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
1723
|
-
const meta = _optionalChain([r, 'optionalAccess',
|
|
1724
|
-
const details = _optionalChain([usage, 'optionalAccess',
|
|
1725
|
-
const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
1726
|
-
const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
1727
|
-
const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
1728
|
-
const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
2063
|
+
const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _98 => _98.usage]), () => ( _optionalChain([r, 'optionalAccess', _99 => _99.message, 'optionalAccess', _100 => _100.usage])));
|
|
2064
|
+
const meta = _optionalChain([r, 'optionalAccess', _101 => _101.usageMetadata]);
|
|
2065
|
+
const details = _optionalChain([usage, 'optionalAccess', _102 => _102.prompt_tokens_details]);
|
|
2066
|
+
const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _103 => _103.cache_read_input_tokens]), () => ( (typeof _optionalChain([details, 'optionalAccess', _104 => _104.cached_tokens]) === "number" ? details.cached_tokens : void 0))), () => ( _optionalChain([meta, 'optionalAccess', _105 => _105.cachedContentTokenCount])));
|
|
2067
|
+
const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _106 => _106.prompt_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _107 => _107.input_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _108 => _108.promptTokenCount]))), () => ( void 0));
|
|
2068
|
+
const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _109 => _109.completion_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _110 => _110.output_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _111 => _111.candidatesTokenCount]))), () => ( void 0));
|
|
2069
|
+
const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _112 => _112.model]), () => ( _optionalChain([r, 'optionalAccess', _113 => _113.modelVersion])));
|
|
1729
2070
|
return {
|
|
1730
2071
|
inputTokens: typeof input === "number" ? input : void 0,
|
|
1731
2072
|
outputTokens: typeof output === "number" ? output : void 0,
|
|
@@ -1734,7 +2075,7 @@ function extractUsage(result) {
|
|
|
1734
2075
|
};
|
|
1735
2076
|
}
|
|
1736
2077
|
function rollUp(model, usage) {
|
|
1737
|
-
|
|
2078
|
+
_chunkUXTIMS3Gcjs.recordOperationAiUsage.call(void 0, {
|
|
1738
2079
|
model: _nullishCoalesce(usage.responseModel, () => ( model)),
|
|
1739
2080
|
...usage.inputTokens !== void 0 ? { inputTokens: usage.inputTokens } : {},
|
|
1740
2081
|
...usage.outputTokens !== void 0 ? { outputTokens: usage.outputTokens } : {},
|
|
@@ -1818,10 +2159,10 @@ function wrapStream(stream, span, model) {
|
|
|
1818
2159
|
});
|
|
1819
2160
|
}
|
|
1820
2161
|
function instrumentLlmClient(client, options) {
|
|
1821
|
-
const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2162
|
+
const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _114 => _114.provider]), () => ( detectProvider(client)))).toLowerCase();
|
|
1822
2163
|
const proxied = /* @__PURE__ */ new WeakMap();
|
|
1823
2164
|
function resolveUserId() {
|
|
1824
|
-
return typeof _optionalChain([options, 'optionalAccess',
|
|
2165
|
+
return typeof _optionalChain([options, 'optionalAccess', _115 => _115.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _116 => _116.userId]);
|
|
1825
2166
|
}
|
|
1826
2167
|
function traceCall(fn, self, callPath, args) {
|
|
1827
2168
|
const request = args[0];
|
|
@@ -1835,7 +2176,7 @@ function instrumentLlmClient(client, options) {
|
|
|
1835
2176
|
"gen_ai.system": provider,
|
|
1836
2177
|
"gen_ai.request.model": request.model,
|
|
1837
2178
|
...userId ? { "autter.user_id": userId } : {},
|
|
1838
|
-
...redactWithActive(_optionalChain([options, 'optionalAccess',
|
|
2179
|
+
...redactWithActive(_optionalChain([options, 'optionalAccess', _117 => _117.attributes]))
|
|
1839
2180
|
}
|
|
1840
2181
|
});
|
|
1841
2182
|
let result;
|
|
@@ -1917,14 +2258,14 @@ function startCaughtExceptionSampler(options = {}) {
|
|
|
1917
2258
|
const rate = Math.max(0, Math.min(1, _nullishCoalesce(options.sampleRate, () => ( 0.01))));
|
|
1918
2259
|
const cap = Math.max(1, Math.min(100, _nullishCoalesce(options.maxPerMinute, () => ( 10))));
|
|
1919
2260
|
const session = new _inspector2.default.Session();
|
|
1920
|
-
let
|
|
2261
|
+
let active = true;
|
|
1921
2262
|
let minute = 0;
|
|
1922
2263
|
let sent = 0;
|
|
1923
2264
|
session.connect();
|
|
1924
2265
|
session.on("Debugger.paused", (message) => {
|
|
1925
2266
|
session.post("Debugger.resume", () => {
|
|
1926
2267
|
});
|
|
1927
|
-
if (!
|
|
2268
|
+
if (!active || message.params.reason !== "exception") return;
|
|
1928
2269
|
const nowMinute = Math.floor(Date.now() / 6e4);
|
|
1929
2270
|
if (nowMinute !== minute) {
|
|
1930
2271
|
minute = nowMinute;
|
|
@@ -1939,57 +2280,95 @@ function startCaughtExceptionSampler(options = {}) {
|
|
|
1939
2280
|
error.stack = `${error.name}: ${error.message}
|
|
1940
2281
|
${frames.join("\n")}`;
|
|
1941
2282
|
queueMicrotask(() => {
|
|
1942
|
-
if (
|
|
2283
|
+
if (active) captureException(error, { "autter.handled": true, "autter.sampled": true });
|
|
1943
2284
|
});
|
|
1944
2285
|
});
|
|
1945
2286
|
session.post("Debugger.enable", (error) => {
|
|
1946
|
-
if (!error &&
|
|
2287
|
+
if (!error && active) session.post("Debugger.setPauseOnExceptions", { state: "all" }, () => {
|
|
1947
2288
|
});
|
|
1948
2289
|
});
|
|
1949
2290
|
return { stop() {
|
|
1950
|
-
if (!
|
|
1951
|
-
|
|
2291
|
+
if (!active) return;
|
|
2292
|
+
active = false;
|
|
1952
2293
|
session.post("Debugger.setPauseOnExceptions", { state: "none" }, () => {
|
|
1953
2294
|
session.post("Debugger.disable", () => session.disconnect());
|
|
1954
2295
|
});
|
|
1955
2296
|
} };
|
|
1956
2297
|
}
|
|
1957
2298
|
|
|
2299
|
+
// src/framework-errors.ts
|
|
2300
|
+
function recordBoundaryError(error, req, rule) {
|
|
2301
|
+
try {
|
|
2302
|
+
const state = requestStateOf(req);
|
|
2303
|
+
if (state) _chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error, false, state);
|
|
2304
|
+
captureAtBoundary(error, state, rule);
|
|
2305
|
+
} catch (e30) {
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
function autterErrorHandler(options = {}) {
|
|
2309
|
+
return function autterErrorHandlerMiddleware(error, req, _res, next) {
|
|
2310
|
+
recordBoundaryError(error, req, options.capture);
|
|
2311
|
+
next(error);
|
|
2312
|
+
};
|
|
2313
|
+
}
|
|
2314
|
+
function autterFastifyErrors(fastify, options, done) {
|
|
2315
|
+
const rule = _optionalChain([options, 'optionalAccess', _118 => _118.capture]);
|
|
2316
|
+
fastify.addHook("onError", ((request, _reply, error, next) => {
|
|
2317
|
+
recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _119 => _119.raw]), rule);
|
|
2318
|
+
next();
|
|
2319
|
+
}));
|
|
2320
|
+
_optionalChain([done, 'optionalCall', _120 => _120()]);
|
|
2321
|
+
}
|
|
2322
|
+
autterFastifyErrors[/* @__PURE__ */ Symbol.for("skip-override")] = true;
|
|
2323
|
+
autterFastifyErrors[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "autter-runtime-errors";
|
|
2324
|
+
function autterKoa(options = {}) {
|
|
2325
|
+
return async function autterKoaMiddleware(ctx, next) {
|
|
2326
|
+
try {
|
|
2327
|
+
await next();
|
|
2328
|
+
} catch (error) {
|
|
2329
|
+
recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _121 => _121.req]), options.capture);
|
|
2330
|
+
throw error;
|
|
2331
|
+
}
|
|
2332
|
+
};
|
|
2333
|
+
}
|
|
2334
|
+
|
|
1958
2335
|
// src/logging-only.ts
|
|
1959
2336
|
|
|
1960
2337
|
|
|
1961
2338
|
|
|
1962
2339
|
|
|
1963
|
-
var
|
|
2340
|
+
var L = _chunk4MVWIRBIcjs.sharedSlot.call(void 0, "logging", () => ({ active: null }));
|
|
1964
2341
|
function initAutterLogging(options) {
|
|
1965
|
-
if (
|
|
2342
|
+
if (L.active) return L.active;
|
|
1966
2343
|
if (serverActive()) {
|
|
1967
2344
|
console.warn(
|
|
1968
2345
|
"[autter-runtime] initAutterLogging() ignored: initAutterServer() is already active and includes logging"
|
|
1969
2346
|
);
|
|
1970
2347
|
return {
|
|
1971
2348
|
captureException,
|
|
1972
|
-
flush:
|
|
2349
|
+
flush: _chunkUXTIMS3Gcjs.flushRuntimeLogs,
|
|
1973
2350
|
shutdown: async () => {
|
|
1974
2351
|
}
|
|
1975
2352
|
};
|
|
1976
2353
|
}
|
|
1977
|
-
if (
|
|
2354
|
+
if (_chunk4MVWIRBIcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk4MVWIRBIcjs.setDebugMode.call(void 0, true);
|
|
1978
2355
|
const endpoint = (_nullishCoalesce(options.endpoint, () => ( "https://otlp.autter.dev"))).replace(/\/$/, "");
|
|
1979
2356
|
const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
|
|
1980
|
-
const redact =
|
|
2357
|
+
const redact = _chunkUXTIMS3Gcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
|
|
1981
2358
|
const mode = _nullishCoalesce(options.exceptions, () => ( "auto"));
|
|
1982
|
-
|
|
2359
|
+
_chunk4MVWIRBIcjs.debugLog.call(void 0, `initialising logger-only service=${options.service} endpoint=${endpoint}`);
|
|
1983
2360
|
function captureException2(error, attributes) {
|
|
1984
2361
|
markCaptured(error);
|
|
1985
|
-
const
|
|
2362
|
+
const split = _chunkUXTIMS3Gcjs.splitFingerprint.call(void 0, attributes);
|
|
2363
|
+
const fingerprint = _chunkUXTIMS3Gcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
|
|
2364
|
+
const redacted = redact(split.attributes);
|
|
1986
2365
|
const span = _api.trace.getActiveSpan();
|
|
1987
|
-
if (mode === "auto" && _optionalChain([span, 'optionalAccess',
|
|
1988
|
-
|
|
1989
|
-
|
|
2366
|
+
if (mode === "auto" && _optionalChain([span, 'optionalAccess', _122 => _122.isRecording, 'call', _123 => _123()])) {
|
|
2367
|
+
_chunkUXTIMS3Gcjs.noteOperationError.call(void 0, error);
|
|
2368
|
+
_chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
1990
2369
|
span.setAttributes({ "autter.severity": "error", ...redacted, ...structuredErrorAttributes(error) });
|
|
1991
|
-
const declared =
|
|
1992
|
-
if (
|
|
2370
|
+
const declared = { ..._chunkUXTIMS3Gcjs.errorAttributes.call(void 0, error), ...fingerprint };
|
|
2371
|
+
if (_chunkUXTIMS3Gcjs.isError.call(void 0, error)) {
|
|
1993
2372
|
span.addEvent("exception", {
|
|
1994
2373
|
"exception.type": error.name,
|
|
1995
2374
|
"exception.message": error.message,
|
|
@@ -2005,15 +2384,15 @@ function initAutterLogging(options) {
|
|
|
2005
2384
|
}
|
|
2006
2385
|
span.setStatus({
|
|
2007
2386
|
code: _api.SpanStatusCode.ERROR,
|
|
2008
|
-
message:
|
|
2387
|
+
message: _chunkUXTIMS3Gcjs.isError.call(void 0, error) ? error.message : String(error)
|
|
2009
2388
|
});
|
|
2010
2389
|
return;
|
|
2011
2390
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2391
|
+
_chunkUXTIMS3Gcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2392
|
+
_chunkUXTIMS3Gcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2014
2393
|
}
|
|
2015
2394
|
const captured = /* @__PURE__ */ new WeakSet();
|
|
2016
|
-
|
|
2395
|
+
_chunkUXTIMS3Gcjs.configureRuntimeLogger.call(void 0, {
|
|
2017
2396
|
endpoint,
|
|
2018
2397
|
apiKey: _nullishCoalesce(options.apiKey, () => ( "")),
|
|
2019
2398
|
service: options.service,
|
|
@@ -2022,7 +2401,7 @@ function initAutterLogging(options) {
|
|
|
2022
2401
|
...options.logging ? { options: options.logging } : {},
|
|
2023
2402
|
redact,
|
|
2024
2403
|
reportOutcome: (name, message, attributes) => {
|
|
2025
|
-
|
|
2404
|
+
_chunkUXTIMS3Gcjs.runtimeLogger.error(message, {
|
|
2026
2405
|
...attributes,
|
|
2027
2406
|
"autter.outcome.name": name.slice(0, 200),
|
|
2028
2407
|
"autter.outcome.message": message.slice(0, 1e3)
|
|
@@ -2037,31 +2416,42 @@ function initAutterLogging(options) {
|
|
|
2037
2416
|
}
|
|
2038
2417
|
});
|
|
2039
2418
|
setLoggerOnlyCapture(captureException2);
|
|
2040
|
-
const onCrash = (error) =>
|
|
2041
|
-
|
|
2419
|
+
const onCrash = (error) => {
|
|
2420
|
+
if (recordedAsRejection(error)) return;
|
|
2421
|
+
captureException2(error, { "autter.unhandled": true });
|
|
2422
|
+
};
|
|
2423
|
+
let uninstallRejections = null;
|
|
2424
|
+
if (options.captureGlobalErrors !== false) {
|
|
2042
2425
|
process.on("uncaughtExceptionMonitor", onCrash);
|
|
2043
|
-
|
|
2044
|
-
|
|
2426
|
+
if (options.captureUnhandledRejections !== false)
|
|
2427
|
+
uninstallRejections = installUnhandledRejectionCapture(
|
|
2428
|
+
(reason) => captureException2(reason, { "autter.unhandled_rejection": true })
|
|
2429
|
+
);
|
|
2430
|
+
}
|
|
2431
|
+
_chunk4MVWIRBIcjs.registerFlushTarget.call(void 0, "logging", { forceFlush: () => _chunkUXTIMS3Gcjs.flushRuntimeLogs.call(void 0, ) });
|
|
2432
|
+
let autoFlushHandle = options.autoFlush === false ? null : _chunk4MVWIRBIcjs.installAutterAutoFlush.call(void 0, );
|
|
2045
2433
|
const handle = {
|
|
2046
2434
|
captureException: captureException2,
|
|
2047
|
-
flush:
|
|
2435
|
+
flush: _chunkUXTIMS3Gcjs.flushRuntimeLogs,
|
|
2048
2436
|
shutdown: async () => {
|
|
2049
2437
|
process.off("uncaughtExceptionMonitor", onCrash);
|
|
2438
|
+
_optionalChain([uninstallRejections, 'optionalCall', _124 => _124()]);
|
|
2439
|
+
uninstallRejections = null;
|
|
2050
2440
|
setLoggerOnlyCapture(null);
|
|
2051
|
-
_optionalChain([autoFlushHandle, 'optionalAccess',
|
|
2441
|
+
_optionalChain([autoFlushHandle, 'optionalAccess', _125 => _125.dispose, 'call', _126 => _126()]);
|
|
2052
2442
|
autoFlushHandle = null;
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
await
|
|
2443
|
+
_chunk4MVWIRBIcjs.unregisterFlushTargets.call(void 0, );
|
|
2444
|
+
if (L.active === handle) L.active = null;
|
|
2445
|
+
await _chunkUXTIMS3Gcjs.shutdownRuntimeLogger.call(void 0, );
|
|
2056
2446
|
}
|
|
2057
2447
|
};
|
|
2058
|
-
|
|
2448
|
+
L.active = handle;
|
|
2059
2449
|
return handle;
|
|
2060
2450
|
}
|
|
2061
2451
|
|
|
2062
2452
|
// src/enrichers.ts
|
|
2063
2453
|
function headerOf(req, name) {
|
|
2064
|
-
const headers = _optionalChain([req, 'optionalAccess',
|
|
2454
|
+
const headers = _optionalChain([req, 'optionalAccess', _127 => _127.headers]);
|
|
2065
2455
|
if (!headers) return void 0;
|
|
2066
2456
|
if (typeof headers.get === "function") {
|
|
2067
2457
|
return _nullishCoalesce(headers.get(name), () => ( void 0));
|
|
@@ -2074,7 +2464,7 @@ function enrichUserAgent() {
|
|
|
2074
2464
|
return (event, { req }) => {
|
|
2075
2465
|
const ua = headerOf(req, "user-agent");
|
|
2076
2466
|
if (!ua) return;
|
|
2077
|
-
const info =
|
|
2467
|
+
const info = _chunkUXTIMS3Gcjs.parseUserAgent.call(void 0, ua);
|
|
2078
2468
|
if (info.browser) event.attributes["user_agent.browser"] = info.browser;
|
|
2079
2469
|
if (info.os) event.attributes["user_agent.os"] = info.os;
|
|
2080
2470
|
event.attributes["user_agent.device"] = info.device;
|
|
@@ -2086,7 +2476,7 @@ function enrichRequestSize() {
|
|
|
2086
2476
|
const request = Number(headerOf(req, "content-length"));
|
|
2087
2477
|
if (Number.isFinite(request) && request >= 0)
|
|
2088
2478
|
event.attributes["http.request.body.size"] = request;
|
|
2089
|
-
const raw = _optionalChain([res, 'optionalAccess',
|
|
2479
|
+
const raw = _optionalChain([res, 'optionalAccess', _128 => _128.getHeader, 'optionalCall', _129 => _129(
|
|
2090
2480
|
"content-length"
|
|
2091
2481
|
)]);
|
|
2092
2482
|
const response = Number(raw);
|
|
@@ -2104,7 +2494,7 @@ var COUNTRY_HEADERS = [
|
|
|
2104
2494
|
function enrichEdgeGeo() {
|
|
2105
2495
|
return (event, { req }) => {
|
|
2106
2496
|
for (const name of COUNTRY_HEADERS) {
|
|
2107
|
-
const value = _optionalChain([headerOf, 'call',
|
|
2497
|
+
const value = _optionalChain([headerOf, 'call', _130 => _130(req, name), 'optionalAccess', _131 => _131.trim, 'call', _132 => _132(), 'access', _133 => _133.toUpperCase, 'call', _134 => _134()]);
|
|
2108
2498
|
if (value && /^[A-Z]{2}$/.test(value) && value !== "XX" && value !== "T1") {
|
|
2109
2499
|
event.attributes["geo.country.iso_code"] = value;
|
|
2110
2500
|
return;
|
|
@@ -2138,9 +2528,9 @@ var COMMIT_VARS = [
|
|
|
2138
2528
|
"SOURCE_VERSION"
|
|
2139
2529
|
];
|
|
2140
2530
|
function enrichDeployment(env = process.env) {
|
|
2141
|
-
const pick = (names) => names.map((name) => _optionalChain([env, 'access',
|
|
2142
|
-
const region = _optionalChain([pick, 'call',
|
|
2143
|
-
const commit = _optionalChain([pick, 'call',
|
|
2531
|
+
const pick = (names) => names.map((name) => _optionalChain([env, 'access', _135 => _135[name], 'optionalAccess', _136 => _136.trim, 'call', _137 => _137()])).find((value) => value);
|
|
2532
|
+
const region = _optionalChain([pick, 'call', _138 => _138(REGION_VARS), 'optionalAccess', _139 => _139.slice, 'call', _140 => _140(0, 64)]);
|
|
2533
|
+
const commit = _optionalChain([pick, 'call', _141 => _141(COMMIT_VARS), 'optionalAccess', _142 => _142.slice, 'call', _143 => _143(0, 64)]);
|
|
2144
2534
|
return (event) => {
|
|
2145
2535
|
if (region) event.attributes["deployment.region"] = region;
|
|
2146
2536
|
if (commit) event.attributes["deployment.commit"] = commit;
|
|
@@ -2195,4 +2585,10 @@ function enrichDeployment(env = process.env) {
|
|
|
2195
2585
|
|
|
2196
2586
|
|
|
2197
2587
|
|
|
2198
|
-
|
|
2588
|
+
|
|
2589
|
+
|
|
2590
|
+
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
exports.CODE_PATTERN = _chunkUXTIMS3Gcjs.CODE_PATTERN; exports.COMPAT_MANIFEST = _chunk4MVWIRBIcjs.COMPAT_MANIFEST; exports.INGESTER_VERSION_HEADER = _chunk4MVWIRBIcjs.INGESTER_VERSION_HEADER; exports.RuntimeError = _chunkUXTIMS3Gcjs.RuntimeError; exports.SDK_IDENTITY = _chunk4MVWIRBIcjs.SDK_IDENTITY; exports.addBreadcrumb = _chunkUXTIMS3Gcjs.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 = _chunkUXTIMS3Gcjs.consoleSink; exports.createBrowserRelayFetchHandler = createBrowserRelayFetchHandler; exports.createBrowserRelayHandler = createBrowserRelayHandler; exports.createRuntimeLogger = _chunkUXTIMS3Gcjs.createRuntimeLogger; exports.defineRuntimeErrors = _chunkUXTIMS3Gcjs.defineRuntimeErrors; exports.emitLlmSelftestTrace = emitLlmSelftestTrace; exports.enrichDeployment = enrichDeployment; exports.enrichEdgeGeo = enrichEdgeGeo; exports.enrichRequestSize = enrichRequestSize; exports.enrichUserAgent = enrichUserAgent; exports.errorAttributes = _chunkUXTIMS3Gcjs.errorAttributes; exports.evaluateCompat = _chunk4MVWIRBIcjs.evaluateCompat; exports.fetchIngesterCompat = _chunk4MVWIRBIcjs.fetchIngesterCompat; exports.fileSink = _chunkUXTIMS3Gcjs.fileSink; exports.flushRuntimeLogs = _chunkUXTIMS3Gcjs.flushRuntimeLogs; exports.initAutterLogging = initAutterLogging; exports.initAutterServer = initAutterServer; exports.installAutterAutoFlush = _chunk4MVWIRBIcjs.installAutterAutoFlush; exports.instrumentLlmClient = instrumentLlmClient; exports.isRuntimeErrorLike = _chunkUXTIMS3Gcjs.isRuntimeErrorLike; exports.makeSafeCapture = makeSafeCapture; exports.otlpSink = _chunkUXTIMS3Gcjs.otlpSink; exports.redactAttributes = _chunkUXTIMS3Gcjs.redactAttributes; exports.redactText = _chunkUXTIMS3Gcjs.redactText; exports.reportOutcome = reportOutcome; exports.runDoctor = _chunk7OTD2YPTcjs.runDoctor; exports.runInBackground = _chunkUXTIMS3Gcjs.runInBackground; exports.runtimeContext = _chunkUXTIMS3Gcjs.runtimeContext; exports.runtimeLogStats = _chunkUXTIMS3Gcjs.runtimeLogStats; exports.runtimeLogger = _chunkUXTIMS3Gcjs.runtimeLogger; exports.sanitizeBrowserPayload = sanitizeBrowserPayload; exports.startCaughtExceptionSampler = startCaughtExceptionSampler; exports.toClientError = _chunkUXTIMS3Gcjs.toClientError; exports.trackLlmCall = trackLlmCall; exports.unhandledRejectionsMode = unhandledRejectionsMode; exports.withLlmCall = withLlmCall; exports.withProcessSpan = withProcessSpan; exports.withRuntimeOperation = _chunkUXTIMS3Gcjs.withRuntimeOperation; exports.withRuntimeRequest = withRuntimeRequest;
|