@autter/runtime-node 1.8.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -1
- package/dist/{chunk-MOZOUEMA.cjs → chunk-3P573RHA.cjs} +44 -3
- package/dist/{chunk-QKY2OQSO.js → chunk-D3PJ7TQ4.js} +550 -36
- package/dist/{chunk-37W7YYXO.cjs → chunk-FV64SIRQ.cjs} +613 -99
- package/dist/{chunk-UC3QH4PC.js → chunk-FYMEBULO.js} +4 -3
- package/dist/{chunk-7H3FCV4P.cjs → chunk-LYXQC4FI.cjs} +14 -13
- package/dist/{chunk-B5ZMOCEM.js → chunk-VIP2EL47.js} +44 -3
- package/dist/cli.cjs +8 -8
- package/dist/cli.js +2 -2
- package/dist/index.cjs +489 -252
- package/dist/index.d.cts +76 -4
- package/dist/index.d.ts +76 -4
- package/dist/index.js +263 -26
- package/dist/{sinks-CIdlmYwy.d.cts → sinks-BfUoE96B.d.cts} +42 -4
- package/dist/{sinks-CIdlmYwy.d.ts → sinks-BfUoE96B.d.ts} +42 -4
- 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 +7 -3
package/dist/index.cjs
CHANGED
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
var _chunk37W7YYXOcjs = require('./chunk-37W7YYXO.cjs');
|
|
50
49
|
|
|
51
50
|
|
|
52
|
-
var _chunk7H3FCV4Pcjs = require('./chunk-7H3FCV4P.cjs');
|
|
53
51
|
|
|
54
52
|
|
|
55
53
|
|
|
54
|
+
var _chunkFV64SIRQcjs = require('./chunk-FV64SIRQ.cjs');
|
|
56
55
|
|
|
57
56
|
|
|
57
|
+
var _chunkLYXQC4FIcjs = require('./chunk-LYXQC4FI.cjs');
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
@@ -71,7 +71,12 @@ var _chunk7H3FCV4Pcjs = require('./chunk-7H3FCV4P.cjs');
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
var _chunk3P573RHAcjs = require('./chunk-3P573RHA.cjs');
|
|
75
80
|
|
|
76
81
|
// src/relay.ts
|
|
77
82
|
var IpWindow = (_class = class {
|
|
@@ -96,6 +101,112 @@ function firstForwardedFor(value) {
|
|
|
96
101
|
const raw = Array.isArray(value) ? value[0] : value;
|
|
97
102
|
return raw ? (_nullishCoalesce(raw.split(",")[0], () => ( ""))).trim() : "";
|
|
98
103
|
}
|
|
104
|
+
var TRUST_AUTO = { mode: "auto" };
|
|
105
|
+
var warnedTrustProxy = false;
|
|
106
|
+
function resolveTrustProxy(value) {
|
|
107
|
+
if (value === void 0 || value === null || value === "auto") return TRUST_AUTO;
|
|
108
|
+
if (value === true) return { mode: "all" };
|
|
109
|
+
if (value === false || value === 0) return { mode: "never" };
|
|
110
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 100) {
|
|
111
|
+
return { mode: "hops", hops: value };
|
|
112
|
+
}
|
|
113
|
+
if (typeof value === "string") {
|
|
114
|
+
const v = value.trim().toLowerCase();
|
|
115
|
+
if (v === "" || v === "auto") return TRUST_AUTO;
|
|
116
|
+
if (v === "false" || v === "0" || v === "no" || v === "off") return { mode: "never" };
|
|
117
|
+
if (v === "true" || v === "yes" || v === "on") return { mode: "all" };
|
|
118
|
+
if (/^[1-9][0-9]?$/.test(v)) return { mode: "hops", hops: Number(v) };
|
|
119
|
+
}
|
|
120
|
+
if (!warnedTrustProxy) {
|
|
121
|
+
warnedTrustProxy = true;
|
|
122
|
+
console.warn(
|
|
123
|
+
`[autter-runtime] relay: trustProxy ${JSON.stringify(value)} is not recognised; using "auto".`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return TRUST_AUTO;
|
|
127
|
+
}
|
|
128
|
+
var IPV4_RE = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
|
|
129
|
+
function normalizeAddress(entry) {
|
|
130
|
+
if (!entry) return null;
|
|
131
|
+
let a = entry.trim();
|
|
132
|
+
if (!a || a.length > 64) return null;
|
|
133
|
+
const bracketed = /^\[([0-9A-Fa-f:.]+)\](?::\d{1,5})?$/.exec(a);
|
|
134
|
+
if (bracketed) a = _nullishCoalesce(bracketed[1], () => ( ""));
|
|
135
|
+
else if (/^[\d.]+:\d{1,5}$/.test(a)) a = a.slice(0, a.lastIndexOf(":"));
|
|
136
|
+
a = a.toLowerCase();
|
|
137
|
+
if (a.startsWith("::ffff:") && IPV4_RE.test(a.slice(7))) a = a.slice(7);
|
|
138
|
+
if (IPV4_RE.test(a)) return a;
|
|
139
|
+
if (/^[0-9a-f:]+(:(\d{1,3}\.){3}\d{1,3})?$/.test(a) && a.includes(":") && a.split(":").length <= 9) {
|
|
140
|
+
return a;
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
function isPrivateAddress(a) {
|
|
145
|
+
if (IPV4_RE.test(a)) {
|
|
146
|
+
const [x, y] = a.split(".").map(Number);
|
|
147
|
+
return x === 10 || x === 127 || x === 0 || x === 169 && y === 254 || x === 172 && y >= 16 && y <= 31 || x === 192 && y === 168 || x === 100 && y >= 64 && y <= 127;
|
|
148
|
+
}
|
|
149
|
+
return a === "::1" || a === "::" || /^f[cd]/.test(a) || /^fe[89ab]/.test(a);
|
|
150
|
+
}
|
|
151
|
+
function forwardedEntries(value) {
|
|
152
|
+
const raw = Array.isArray(value) ? value.join(",") : value;
|
|
153
|
+
if (!raw) return [];
|
|
154
|
+
const out = [];
|
|
155
|
+
for (const part of raw.split(",")) {
|
|
156
|
+
const a = normalizeAddress(part);
|
|
157
|
+
if (a) out.push(a);
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
function rightmostPublic(entries) {
|
|
162
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
163
|
+
const a = entries[i];
|
|
164
|
+
if (a && !isPrivateAddress(a)) return a;
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
function fromCustom(opts, request) {
|
|
169
|
+
if (!opts.clientIp) return null;
|
|
170
|
+
try {
|
|
171
|
+
const v = opts.clientIp(request);
|
|
172
|
+
return typeof v === "string" && v.trim() ? v.trim().slice(0, 64) : null;
|
|
173
|
+
} catch (e2) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function fetchClientKey(request, opts) {
|
|
178
|
+
const custom = fromCustom(opts, request);
|
|
179
|
+
if (custom) return custom;
|
|
180
|
+
const trust = resolveTrustProxy(opts.trustProxy);
|
|
181
|
+
if (trust.mode === "never") return "shared";
|
|
182
|
+
const header = request.headers.get("x-forwarded-for");
|
|
183
|
+
if (trust.mode === "all") return firstForwardedFor(header) || "shared";
|
|
184
|
+
const entries = forwardedEntries(header);
|
|
185
|
+
if (trust.mode === "hops") {
|
|
186
|
+
return _nullishCoalesce(entries[Math.max(0, entries.length - trust.hops)], () => ( "shared"));
|
|
187
|
+
}
|
|
188
|
+
const cf = request.cf;
|
|
189
|
+
if (cf !== null && typeof cf === "object") {
|
|
190
|
+
const viaCf = normalizeAddress(request.headers.get("cf-connecting-ip"));
|
|
191
|
+
if (viaCf) return viaCf;
|
|
192
|
+
}
|
|
193
|
+
return _nullishCoalesce(_nullishCoalesce(rightmostPublic(entries), () => ( entries[entries.length - 1])), () => ( "shared"));
|
|
194
|
+
}
|
|
195
|
+
function nodeClientKey(req, opts) {
|
|
196
|
+
const custom = fromCustom(opts, req);
|
|
197
|
+
if (custom) return custom;
|
|
198
|
+
const trust = resolveTrustProxy(opts.trustProxy);
|
|
199
|
+
const peer = normalizeAddress(_optionalChain([req, 'access', _ => _.socket, 'optionalAccess', _2 => _2.remoteAddress]));
|
|
200
|
+
if (trust.mode === "never") return _nullishCoalesce(peer, () => ( "unknown"));
|
|
201
|
+
const header = req.headers["x-forwarded-for"];
|
|
202
|
+
if (trust.mode === "all") return firstForwardedFor(header) || peer || "unknown";
|
|
203
|
+
const entries = forwardedEntries(header);
|
|
204
|
+
if (trust.mode === "hops") {
|
|
205
|
+
return _nullishCoalesce(_nullishCoalesce(entries[Math.max(0, entries.length - trust.hops)], () => ( peer)), () => ( "unknown"));
|
|
206
|
+
}
|
|
207
|
+
if (peer && !isPrivateAddress(peer)) return peer;
|
|
208
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(rightmostPublic(entries), () => ( peer)), () => ( entries[entries.length - 1])), () => ( "unknown"));
|
|
209
|
+
}
|
|
99
210
|
var DEFAULT_ENDPOINT = "https://otlp.autter.dev";
|
|
100
211
|
var DEFAULT_MAX_BODY = 64 * 1024;
|
|
101
212
|
var MAX_EVENTS = 50;
|
|
@@ -136,7 +247,7 @@ function boundContext(value) {
|
|
|
136
247
|
let isArr = false;
|
|
137
248
|
try {
|
|
138
249
|
isArr = Array.isArray(v);
|
|
139
|
-
} catch (
|
|
250
|
+
} catch (e3) {
|
|
140
251
|
return void 0;
|
|
141
252
|
}
|
|
142
253
|
if (isArr) {
|
|
@@ -145,7 +256,7 @@ function boundContext(value) {
|
|
|
145
256
|
let len = 0;
|
|
146
257
|
try {
|
|
147
258
|
len = arr.length;
|
|
148
|
-
} catch (
|
|
259
|
+
} catch (e4) {
|
|
149
260
|
return out2;
|
|
150
261
|
}
|
|
151
262
|
for (let i = 0; i < len && i < CONTEXT_MAX_ARRAY; i++) {
|
|
@@ -154,7 +265,7 @@ function boundContext(value) {
|
|
|
154
265
|
let el;
|
|
155
266
|
try {
|
|
156
267
|
el = walk(arr[i], depth + 1);
|
|
157
|
-
} catch (
|
|
268
|
+
} catch (e5) {
|
|
158
269
|
el = void 0;
|
|
159
270
|
}
|
|
160
271
|
if (el !== void 0) out2.push(el);
|
|
@@ -164,7 +275,7 @@ function boundContext(value) {
|
|
|
164
275
|
let keys;
|
|
165
276
|
try {
|
|
166
277
|
keys = Object.keys(obj);
|
|
167
|
-
} catch (
|
|
278
|
+
} catch (e6) {
|
|
168
279
|
return void 0;
|
|
169
280
|
}
|
|
170
281
|
const out = {};
|
|
@@ -176,7 +287,7 @@ function boundContext(value) {
|
|
|
176
287
|
let child;
|
|
177
288
|
try {
|
|
178
289
|
child = walk(obj[key], depth + 1);
|
|
179
|
-
} catch (
|
|
290
|
+
} catch (e7) {
|
|
180
291
|
child = void 0;
|
|
181
292
|
}
|
|
182
293
|
if (child !== void 0) out[key] = child;
|
|
@@ -186,7 +297,7 @@ function boundContext(value) {
|
|
|
186
297
|
let result;
|
|
187
298
|
try {
|
|
188
299
|
result = walk(value, 0);
|
|
189
|
-
} catch (
|
|
300
|
+
} catch (e8) {
|
|
190
301
|
result = void 0;
|
|
191
302
|
}
|
|
192
303
|
return result && typeof result === "object" ? result : {};
|
|
@@ -225,7 +336,7 @@ function relayContext(raw, redactor) {
|
|
|
225
336
|
return Array.isArray(bounded) ? {} : { context: redactor(bounded) };
|
|
226
337
|
}
|
|
227
338
|
function relayBreadcrumbs(raw, redactor) {
|
|
228
|
-
const breadcrumbs =
|
|
339
|
+
const breadcrumbs = _chunkFV64SIRQcjs.sanitizeBreadcrumbs.call(void 0, raw, redactor);
|
|
229
340
|
return breadcrumbs ? { breadcrumbs } : {};
|
|
230
341
|
}
|
|
231
342
|
var DEBUG_ID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
@@ -242,10 +353,10 @@ function relayDebugIds(raw, redactor) {
|
|
|
242
353
|
return count ? { debugIds } : {};
|
|
243
354
|
}
|
|
244
355
|
function relayFingerprint(raw, redactor) {
|
|
245
|
-
const values =
|
|
356
|
+
const values = _chunkFV64SIRQcjs.fingerprintValues.call(void 0, raw, redactor.text);
|
|
246
357
|
return values ? { fingerprint: Array.isArray(raw) ? values : values[0] } : {};
|
|
247
358
|
}
|
|
248
|
-
var defaultRelayRedactor =
|
|
359
|
+
var defaultRelayRedactor = _chunkFV64SIRQcjs.makeRedactor.call(void 0, true);
|
|
249
360
|
function sanitizeBrowserPayload(raw, redactor = defaultRelayRedactor) {
|
|
250
361
|
if (typeof raw !== "object" || raw === null) return null;
|
|
251
362
|
const p = raw;
|
|
@@ -290,46 +401,68 @@ function sanitizeBrowserPayload(raw, redactor = defaultRelayRedactor) {
|
|
|
290
401
|
events
|
|
291
402
|
};
|
|
292
403
|
}
|
|
404
|
+
var FORWARD_ATTEMPTS = 3;
|
|
405
|
+
var FORWARD_MAX_WAIT_MS = 1e4;
|
|
293
406
|
function forward(payload, opts) {
|
|
294
407
|
const endpoint = (_nullishCoalesce(opts.endpoint, () => ( DEFAULT_ENDPOINT))).replace(/\/$/, "");
|
|
295
408
|
const url = `${endpoint}/v1/browser`;
|
|
296
409
|
const compat = opts.compatCheck !== false;
|
|
297
|
-
if (compat)
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
410
|
+
if (compat) _chunk3P573RHAcjs.ensureCompatConfigured.call(void 0, endpoint);
|
|
411
|
+
const body = JSON.stringify(payload);
|
|
412
|
+
const attempt = async (n) => {
|
|
413
|
+
let response;
|
|
414
|
+
try {
|
|
415
|
+
response = await fetch(url, {
|
|
416
|
+
method: "POST",
|
|
417
|
+
headers: {
|
|
418
|
+
"content-type": "application/json",
|
|
419
|
+
authorization: `Bearer ${opts.apiKey}`
|
|
420
|
+
},
|
|
421
|
+
body,
|
|
422
|
+
signal: AbortSignal.timeout(1e4)
|
|
423
|
+
});
|
|
424
|
+
} catch (err) {
|
|
425
|
+
if (n >= FORWARD_ATTEMPTS) throw err;
|
|
426
|
+
await sleep(1e3 * 2 ** (n - 1));
|
|
427
|
+
return attempt(n + 1);
|
|
428
|
+
}
|
|
429
|
+
if ((response.status === 429 || response.status >= 500) && n < FORWARD_ATTEMPTS) {
|
|
430
|
+
const seconds = Number(response.headers.get("retry-after"));
|
|
431
|
+
await _optionalChain([response, 'access', _3 => _3.body, 'optionalAccess', _4 => _4.cancel, 'call', _5 => _5(), 'access', _6 => _6.catch, 'call', _7 => _7(() => {
|
|
432
|
+
})]);
|
|
433
|
+
await sleep(seconds > 0 ? Math.min(seconds * 1e3, FORWARD_MAX_WAIT_MS) : 1e3 * 2 ** (n - 1));
|
|
434
|
+
return attempt(n + 1);
|
|
435
|
+
}
|
|
307
436
|
if (!compat) return;
|
|
308
437
|
const types = new Set(
|
|
309
438
|
(_nullishCoalesce(payload.events, () => ( []))).map((e) => String(e.type))
|
|
310
439
|
);
|
|
311
|
-
|
|
312
|
-
for (const feature of
|
|
440
|
+
_chunk3P573RHAcjs.observeIngesterResponse.call(void 0, { status: response.status, headers: response.headers });
|
|
441
|
+
for (const feature of _chunk3P573RHAcjs.featuresForBrowserEvents.call(void 0, types)) _chunk3P573RHAcjs.noteCompatFeature.call(void 0, feature);
|
|
313
442
|
if ((_nullishCoalesce(payload.events, () => ( []))).some((e) => e.traceId)) {
|
|
314
|
-
|
|
443
|
+
_chunk3P573RHAcjs.noteCompatFeature.call(void 0, "browser_trace_propagation");
|
|
315
444
|
}
|
|
316
|
-
|
|
317
|
-
}
|
|
445
|
+
_chunk3P573RHAcjs.noteRelayRejection.call(void 0, types, response.status, response.headers);
|
|
446
|
+
};
|
|
447
|
+
void attempt(1).catch((err) => {
|
|
318
448
|
(_nullishCoalesce(opts.onError, () => ( ((e) => console.warn("autter relay forward failed:", e)))))(
|
|
319
449
|
err
|
|
320
450
|
);
|
|
321
451
|
});
|
|
322
452
|
}
|
|
453
|
+
function sleep(ms) {
|
|
454
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
455
|
+
}
|
|
323
456
|
function createBrowserRelayFetchHandler(opts) {
|
|
324
457
|
const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
|
|
325
|
-
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor :
|
|
458
|
+
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkFV64SIRQcjs.makeRedactor.call(void 0, opts.redact);
|
|
326
459
|
const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
|
|
327
460
|
return async (request) => {
|
|
328
461
|
if (request.method !== "POST") {
|
|
329
462
|
return new Response(null, { status: 405 });
|
|
330
463
|
}
|
|
331
464
|
if (limiter) {
|
|
332
|
-
const ip =
|
|
465
|
+
const ip = fetchClientKey(request, opts);
|
|
333
466
|
if (!limiter.allow(ip)) {
|
|
334
467
|
return new Response(JSON.stringify({ error: "rate limit exceeded" }), {
|
|
335
468
|
status: 429
|
|
@@ -339,7 +472,7 @@ function createBrowserRelayFetchHandler(opts) {
|
|
|
339
472
|
let bounded;
|
|
340
473
|
try {
|
|
341
474
|
bounded = await readBodyBounded(request, maxBody);
|
|
342
|
-
} catch (
|
|
475
|
+
} catch (e9) {
|
|
343
476
|
return new Response(JSON.stringify({ error: "invalid json" }), {
|
|
344
477
|
status: 400
|
|
345
478
|
});
|
|
@@ -352,7 +485,7 @@ function createBrowserRelayFetchHandler(opts) {
|
|
|
352
485
|
let raw;
|
|
353
486
|
try {
|
|
354
487
|
raw = JSON.parse(bounded.text);
|
|
355
|
-
} catch (
|
|
488
|
+
} catch (e10) {
|
|
356
489
|
return new Response(JSON.stringify({ error: "invalid json" }), {
|
|
357
490
|
status: 400
|
|
358
491
|
});
|
|
@@ -369,7 +502,7 @@ function createBrowserRelayFetchHandler(opts) {
|
|
|
369
502
|
}
|
|
370
503
|
function createBrowserRelayHandler(opts) {
|
|
371
504
|
const maxBody = _nullishCoalesce(opts.maxBodyBytes, () => ( DEFAULT_MAX_BODY));
|
|
372
|
-
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor :
|
|
505
|
+
const redactor = opts.redact === void 0 || opts.redact === true ? defaultRelayRedactor : _chunkFV64SIRQcjs.makeRedactor.call(void 0, opts.redact);
|
|
373
506
|
const limiter = opts.perIpRateLimit === false ? null : new IpWindow(_nullishCoalesce(opts.perIpRateLimit, () => ( 120)));
|
|
374
507
|
function respond(res, status, body) {
|
|
375
508
|
res.statusCode = status;
|
|
@@ -395,7 +528,7 @@ function createBrowserRelayHandler(opts) {
|
|
|
395
528
|
return;
|
|
396
529
|
}
|
|
397
530
|
if (limiter) {
|
|
398
|
-
const ip =
|
|
531
|
+
const ip = nodeClientKey(req, opts);
|
|
399
532
|
if (!limiter.allow(ip)) {
|
|
400
533
|
respond(res, 429, { error: "rate limit exceeded" });
|
|
401
534
|
return;
|
|
@@ -406,7 +539,7 @@ function createBrowserRelayHandler(opts) {
|
|
|
406
539
|
if (typeof raw === "string" || Buffer.isBuffer(raw)) {
|
|
407
540
|
try {
|
|
408
541
|
raw = JSON.parse(raw.toString());
|
|
409
|
-
} catch (
|
|
542
|
+
} catch (e11) {
|
|
410
543
|
respond(res, 400, { error: "invalid json" });
|
|
411
544
|
return;
|
|
412
545
|
}
|
|
@@ -431,7 +564,7 @@ function createBrowserRelayHandler(opts) {
|
|
|
431
564
|
if (aborted) return;
|
|
432
565
|
try {
|
|
433
566
|
handleParsed(JSON.parse(Buffer.concat(chunks).toString()), res);
|
|
434
|
-
} catch (
|
|
567
|
+
} catch (e12) {
|
|
435
568
|
respond(res, 400, { error: "invalid json" });
|
|
436
569
|
}
|
|
437
570
|
});
|
|
@@ -502,7 +635,7 @@ function splitUrl(value) {
|
|
|
502
635
|
function decodeName(raw) {
|
|
503
636
|
try {
|
|
504
637
|
return decodeURIComponent(raw.replace(/\+/g, " "));
|
|
505
|
-
} catch (
|
|
638
|
+
} catch (e13) {
|
|
506
639
|
return raw;
|
|
507
640
|
}
|
|
508
641
|
}
|
|
@@ -524,7 +657,7 @@ function makeUrlQueryPolicy(keepQueryParams = []) {
|
|
|
524
657
|
if (!name.includes("?") && !name.includes("#")) return name;
|
|
525
658
|
return name.split(" ").map((token) => {
|
|
526
659
|
if (!token.startsWith("/") && !SCHEME.test(token)) return token;
|
|
527
|
-
return _nullishCoalesce(_optionalChain([splitUrl, 'call',
|
|
660
|
+
return _nullishCoalesce(_optionalChain([splitUrl, 'call', _8 => _8(token), 'optionalAccess', _9 => _9.base]), () => ( token));
|
|
528
661
|
}).join(" ");
|
|
529
662
|
};
|
|
530
663
|
return {
|
|
@@ -636,7 +769,7 @@ var RedactingSpanExporter = class {
|
|
|
636
769
|
for (const span of spans) {
|
|
637
770
|
try {
|
|
638
771
|
scrubbed.push(redactSpan(span, redactor, this.query));
|
|
639
|
-
} catch (
|
|
772
|
+
} catch (e14) {
|
|
640
773
|
failed++;
|
|
641
774
|
}
|
|
642
775
|
}
|
|
@@ -659,7 +792,7 @@ var RedactingSpanExporter = class {
|
|
|
659
792
|
return this.inner.shutdown();
|
|
660
793
|
}
|
|
661
794
|
forceFlush() {
|
|
662
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
795
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _10 => _10.inner, 'access', _11 => _11.forceFlush, 'optionalCall', _12 => _12()]), () => ( Promise.resolve()));
|
|
663
796
|
}
|
|
664
797
|
};
|
|
665
798
|
var RedactingMetricExporter = class {
|
|
@@ -716,7 +849,7 @@ function startMemoryMetrics() {
|
|
|
716
849
|
[heapUsed, (result) => result.observe(process.memoryUsage().heapUsed)],
|
|
717
850
|
[heapLimit, (result) => result.observe(_v8.getHeapStatistics.call(void 0, ).heap_size_limit)],
|
|
718
851
|
[containerLimit, (result) => {
|
|
719
|
-
const constrained = _nullishCoalesce(_optionalChain([process, 'access',
|
|
852
|
+
const constrained = _nullishCoalesce(_optionalChain([process, 'access', _13 => _13.constrainedMemory, 'optionalCall', _14 => _14()]), () => ( 0));
|
|
720
853
|
if (constrained > 0) result.observe(constrained);
|
|
721
854
|
}],
|
|
722
855
|
[afterGc, (result) => {
|
|
@@ -746,7 +879,6 @@ var _async_hooks = require('async_hooks');
|
|
|
746
879
|
|
|
747
880
|
var REQUEST_STATE = /* @__PURE__ */ Symbol.for("autter.runtime.request");
|
|
748
881
|
var BOUND = /* @__PURE__ */ Symbol.for("autter.runtime.bound");
|
|
749
|
-
var CAPTURED = _chunkMOZOUEMAcjs.sharedSlot.call(void 0, "requests", () => ({ captured: /* @__PURE__ */ new WeakSet() })).captured;
|
|
750
882
|
var capturer = () => {
|
|
751
883
|
};
|
|
752
884
|
function setRequestExceptionCapturer(fn) {
|
|
@@ -757,24 +889,30 @@ var annotator = () => {
|
|
|
757
889
|
function setRequestSpanAnnotator(fn) {
|
|
758
890
|
annotator = fn;
|
|
759
891
|
}
|
|
760
|
-
function
|
|
761
|
-
if (
|
|
892
|
+
function decide(rule, error, fallback) {
|
|
893
|
+
if (rule === void 0) return fallback;
|
|
894
|
+
if (typeof rule !== "function") return rule;
|
|
895
|
+
try {
|
|
896
|
+
return rule(error) === true;
|
|
897
|
+
} catch (e15) {
|
|
898
|
+
return false;
|
|
899
|
+
}
|
|
762
900
|
}
|
|
763
901
|
function expressRouteOf(req) {
|
|
764
902
|
const props = req;
|
|
765
|
-
const path = _optionalChain([props, 'optionalAccess',
|
|
903
|
+
const path = _optionalChain([props, 'optionalAccess', _15 => _15.route, 'optionalAccess', _16 => _16.path]);
|
|
766
904
|
if (typeof path !== "string" || path === "") return null;
|
|
767
|
-
const base = typeof _optionalChain([props, 'optionalAccess',
|
|
905
|
+
const base = typeof _optionalChain([props, 'optionalAccess', _17 => _17.baseUrl]) === "string" ? props.baseUrl : "";
|
|
768
906
|
const route = base + path;
|
|
769
907
|
return route.startsWith("/") ? route : null;
|
|
770
908
|
}
|
|
771
909
|
function defaultShouldCapture(error) {
|
|
772
|
-
return error instanceof
|
|
910
|
+
return error instanceof _chunkFV64SIRQcjs.RuntimeError || _chunkFV64SIRQcjs.errorCodeOf.call(void 0, error) !== void 0 || _chunkFV64SIRQcjs.responseStatusOf.call(void 0, error) >= 500;
|
|
773
911
|
}
|
|
774
912
|
function onRequestSpan(fn) {
|
|
775
913
|
const active = _api.context.active();
|
|
776
914
|
const metadata = _core.getRPCMetadata.call(void 0, active);
|
|
777
|
-
const span = _optionalChain([metadata, 'optionalAccess',
|
|
915
|
+
const span = _optionalChain([metadata, 'optionalAccess', _18 => _18.type]) === _core.RPCType.HTTP ? metadata.span : void 0;
|
|
778
916
|
if (!span || !span.isRecording() || _api.trace.getSpan(active) === span) {
|
|
779
917
|
fn();
|
|
780
918
|
return;
|
|
@@ -785,17 +923,17 @@ function captureAtBoundary(error, state, rule = void 0, attributes) {
|
|
|
785
923
|
let wanted;
|
|
786
924
|
try {
|
|
787
925
|
wanted = typeof rule === "function" ? rule(error) : rule === void 0 ? defaultShouldCapture(error) : rule;
|
|
788
|
-
} catch (
|
|
926
|
+
} catch (e16) {
|
|
789
927
|
wanted = false;
|
|
790
928
|
}
|
|
791
929
|
if (!wanted) return;
|
|
792
|
-
if (
|
|
793
|
-
markCaptured(error);
|
|
930
|
+
if (_chunkFV64SIRQcjs.isCaptured.call(void 0, error)) return;
|
|
931
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
794
932
|
try {
|
|
795
933
|
const run = () => onRequestSpan(() => capturer(error, attributes));
|
|
796
|
-
if (state && !state.sealed)
|
|
934
|
+
if (state && !state.sealed) _chunkFV64SIRQcjs.local.run(state, run);
|
|
797
935
|
else run();
|
|
798
|
-
} catch (
|
|
936
|
+
} catch (e17) {
|
|
799
937
|
}
|
|
800
938
|
}
|
|
801
939
|
function requestStateOf(req) {
|
|
@@ -803,15 +941,15 @@ function requestStateOf(req) {
|
|
|
803
941
|
return req[REQUEST_STATE];
|
|
804
942
|
}
|
|
805
943
|
function captureRequestError(error, attributes) {
|
|
806
|
-
if (
|
|
944
|
+
if (_chunkFV64SIRQcjs.isCaptured.call(void 0, error)) {
|
|
807
945
|
if (!attributes) return;
|
|
808
946
|
try {
|
|
809
947
|
onRequestSpan(() => annotator(attributes));
|
|
810
|
-
} catch (
|
|
948
|
+
} catch (e18) {
|
|
811
949
|
}
|
|
812
950
|
return;
|
|
813
951
|
}
|
|
814
|
-
captureAtBoundary(error,
|
|
952
|
+
captureAtBoundary(error, _chunkFV64SIRQcjs.currentOperation.call(void 0, ), true, attributes);
|
|
815
953
|
}
|
|
816
954
|
function bindEmitter(emitter, state) {
|
|
817
955
|
const target = emitter;
|
|
@@ -823,7 +961,7 @@ function bindEmitter(emitter, state) {
|
|
|
823
961
|
let wrapped = wrappers.get(listener);
|
|
824
962
|
if (!wrapped) {
|
|
825
963
|
wrapped = function(...args) {
|
|
826
|
-
return
|
|
964
|
+
return _chunkFV64SIRQcjs.local.run(
|
|
827
965
|
state,
|
|
828
966
|
() => listener.apply(this, args)
|
|
829
967
|
);
|
|
@@ -878,7 +1016,7 @@ function exposeOnCors(res, header) {
|
|
|
878
1016
|
if (value && key && inline) inline[key] = value;
|
|
879
1017
|
else if (value) res.setHeader("access-control-expose-headers", value);
|
|
880
1018
|
}
|
|
881
|
-
} catch (
|
|
1019
|
+
} catch (e19) {
|
|
882
1020
|
}
|
|
883
1021
|
return original.apply(this, args);
|
|
884
1022
|
};
|
|
@@ -890,23 +1028,24 @@ function pathOf(req) {
|
|
|
890
1028
|
function finishRequest(state, input) {
|
|
891
1029
|
if (state.sealed) return;
|
|
892
1030
|
state.name = (_nullishCoalesce(input.name, () => ( `${input.method} ${input.route}`))).slice(0, 200);
|
|
893
|
-
state.outcome =
|
|
1031
|
+
state.outcome = _chunkFV64SIRQcjs.requestOutcome.call(void 0, {
|
|
894
1032
|
...state.explicitOutcome ? { explicit: state.outcome } : {},
|
|
895
1033
|
...state.error !== void 0 ? { error: state.error } : {},
|
|
896
1034
|
...state.errorThrown ? { thrown: true } : {},
|
|
897
1035
|
status: input.status,
|
|
898
|
-
aborted: input.aborted
|
|
1036
|
+
aborted: input.aborted,
|
|
1037
|
+
...state.degraded ? { degraded: true } : {}
|
|
899
1038
|
});
|
|
900
1039
|
const span = _api.trace.getActiveSpan();
|
|
901
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1040
|
+
if (_optionalChain([span, 'optionalAccess', _19 => _19.isRecording, 'call', _20 => _20()])) span.setAttribute("autter.operation.outcome", state.outcome);
|
|
902
1041
|
if (input.span) {
|
|
903
1042
|
const remote = _api.trace.wrapSpanContext(input.span);
|
|
904
1043
|
_api.context.with(
|
|
905
1044
|
_api.trace.setSpan(_api.context.active(), remote),
|
|
906
|
-
() =>
|
|
1045
|
+
() => _chunkFV64SIRQcjs.reportExplicitFailure.call(void 0, state)
|
|
907
1046
|
);
|
|
908
|
-
} else
|
|
909
|
-
|
|
1047
|
+
} else _chunkFV64SIRQcjs.reportExplicitFailure.call(void 0, state);
|
|
1048
|
+
_chunkFV64SIRQcjs.emitSummary.call(void 0, state, {
|
|
910
1049
|
http: {
|
|
911
1050
|
"http.request.method": input.method,
|
|
912
1051
|
"http.route": input.route,
|
|
@@ -917,14 +1056,14 @@ function finishRequest(state, input) {
|
|
|
917
1056
|
});
|
|
918
1057
|
}
|
|
919
1058
|
function beginNodeRequest(req, res, options, route) {
|
|
920
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
921
|
-
const requestId =
|
|
1059
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkFV64SIRQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1060
|
+
const requestId = _chunkFV64SIRQcjs.resolveRequestId.call(void 0,
|
|
922
1061
|
options.trustRequestId === false ? void 0 : req.headers[header]
|
|
923
1062
|
);
|
|
924
1063
|
const method = (_nullishCoalesce(req.method, () => ( "GET"))).toUpperCase();
|
|
925
1064
|
const path = pathOf(req);
|
|
926
|
-
const state =
|
|
927
|
-
name: `${method} ${
|
|
1065
|
+
const state = _chunkFV64SIRQcjs.createRequestState.call(void 0, {
|
|
1066
|
+
name: `${method} ${_chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, path)}`,
|
|
928
1067
|
requestId,
|
|
929
1068
|
req,
|
|
930
1069
|
res
|
|
@@ -933,22 +1072,22 @@ function beginNodeRequest(req, res, options, route) {
|
|
|
933
1072
|
try {
|
|
934
1073
|
if (!res.headersSent) res.setHeader(header, requestId);
|
|
935
1074
|
exposeOnCors(res, header);
|
|
936
|
-
} catch (
|
|
1075
|
+
} catch (e20) {
|
|
937
1076
|
}
|
|
938
1077
|
const span = _api.trace.getActiveSpan();
|
|
939
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1078
|
+
if (_optionalChain([span, 'optionalAccess', _21 => _21.isRecording, 'call', _22 => _22()]))
|
|
940
1079
|
span.setAttributes({
|
|
941
1080
|
"autter.request.id": requestId,
|
|
942
1081
|
"autter.operation.kind": "request"
|
|
943
1082
|
});
|
|
944
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
1083
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _23 => _23.spanContext, 'call', _24 => _24()]);
|
|
945
1084
|
bindEmitter(req, state);
|
|
946
1085
|
bindEmitter(res, state);
|
|
947
1086
|
let finished = false;
|
|
948
1087
|
const done = () => {
|
|
949
1088
|
finishRequest(state, {
|
|
950
1089
|
method,
|
|
951
|
-
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall',
|
|
1090
|
+
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([route, 'optionalCall', _25 => _25()]), () => ( expressRouteOf(req))), () => ( _chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, path))),
|
|
952
1091
|
status: res.statusCode,
|
|
953
1092
|
aborted: !finished,
|
|
954
1093
|
...spanContext ? { span: spanContext } : {}
|
|
@@ -962,50 +1101,50 @@ function beginNodeRequest(req, res, options, route) {
|
|
|
962
1101
|
return state;
|
|
963
1102
|
}
|
|
964
1103
|
function autterRequests(options = {}) {
|
|
965
|
-
const ignored =
|
|
1104
|
+
const ignored = _chunkFV64SIRQcjs.compileIgnore.call(void 0, options.ignore);
|
|
966
1105
|
return function autterRequestsMiddleware(req, res, next) {
|
|
967
1106
|
if (req[REQUEST_STATE] || ignored(pathOf(req))) {
|
|
968
1107
|
next();
|
|
969
1108
|
return;
|
|
970
1109
|
}
|
|
971
1110
|
const state = beginNodeRequest(req, res, options);
|
|
972
|
-
|
|
1111
|
+
_chunkFV64SIRQcjs.local.run(state, () => next());
|
|
973
1112
|
};
|
|
974
1113
|
}
|
|
975
1114
|
function autterErrorResponse(options = {}) {
|
|
976
1115
|
return function autterErrorResponseMiddleware(error, req, res, next) {
|
|
977
1116
|
const state = req[REQUEST_STATE];
|
|
978
|
-
if (state)
|
|
1117
|
+
if (state) _chunkFV64SIRQcjs.noteOperationError.call(void 0, error, true, state);
|
|
979
1118
|
captureAtBoundary(error, state, options.capture);
|
|
980
1119
|
if (res.headersSent) {
|
|
981
1120
|
next(error);
|
|
982
1121
|
return;
|
|
983
1122
|
}
|
|
984
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
985
|
-
const inbound = _optionalChain([req, 'access',
|
|
986
|
-
const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
987
|
-
res.statusCode =
|
|
1123
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkFV64SIRQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1124
|
+
const inbound = _optionalChain([req, 'access', _26 => _26.headers, 'optionalAccess', _27 => _27[header]]);
|
|
1125
|
+
const requestId = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _28 => _28.requestId]), () => ( (typeof inbound === "string" ? inbound.slice(0, 128) : void 0)));
|
|
1126
|
+
res.statusCode = _chunkFV64SIRQcjs.responseStatusOf.call(void 0, error);
|
|
988
1127
|
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
989
|
-
res.end(JSON.stringify(
|
|
1128
|
+
res.end(JSON.stringify(_chunkFV64SIRQcjs.toClientError.call(void 0, error, requestId)));
|
|
990
1129
|
};
|
|
991
1130
|
}
|
|
992
1131
|
var RESOURCE = /* @__PURE__ */ Symbol.for("autter.runtime.resource");
|
|
993
1132
|
function autterFastify(fastify, options, done) {
|
|
994
1133
|
const opts = _nullishCoalesce(options, () => ( {}));
|
|
995
|
-
const header = (_nullishCoalesce(opts.requestIdHeader, () => (
|
|
996
|
-
const ignored =
|
|
1134
|
+
const header = (_nullishCoalesce(opts.requestIdHeader, () => ( _chunkFV64SIRQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1135
|
+
const ignored = _chunkFV64SIRQcjs.compileIgnore.call(void 0, opts.ignore);
|
|
997
1136
|
const stateOf = (request) => request[REQUEST_STATE];
|
|
998
1137
|
fastify.addHook("onRequest", ((request, reply, next) => {
|
|
999
1138
|
if (ignored(request.url) || request.raw[REQUEST_STATE]) {
|
|
1000
1139
|
next();
|
|
1001
1140
|
return;
|
|
1002
1141
|
}
|
|
1003
|
-
const requestId =
|
|
1142
|
+
const requestId = _chunkFV64SIRQcjs.resolveRequestId.call(void 0,
|
|
1004
1143
|
opts.trustRequestId === false ? void 0 : request.headers[header]
|
|
1005
1144
|
);
|
|
1006
1145
|
const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
|
|
1007
|
-
const state =
|
|
1008
|
-
name: `${method} ${
|
|
1146
|
+
const state = _chunkFV64SIRQcjs.createRequestState.call(void 0, {
|
|
1147
|
+
name: `${method} ${_chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, request.url)}`,
|
|
1009
1148
|
requestId,
|
|
1010
1149
|
req: request.raw,
|
|
1011
1150
|
res: reply.raw
|
|
@@ -1014,18 +1153,18 @@ function autterFastify(fastify, options, done) {
|
|
|
1014
1153
|
request.raw[REQUEST_STATE] = state;
|
|
1015
1154
|
reply.header(header, requestId);
|
|
1016
1155
|
const span = _api.trace.getActiveSpan();
|
|
1017
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1156
|
+
if (_optionalChain([span, 'optionalAccess', _29 => _29.isRecording, 'call', _30 => _30()]))
|
|
1018
1157
|
span.setAttributes({
|
|
1019
1158
|
"autter.request.id": requestId,
|
|
1020
1159
|
"autter.operation.kind": "request"
|
|
1021
1160
|
});
|
|
1022
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
1161
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _31 => _31.spanContext, 'call', _32 => _32()]);
|
|
1023
1162
|
bindEmitter(request.raw, state);
|
|
1024
1163
|
bindEmitter(reply.raw, state);
|
|
1025
1164
|
let finished = false;
|
|
1026
1165
|
const finish = (aborted) => finishRequest(state, {
|
|
1027
1166
|
method,
|
|
1028
|
-
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access',
|
|
1167
|
+
route: _nullishCoalesce(_nullishCoalesce(_optionalChain([request, 'access', _33 => _33.routeOptions, 'optionalAccess', _34 => _34.url]), () => ( request.routerPath)), () => ( _chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, request.url))),
|
|
1029
1168
|
status: reply.raw.statusCode || reply.statusCode,
|
|
1030
1169
|
aborted,
|
|
1031
1170
|
...spanContext ? { span: spanContext } : {}
|
|
@@ -1035,7 +1174,7 @@ function autterFastify(fastify, options, done) {
|
|
|
1035
1174
|
finish(false);
|
|
1036
1175
|
});
|
|
1037
1176
|
reply.raw.once("close", () => finish(!finished));
|
|
1038
|
-
|
|
1177
|
+
_chunkFV64SIRQcjs.local.run(state, () => {
|
|
1039
1178
|
request[RESOURCE] = new (0, _async_hooks.AsyncResource)("autter-request");
|
|
1040
1179
|
next();
|
|
1041
1180
|
});
|
|
@@ -1051,13 +1190,13 @@ function autterFastify(fastify, options, done) {
|
|
|
1051
1190
|
const value = exposeHeaderValue(reply.getHeader("access-control-expose-headers"), header);
|
|
1052
1191
|
if (value) reply.header("access-control-expose-headers", value);
|
|
1053
1192
|
}
|
|
1054
|
-
} catch (
|
|
1193
|
+
} catch (e21) {
|
|
1055
1194
|
}
|
|
1056
1195
|
next(null, payload);
|
|
1057
1196
|
}));
|
|
1058
1197
|
fastify.addHook("onError", ((request, _reply, error, next) => {
|
|
1059
1198
|
const state = stateOf(request);
|
|
1060
|
-
if (state)
|
|
1199
|
+
if (state) _chunkFV64SIRQcjs.noteOperationError.call(void 0, error, true, state);
|
|
1061
1200
|
captureAtBoundary(error, state);
|
|
1062
1201
|
next();
|
|
1063
1202
|
}));
|
|
@@ -1079,56 +1218,62 @@ function withHeaders(response, header, requestId) {
|
|
|
1079
1218
|
};
|
|
1080
1219
|
try {
|
|
1081
1220
|
return apply(response);
|
|
1082
|
-
} catch (
|
|
1221
|
+
} catch (e22) {
|
|
1083
1222
|
try {
|
|
1084
1223
|
return apply(new Response(response.body, response));
|
|
1085
|
-
} catch (
|
|
1224
|
+
} catch (e23) {
|
|
1086
1225
|
return response;
|
|
1087
1226
|
}
|
|
1088
1227
|
}
|
|
1089
1228
|
}
|
|
1090
1229
|
function withRuntimeRequest(handler, options = {}) {
|
|
1091
|
-
const header = (_nullishCoalesce(options.requestIdHeader, () => (
|
|
1092
|
-
const ignored =
|
|
1230
|
+
const header = (_nullishCoalesce(options.requestIdHeader, () => ( _chunkFV64SIRQcjs.DEFAULT_REQUEST_ID_HEADER))).toLowerCase();
|
|
1231
|
+
const ignored = _chunkFV64SIRQcjs.compileIgnore.call(void 0, options.ignore);
|
|
1093
1232
|
return async (request, ...rest) => {
|
|
1094
1233
|
let pathname = "/";
|
|
1095
1234
|
try {
|
|
1096
1235
|
pathname = new URL(request.url, "http://localhost").pathname;
|
|
1097
|
-
} catch (
|
|
1236
|
+
} catch (e24) {
|
|
1098
1237
|
}
|
|
1099
1238
|
if (ignored(pathname)) return handler(request, ...rest);
|
|
1100
|
-
const requestId =
|
|
1239
|
+
const requestId = _chunkFV64SIRQcjs.resolveRequestId.call(void 0,
|
|
1101
1240
|
options.trustRequestId === false ? void 0 : request.headers.get(header)
|
|
1102
1241
|
);
|
|
1103
1242
|
const method = String(_nullishCoalesce(request.method, () => ( "GET"))).toUpperCase();
|
|
1104
|
-
const route = _nullishCoalesce(options.route, () => (
|
|
1105
|
-
const state =
|
|
1243
|
+
const route = _nullishCoalesce(options.route, () => ( _chunkFV64SIRQcjs.normalizeRoutePath.call(void 0, pathname)));
|
|
1244
|
+
const state = _chunkFV64SIRQcjs.createRequestState.call(void 0, {
|
|
1106
1245
|
name: `${method} ${_nullishCoalesce(options.name, () => ( route))}`,
|
|
1107
1246
|
requestId,
|
|
1108
1247
|
req: request
|
|
1109
1248
|
});
|
|
1110
1249
|
const span = _api.trace.getActiveSpan();
|
|
1111
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
1250
|
+
if (_optionalChain([span, 'optionalAccess', _35 => _35.isRecording, 'call', _36 => _36()]))
|
|
1112
1251
|
span.setAttributes({
|
|
1113
1252
|
"autter.request.id": requestId,
|
|
1114
1253
|
"autter.operation.kind": "request"
|
|
1115
1254
|
});
|
|
1116
|
-
const spanContext = _optionalChain([span, 'optionalAccess',
|
|
1255
|
+
const spanContext = _optionalChain([span, 'optionalAccess', _37 => _37.spanContext, 'call', _38 => _38()]);
|
|
1117
1256
|
let status = 500;
|
|
1118
1257
|
try {
|
|
1119
|
-
const response = await
|
|
1258
|
+
const response = await _chunkFV64SIRQcjs.local.run(state, async () => {
|
|
1120
1259
|
try {
|
|
1121
1260
|
return await handler(request, ...rest);
|
|
1122
1261
|
} catch (error) {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1262
|
+
if (decide(options.capture, error, true)) {
|
|
1263
|
+
_chunkFV64SIRQcjs.noteOperationError.call(void 0, error, true, state);
|
|
1264
|
+
captureAtBoundary(error, state, true);
|
|
1265
|
+
}
|
|
1266
|
+
if (!decide(options.errorResponse, error, false)) throw error;
|
|
1267
|
+
return new Response(JSON.stringify(_chunkFV64SIRQcjs.toClientError.call(void 0, error, requestId)), {
|
|
1268
|
+
status: _chunkFV64SIRQcjs.responseStatusOf.call(void 0, error),
|
|
1269
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
1270
|
+
});
|
|
1126
1271
|
}
|
|
1127
1272
|
});
|
|
1128
1273
|
status = response.status;
|
|
1129
1274
|
return withHeaders(response, header, requestId);
|
|
1130
1275
|
} finally {
|
|
1131
|
-
const aborted = _optionalChain([request, 'access',
|
|
1276
|
+
const aborted = _optionalChain([request, 'access', _39 => _39.signal, 'optionalAccess', _40 => _40.aborted]) === true;
|
|
1132
1277
|
finishRequest(state, {
|
|
1133
1278
|
method,
|
|
1134
1279
|
route,
|
|
@@ -1139,9 +1284,9 @@ function withRuntimeRequest(handler, options = {}) {
|
|
|
1139
1284
|
});
|
|
1140
1285
|
if (options.waitUntil) {
|
|
1141
1286
|
try {
|
|
1142
|
-
options.waitUntil(
|
|
1287
|
+
options.waitUntil(_chunkFV64SIRQcjs.flushRuntimeLogs.call(void 0, ).catch(() => {
|
|
1143
1288
|
}));
|
|
1144
|
-
} catch (
|
|
1289
|
+
} catch (e25) {
|
|
1145
1290
|
}
|
|
1146
1291
|
}
|
|
1147
1292
|
}
|
|
@@ -1151,7 +1296,7 @@ function startHookRequest(res) {
|
|
|
1151
1296
|
const req = res.req;
|
|
1152
1297
|
if (!req || req[REQUEST_STATE]) return;
|
|
1153
1298
|
const state = beginNodeRequest(req, res, {});
|
|
1154
|
-
|
|
1299
|
+
_chunkFV64SIRQcjs.local.enterWith(state);
|
|
1155
1300
|
}
|
|
1156
1301
|
|
|
1157
1302
|
// src/unhandled-rejections.ts
|
|
@@ -1177,7 +1322,7 @@ var recorded = /* @__PURE__ */ new WeakSet();
|
|
|
1177
1322
|
function markRecorded(reason) {
|
|
1178
1323
|
if (!reason || typeof reason !== "object") return;
|
|
1179
1324
|
recorded.add(reason);
|
|
1180
|
-
_optionalChain([setImmediate, 'call',
|
|
1325
|
+
_optionalChain([setImmediate, 'call', _41 => _41(() => recorded.delete(reason)), 'access', _42 => _42.unref, 'optionalCall', _43 => _43()]);
|
|
1181
1326
|
}
|
|
1182
1327
|
function recordedAsRejection(error) {
|
|
1183
1328
|
return !!error && typeof error === "object" && recorded.has(error);
|
|
@@ -1203,7 +1348,7 @@ function unhandledRejectionsMode(execArgv = process.execArgv, nodeOptions = proc
|
|
|
1203
1348
|
function isErrorLike(value) {
|
|
1204
1349
|
try {
|
|
1205
1350
|
return typeof value === "object" && value !== null && Object.prototype.hasOwnProperty.call(value, "stack");
|
|
1206
|
-
} catch (
|
|
1351
|
+
} catch (e26) {
|
|
1207
1352
|
return false;
|
|
1208
1353
|
}
|
|
1209
1354
|
}
|
|
@@ -1211,16 +1356,16 @@ function describeReason(reason) {
|
|
|
1211
1356
|
if (typeof reason !== "object" && typeof reason !== "function" || reason === null) {
|
|
1212
1357
|
try {
|
|
1213
1358
|
return String(reason);
|
|
1214
|
-
} catch (
|
|
1359
|
+
} catch (e27) {
|
|
1215
1360
|
return typeof reason;
|
|
1216
1361
|
}
|
|
1217
1362
|
}
|
|
1218
1363
|
try {
|
|
1219
1364
|
const proto = Object.getPrototypeOf(reason);
|
|
1220
|
-
const ctor = _optionalChain([proto, 'optionalAccess',
|
|
1365
|
+
const ctor = _optionalChain([proto, 'optionalAccess', _44 => _44.constructor]);
|
|
1221
1366
|
const name = typeof ctor === "function" ? ctor.name : "";
|
|
1222
1367
|
return name ? `#<${name}>` : "[object Object]";
|
|
1223
|
-
} catch (
|
|
1368
|
+
} catch (e28) {
|
|
1224
1369
|
return "[object Object]";
|
|
1225
1370
|
}
|
|
1226
1371
|
}
|
|
@@ -1231,7 +1376,7 @@ function toUncaught(reason, from) {
|
|
|
1231
1376
|
);
|
|
1232
1377
|
error.name = "UnhandledPromiseRejection";
|
|
1233
1378
|
error.code = "ERR_UNHANDLED_REJECTION";
|
|
1234
|
-
_optionalChain([Error, 'access',
|
|
1379
|
+
_optionalChain([Error, 'access', _45 => _45.captureStackTrace, 'optionalCall', _46 => _46(error, from)]);
|
|
1235
1380
|
return error;
|
|
1236
1381
|
}
|
|
1237
1382
|
var warningId = 0;
|
|
@@ -1243,7 +1388,7 @@ function emitNodeWarning(reason) {
|
|
|
1243
1388
|
`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})`,
|
|
1244
1389
|
"UnhandledPromiseRejectionWarning"
|
|
1245
1390
|
);
|
|
1246
|
-
} catch (
|
|
1391
|
+
} catch (e29) {
|
|
1247
1392
|
}
|
|
1248
1393
|
}
|
|
1249
1394
|
function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMode()) {
|
|
@@ -1270,7 +1415,7 @@ function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMod
|
|
|
1270
1415
|
}
|
|
1271
1416
|
markRecorded(reason);
|
|
1272
1417
|
capture(reason);
|
|
1273
|
-
} catch (
|
|
1418
|
+
} catch (e30) {
|
|
1274
1419
|
}
|
|
1275
1420
|
};
|
|
1276
1421
|
listener[LISTENER_MARK] = true;
|
|
@@ -1285,9 +1430,9 @@ function installUnhandledRejectionCapture(capture, mode = unhandledRejectionsMod
|
|
|
1285
1430
|
var ours = /* @__PURE__ */ new WeakMap();
|
|
1286
1431
|
var RAW_PATH_SPAN_TYPES = /* @__PURE__ */ new Set(["BaseServer.renderToResponse"]);
|
|
1287
1432
|
function noteFrameworkRoute(parent, attributes) {
|
|
1288
|
-
const route = _optionalChain([attributes, 'optionalAccess',
|
|
1433
|
+
const route = _optionalChain([attributes, 'optionalAccess', _47 => _47["next.route"]]);
|
|
1289
1434
|
if (typeof route !== "string" || !route.startsWith("/")) return;
|
|
1290
|
-
if (RAW_PATH_SPAN_TYPES.has(String(_nullishCoalesce(_optionalChain([attributes, 'optionalAccess',
|
|
1435
|
+
if (RAW_PATH_SPAN_TYPES.has(String(_nullishCoalesce(_optionalChain([attributes, 'optionalAccess', _48 => _48["next.span_type"]]), () => ( ""))))) return;
|
|
1291
1436
|
const rpc = _core.getRPCMetadata.call(void 0, parent);
|
|
1292
1437
|
if (!rpc || rpc.type !== _core.RPCType.HTTP) return;
|
|
1293
1438
|
const mine = ours.get(rpc);
|
|
@@ -1305,7 +1450,7 @@ var RouteLabelSampler = class {
|
|
|
1305
1450
|
shouldSample(ctx, traceId, spanName, spanKind, attributes, links) {
|
|
1306
1451
|
try {
|
|
1307
1452
|
noteFrameworkRoute(ctx, attributes);
|
|
1308
|
-
} catch (
|
|
1453
|
+
} catch (e31) {
|
|
1309
1454
|
}
|
|
1310
1455
|
return this.delegate.shouldSample(ctx, traceId, spanName, spanKind, attributes, links);
|
|
1311
1456
|
}
|
|
@@ -1315,11 +1460,13 @@ var RouteLabelSampler = class {
|
|
|
1315
1460
|
};
|
|
1316
1461
|
|
|
1317
1462
|
// src/server.ts
|
|
1318
|
-
var S =
|
|
1463
|
+
var S = _chunk3P573RHAcjs.sharedSlot.call(void 0, "server", () => ({
|
|
1319
1464
|
active: null,
|
|
1320
1465
|
alwaysOnProvider: null,
|
|
1321
|
-
redactor:
|
|
1466
|
+
redactor: _chunkFV64SIRQcjs.makeRedactor.call(void 0, true),
|
|
1322
1467
|
loggerOnlyCapture: null,
|
|
1468
|
+
handled: null,
|
|
1469
|
+
loggerOnlyHandled: null,
|
|
1323
1470
|
hookRequests: false
|
|
1324
1471
|
}));
|
|
1325
1472
|
var LLM_MARKER_ATTRIBUTES = [
|
|
@@ -1418,7 +1565,7 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
|
|
|
1418
1565
|
this.retainErrors = retainErrors;
|
|
1419
1566
|
this.slowThresholdMs = slowThresholdMs;
|
|
1420
1567
|
this.sweeper = setInterval(() => this.sweep(), RETENTION_SWEEP_INTERVAL_MS);
|
|
1421
|
-
_optionalChain([this, 'access',
|
|
1568
|
+
_optionalChain([this, 'access', _49 => _49.sweeper, 'access', _50 => _50.unref, 'optionalCall', _51 => _51()]);
|
|
1422
1569
|
}
|
|
1423
1570
|
|
|
1424
1571
|
|
|
@@ -1449,7 +1596,7 @@ var ErrorTraceRetentionProcessor = (_class2 = class {
|
|
|
1449
1596
|
}
|
|
1450
1597
|
/** Promote the active trace, if any — called on captured errors. */
|
|
1451
1598
|
retainActiveTrace() {
|
|
1452
|
-
const active = _optionalChain([_api.trace, 'access',
|
|
1599
|
+
const active = _optionalChain([_api.trace, 'access', _52 => _52.getActiveSpan, 'call', _53 => _53(), 'optionalAccess', _54 => _54.spanContext, 'call', _55 => _55()]);
|
|
1453
1600
|
if (!active || (active.traceFlags & _api.TraceFlags.SAMPLED) !== 0) return;
|
|
1454
1601
|
const entry = this.entryFor(active.traceId);
|
|
1455
1602
|
if (entry.retained) return;
|
|
@@ -1570,15 +1717,15 @@ async function runLlmSpan(tracer, info, fn) {
|
|
|
1570
1717
|
return result;
|
|
1571
1718
|
} catch (err) {
|
|
1572
1719
|
recordError(span, err);
|
|
1573
|
-
if (
|
|
1720
|
+
if (_chunkFV64SIRQcjs.isError.call(void 0, err)) span.setAttribute("error.type", err.name);
|
|
1574
1721
|
throw err;
|
|
1575
1722
|
} finally {
|
|
1576
1723
|
span.end();
|
|
1577
|
-
|
|
1724
|
+
_chunkFV64SIRQcjs.recordOperationAiUsage.call(void 0, { ...usage, model: _nullishCoalesce(responseModel, () => ( info.model)) });
|
|
1578
1725
|
}
|
|
1579
1726
|
}
|
|
1580
1727
|
function recordLlmCall(tracer, call) {
|
|
1581
|
-
|
|
1728
|
+
_chunkFV64SIRQcjs.recordOperationAiUsage.call(void 0, { ...call, model: call.model });
|
|
1582
1729
|
const durationMs = Math.max(0, _nullishCoalesce(call.durationMs, () => ( 0)));
|
|
1583
1730
|
const endTime = /* @__PURE__ */ new Date();
|
|
1584
1731
|
const startTime = new Date(endTime.getTime() - durationMs);
|
|
@@ -1592,7 +1739,7 @@ function recordLlmCall(tracer, call) {
|
|
|
1592
1739
|
);
|
|
1593
1740
|
if (call.error !== void 0 && call.error !== null) {
|
|
1594
1741
|
recordError(span, call.error);
|
|
1595
|
-
if (
|
|
1742
|
+
if (_chunkFV64SIRQcjs.isError.call(void 0, call.error)) {
|
|
1596
1743
|
span.setAttribute("error.type", call.error.name);
|
|
1597
1744
|
}
|
|
1598
1745
|
} else {
|
|
@@ -1603,7 +1750,7 @@ function recordLlmCall(tracer, call) {
|
|
|
1603
1750
|
async function runWithSpan(tracer, name, fn, attributes, links) {
|
|
1604
1751
|
const span = tracer.startSpan(name, {
|
|
1605
1752
|
attributes,
|
|
1606
|
-
..._optionalChain([links, 'optionalAccess',
|
|
1753
|
+
..._optionalChain([links, 'optionalAccess', _56 => _56.length]) ? { links } : {}
|
|
1607
1754
|
});
|
|
1608
1755
|
try {
|
|
1609
1756
|
const result = await _api.context.with(
|
|
@@ -1620,14 +1767,14 @@ async function runWithSpan(tracer, name, fn, attributes, links) {
|
|
|
1620
1767
|
}
|
|
1621
1768
|
}
|
|
1622
1769
|
function recordError(span, err) {
|
|
1623
|
-
const isErr =
|
|
1770
|
+
const isErr = _chunkFV64SIRQcjs.isError.call(void 0, err);
|
|
1624
1771
|
const message = S.redactor.text(isErr ? err.message : String(err));
|
|
1625
1772
|
if (isErr) {
|
|
1626
1773
|
span.addEvent("exception", {
|
|
1627
1774
|
"exception.type": err.name,
|
|
1628
1775
|
"exception.message": message,
|
|
1629
1776
|
...err.stack ? { "exception.stacktrace": S.redactor.text(err.stack) } : {},
|
|
1630
|
-
...
|
|
1777
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text, err)
|
|
1631
1778
|
});
|
|
1632
1779
|
}
|
|
1633
1780
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
|
|
@@ -1640,14 +1787,14 @@ function patchLoadedHttpModules() {
|
|
|
1640
1787
|
const load = _module.createRequire.call(void 0, _path.join.call(void 0, process.cwd(), "autter-runtime-http.cjs"));
|
|
1641
1788
|
load("http");
|
|
1642
1789
|
load("https");
|
|
1643
|
-
} catch (
|
|
1790
|
+
} catch (e32) {
|
|
1644
1791
|
}
|
|
1645
1792
|
}
|
|
1646
1793
|
var METRIC_ROUTE_ATTR = "autter.metric_has_route";
|
|
1647
1794
|
function captureRequestRoute(span, response) {
|
|
1648
1795
|
if (!(response instanceof _http.ServerResponse)) return;
|
|
1649
1796
|
const rpcMetadata = _core.getRPCMetadata.call(void 0, _api.context.active());
|
|
1650
|
-
if (_optionalChain([rpcMetadata, 'optionalAccess',
|
|
1797
|
+
if (_optionalChain([rpcMetadata, 'optionalAccess', _57 => _57.type]) !== _core.RPCType.HTTP) return;
|
|
1651
1798
|
let failed = false;
|
|
1652
1799
|
response.on(_events.errorMonitor, () => {
|
|
1653
1800
|
failed = true;
|
|
@@ -1665,14 +1812,14 @@ function captureRequestRoute(span, response) {
|
|
|
1665
1812
|
if (S.hookRequests) startHookRequest(response);
|
|
1666
1813
|
}
|
|
1667
1814
|
function structuredErrorAttributes(error) {
|
|
1668
|
-
const attrs = { ...
|
|
1669
|
-
const internal =
|
|
1815
|
+
const attrs = { ..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error, { causes: false }) };
|
|
1816
|
+
const internal = _chunkFV64SIRQcjs.errorInternal.call(void 0, error);
|
|
1670
1817
|
if (internal) {
|
|
1671
1818
|
try {
|
|
1672
1819
|
attrs["autter.error.internal"] = JSON.stringify(
|
|
1673
1820
|
S.redactor(internal)
|
|
1674
1821
|
).slice(0, 4e3);
|
|
1675
|
-
} catch (
|
|
1822
|
+
} catch (e33) {
|
|
1676
1823
|
}
|
|
1677
1824
|
}
|
|
1678
1825
|
return attrs;
|
|
@@ -1684,9 +1831,9 @@ function initAutterServer(options) {
|
|
|
1684
1831
|
""
|
|
1685
1832
|
);
|
|
1686
1833
|
const headers = { authorization: `Bearer ${options.apiKey}` };
|
|
1687
|
-
const redactor =
|
|
1834
|
+
const redactor = _chunkFV64SIRQcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
|
|
1688
1835
|
const queryPolicy = makeUrlQueryPolicy(options.keepQueryParams);
|
|
1689
|
-
const traceExporter = () => new (0,
|
|
1836
|
+
const traceExporter = () => new (0, _chunk3P573RHAcjs.CountingExporter)(
|
|
1690
1837
|
new RedactingSpanExporter(
|
|
1691
1838
|
new (0, _exportertraceotlphttp.OTLPTraceExporter)({ url: `${endpoint}/v1/traces`, headers }),
|
|
1692
1839
|
() => redactor,
|
|
@@ -1694,11 +1841,11 @@ function initAutterServer(options) {
|
|
|
1694
1841
|
)
|
|
1695
1842
|
);
|
|
1696
1843
|
const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
|
|
1697
|
-
if (
|
|
1698
|
-
|
|
1844
|
+
if (_chunk3P573RHAcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk3P573RHAcjs.setDebugMode.call(void 0, true);
|
|
1845
|
+
_chunk3P573RHAcjs.debugLog.call(void 0, `initialising service=${options.service} endpoint=${endpoint}`);
|
|
1699
1846
|
S.redactor = redactor;
|
|
1700
|
-
const distro = _nullishCoalesce(options.distro, () => (
|
|
1701
|
-
|
|
1847
|
+
const distro = _nullishCoalesce(options.distro, () => ( _chunk3P573RHAcjs.SDK_IDENTITY));
|
|
1848
|
+
_chunk3P573RHAcjs.configureCompatCheck.call(void 0, { endpoint, enabled: options.compatCheck !== false, sdk: distro });
|
|
1702
1849
|
const resource = new (0, _resources.Resource)({
|
|
1703
1850
|
[_semanticconventions.ATTR_SERVICE_NAME]: options.service,
|
|
1704
1851
|
"service.instance.id": (options.instanceId || process.env.AUTTER_RUNTIME_INSTANCE_ID || _crypto.randomUUID.call(void 0, )).slice(0, 128),
|
|
@@ -1719,7 +1866,7 @@ function initAutterServer(options) {
|
|
|
1719
1866
|
// its span-fed per-route counts.
|
|
1720
1867
|
"autter.metrics_routes": true
|
|
1721
1868
|
});
|
|
1722
|
-
const errorFilter =
|
|
1869
|
+
const errorFilter = _chunkFV64SIRQcjs.createErrorFilter.call(void 0, { ignoreErrors: options.ignoreErrors, sampleRate: options.sampleRate });
|
|
1723
1870
|
const rootSampler = new (0, _sdktracebase.TraceIdRatioBasedSampler)(_nullishCoalesce(options.traceSampleRate, () => ( 0.01)));
|
|
1724
1871
|
const headSampler = new (0, _sdktracebase.ParentBasedSampler)({
|
|
1725
1872
|
root: rootSampler,
|
|
@@ -1781,9 +1928,9 @@ function initAutterServer(options) {
|
|
|
1781
1928
|
sdk.start();
|
|
1782
1929
|
patchLoadedHttpModules();
|
|
1783
1930
|
const stopMemoryMetrics = options.memoryMetrics === false ? null : startMemoryMetrics();
|
|
1784
|
-
|
|
1785
|
-
if (stopMemoryMetrics)
|
|
1786
|
-
if (options.llmTracing !== false)
|
|
1931
|
+
_chunk3P573RHAcjs.noteCompatFeature.call(void 0, "endpoint_latency");
|
|
1932
|
+
if (stopMemoryMetrics) _chunk3P573RHAcjs.noteCompatFeature.call(void 0, "memory_metrics");
|
|
1933
|
+
if (options.llmTracing !== false) _chunk3P573RHAcjs.noteCompatFeature.call(void 0, "llm_calls");
|
|
1787
1934
|
const alwaysOnProvider = new (0, _sdktracebase.BasicTracerProvider)({
|
|
1788
1935
|
resource,
|
|
1789
1936
|
sampler: new (0, _sdktracebase.AlwaysOnSampler)(),
|
|
@@ -1795,44 +1942,44 @@ function initAutterServer(options) {
|
|
|
1795
1942
|
const processTracer = alwaysOnProvider.getTracer("autter-processes");
|
|
1796
1943
|
const llmTracer = alwaysOnProvider.getTracer("autter-llm");
|
|
1797
1944
|
function captureException2(error, attributes) {
|
|
1798
|
-
const isErrValue =
|
|
1945
|
+
const isErrValue = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
1799
1946
|
const reported = errorFilter({
|
|
1800
1947
|
type: isErrValue ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
|
|
1801
1948
|
message: isErrValue ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
|
|
1802
|
-
crash: _optionalChain([attributes, 'optionalAccess',
|
|
1949
|
+
crash: _optionalChain([attributes, 'optionalAccess', _58 => _58["autter.unhandled"]]) === true || _optionalChain([attributes, 'optionalAccess', _59 => _59["autter.unhandled_rejection"]]) === true
|
|
1803
1950
|
});
|
|
1804
1951
|
if (!reported) {
|
|
1805
|
-
markCaptured(error);
|
|
1952
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
1806
1953
|
return;
|
|
1807
1954
|
}
|
|
1808
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
1809
|
-
|
|
1810
|
-
const isErr =
|
|
1955
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _60 => _60.retainActiveTrace, 'call', _61 => _61()]);
|
|
1956
|
+
_chunk3P573RHAcjs.telemetryStats.markCaptured();
|
|
1957
|
+
const isErr = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
1811
1958
|
const message = redactor.text(isErr ? error.message : String(error));
|
|
1812
1959
|
const stackText = isErr && error.stack ? redactor.text(error.stack) : "";
|
|
1813
|
-
const split =
|
|
1814
|
-
const fingerprint =
|
|
1815
|
-
if (fingerprint["autter.fingerprint"])
|
|
1960
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
1961
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
|
|
1962
|
+
if (fingerprint["autter.fingerprint"]) _chunk3P573RHAcjs.noteCompatFeature.call(void 0, "fingerprint_override");
|
|
1816
1963
|
const redacted = redactor(split.attributes);
|
|
1817
1964
|
const activeSpan = _api.trace.getActiveSpan();
|
|
1818
|
-
const reuseActive = _optionalChain([activeSpan, 'optionalAccess',
|
|
1965
|
+
const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _62 => _62.isRecording, 'call', _63 => _63()]) === true;
|
|
1819
1966
|
const span = reuseActive ? activeSpan : errorTracer.startSpan(isErr ? error.name : "Error");
|
|
1820
1967
|
const structured = structuredErrorAttributes(error);
|
|
1821
|
-
const causes =
|
|
1968
|
+
const causes = _chunkFV64SIRQcjs.errorAttributes.call(void 0, error);
|
|
1822
1969
|
const declared = {
|
|
1823
1970
|
...Object.fromEntries(Object.entries(causes).filter(([key]) => key !== "autter.error.internal")),
|
|
1824
1971
|
...fingerprint
|
|
1825
1972
|
};
|
|
1826
|
-
const requestId = _optionalChain([
|
|
1973
|
+
const requestId = _optionalChain([_chunkFV64SIRQcjs.currentOperation.call(void 0, ), 'optionalAccess', _64 => _64.requestId]);
|
|
1827
1974
|
span.setAttributes({
|
|
1828
1975
|
"autter.severity": "error",
|
|
1829
1976
|
...redacted,
|
|
1830
1977
|
...structured,
|
|
1831
1978
|
...requestId ? { "autter.request.id": requestId } : {}
|
|
1832
1979
|
});
|
|
1833
|
-
markCaptured(error);
|
|
1834
|
-
|
|
1835
|
-
|
|
1980
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
1981
|
+
_chunkFV64SIRQcjs.noteOperationError.call(void 0, error);
|
|
1982
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
1836
1983
|
if (isErr && stackText) {
|
|
1837
1984
|
span.addEvent("exception", {
|
|
1838
1985
|
"exception.type": error.name,
|
|
@@ -1840,17 +1987,17 @@ function initAutterServer(options) {
|
|
|
1840
1987
|
"exception.stacktrace": stackText,
|
|
1841
1988
|
...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
|
|
1842
1989
|
...declared,
|
|
1843
|
-
...
|
|
1990
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
|
|
1844
1991
|
});
|
|
1845
1992
|
} else {
|
|
1846
|
-
const stack = _optionalChain([new Error(), 'access',
|
|
1993
|
+
const stack = _optionalChain([new Error(), 'access', _65 => _65.stack, 'optionalAccess', _66 => _66.split, 'call', _67 => _67("\n"), 'access', _68 => _68.filter, 'call', _69 => _69((line, i) => i === 0 || !line.includes("captureException")), 'access', _70 => _70.join, 'call', _71 => _71("\n")]);
|
|
1847
1994
|
span.addEvent("exception", {
|
|
1848
1995
|
"exception.type": isErr ? error.name : "Error",
|
|
1849
1996
|
"exception.message": message,
|
|
1850
1997
|
...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
|
|
1851
1998
|
...redacted["autter.handled"] === true ? { "autter.handled": true, "autter.sampled": redacted["autter.sampled"] === true } : {},
|
|
1852
1999
|
...declared,
|
|
1853
|
-
...
|
|
2000
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
|
|
1854
2001
|
});
|
|
1855
2002
|
}
|
|
1856
2003
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message });
|
|
@@ -1859,10 +2006,10 @@ function initAutterServer(options) {
|
|
|
1859
2006
|
function captureMessage2(message, severity = "warning", attributes) {
|
|
1860
2007
|
if (!errorFilter({ type: "Message", message: String(message), severity })) return;
|
|
1861
2008
|
if (severity === "error" || severity === "fatal") {
|
|
1862
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
2009
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _72 => _72.retainActiveTrace, 'call', _73 => _73()]);
|
|
1863
2010
|
}
|
|
1864
|
-
|
|
1865
|
-
const stack = _optionalChain([new Error(), 'access',
|
|
2011
|
+
_chunk3P573RHAcjs.telemetryStats.markCaptured();
|
|
2012
|
+
const stack = _optionalChain([new Error(), 'access', _74 => _74.stack, 'optionalAccess', _75 => _75.split, 'call', _76 => _76("\n"), 'access', _77 => _77.filter, 'call', _78 => _78((line, i) => i === 0 || !line.includes("captureMessage")), 'access', _79 => _79.join, 'call', _80 => _80("\n")]);
|
|
1866
2013
|
const safeMessage = redactor.text(message);
|
|
1867
2014
|
const span = errorTracer.startSpan("Message", {
|
|
1868
2015
|
attributes: { "autter.severity": severity, ...redactor(attributes) }
|
|
@@ -1872,17 +2019,17 @@ function initAutterServer(options) {
|
|
|
1872
2019
|
"exception.message": safeMessage,
|
|
1873
2020
|
...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
|
|
1874
2021
|
"autter.severity": severity,
|
|
1875
|
-
...
|
|
2022
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, redactor.text)
|
|
1876
2023
|
});
|
|
1877
2024
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
|
|
1878
2025
|
span.end();
|
|
1879
2026
|
}
|
|
1880
2027
|
function reportOutcome2(name, message, attributes) {
|
|
1881
2028
|
if (!errorFilter({ type: "OutcomeFailure", message: `${name}: ${message}` })) return;
|
|
1882
|
-
_optionalChain([errorTraceBuffer, 'optionalAccess',
|
|
1883
|
-
|
|
2029
|
+
_optionalChain([errorTraceBuffer, 'optionalAccess', _81 => _81.retainActiveTrace, 'call', _82 => _82()]);
|
|
2030
|
+
_chunk3P573RHAcjs.telemetryStats.markCaptured();
|
|
1884
2031
|
const activeSpan = _api.trace.getActiveSpan();
|
|
1885
|
-
const reuseActive = _optionalChain([activeSpan, 'optionalAccess',
|
|
2032
|
+
const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _83 => _83.isRecording, 'call', _84 => _84()]) === true;
|
|
1886
2033
|
const span = reuseActive ? activeSpan : errorTracer.startSpan("OutcomeFailure");
|
|
1887
2034
|
const safeOutcome = redactor({ "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
|
|
1888
2035
|
const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
|
|
@@ -1896,7 +2043,38 @@ function initAutterServer(options) {
|
|
|
1896
2043
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
|
|
1897
2044
|
if (!reuseActive) span.end();
|
|
1898
2045
|
}
|
|
1899
|
-
|
|
2046
|
+
function captureHandled(error, attributes, severity) {
|
|
2047
|
+
const isErr = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
2048
|
+
if (!errorFilter({
|
|
2049
|
+
type: isErr ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
|
|
2050
|
+
message: isErr ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
|
|
2051
|
+
severity
|
|
2052
|
+
})) return;
|
|
2053
|
+
if (severity === "error") _optionalChain([errorTraceBuffer, 'optionalAccess', _85 => _85.retainActiveTrace, 'call', _86 => _86()]);
|
|
2054
|
+
_chunk3P573RHAcjs.telemetryStats.markCaptured();
|
|
2055
|
+
const message = redactor.text(isErr ? error.message : String(error));
|
|
2056
|
+
const stack = isErr && error.stack ? error.stack : _optionalChain([new Error(), 'access', _87 => _87.stack, 'optionalAccess', _88 => _88.split, 'call', _89 => _89("\n"), 'access', _90 => _90.filter, 'call', _91 => _91((line, i) => i === 0 || !/captureHandled|report(?:Degraded|LoggedError)/.test(line)), 'access', _92 => _92.join, 'call', _93 => _93("\n")]);
|
|
2057
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2058
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redactor.text);
|
|
2059
|
+
const redacted = redactor(split.attributes);
|
|
2060
|
+
const activeSpan = _api.trace.getActiveSpan();
|
|
2061
|
+
const reuseActive = _optionalChain([activeSpan, 'optionalAccess', _94 => _94.isRecording, 'call', _95 => _95()]) === true;
|
|
2062
|
+
const span = reuseActive ? activeSpan : errorTracer.startSpan(isErr ? error.name : "Error");
|
|
2063
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2064
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint, "autter.severity": severity });
|
|
2065
|
+
span.addEvent("exception", {
|
|
2066
|
+
...redacted,
|
|
2067
|
+
"exception.type": isErr ? error.name : "Error",
|
|
2068
|
+
"exception.message": message,
|
|
2069
|
+
...stack ? { "exception.stacktrace": redactor.text(stack) } : {},
|
|
2070
|
+
"autter.severity": severity,
|
|
2071
|
+
..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error),
|
|
2072
|
+
...fingerprint,
|
|
2073
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, redactor.text, error)
|
|
2074
|
+
});
|
|
2075
|
+
if (!reuseActive) span.end();
|
|
2076
|
+
}
|
|
2077
|
+
_chunkFV64SIRQcjs.configureRuntimeLogger.call(void 0, {
|
|
1900
2078
|
endpoint,
|
|
1901
2079
|
apiKey: options.apiKey,
|
|
1902
2080
|
service: options.service,
|
|
@@ -1908,7 +2086,9 @@ function initAutterServer(options) {
|
|
|
1908
2086
|
run: (name, fn, attributes, links) => runWithSpan(processTracer, name, fn, redactor(attributes), links),
|
|
1909
2087
|
reportOutcome: reportOutcome2
|
|
1910
2088
|
});
|
|
1911
|
-
S.hookRequests = _optionalChain([options, 'access',
|
|
2089
|
+
S.hookRequests = _optionalChain([options, 'access', _96 => _96.logging, 'optionalAccess', _97 => _97.requests]) === true;
|
|
2090
|
+
S.handled = captureHandled;
|
|
2091
|
+
_chunkFV64SIRQcjs.startLoggedErrorCapture.call(void 0, options.captureLoggedErrors);
|
|
1912
2092
|
let onCrash = null;
|
|
1913
2093
|
let uninstallRejections = null;
|
|
1914
2094
|
if (options.captureGlobalErrors !== false) {
|
|
@@ -1928,7 +2108,7 @@ function initAutterServer(options) {
|
|
|
1928
2108
|
const flushTarget = {
|
|
1929
2109
|
forceFlush: async () => {
|
|
1930
2110
|
const results = await Promise.allSettled([
|
|
1931
|
-
|
|
2111
|
+
_chunkFV64SIRQcjs.flushRuntimeLogs.call(void 0, ),
|
|
1932
2112
|
Promise.resolve().then(() => alwaysOnProvider.forceFlush()),
|
|
1933
2113
|
Promise.resolve().then(() => mainSpanProcessor.forceFlush()),
|
|
1934
2114
|
...errorTraceBuffer ? [Promise.resolve().then(() => errorTraceBuffer.forceFlush())] : [],
|
|
@@ -1942,10 +2122,10 @@ function initAutterServer(options) {
|
|
|
1942
2122
|
}
|
|
1943
2123
|
}
|
|
1944
2124
|
};
|
|
1945
|
-
|
|
2125
|
+
_chunk3P573RHAcjs.registerFlushTarget.call(void 0, "active-server", flushTarget);
|
|
1946
2126
|
let autoFlushHandle = null;
|
|
1947
2127
|
if (options.autoFlush !== false) {
|
|
1948
|
-
autoFlushHandle =
|
|
2128
|
+
autoFlushHandle = _chunk3P573RHAcjs.installAutterAutoFlush.call(void 0, );
|
|
1949
2129
|
}
|
|
1950
2130
|
const server = {
|
|
1951
2131
|
captureException: captureException2,
|
|
@@ -1955,22 +2135,24 @@ function initAutterServer(options) {
|
|
|
1955
2135
|
withLlmCall: (info, fn) => runLlmSpan(llmTracer, info, fn),
|
|
1956
2136
|
trackLlmCall: (call) => recordLlmCall(llmTracer, call),
|
|
1957
2137
|
shutdown: async () => {
|
|
1958
|
-
|
|
2138
|
+
if (S.active === server) _chunkFV64SIRQcjs.stopLoggedErrorCapture.call(void 0, );
|
|
2139
|
+
const logShutdown = await Promise.allSettled([_chunkFV64SIRQcjs.shutdownRuntimeLogger.call(void 0, )]);
|
|
1959
2140
|
if (onCrash) process.off("uncaughtExceptionMonitor", onCrash);
|
|
1960
|
-
_optionalChain([uninstallRejections, 'optionalCall',
|
|
1961
|
-
_optionalChain([stopMemoryMetrics, 'optionalCall',
|
|
2141
|
+
_optionalChain([uninstallRejections, 'optionalCall', _98 => _98()]);
|
|
2142
|
+
_optionalChain([stopMemoryMetrics, 'optionalCall', _99 => _99()]);
|
|
1962
2143
|
if (S.active === server) {
|
|
1963
2144
|
S.active = null;
|
|
1964
2145
|
S.alwaysOnProvider = null;
|
|
2146
|
+
S.handled = null;
|
|
1965
2147
|
S.hookRequests = false;
|
|
1966
|
-
S.redactor =
|
|
2148
|
+
S.redactor = _chunkFV64SIRQcjs.makeRedactor.call(void 0, true);
|
|
1967
2149
|
}
|
|
1968
|
-
_optionalChain([autoFlushHandle, 'optionalAccess',
|
|
2150
|
+
_optionalChain([autoFlushHandle, 'optionalAccess', _100 => _100.dispose, 'call', _101 => _101()]);
|
|
1969
2151
|
autoFlushHandle = null;
|
|
1970
|
-
|
|
1971
|
-
|
|
2152
|
+
_chunk3P573RHAcjs.unregisterFlushTargets.call(void 0, );
|
|
2153
|
+
_chunk3P573RHAcjs.telemetryStats.markAllFlushed();
|
|
1972
2154
|
await Promise.allSettled([alwaysOnProvider.shutdown(), sdk.shutdown()]);
|
|
1973
|
-
if (_optionalChain([logShutdown, 'access',
|
|
2155
|
+
if (_optionalChain([logShutdown, 'access', _102 => _102[0], 'optionalAccess', _103 => _103.status]) === "rejected") throw logShutdown[0].reason;
|
|
1974
2156
|
}
|
|
1975
2157
|
};
|
|
1976
2158
|
S.active = server;
|
|
@@ -1986,27 +2168,53 @@ function captureException(error, attributes) {
|
|
|
1986
2168
|
S.loggerOnlyCapture(error, attributes);
|
|
1987
2169
|
return;
|
|
1988
2170
|
}
|
|
1989
|
-
markCaptured(error);
|
|
1990
|
-
|
|
1991
|
-
const split =
|
|
1992
|
-
const fingerprint =
|
|
1993
|
-
|
|
1994
|
-
const span = _api.trace.getTracer("autter-errors").startSpan(
|
|
2171
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2172
|
+
_chunkFV64SIRQcjs.noteOperationError.call(void 0, error);
|
|
2173
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2174
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text);
|
|
2175
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...split.attributes, ...fingerprint });
|
|
2176
|
+
const span = _api.trace.getTracer("autter-errors").startSpan(_chunkFV64SIRQcjs.isError.call(void 0, error) ? error.name : "Error", {
|
|
1995
2177
|
attributes: { ...S.redactor(split.attributes), ...fingerprint }
|
|
1996
2178
|
});
|
|
1997
2179
|
recordError(span, error);
|
|
1998
2180
|
span.end();
|
|
1999
2181
|
}
|
|
2000
|
-
function setLoggerOnlyCapture(fn) {
|
|
2182
|
+
function setLoggerOnlyCapture(fn, handled = null) {
|
|
2001
2183
|
S.loggerOnlyCapture = fn;
|
|
2184
|
+
S.loggerOnlyHandled = handled;
|
|
2185
|
+
}
|
|
2186
|
+
function captureHandledError(error, attributes, severity) {
|
|
2187
|
+
if (S.active) {
|
|
2188
|
+
_optionalChain([S, 'access', _104 => _104.handled, 'optionalCall', _105 => _105(error, attributes, severity)]);
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
if (S.loggerOnlyHandled) {
|
|
2192
|
+
S.loggerOnlyHandled(error, attributes, severity);
|
|
2193
|
+
return;
|
|
2194
|
+
}
|
|
2195
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2196
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2197
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...split.attributes, "autter.severity": severity });
|
|
2198
|
+
const span = _api.trace.getTracer("autter-errors").startSpan(_chunkFV64SIRQcjs.isError.call(void 0, error) ? error.name : "Error");
|
|
2199
|
+
span.addEvent("exception", {
|
|
2200
|
+
...S.redactor(split.attributes),
|
|
2201
|
+
"exception.type": _chunkFV64SIRQcjs.isError.call(void 0, error) ? error.name : "Error",
|
|
2202
|
+
"exception.message": S.redactor.text(_chunkFV64SIRQcjs.isError.call(void 0, error) ? error.message : String(error)),
|
|
2203
|
+
..._chunkFV64SIRQcjs.isError.call(void 0, error) && error.stack ? { "exception.stacktrace": S.redactor.text(error.stack) } : {},
|
|
2204
|
+
"autter.severity": severity,
|
|
2205
|
+
..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error),
|
|
2206
|
+
..._chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, S.redactor.text)
|
|
2207
|
+
});
|
|
2208
|
+
span.end();
|
|
2002
2209
|
}
|
|
2003
2210
|
function serverActive() {
|
|
2004
2211
|
return S.active !== null;
|
|
2005
2212
|
}
|
|
2006
2213
|
setRequestExceptionCapturer((error, attributes) => captureException(error, attributes));
|
|
2214
|
+
_chunkFV64SIRQcjs.setHandledCapture.call(void 0, captureHandledError);
|
|
2007
2215
|
setRequestSpanAnnotator((attributes) => {
|
|
2008
2216
|
const span = _api.trace.getActiveSpan();
|
|
2009
|
-
if (_optionalChain([span, 'optionalAccess',
|
|
2217
|
+
if (_optionalChain([span, 'optionalAccess', _106 => _106.isRecording, 'call', _107 => _107()])) span.setAttributes(S.redactor(_chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes).attributes));
|
|
2010
2218
|
});
|
|
2011
2219
|
function withProcessSpan(name, fn, attributes) {
|
|
2012
2220
|
if (S.active) return S.active.withProcessSpan(name, fn, attributes);
|
|
@@ -2041,7 +2249,7 @@ function captureMessage(message, severity = "warning", attributes) {
|
|
|
2041
2249
|
"exception.type": "Message",
|
|
2042
2250
|
"exception.message": safeMessage,
|
|
2043
2251
|
"autter.severity": severity,
|
|
2044
|
-
...
|
|
2252
|
+
..._chunkFV64SIRQcjs.breadcrumbEventAttributes.call(void 0, S.redactor.text)
|
|
2045
2253
|
});
|
|
2046
2254
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: safeMessage });
|
|
2047
2255
|
span.end();
|
|
@@ -2049,11 +2257,11 @@ function captureMessage(message, severity = "warning", attributes) {
|
|
|
2049
2257
|
function reportOutcome(name, message, attributes) {
|
|
2050
2258
|
if (S.active) return S.active.reportOutcome(name, message, attributes);
|
|
2051
2259
|
const span = _api.trace.getTracer("autter-outcomes").startSpan("OutcomeFailure");
|
|
2052
|
-
const safeOutcome =
|
|
2260
|
+
const safeOutcome = _chunkFV64SIRQcjs.redactAttributes.call(void 0, { "autter.outcome.name": name.slice(0, 200), "autter.outcome.message": message.slice(0, 1e3) });
|
|
2053
2261
|
const safeName = String(_nullishCoalesce(safeOutcome["autter.outcome.name"], () => ( "operation")));
|
|
2054
2262
|
const safeMessage = String(_nullishCoalesce(safeOutcome["autter.outcome.message"], () => ( "failed")));
|
|
2055
2263
|
span.addEvent("autter.outcome", {
|
|
2056
|
-
...
|
|
2264
|
+
..._chunkFV64SIRQcjs.redactAttributes.call(void 0, attributes),
|
|
2057
2265
|
"autter.outcome.status": "error",
|
|
2058
2266
|
"autter.outcome.name": safeName,
|
|
2059
2267
|
"autter.outcome.message": safeMessage
|
|
@@ -2062,7 +2270,7 @@ function reportOutcome(name, message, attributes) {
|
|
|
2062
2270
|
span.end();
|
|
2063
2271
|
}
|
|
2064
2272
|
function makeSafeCapture(options) {
|
|
2065
|
-
const clean = (attributes) => attributes ? { ...
|
|
2273
|
+
const clean = (attributes) => attributes ? { ..._chunkFV64SIRQcjs.redactAttributes.call(void 0, attributes, options) } : void 0;
|
|
2066
2274
|
return {
|
|
2067
2275
|
captureException: (error, attributes) => captureException(error, clean(attributes)),
|
|
2068
2276
|
captureMessage: (message, severity, attributes) => captureMessage(message, _nullishCoalesce(severity, () => ( "warning")), clean(attributes))
|
|
@@ -2089,7 +2297,7 @@ async function emitLlmSelftestTrace() {
|
|
|
2089
2297
|
attributes: { "autter.selftest": true }
|
|
2090
2298
|
},
|
|
2091
2299
|
(llm) => {
|
|
2092
|
-
traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access',
|
|
2300
|
+
traceId = _nullishCoalesce(_optionalChain([_api.trace, 'access', _108 => _108.getActiveSpan, 'call', _109 => _109(), 'optionalAccess', _110 => _110.spanContext, 'call', _111 => _111(), 'access', _112 => _112.traceId]), () => ( ""));
|
|
2093
2301
|
llm.setUsage({ inputTokens: 1, outputTokens: 1 });
|
|
2094
2302
|
llm.setCost(0);
|
|
2095
2303
|
}
|
|
@@ -2117,7 +2325,7 @@ var CALL_METHODS = /* @__PURE__ */ new Set([
|
|
|
2117
2325
|
// openai beta structured outputs
|
|
2118
2326
|
]);
|
|
2119
2327
|
function detectProvider(client) {
|
|
2120
|
-
const name = _nullishCoalesce(_optionalChain([client, 'access',
|
|
2328
|
+
const name = _nullishCoalesce(_optionalChain([client, 'access', _113 => _113.constructor, 'optionalAccess', _114 => _114.name, 'optionalAccess', _115 => _115.toLowerCase, 'call', _116 => _116()]), () => ( ""));
|
|
2121
2329
|
for (const known of ["openai", "anthropic", "mistral", "groq", "cohere"]) {
|
|
2122
2330
|
if (name.includes(known)) return known;
|
|
2123
2331
|
}
|
|
@@ -2125,7 +2333,7 @@ function detectProvider(client) {
|
|
|
2125
2333
|
const baseUrl = String(
|
|
2126
2334
|
_nullishCoalesce(_nullishCoalesce(client.baseURL, () => ( client.baseUrl)), () => ( ""))
|
|
2127
2335
|
);
|
|
2128
|
-
const host = _nullishCoalesce(_optionalChain([baseUrl, 'access',
|
|
2336
|
+
const host = _nullishCoalesce(_optionalChain([baseUrl, 'access', _117 => _117.match, 'call', _118 => _118(/https?:\/\/([^/]+)/), 'optionalAccess', _119 => _119[1]]), () => ( ""));
|
|
2129
2337
|
if (host.includes("openai")) return "openai";
|
|
2130
2338
|
if (host.includes("anthropic")) return "anthropic";
|
|
2131
2339
|
if (host.includes("googleapis")) return "google";
|
|
@@ -2135,13 +2343,13 @@ function detectProvider(client) {
|
|
|
2135
2343
|
}
|
|
2136
2344
|
function extractUsage(result) {
|
|
2137
2345
|
const r = result;
|
|
2138
|
-
const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
2139
|
-
const meta = _optionalChain([r, 'optionalAccess',
|
|
2140
|
-
const details = _optionalChain([usage, 'optionalAccess',
|
|
2141
|
-
const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
2142
|
-
const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
2143
|
-
const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess',
|
|
2144
|
-
const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
2346
|
+
const usage = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.usage]), () => ( _optionalChain([r, 'optionalAccess', _121 => _121.message, 'optionalAccess', _122 => _122.usage])));
|
|
2347
|
+
const meta = _optionalChain([r, 'optionalAccess', _123 => _123.usageMetadata]);
|
|
2348
|
+
const details = _optionalChain([usage, 'optionalAccess', _124 => _124.prompt_tokens_details]);
|
|
2349
|
+
const cached = _nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _125 => _125.cache_read_input_tokens]), () => ( (typeof _optionalChain([details, 'optionalAccess', _126 => _126.cached_tokens]) === "number" ? details.cached_tokens : void 0))), () => ( _optionalChain([meta, 'optionalAccess', _127 => _127.cachedContentTokenCount])));
|
|
2350
|
+
const input = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _128 => _128.prompt_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _129 => _129.input_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _130 => _130.promptTokenCount]))), () => ( void 0));
|
|
2351
|
+
const output = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([usage, 'optionalAccess', _131 => _131.completion_tokens]), () => ( _optionalChain([usage, 'optionalAccess', _132 => _132.output_tokens]))), () => ( _optionalChain([meta, 'optionalAccess', _133 => _133.candidatesTokenCount]))), () => ( void 0));
|
|
2352
|
+
const responseModel = _nullishCoalesce(_optionalChain([r, 'optionalAccess', _134 => _134.model]), () => ( _optionalChain([r, 'optionalAccess', _135 => _135.modelVersion])));
|
|
2145
2353
|
return {
|
|
2146
2354
|
inputTokens: typeof input === "number" ? input : void 0,
|
|
2147
2355
|
outputTokens: typeof output === "number" ? output : void 0,
|
|
@@ -2150,7 +2358,7 @@ function extractUsage(result) {
|
|
|
2150
2358
|
};
|
|
2151
2359
|
}
|
|
2152
2360
|
function rollUp(model, usage) {
|
|
2153
|
-
|
|
2361
|
+
_chunkFV64SIRQcjs.recordOperationAiUsage.call(void 0, {
|
|
2154
2362
|
model: _nullishCoalesce(usage.responseModel, () => ( model)),
|
|
2155
2363
|
...usage.inputTokens !== void 0 ? { inputTokens: usage.inputTokens } : {},
|
|
2156
2364
|
...usage.outputTokens !== void 0 ? { outputTokens: usage.outputTokens } : {},
|
|
@@ -2234,10 +2442,10 @@ function wrapStream(stream, span, model) {
|
|
|
2234
2442
|
});
|
|
2235
2443
|
}
|
|
2236
2444
|
function instrumentLlmClient(client, options) {
|
|
2237
|
-
const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2445
|
+
const provider = (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _136 => _136.provider]), () => ( detectProvider(client)))).toLowerCase();
|
|
2238
2446
|
const proxied = /* @__PURE__ */ new WeakMap();
|
|
2239
2447
|
function resolveUserId() {
|
|
2240
|
-
return typeof _optionalChain([options, 'optionalAccess',
|
|
2448
|
+
return typeof _optionalChain([options, 'optionalAccess', _137 => _137.userId]) === "function" ? options.userId() : _optionalChain([options, 'optionalAccess', _138 => _138.userId]);
|
|
2241
2449
|
}
|
|
2242
2450
|
function traceCall(fn, self, callPath, args) {
|
|
2243
2451
|
const request = args[0];
|
|
@@ -2251,7 +2459,7 @@ function instrumentLlmClient(client, options) {
|
|
|
2251
2459
|
"gen_ai.system": provider,
|
|
2252
2460
|
"gen_ai.request.model": request.model,
|
|
2253
2461
|
...userId ? { "autter.user_id": userId } : {},
|
|
2254
|
-
...redactWithActive(_optionalChain([options, 'optionalAccess',
|
|
2462
|
+
...redactWithActive(_optionalChain([options, 'optionalAccess', _139 => _139.attributes]))
|
|
2255
2463
|
}
|
|
2256
2464
|
});
|
|
2257
2465
|
let result;
|
|
@@ -2375,9 +2583,9 @@ ${frames.join("\n")}`;
|
|
|
2375
2583
|
function recordBoundaryError(error, req, rule) {
|
|
2376
2584
|
try {
|
|
2377
2585
|
const state = requestStateOf(req);
|
|
2378
|
-
if (state)
|
|
2586
|
+
if (state) _chunkFV64SIRQcjs.noteOperationError.call(void 0, error, false, state);
|
|
2379
2587
|
captureAtBoundary(error, state, rule);
|
|
2380
|
-
} catch (
|
|
2588
|
+
} catch (e34) {
|
|
2381
2589
|
}
|
|
2382
2590
|
}
|
|
2383
2591
|
function autterErrorHandler(options = {}) {
|
|
@@ -2387,12 +2595,12 @@ function autterErrorHandler(options = {}) {
|
|
|
2387
2595
|
};
|
|
2388
2596
|
}
|
|
2389
2597
|
function autterFastifyErrors(fastify, options, done) {
|
|
2390
|
-
const rule = _optionalChain([options, 'optionalAccess',
|
|
2598
|
+
const rule = _optionalChain([options, 'optionalAccess', _140 => _140.capture]);
|
|
2391
2599
|
fastify.addHook("onError", ((request, _reply, error, next) => {
|
|
2392
|
-
recordBoundaryError(error, _optionalChain([request, 'optionalAccess',
|
|
2600
|
+
recordBoundaryError(error, _optionalChain([request, 'optionalAccess', _141 => _141.raw]), rule);
|
|
2393
2601
|
next();
|
|
2394
2602
|
}));
|
|
2395
|
-
_optionalChain([done, 'optionalCall',
|
|
2603
|
+
_optionalChain([done, 'optionalCall', _142 => _142()]);
|
|
2396
2604
|
}
|
|
2397
2605
|
autterFastifyErrors[/* @__PURE__ */ Symbol.for("skip-override")] = true;
|
|
2398
2606
|
autterFastifyErrors[/* @__PURE__ */ Symbol.for("fastify.display-name")] = "autter-runtime-errors";
|
|
@@ -2401,7 +2609,7 @@ function autterKoa(options = {}) {
|
|
|
2401
2609
|
try {
|
|
2402
2610
|
await next();
|
|
2403
2611
|
} catch (error) {
|
|
2404
|
-
recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess',
|
|
2612
|
+
recordBoundaryError(error, _optionalChain([ctx, 'optionalAccess', _143 => _143.req]), options.capture);
|
|
2405
2613
|
throw error;
|
|
2406
2614
|
}
|
|
2407
2615
|
};
|
|
@@ -2412,7 +2620,7 @@ function autterKoa(options = {}) {
|
|
|
2412
2620
|
|
|
2413
2621
|
|
|
2414
2622
|
|
|
2415
|
-
var L =
|
|
2623
|
+
var L = _chunk3P573RHAcjs.sharedSlot.call(void 0, "logging", () => ({ active: null }));
|
|
2416
2624
|
function initAutterLogging(options) {
|
|
2417
2625
|
if (L.active) return L.active;
|
|
2418
2626
|
if (serverActive()) {
|
|
@@ -2421,37 +2629,37 @@ function initAutterLogging(options) {
|
|
|
2421
2629
|
);
|
|
2422
2630
|
return {
|
|
2423
2631
|
captureException,
|
|
2424
|
-
flush:
|
|
2632
|
+
flush: _chunkFV64SIRQcjs.flushRuntimeLogs,
|
|
2425
2633
|
shutdown: async () => {
|
|
2426
2634
|
}
|
|
2427
2635
|
};
|
|
2428
2636
|
}
|
|
2429
|
-
if (
|
|
2637
|
+
if (_chunk3P573RHAcjs.isDebugEnabled.call(void 0, ) || options.debug === true) _chunk3P573RHAcjs.setDebugMode.call(void 0, true);
|
|
2430
2638
|
const endpoint = (_nullishCoalesce(options.endpoint, () => ( "https://otlp.autter.dev"))).replace(/\/$/, "");
|
|
2431
2639
|
const environment = _nullishCoalesce(_nullishCoalesce(options.environment, () => ( process.env.NODE_ENV)), () => ( "production"));
|
|
2432
|
-
const redact =
|
|
2640
|
+
const redact = _chunkFV64SIRQcjs.makeRedactor.call(void 0, _nullishCoalesce(options.redactAttributes, () => ( true)));
|
|
2433
2641
|
const mode = _nullishCoalesce(options.exceptions, () => ( "auto"));
|
|
2434
|
-
|
|
2435
|
-
const errorFilter =
|
|
2642
|
+
_chunk3P573RHAcjs.debugLog.call(void 0, `initialising logger-only service=${options.service} endpoint=${endpoint}`);
|
|
2643
|
+
const errorFilter = _chunkFV64SIRQcjs.createErrorFilter.call(void 0, { ignoreErrors: options.ignoreErrors, sampleRate: options.sampleRate });
|
|
2436
2644
|
function captureException2(error, attributes) {
|
|
2437
|
-
markCaptured(error);
|
|
2438
|
-
const isErrValue =
|
|
2645
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2646
|
+
const isErrValue = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
2439
2647
|
const reported = errorFilter({
|
|
2440
2648
|
type: isErrValue ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
|
|
2441
2649
|
message: isErrValue ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
|
|
2442
|
-
crash: _optionalChain([attributes, 'optionalAccess',
|
|
2650
|
+
crash: _optionalChain([attributes, 'optionalAccess', _144 => _144["autter.unhandled"]]) === true || _optionalChain([attributes, 'optionalAccess', _145 => _145["autter.unhandled_rejection"]]) === true
|
|
2443
2651
|
});
|
|
2444
2652
|
if (!reported) return;
|
|
2445
|
-
const split =
|
|
2446
|
-
const fingerprint =
|
|
2653
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2654
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
|
|
2447
2655
|
const redacted = redact(split.attributes);
|
|
2448
2656
|
const span = _api.trace.getActiveSpan();
|
|
2449
|
-
if (mode === "auto" && _optionalChain([span, 'optionalAccess',
|
|
2450
|
-
|
|
2451
|
-
|
|
2657
|
+
if (mode === "auto" && _optionalChain([span, 'optionalAccess', _146 => _146.isRecording, 'call', _147 => _147()])) {
|
|
2658
|
+
_chunkFV64SIRQcjs.noteOperationError.call(void 0, error);
|
|
2659
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2452
2660
|
span.setAttributes({ "autter.severity": "error", ...redacted, ...structuredErrorAttributes(error) });
|
|
2453
|
-
const declared = { ...
|
|
2454
|
-
if (
|
|
2661
|
+
const declared = { ..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error), ...fingerprint };
|
|
2662
|
+
if (_chunkFV64SIRQcjs.isError.call(void 0, error)) {
|
|
2455
2663
|
span.addEvent("exception", {
|
|
2456
2664
|
"exception.type": error.name,
|
|
2457
2665
|
"exception.message": error.message,
|
|
@@ -2467,15 +2675,42 @@ function initAutterLogging(options) {
|
|
|
2467
2675
|
}
|
|
2468
2676
|
span.setStatus({
|
|
2469
2677
|
code: _api.SpanStatusCode.ERROR,
|
|
2470
|
-
message:
|
|
2678
|
+
message: _chunkFV64SIRQcjs.isError.call(void 0, error) ? error.message : String(error)
|
|
2679
|
+
});
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2682
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2683
|
+
_chunkFV64SIRQcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2684
|
+
}
|
|
2685
|
+
function captureHandled(error, attributes, severity) {
|
|
2686
|
+
_chunkFV64SIRQcjs.markCaptured.call(void 0, error);
|
|
2687
|
+
const isErrValue = _chunkFV64SIRQcjs.isError.call(void 0, error);
|
|
2688
|
+
if (!errorFilter({
|
|
2689
|
+
type: isErrValue ? String(_nullishCoalesce(error.name, () => ( ""))) : "Error",
|
|
2690
|
+
message: isErrValue ? String(_nullishCoalesce(error.message, () => ( ""))) : String(error),
|
|
2691
|
+
severity
|
|
2692
|
+
})) return;
|
|
2693
|
+
const split = _chunkFV64SIRQcjs.splitFingerprint.call(void 0, attributes);
|
|
2694
|
+
const fingerprint = _chunkFV64SIRQcjs.fingerprintEventAttributes.call(void 0, split.fingerprint, redact.text);
|
|
2695
|
+
const redacted = redact(split.attributes);
|
|
2696
|
+
_chunkFV64SIRQcjs.notifyException.call(void 0, error, { ...redacted, ...fingerprint, "autter.severity": severity });
|
|
2697
|
+
const span = _api.trace.getActiveSpan();
|
|
2698
|
+
if (mode === "auto" && _optionalChain([span, 'optionalAccess', _148 => _148.isRecording, 'call', _149 => _149()])) {
|
|
2699
|
+
span.addEvent("exception", {
|
|
2700
|
+
...redacted,
|
|
2701
|
+
"exception.type": isErrValue ? error.name : "Error",
|
|
2702
|
+
"exception.message": redact.text(isErrValue ? error.message : String(error)),
|
|
2703
|
+
...isErrValue && error.stack ? { "exception.stacktrace": redact.text(error.stack) } : {},
|
|
2704
|
+
"autter.severity": severity,
|
|
2705
|
+
..._chunkFV64SIRQcjs.errorAttributes.call(void 0, error),
|
|
2706
|
+
...fingerprint
|
|
2471
2707
|
});
|
|
2472
2708
|
return;
|
|
2473
2709
|
}
|
|
2474
|
-
|
|
2475
|
-
_chunk37W7YYXOcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint });
|
|
2710
|
+
_chunkFV64SIRQcjs.captureExceptionAsLog.call(void 0, error, { ...redacted, ...fingerprint }, severity);
|
|
2476
2711
|
}
|
|
2477
2712
|
const captured = /* @__PURE__ */ new WeakSet();
|
|
2478
|
-
|
|
2713
|
+
_chunkFV64SIRQcjs.configureRuntimeLogger.call(void 0, {
|
|
2479
2714
|
endpoint,
|
|
2480
2715
|
apiKey: _nullishCoalesce(options.apiKey, () => ( "")),
|
|
2481
2716
|
service: options.service,
|
|
@@ -2484,7 +2719,7 @@ function initAutterLogging(options) {
|
|
|
2484
2719
|
...options.logging ? { options: options.logging } : {},
|
|
2485
2720
|
redact,
|
|
2486
2721
|
reportOutcome: (name, message, attributes) => {
|
|
2487
|
-
|
|
2722
|
+
_chunkFV64SIRQcjs.runtimeLogger.error(message, {
|
|
2488
2723
|
...attributes,
|
|
2489
2724
|
"autter.outcome.name": name.slice(0, 200),
|
|
2490
2725
|
"autter.outcome.message": message.slice(0, 1e3)
|
|
@@ -2498,7 +2733,8 @@ function initAutterLogging(options) {
|
|
|
2498
2733
|
captureException2(error);
|
|
2499
2734
|
}
|
|
2500
2735
|
});
|
|
2501
|
-
setLoggerOnlyCapture(captureException2);
|
|
2736
|
+
setLoggerOnlyCapture(captureException2, captureHandled);
|
|
2737
|
+
_chunkFV64SIRQcjs.startLoggedErrorCapture.call(void 0, options.captureLoggedErrors);
|
|
2502
2738
|
const onCrash = (error) => {
|
|
2503
2739
|
if (recordedAsRejection(error)) return;
|
|
2504
2740
|
captureException2(error, { "autter.unhandled": true });
|
|
@@ -2511,21 +2747,22 @@ function initAutterLogging(options) {
|
|
|
2511
2747
|
(reason) => captureException2(reason, { "autter.unhandled_rejection": true })
|
|
2512
2748
|
);
|
|
2513
2749
|
}
|
|
2514
|
-
|
|
2515
|
-
let autoFlushHandle = options.autoFlush === false ? null :
|
|
2750
|
+
_chunk3P573RHAcjs.registerFlushTarget.call(void 0, "logging", { forceFlush: () => _chunkFV64SIRQcjs.flushRuntimeLogs.call(void 0, ) });
|
|
2751
|
+
let autoFlushHandle = options.autoFlush === false ? null : _chunk3P573RHAcjs.installAutterAutoFlush.call(void 0, );
|
|
2516
2752
|
const handle = {
|
|
2517
2753
|
captureException: captureException2,
|
|
2518
|
-
flush:
|
|
2754
|
+
flush: _chunkFV64SIRQcjs.flushRuntimeLogs,
|
|
2519
2755
|
shutdown: async () => {
|
|
2756
|
+
if (L.active === handle) _chunkFV64SIRQcjs.stopLoggedErrorCapture.call(void 0, );
|
|
2520
2757
|
process.off("uncaughtExceptionMonitor", onCrash);
|
|
2521
|
-
_optionalChain([uninstallRejections, 'optionalCall',
|
|
2758
|
+
_optionalChain([uninstallRejections, 'optionalCall', _150 => _150()]);
|
|
2522
2759
|
uninstallRejections = null;
|
|
2523
2760
|
setLoggerOnlyCapture(null);
|
|
2524
|
-
_optionalChain([autoFlushHandle, 'optionalAccess',
|
|
2761
|
+
_optionalChain([autoFlushHandle, 'optionalAccess', _151 => _151.dispose, 'call', _152 => _152()]);
|
|
2525
2762
|
autoFlushHandle = null;
|
|
2526
|
-
|
|
2763
|
+
_chunk3P573RHAcjs.unregisterFlushTargets.call(void 0, );
|
|
2527
2764
|
if (L.active === handle) L.active = null;
|
|
2528
|
-
await
|
|
2765
|
+
await _chunkFV64SIRQcjs.shutdownRuntimeLogger.call(void 0, );
|
|
2529
2766
|
}
|
|
2530
2767
|
};
|
|
2531
2768
|
L.active = handle;
|
|
@@ -2534,7 +2771,7 @@ function initAutterLogging(options) {
|
|
|
2534
2771
|
|
|
2535
2772
|
// src/enrichers.ts
|
|
2536
2773
|
function headerOf(req, name) {
|
|
2537
|
-
const headers = _optionalChain([req, 'optionalAccess',
|
|
2774
|
+
const headers = _optionalChain([req, 'optionalAccess', _153 => _153.headers]);
|
|
2538
2775
|
if (!headers) return void 0;
|
|
2539
2776
|
if (typeof headers.get === "function") {
|
|
2540
2777
|
return _nullishCoalesce(headers.get(name), () => ( void 0));
|
|
@@ -2547,7 +2784,7 @@ function enrichUserAgent() {
|
|
|
2547
2784
|
return (event, { req }) => {
|
|
2548
2785
|
const ua = headerOf(req, "user-agent");
|
|
2549
2786
|
if (!ua) return;
|
|
2550
|
-
const info =
|
|
2787
|
+
const info = _chunkFV64SIRQcjs.parseUserAgent.call(void 0, ua);
|
|
2551
2788
|
if (info.browser) event.attributes["user_agent.browser"] = info.browser;
|
|
2552
2789
|
if (info.os) event.attributes["user_agent.os"] = info.os;
|
|
2553
2790
|
event.attributes["user_agent.device"] = info.device;
|
|
@@ -2559,7 +2796,7 @@ function enrichRequestSize() {
|
|
|
2559
2796
|
const request = Number(headerOf(req, "content-length"));
|
|
2560
2797
|
if (Number.isFinite(request) && request >= 0)
|
|
2561
2798
|
event.attributes["http.request.body.size"] = request;
|
|
2562
|
-
const raw = _optionalChain([res, 'optionalAccess',
|
|
2799
|
+
const raw = _optionalChain([res, 'optionalAccess', _154 => _154.getHeader, 'optionalCall', _155 => _155(
|
|
2563
2800
|
"content-length"
|
|
2564
2801
|
)]);
|
|
2565
2802
|
const response = Number(raw);
|
|
@@ -2577,7 +2814,7 @@ var COUNTRY_HEADERS = [
|
|
|
2577
2814
|
function enrichEdgeGeo() {
|
|
2578
2815
|
return (event, { req }) => {
|
|
2579
2816
|
for (const name of COUNTRY_HEADERS) {
|
|
2580
|
-
const value = _optionalChain([headerOf, 'call',
|
|
2817
|
+
const value = _optionalChain([headerOf, 'call', _156 => _156(req, name), 'optionalAccess', _157 => _157.trim, 'call', _158 => _158(), 'access', _159 => _159.toUpperCase, 'call', _160 => _160()]);
|
|
2581
2818
|
if (value && /^[A-Z]{2}$/.test(value) && value !== "XX" && value !== "T1") {
|
|
2582
2819
|
event.attributes["geo.country.iso_code"] = value;
|
|
2583
2820
|
return;
|
|
@@ -2611,9 +2848,9 @@ var COMMIT_VARS = [
|
|
|
2611
2848
|
"SOURCE_VERSION"
|
|
2612
2849
|
];
|
|
2613
2850
|
function enrichDeployment(env = process.env) {
|
|
2614
|
-
const pick = (names) => names.map((name) => _optionalChain([env, 'access',
|
|
2615
|
-
const region = _optionalChain([pick, 'call',
|
|
2616
|
-
const commit = _optionalChain([pick, 'call',
|
|
2851
|
+
const pick = (names) => names.map((name) => _optionalChain([env, 'access', _161 => _161[name], 'optionalAccess', _162 => _162.trim, 'call', _163 => _163()])).find((value) => value);
|
|
2852
|
+
const region = _optionalChain([pick, 'call', _164 => _164(REGION_VARS), 'optionalAccess', _165 => _165.slice, 'call', _166 => _166(0, 64)]);
|
|
2853
|
+
const commit = _optionalChain([pick, 'call', _167 => _167(COMMIT_VARS), 'optionalAccess', _168 => _168.slice, 'call', _169 => _169(0, 64)]);
|
|
2617
2854
|
return (event) => {
|
|
2618
2855
|
if (region) event.attributes["deployment.region"] = region;
|
|
2619
2856
|
if (commit) event.attributes["deployment.commit"] = commit;
|
|
@@ -2674,4 +2911,4 @@ function enrichDeployment(env = process.env) {
|
|
|
2674
2911
|
|
|
2675
2912
|
|
|
2676
2913
|
|
|
2677
|
-
exports.CODE_PATTERN =
|
|
2914
|
+
exports.CODE_PATTERN = _chunkFV64SIRQcjs.CODE_PATTERN; exports.COMPAT_MANIFEST = _chunk3P573RHAcjs.COMPAT_MANIFEST; exports.INGESTER_VERSION_HEADER = _chunk3P573RHAcjs.INGESTER_VERSION_HEADER; exports.RuntimeError = _chunkFV64SIRQcjs.RuntimeError; exports.SDK_IDENTITY = _chunk3P573RHAcjs.SDK_IDENTITY; exports.addBreadcrumb = _chunkFV64SIRQcjs.addBreadcrumb; exports.autterErrorHandler = autterErrorHandler; exports.autterErrorResponse = autterErrorResponse; exports.autterFastify = autterFastify; exports.autterFastifyErrors = autterFastifyErrors; exports.autterKoa = autterKoa; exports.autterRequests = autterRequests; exports.captureException = captureException; exports.captureMessage = captureMessage; exports.captureRequestError = captureRequestError; exports.consoleSink = _chunkFV64SIRQcjs.consoleSink; exports.createBrowserRelayFetchHandler = createBrowserRelayFetchHandler; exports.createBrowserRelayHandler = createBrowserRelayHandler; exports.createRuntimeLogger = _chunkFV64SIRQcjs.createRuntimeLogger; exports.defineRuntimeErrors = _chunkFV64SIRQcjs.defineRuntimeErrors; exports.emitLlmSelftestTrace = emitLlmSelftestTrace; exports.enrichDeployment = enrichDeployment; exports.enrichEdgeGeo = enrichEdgeGeo; exports.enrichRequestSize = enrichRequestSize; exports.enrichUserAgent = enrichUserAgent; exports.errorAttributes = _chunkFV64SIRQcjs.errorAttributes; exports.evaluateCompat = _chunk3P573RHAcjs.evaluateCompat; exports.fetchIngesterCompat = _chunk3P573RHAcjs.fetchIngesterCompat; exports.fileSink = _chunkFV64SIRQcjs.fileSink; exports.flushRuntimeLogs = _chunkFV64SIRQcjs.flushRuntimeLogs; exports.initAutterLogging = initAutterLogging; exports.initAutterServer = initAutterServer; exports.installAutterAutoFlush = _chunk3P573RHAcjs.installAutterAutoFlush; exports.instrumentLlmClient = instrumentLlmClient; exports.isRuntimeErrorLike = _chunkFV64SIRQcjs.isRuntimeErrorLike; exports.makeSafeCapture = makeSafeCapture; exports.otlpSink = _chunkFV64SIRQcjs.otlpSink; exports.redactAttributes = _chunkFV64SIRQcjs.redactAttributes; exports.redactText = _chunkFV64SIRQcjs.redactText; exports.reportOutcome = reportOutcome; exports.runDoctor = _chunkLYXQC4FIcjs.runDoctor; exports.runInBackground = _chunkFV64SIRQcjs.runInBackground; exports.runtimeContext = _chunkFV64SIRQcjs.runtimeContext; exports.runtimeLogStats = _chunkFV64SIRQcjs.runtimeLogStats; exports.runtimeLogger = _chunkFV64SIRQcjs.runtimeLogger; exports.sanitizeBrowserPayload = sanitizeBrowserPayload; exports.startCaughtExceptionSampler = startCaughtExceptionSampler; exports.toClientError = _chunkFV64SIRQcjs.toClientError; exports.trackLlmCall = trackLlmCall; exports.unhandledRejectionsMode = unhandledRejectionsMode; exports.withLlmCall = withLlmCall; exports.withProcessSpan = withProcessSpan; exports.withRuntimeOperation = _chunkFV64SIRQcjs.withRuntimeOperation; exports.withRuntimeRequest = withRuntimeRequest;
|