autotel 2.26.0 → 2.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attribute-redacting-processor.cjs +14 -6
- package/dist/attribute-redacting-processor.d.cts +63 -1
- package/dist/attribute-redacting-processor.d.ts +63 -1
- package/dist/attribute-redacting-processor.js +1 -1
- package/dist/attributes.cjs +21 -21
- package/dist/attributes.js +2 -2
- package/dist/auto.cjs +8 -8
- package/dist/auto.js +6 -6
- package/dist/{chunk-RUD7KS4R.js → chunk-3SDILILG.js} +3 -3
- package/dist/{chunk-RUD7KS4R.js.map → chunk-3SDILILG.js.map} +1 -1
- package/dist/{chunk-B33XPEKY.js → chunk-55ER2KD5.js} +4 -4
- package/dist/chunk-55ER2KD5.js.map +1 -0
- package/dist/{chunk-UJJPTSEI.cjs → chunk-563EL6O6.cjs} +81 -14
- package/dist/chunk-563EL6O6.cjs.map +1 -0
- package/dist/{chunk-TS7IHIRW.cjs → chunk-6YGUN7IY.cjs} +5 -5
- package/dist/{chunk-TS7IHIRW.cjs.map → chunk-6YGUN7IY.cjs.map} +1 -1
- package/dist/{chunk-XDKK53OL.js → chunk-A4E5AQFK.js} +3 -3
- package/dist/{chunk-XDKK53OL.js.map → chunk-A4E5AQFK.js.map} +1 -1
- package/dist/{chunk-WAB4CHBU.js → chunk-BJ2XPN77.js} +3 -3
- package/dist/{chunk-WAB4CHBU.js.map → chunk-BJ2XPN77.js.map} +1 -1
- package/dist/{chunk-KZEC4CHV.cjs → chunk-CEAQK2QY.cjs} +5 -5
- package/dist/{chunk-KZEC4CHV.cjs.map → chunk-CEAQK2QY.cjs.map} +1 -1
- package/dist/chunk-CMNGGTQL.cjs +349 -0
- package/dist/chunk-CMNGGTQL.cjs.map +1 -0
- package/dist/{chunk-VYA6QDNA.js → chunk-DPSA4QLA.js} +4 -2
- package/dist/chunk-DPSA4QLA.js.map +1 -0
- package/dist/{chunk-M4US3P4K.js → chunk-ER43K7ES.js} +3 -3
- package/dist/{chunk-M4US3P4K.js.map → chunk-ER43K7ES.js.map} +1 -1
- package/dist/{chunk-AZ24DJAG.cjs → chunk-FU6R566Y.cjs} +4 -4
- package/dist/chunk-FU6R566Y.cjs.map +1 -0
- package/dist/{chunk-4PTCDOZY.js → chunk-HPUGKUMZ.js} +4 -4
- package/dist/{chunk-4PTCDOZY.js.map → chunk-HPUGKUMZ.js.map} +1 -1
- package/dist/{chunk-XRBP4RYL.cjs → chunk-JKIMEPI2.cjs} +4 -4
- package/dist/{chunk-XRBP4RYL.cjs.map → chunk-JKIMEPI2.cjs.map} +1 -1
- package/dist/{chunk-N344PVE5.cjs → chunk-OBWXM4NN.cjs} +9 -9
- package/dist/{chunk-N344PVE5.cjs.map → chunk-OBWXM4NN.cjs.map} +1 -1
- package/dist/{chunk-OFPZULMQ.cjs → chunk-OC6X2VIN.cjs} +8 -8
- package/dist/{chunk-OFPZULMQ.cjs.map → chunk-OC6X2VIN.cjs.map} +1 -1
- package/dist/{chunk-GTD3NXOS.js → chunk-QC5MNKVF.js} +4 -4
- package/dist/{chunk-GTD3NXOS.js.map → chunk-QC5MNKVF.js.map} +1 -1
- package/dist/chunk-TDNKIHKT.js +341 -0
- package/dist/chunk-TDNKIHKT.js.map +1 -0
- package/dist/{chunk-DGPUZ6TE.js → chunk-U54FTVFH.js} +3 -3
- package/dist/{chunk-DGPUZ6TE.js.map → chunk-U54FTVFH.js.map} +1 -1
- package/dist/{chunk-ZJ5GXCOT.cjs → chunk-UTZR7P7E.cjs} +36 -36
- package/dist/{chunk-ZJ5GXCOT.cjs.map → chunk-UTZR7P7E.cjs.map} +1 -1
- package/dist/{chunk-7FIGORWI.cjs → chunk-VH77IPJN.cjs} +4 -2
- package/dist/chunk-VH77IPJN.cjs.map +1 -0
- package/dist/{chunk-EXOXDI5A.js → chunk-W35FVJBC.js} +73 -8
- package/dist/chunk-W35FVJBC.js.map +1 -0
- package/dist/{chunk-II7GFVAF.cjs → chunk-WZOKY3PW.cjs} +13 -13
- package/dist/{chunk-II7GFVAF.cjs.map → chunk-WZOKY3PW.cjs.map} +1 -1
- package/dist/{chunk-CMADDTHY.cjs → chunk-YEVCD6DR.cjs} +7 -7
- package/dist/{chunk-CMADDTHY.cjs.map → chunk-YEVCD6DR.cjs.map} +1 -1
- package/dist/{chunk-RXFZKLRQ.js → chunk-YN7USLHW.js} +3 -3
- package/dist/{chunk-RXFZKLRQ.js.map → chunk-YN7USLHW.js.map} +1 -1
- package/dist/decorators.cjs +7 -7
- package/dist/decorators.js +7 -7
- package/dist/event.cjs +10 -10
- package/dist/event.js +7 -7
- package/dist/functional.cjs +14 -14
- package/dist/functional.js +7 -7
- package/dist/index.cjs +214 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +141 -33
- package/dist/index.js.map +1 -1
- package/dist/{init-QSj7X6zU.d.cts → init-CMuTaFAV.d.cts} +26 -1
- package/dist/{init-FiR_glVc.d.ts → init-D6JfWEjL.d.ts} +26 -1
- package/dist/instrumentation.cjs +14 -14
- package/dist/instrumentation.js +6 -6
- package/dist/logger.cjs +8 -8
- package/dist/logger.js +1 -1
- package/dist/messaging.cjs +11 -11
- package/dist/messaging.js +8 -8
- package/dist/metric.cjs +1 -1
- package/dist/metric.js +1 -1
- package/dist/sampling.cjs +15 -15
- package/dist/sampling.js +2 -2
- package/dist/semantic-helpers.cjs +12 -12
- package/dist/semantic-helpers.js +8 -8
- package/dist/tail-sampling-processor.cjs +4 -4
- package/dist/tail-sampling-processor.js +3 -3
- package/dist/testing.cjs +1 -1
- package/dist/testing.js +1 -1
- package/dist/webhook.cjs +9 -8
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.js +8 -7
- package/dist/webhook.js.map +1 -1
- package/dist/workflow-distributed.cjs +9 -9
- package/dist/workflow-distributed.js +7 -7
- package/dist/workflow.cjs +12 -12
- package/dist/workflow.js +8 -8
- package/dist/yaml-config.cjs +6 -6
- package/dist/yaml-config.d.cts +1 -1
- package/dist/yaml-config.d.ts +1 -1
- package/dist/yaml-config.js +3 -3
- package/package.json +1 -1
- package/src/attribute-redacting-processor.test.ts +81 -16
- package/src/attribute-redacting-processor.ts +278 -24
- package/src/autotel-logger.ts +2 -2
- package/src/index.ts +2 -1
- package/src/init.ts +117 -2
- package/src/request-logger.test.ts +266 -1
- package/src/request-logger.ts +115 -16
- package/src/structured-error.ts +54 -1
- package/dist/chunk-7FIGORWI.cjs.map +0 -1
- package/dist/chunk-AZ24DJAG.cjs.map +0 -1
- package/dist/chunk-B33XPEKY.js.map +0 -1
- package/dist/chunk-ELW34S4C.cjs +0 -173
- package/dist/chunk-ELW34S4C.cjs.map +0 -1
- package/dist/chunk-EXOXDI5A.js.map +0 -1
- package/dist/chunk-SNINLBEE.js +0 -167
- package/dist/chunk-SNINLBEE.js.map +0 -1
- package/dist/chunk-UJJPTSEI.cjs.map +0 -1
- package/dist/chunk-VYA6QDNA.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk7EQ4G4SI_cjs = require('./chunk-7EQ4G4SI.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunk6YGUN7IY_cjs = require('./chunk-6YGUN7IY.cjs');
|
|
5
|
+
var chunkJKIMEPI2_cjs = require('./chunk-JKIMEPI2.cjs');
|
|
6
6
|
var chunk2ZKEORFN_cjs = require('./chunk-2ZKEORFN.cjs');
|
|
7
7
|
var chunkESMHTKLJ_cjs = require('./chunk-ESMHTKLJ.cjs');
|
|
8
8
|
var chunkT4B5LB6E_cjs = require('./chunk-T4B5LB6E.cjs');
|
|
9
|
-
var
|
|
9
|
+
var chunkOBWXM4NN_cjs = require('./chunk-OBWXM4NN.cjs');
|
|
10
10
|
var chunkINJD3G4K_cjs = require('./chunk-INJD3G4K.cjs');
|
|
11
11
|
var chunkTC5ZPWM4_cjs = require('./chunk-TC5ZPWM4.cjs');
|
|
12
12
|
require('./chunk-YTXEZ4SD.cjs');
|
|
13
13
|
var chunkWJH6IYU2_cjs = require('./chunk-WJH6IYU2.cjs');
|
|
14
|
-
var
|
|
15
|
-
var
|
|
14
|
+
var chunkYEVCD6DR_cjs = require('./chunk-YEVCD6DR.cjs');
|
|
15
|
+
var chunkUTZR7P7E_cjs = require('./chunk-UTZR7P7E.cjs');
|
|
16
16
|
var chunkGML3FBOT_cjs = require('./chunk-GML3FBOT.cjs');
|
|
17
|
-
var
|
|
17
|
+
var chunkWZOKY3PW_cjs = require('./chunk-WZOKY3PW.cjs');
|
|
18
18
|
require('./chunk-NZ72VDNY.cjs');
|
|
19
19
|
require('./chunk-UY3UYPBZ.cjs');
|
|
20
20
|
var chunkD5LMF53P_cjs = require('./chunk-D5LMF53P.cjs');
|
|
21
21
|
var chunkJSNUWSBH_cjs = require('./chunk-JSNUWSBH.cjs');
|
|
22
22
|
var chunkHZ3FYBJG_cjs = require('./chunk-HZ3FYBJG.cjs');
|
|
23
|
-
var
|
|
24
|
-
require('./chunk-
|
|
25
|
-
require('./chunk-
|
|
23
|
+
var chunk563EL6O6_cjs = require('./chunk-563EL6O6.cjs');
|
|
24
|
+
require('./chunk-OC6X2VIN.cjs');
|
|
25
|
+
require('./chunk-CEAQK2QY.cjs');
|
|
26
26
|
var chunkZNMBW67B_cjs = require('./chunk-ZNMBW67B.cjs');
|
|
27
27
|
var chunkIOYFAFHJ_cjs = require('./chunk-IOYFAFHJ.cjs');
|
|
28
|
-
var
|
|
28
|
+
var chunkCMNGGTQL_cjs = require('./chunk-CMNGGTQL.cjs');
|
|
29
29
|
require('./chunk-CU6IDACR.cjs');
|
|
30
30
|
var chunk6S5RUKU3_cjs = require('./chunk-6S5RUKU3.cjs');
|
|
31
31
|
require('./chunk-YS6C2YJE.cjs');
|
|
32
|
-
var
|
|
33
|
-
require('./chunk-
|
|
32
|
+
var chunkVH77IPJN_cjs = require('./chunk-VH77IPJN.cjs');
|
|
33
|
+
require('./chunk-FU6R566Y.cjs');
|
|
34
34
|
require('./chunk-ESLWRGAG.cjs');
|
|
35
35
|
var chunkYREV3LGG_cjs = require('./chunk-YREV3LGG.cjs');
|
|
36
36
|
require('./chunk-JEQ2X3Z6.cjs');
|
|
@@ -42,7 +42,7 @@ async function flush(options) {
|
|
|
42
42
|
const timeout = options?.timeout ?? 2e3;
|
|
43
43
|
const forShutdown = options?.forShutdown ?? false;
|
|
44
44
|
const doFlush = async () => {
|
|
45
|
-
const eventsQueue =
|
|
45
|
+
const eventsQueue = chunkUTZR7P7E_cjs.getEventQueue();
|
|
46
46
|
if (eventsQueue) {
|
|
47
47
|
if (forShutdown) {
|
|
48
48
|
await eventsQueue.shutdown();
|
|
@@ -50,7 +50,7 @@ async function flush(options) {
|
|
|
50
50
|
await eventsQueue.flush();
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
const sdk =
|
|
53
|
+
const sdk = chunk563EL6O6_cjs.getSdk();
|
|
54
54
|
if (sdk) {
|
|
55
55
|
try {
|
|
56
56
|
const sdkAny = sdk;
|
|
@@ -84,7 +84,7 @@ async function flush(options) {
|
|
|
84
84
|
if (timeoutHandle) {
|
|
85
85
|
clearTimeout(timeoutHandle);
|
|
86
86
|
}
|
|
87
|
-
const logger =
|
|
87
|
+
const logger = chunk563EL6O6_cjs.getLogger();
|
|
88
88
|
logger.error(
|
|
89
89
|
{
|
|
90
90
|
err: error instanceof Error ? error : new Error(String(error))
|
|
@@ -95,7 +95,7 @@ async function flush(options) {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
async function shutdown() {
|
|
98
|
-
const logger =
|
|
98
|
+
const logger = chunk563EL6O6_cjs.getLogger();
|
|
99
99
|
let shutdownError = null;
|
|
100
100
|
try {
|
|
101
101
|
await flush({ forShutdown: true });
|
|
@@ -110,7 +110,7 @@ async function shutdown() {
|
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
try {
|
|
113
|
-
const sdk =
|
|
113
|
+
const sdk = chunk563EL6O6_cjs.getSdk();
|
|
114
114
|
if (sdk) {
|
|
115
115
|
await sdk.shutdown();
|
|
116
116
|
}
|
|
@@ -124,14 +124,14 @@ async function shutdown() {
|
|
|
124
124
|
logger.error({ err }, "[autotel] SDK shutdown failed");
|
|
125
125
|
}
|
|
126
126
|
} finally {
|
|
127
|
-
await
|
|
128
|
-
const eventsQueue =
|
|
127
|
+
await chunk563EL6O6_cjs._closeEmbeddedDevtools();
|
|
128
|
+
const eventsQueue = chunkUTZR7P7E_cjs.getEventQueue();
|
|
129
129
|
if (eventsQueue && typeof eventsQueue.cleanup === "function") {
|
|
130
130
|
eventsQueue.cleanup();
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
chunkWZOKY3PW_cjs.resetEvents();
|
|
133
133
|
chunkTC5ZPWM4_cjs.resetMetrics();
|
|
134
|
-
|
|
134
|
+
chunkUTZR7P7E_cjs.resetEventQueue();
|
|
135
135
|
}
|
|
136
136
|
if (shutdownError) {
|
|
137
137
|
throw shutdownError;
|
|
@@ -146,7 +146,7 @@ function registerShutdownHooks() {
|
|
|
146
146
|
if (shuttingDown) return;
|
|
147
147
|
shuttingDown = true;
|
|
148
148
|
if (process.env.NODE_ENV !== "test") {
|
|
149
|
-
|
|
149
|
+
chunk563EL6O6_cjs.getLogger().info(
|
|
150
150
|
{},
|
|
151
151
|
`[autotel] Received ${signal}, flushing telemetry...`
|
|
152
152
|
);
|
|
@@ -154,7 +154,7 @@ function registerShutdownHooks() {
|
|
|
154
154
|
try {
|
|
155
155
|
await shutdown();
|
|
156
156
|
} catch (error) {
|
|
157
|
-
|
|
157
|
+
chunk563EL6O6_cjs.getLogger().error(
|
|
158
158
|
{
|
|
159
159
|
err: error instanceof Error ? error : void 0
|
|
160
160
|
},
|
|
@@ -224,6 +224,7 @@ function flattenToAttributes(fields, prefix = "") {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
// src/structured-error.ts
|
|
227
|
+
var internalKey = /* @__PURE__ */ Symbol.for("autotel.error.internal");
|
|
227
228
|
function createStructuredError(input) {
|
|
228
229
|
const error = new Error(input.message, {
|
|
229
230
|
cause: input.cause
|
|
@@ -235,6 +236,21 @@ function createStructuredError(input) {
|
|
|
235
236
|
if (input.code !== void 0) error.code = input.code;
|
|
236
237
|
if (input.status !== void 0) error.status = input.status;
|
|
237
238
|
if (input.details !== void 0) error.details = input.details;
|
|
239
|
+
if (input.internal !== void 0) {
|
|
240
|
+
Object.defineProperty(error, internalKey, {
|
|
241
|
+
value: input.internal,
|
|
242
|
+
enumerable: false,
|
|
243
|
+
writable: false,
|
|
244
|
+
configurable: true
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
Object.defineProperty(error, "internal", {
|
|
248
|
+
get() {
|
|
249
|
+
return this[internalKey];
|
|
250
|
+
},
|
|
251
|
+
enumerable: false,
|
|
252
|
+
configurable: true
|
|
253
|
+
});
|
|
238
254
|
error.toString = () => {
|
|
239
255
|
const lines = [`${error.name}: ${error.message}`];
|
|
240
256
|
if (error.why) lines.push(` Why: ${error.why}`);
|
|
@@ -242,11 +258,34 @@ function createStructuredError(input) {
|
|
|
242
258
|
if (error.link) lines.push(` Link: ${error.link}`);
|
|
243
259
|
if (error.code !== void 0) lines.push(` Code: ${error.code}`);
|
|
244
260
|
if (error.status !== void 0) lines.push(` Status: ${error.status}`);
|
|
245
|
-
if (error.cause)
|
|
261
|
+
if (error.cause) {
|
|
262
|
+
const cause = error.cause;
|
|
263
|
+
lines.push(` Caused by: ${cause.name}: ${cause.message}`);
|
|
264
|
+
}
|
|
246
265
|
return lines.join("\n");
|
|
247
266
|
};
|
|
248
267
|
return error;
|
|
249
268
|
}
|
|
269
|
+
function structuredErrorToJSON(error) {
|
|
270
|
+
const result = {
|
|
271
|
+
name: error.name,
|
|
272
|
+
message: error.message
|
|
273
|
+
};
|
|
274
|
+
if (error.status !== void 0) result.status = error.status;
|
|
275
|
+
if (error.why || error.fix || error.link) {
|
|
276
|
+
result.data = {
|
|
277
|
+
...error.why && { why: error.why },
|
|
278
|
+
...error.fix && { fix: error.fix },
|
|
279
|
+
...error.link && { link: error.link }
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
if (error.code !== void 0) result.code = error.code;
|
|
283
|
+
if (error.details) result.details = error.details;
|
|
284
|
+
if (error.cause instanceof Error) {
|
|
285
|
+
result.cause = { name: error.cause.name, message: error.cause.message };
|
|
286
|
+
}
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
250
289
|
function getStructuredErrorAttributes(error) {
|
|
251
290
|
const structured = error;
|
|
252
291
|
const attributes = {
|
|
@@ -281,6 +320,29 @@ function recordStructuredError(ctx2, error) {
|
|
|
281
320
|
}
|
|
282
321
|
|
|
283
322
|
// src/request-logger.ts
|
|
323
|
+
var POST_EMIT_FORK_HINT = "For intentional background work tied to this request, use log.fork('label', fn) when available.";
|
|
324
|
+
function warnPostEmit(method, detail) {
|
|
325
|
+
console.warn(
|
|
326
|
+
`[autotel] ${method} called after the wide event was emitted \u2014 ${detail} This data will not appear in observability. ${POST_EMIT_FORK_HINT}`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
function mergeInto(target, source) {
|
|
330
|
+
for (const key in source) {
|
|
331
|
+
const sourceVal = source[key];
|
|
332
|
+
if (sourceVal === void 0) continue;
|
|
333
|
+
const targetVal = target[key];
|
|
334
|
+
if (sourceVal !== null && typeof sourceVal === "object" && !Array.isArray(sourceVal) && targetVal !== null && typeof targetVal === "object" && !Array.isArray(targetVal)) {
|
|
335
|
+
mergeInto(
|
|
336
|
+
targetVal,
|
|
337
|
+
sourceVal
|
|
338
|
+
);
|
|
339
|
+
} else if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {
|
|
340
|
+
target[key] = [...targetVal, ...sourceVal];
|
|
341
|
+
} else {
|
|
342
|
+
target[key] = sourceVal;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
284
346
|
var requestContextStore = new async_hooks.AsyncLocalStorage();
|
|
285
347
|
function runWithRequestContext(ctx2, fn) {
|
|
286
348
|
return requestContextStore.run(ctx2, fn);
|
|
@@ -300,6 +362,8 @@ function resolveContext(ctx2) {
|
|
|
300
362
|
function getRequestLogger(ctx2, options) {
|
|
301
363
|
const activeContext = resolveContext(ctx2);
|
|
302
364
|
let contextState = {};
|
|
365
|
+
let emitted = false;
|
|
366
|
+
let lastSnapshot = null;
|
|
303
367
|
const addLogEvent = (level, message, fields) => {
|
|
304
368
|
const attrs2 = fields ? flattenToAttributes(fields) : void 0;
|
|
305
369
|
activeContext.addEvent(`log.${level}`, {
|
|
@@ -307,44 +371,51 @@ function getRequestLogger(ctx2, options) {
|
|
|
307
371
|
...attrs2
|
|
308
372
|
});
|
|
309
373
|
};
|
|
374
|
+
const sealCheck = (method, keys) => {
|
|
375
|
+
if (emitted) {
|
|
376
|
+
warnPostEmit(
|
|
377
|
+
method,
|
|
378
|
+
`Keys dropped: ${keys.length ? keys.join(", ") : "(empty)"}.`
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
310
382
|
return {
|
|
311
383
|
set(fields) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
};
|
|
384
|
+
sealCheck("log.set()", Object.keys(fields));
|
|
385
|
+
if (emitted) return;
|
|
386
|
+
mergeInto(contextState, fields);
|
|
316
387
|
activeContext.setAttributes(flattenToAttributes(fields));
|
|
317
388
|
},
|
|
318
389
|
info(message, fields) {
|
|
390
|
+
const keys = fields ? ["message", ...Object.keys(fields).filter((k) => k !== "requestLogs")] : ["message"];
|
|
391
|
+
sealCheck("log.info()", keys);
|
|
392
|
+
if (emitted) return;
|
|
319
393
|
addLogEvent("info", message, fields);
|
|
320
394
|
if (fields) {
|
|
321
|
-
contextState
|
|
322
|
-
...contextState,
|
|
323
|
-
...fields
|
|
324
|
-
};
|
|
395
|
+
mergeInto(contextState, fields);
|
|
325
396
|
activeContext.setAttributes(flattenToAttributes(fields));
|
|
326
397
|
}
|
|
327
398
|
},
|
|
328
399
|
warn(message, fields) {
|
|
400
|
+
const keys = fields ? ["message", ...Object.keys(fields).filter((k) => k !== "requestLogs")] : ["message"];
|
|
401
|
+
sealCheck("log.warn()", keys);
|
|
402
|
+
if (emitted) return;
|
|
329
403
|
addLogEvent("warn", message, fields);
|
|
330
404
|
activeContext.setAttribute("autotel.log.level", "warn");
|
|
331
405
|
if (fields) {
|
|
332
|
-
contextState
|
|
333
|
-
...contextState,
|
|
334
|
-
...fields
|
|
335
|
-
};
|
|
406
|
+
mergeInto(contextState, fields);
|
|
336
407
|
activeContext.setAttributes(flattenToAttributes(fields));
|
|
337
408
|
}
|
|
338
409
|
},
|
|
339
410
|
error(error, fields) {
|
|
411
|
+
const keys = fields ? [...Object.keys(fields), "error"] : ["error"];
|
|
412
|
+
sealCheck("log.error()", keys);
|
|
413
|
+
if (emitted) return;
|
|
340
414
|
const err = typeof error === "string" ? new Error(error) : error;
|
|
341
415
|
recordStructuredError(activeContext, err);
|
|
342
416
|
addLogEvent("error", err.message, fields);
|
|
343
417
|
if (fields) {
|
|
344
|
-
contextState
|
|
345
|
-
...contextState,
|
|
346
|
-
...fields
|
|
347
|
-
};
|
|
418
|
+
mergeInto(contextState, fields);
|
|
348
419
|
activeContext.setAttributes(flattenToAttributes(fields));
|
|
349
420
|
}
|
|
350
421
|
activeContext.setAttribute("autotel.log.level", "error");
|
|
@@ -353,6 +424,10 @@ function getRequestLogger(ctx2, options) {
|
|
|
353
424
|
return { ...contextState };
|
|
354
425
|
},
|
|
355
426
|
emitNow(overrides) {
|
|
427
|
+
if (emitted) {
|
|
428
|
+
warnPostEmit("log.emitNow()", "Ignoring duplicate emit.");
|
|
429
|
+
return lastSnapshot;
|
|
430
|
+
}
|
|
356
431
|
const mergedContext = {
|
|
357
432
|
...contextState,
|
|
358
433
|
...overrides ?? {}
|
|
@@ -374,7 +449,40 @@ function getRequestLogger(ctx2, options) {
|
|
|
374
449
|
console.warn("[autotel] request logger onEmit failed:", error);
|
|
375
450
|
});
|
|
376
451
|
}
|
|
452
|
+
emitted = true;
|
|
453
|
+
lastSnapshot = snapshot;
|
|
377
454
|
return snapshot;
|
|
455
|
+
},
|
|
456
|
+
fork(label, fn) {
|
|
457
|
+
const parentRequestId = activeContext.correlationId;
|
|
458
|
+
if (typeof parentRequestId !== "string" || parentRequestId.length === 0) {
|
|
459
|
+
throw new Error(
|
|
460
|
+
"[autotel] log.fork() requires the parent logger to have a correlationId. Ensure the request was created by autotel middleware."
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
const tracer = api.trace.getTracer("autotel.request-logger");
|
|
464
|
+
void tracer.startActiveSpan(`request.fork:${label}`, (childSpan) => {
|
|
465
|
+
const childContext = {
|
|
466
|
+
...chunkHZ3FYBJG_cjs.createTraceContext(childSpan),
|
|
467
|
+
correlationId: crypto.randomUUID()
|
|
468
|
+
};
|
|
469
|
+
requestContextStore.run(childContext, () => {
|
|
470
|
+
const childLog = getRequestLogger(childContext);
|
|
471
|
+
childLog.set({
|
|
472
|
+
operation: label,
|
|
473
|
+
_parentCorrelationId: parentRequestId
|
|
474
|
+
});
|
|
475
|
+
void Promise.resolve().then(() => fn()).then(() => {
|
|
476
|
+
childLog.emitNow();
|
|
477
|
+
}).catch((err) => {
|
|
478
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
479
|
+
childLog.error(error);
|
|
480
|
+
childLog.emitNow();
|
|
481
|
+
}).finally(() => {
|
|
482
|
+
childSpan.end();
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
});
|
|
378
486
|
}
|
|
379
487
|
};
|
|
380
488
|
}
|
|
@@ -385,83 +493,83 @@ Object.defineProperty(exports, "createDrainPipeline", {
|
|
|
385
493
|
});
|
|
386
494
|
Object.defineProperty(exports, "getCurrentWorkflowContext", {
|
|
387
495
|
enumerable: true,
|
|
388
|
-
get: function () { return
|
|
496
|
+
get: function () { return chunk6YGUN7IY_cjs.getCurrentWorkflowContext; }
|
|
389
497
|
});
|
|
390
498
|
Object.defineProperty(exports, "isInWorkflow", {
|
|
391
499
|
enumerable: true,
|
|
392
|
-
get: function () { return
|
|
500
|
+
get: function () { return chunk6YGUN7IY_cjs.isInWorkflow; }
|
|
393
501
|
});
|
|
394
502
|
Object.defineProperty(exports, "traceStep", {
|
|
395
503
|
enumerable: true,
|
|
396
|
-
get: function () { return
|
|
504
|
+
get: function () { return chunk6YGUN7IY_cjs.traceStep; }
|
|
397
505
|
});
|
|
398
506
|
Object.defineProperty(exports, "traceWorkflow", {
|
|
399
507
|
enumerable: true,
|
|
400
|
-
get: function () { return
|
|
508
|
+
get: function () { return chunk6YGUN7IY_cjs.traceWorkflow; }
|
|
401
509
|
});
|
|
402
510
|
Object.defineProperty(exports, "attrs", {
|
|
403
511
|
enumerable: true,
|
|
404
|
-
get: function () { return
|
|
512
|
+
get: function () { return chunkJKIMEPI2_cjs.attrs; }
|
|
405
513
|
});
|
|
406
514
|
Object.defineProperty(exports, "autoRedactPII", {
|
|
407
515
|
enumerable: true,
|
|
408
|
-
get: function () { return
|
|
516
|
+
get: function () { return chunkJKIMEPI2_cjs.autoRedactPII; }
|
|
409
517
|
});
|
|
410
518
|
Object.defineProperty(exports, "dbClient", {
|
|
411
519
|
enumerable: true,
|
|
412
|
-
get: function () { return
|
|
520
|
+
get: function () { return chunkJKIMEPI2_cjs.dbClient; }
|
|
413
521
|
});
|
|
414
522
|
Object.defineProperty(exports, "httpClient", {
|
|
415
523
|
enumerable: true,
|
|
416
|
-
get: function () { return
|
|
524
|
+
get: function () { return chunkJKIMEPI2_cjs.httpClient; }
|
|
417
525
|
});
|
|
418
526
|
Object.defineProperty(exports, "httpServer", {
|
|
419
527
|
enumerable: true,
|
|
420
|
-
get: function () { return
|
|
528
|
+
get: function () { return chunkJKIMEPI2_cjs.httpServer; }
|
|
421
529
|
});
|
|
422
530
|
Object.defineProperty(exports, "identify", {
|
|
423
531
|
enumerable: true,
|
|
424
|
-
get: function () { return
|
|
532
|
+
get: function () { return chunkJKIMEPI2_cjs.identify; }
|
|
425
533
|
});
|
|
426
534
|
Object.defineProperty(exports, "mergeAttrs", {
|
|
427
535
|
enumerable: true,
|
|
428
|
-
get: function () { return
|
|
536
|
+
get: function () { return chunkJKIMEPI2_cjs.mergeAttrs; }
|
|
429
537
|
});
|
|
430
538
|
Object.defineProperty(exports, "mergeServiceResource", {
|
|
431
539
|
enumerable: true,
|
|
432
|
-
get: function () { return
|
|
540
|
+
get: function () { return chunkJKIMEPI2_cjs.mergeServiceResource; }
|
|
433
541
|
});
|
|
434
542
|
Object.defineProperty(exports, "request", {
|
|
435
543
|
enumerable: true,
|
|
436
|
-
get: function () { return
|
|
544
|
+
get: function () { return chunkJKIMEPI2_cjs.request; }
|
|
437
545
|
});
|
|
438
546
|
Object.defineProperty(exports, "safeSetAttributes", {
|
|
439
547
|
enumerable: true,
|
|
440
|
-
get: function () { return
|
|
548
|
+
get: function () { return chunkJKIMEPI2_cjs.safeSetAttributes; }
|
|
441
549
|
});
|
|
442
550
|
Object.defineProperty(exports, "setDevice", {
|
|
443
551
|
enumerable: true,
|
|
444
|
-
get: function () { return
|
|
552
|
+
get: function () { return chunkJKIMEPI2_cjs.setDevice; }
|
|
445
553
|
});
|
|
446
554
|
Object.defineProperty(exports, "setError", {
|
|
447
555
|
enumerable: true,
|
|
448
|
-
get: function () { return
|
|
556
|
+
get: function () { return chunkJKIMEPI2_cjs.setError; }
|
|
449
557
|
});
|
|
450
558
|
Object.defineProperty(exports, "setException", {
|
|
451
559
|
enumerable: true,
|
|
452
|
-
get: function () { return
|
|
560
|
+
get: function () { return chunkJKIMEPI2_cjs.setException; }
|
|
453
561
|
});
|
|
454
562
|
Object.defineProperty(exports, "setSession", {
|
|
455
563
|
enumerable: true,
|
|
456
|
-
get: function () { return
|
|
564
|
+
get: function () { return chunkJKIMEPI2_cjs.setSession; }
|
|
457
565
|
});
|
|
458
566
|
Object.defineProperty(exports, "setUser", {
|
|
459
567
|
enumerable: true,
|
|
460
|
-
get: function () { return
|
|
568
|
+
get: function () { return chunkJKIMEPI2_cjs.setUser; }
|
|
461
569
|
});
|
|
462
570
|
Object.defineProperty(exports, "validateAttribute", {
|
|
463
571
|
enumerable: true,
|
|
464
|
-
get: function () { return
|
|
572
|
+
get: function () { return chunkJKIMEPI2_cjs.validateAttribute; }
|
|
465
573
|
});
|
|
466
574
|
Object.defineProperty(exports, "httpRequestHeaderAttribute", {
|
|
467
575
|
enumerable: true,
|
|
@@ -489,11 +597,11 @@ Object.defineProperty(exports, "parseError", {
|
|
|
489
597
|
});
|
|
490
598
|
Object.defineProperty(exports, "traceConsumer", {
|
|
491
599
|
enumerable: true,
|
|
492
|
-
get: function () { return
|
|
600
|
+
get: function () { return chunkOBWXM4NN_cjs.traceConsumer; }
|
|
493
601
|
});
|
|
494
602
|
Object.defineProperty(exports, "traceProducer", {
|
|
495
603
|
enumerable: true,
|
|
496
|
-
get: function () { return
|
|
604
|
+
get: function () { return chunkOBWXM4NN_cjs.traceProducer; }
|
|
497
605
|
});
|
|
498
606
|
Object.defineProperty(exports, "BusinessBaggage", {
|
|
499
607
|
enumerable: true,
|
|
@@ -537,55 +645,55 @@ Object.defineProperty(exports, "getMeter", {
|
|
|
537
645
|
});
|
|
538
646
|
Object.defineProperty(exports, "traceDB", {
|
|
539
647
|
enumerable: true,
|
|
540
|
-
get: function () { return
|
|
648
|
+
get: function () { return chunkYEVCD6DR_cjs.traceDB; }
|
|
541
649
|
});
|
|
542
650
|
Object.defineProperty(exports, "traceHTTP", {
|
|
543
651
|
enumerable: true,
|
|
544
|
-
get: function () { return
|
|
652
|
+
get: function () { return chunkYEVCD6DR_cjs.traceHTTP; }
|
|
545
653
|
});
|
|
546
654
|
Object.defineProperty(exports, "traceLLM", {
|
|
547
655
|
enumerable: true,
|
|
548
|
-
get: function () { return
|
|
656
|
+
get: function () { return chunkYEVCD6DR_cjs.traceLLM; }
|
|
549
657
|
});
|
|
550
658
|
Object.defineProperty(exports, "traceMessaging", {
|
|
551
659
|
enumerable: true,
|
|
552
|
-
get: function () { return
|
|
660
|
+
get: function () { return chunkYEVCD6DR_cjs.traceMessaging; }
|
|
553
661
|
});
|
|
554
662
|
Object.defineProperty(exports, "ctx", {
|
|
555
663
|
enumerable: true,
|
|
556
|
-
get: function () { return
|
|
664
|
+
get: function () { return chunkUTZR7P7E_cjs.ctx; }
|
|
557
665
|
});
|
|
558
666
|
Object.defineProperty(exports, "getEventQueue", {
|
|
559
667
|
enumerable: true,
|
|
560
|
-
get: function () { return
|
|
668
|
+
get: function () { return chunkUTZR7P7E_cjs.getEventQueue; }
|
|
561
669
|
});
|
|
562
670
|
Object.defineProperty(exports, "instrument", {
|
|
563
671
|
enumerable: true,
|
|
564
|
-
get: function () { return
|
|
672
|
+
get: function () { return chunkUTZR7P7E_cjs.instrument; }
|
|
565
673
|
});
|
|
566
674
|
Object.defineProperty(exports, "span", {
|
|
567
675
|
enumerable: true,
|
|
568
|
-
get: function () { return
|
|
676
|
+
get: function () { return chunkUTZR7P7E_cjs.span; }
|
|
569
677
|
});
|
|
570
678
|
Object.defineProperty(exports, "trace", {
|
|
571
679
|
enumerable: true,
|
|
572
|
-
get: function () { return
|
|
680
|
+
get: function () { return chunkUTZR7P7E_cjs.trace; }
|
|
573
681
|
});
|
|
574
682
|
Object.defineProperty(exports, "track", {
|
|
575
683
|
enumerable: true,
|
|
576
|
-
get: function () { return
|
|
684
|
+
get: function () { return chunkUTZR7P7E_cjs.track; }
|
|
577
685
|
});
|
|
578
686
|
Object.defineProperty(exports, "withBaggage", {
|
|
579
687
|
enumerable: true,
|
|
580
|
-
get: function () { return
|
|
688
|
+
get: function () { return chunkUTZR7P7E_cjs.withBaggage; }
|
|
581
689
|
});
|
|
582
690
|
Object.defineProperty(exports, "withNewContext", {
|
|
583
691
|
enumerable: true,
|
|
584
|
-
get: function () { return
|
|
692
|
+
get: function () { return chunkUTZR7P7E_cjs.withNewContext; }
|
|
585
693
|
});
|
|
586
694
|
Object.defineProperty(exports, "withTracing", {
|
|
587
695
|
enumerable: true,
|
|
588
|
-
get: function () { return
|
|
696
|
+
get: function () { return chunkUTZR7P7E_cjs.withTracing; }
|
|
589
697
|
});
|
|
590
698
|
Object.defineProperty(exports, "createDeterministicTraceId", {
|
|
591
699
|
enumerable: true,
|
|
@@ -633,15 +741,15 @@ Object.defineProperty(exports, "runWithSpan", {
|
|
|
633
741
|
});
|
|
634
742
|
Object.defineProperty(exports, "Event", {
|
|
635
743
|
enumerable: true,
|
|
636
|
-
get: function () { return
|
|
744
|
+
get: function () { return chunkWZOKY3PW_cjs.Event; }
|
|
637
745
|
});
|
|
638
746
|
Object.defineProperty(exports, "getEvents", {
|
|
639
747
|
enumerable: true,
|
|
640
|
-
get: function () { return
|
|
748
|
+
get: function () { return chunkWZOKY3PW_cjs.getEvents; }
|
|
641
749
|
});
|
|
642
750
|
Object.defineProperty(exports, "resetEvents", {
|
|
643
751
|
enumerable: true,
|
|
644
|
-
get: function () { return
|
|
752
|
+
get: function () { return chunkWZOKY3PW_cjs.resetEvents; }
|
|
645
753
|
});
|
|
646
754
|
Object.defineProperty(exports, "getOperationContext", {
|
|
647
755
|
enumerable: true,
|
|
@@ -685,15 +793,23 @@ Object.defineProperty(exports, "defineBaggageSchema", {
|
|
|
685
793
|
});
|
|
686
794
|
Object.defineProperty(exports, "BaggageSpanProcessor", {
|
|
687
795
|
enumerable: true,
|
|
688
|
-
get: function () { return
|
|
796
|
+
get: function () { return chunk563EL6O6_cjs.BaggageSpanProcessor; }
|
|
689
797
|
});
|
|
690
798
|
Object.defineProperty(exports, "createStringRedactor", {
|
|
691
799
|
enumerable: true,
|
|
692
|
-
get: function () { return
|
|
800
|
+
get: function () { return chunk563EL6O6_cjs.createStringRedactor; }
|
|
693
801
|
});
|
|
694
802
|
Object.defineProperty(exports, "init", {
|
|
695
803
|
enumerable: true,
|
|
696
|
-
get: function () { return
|
|
804
|
+
get: function () { return chunk563EL6O6_cjs.init; }
|
|
805
|
+
});
|
|
806
|
+
Object.defineProperty(exports, "isLoggerLocked", {
|
|
807
|
+
enumerable: true,
|
|
808
|
+
get: function () { return chunk563EL6O6_cjs.isLoggerLocked; }
|
|
809
|
+
});
|
|
810
|
+
Object.defineProperty(exports, "lockLogger", {
|
|
811
|
+
enumerable: true,
|
|
812
|
+
get: function () { return chunk563EL6O6_cjs.lockLogger; }
|
|
697
813
|
});
|
|
698
814
|
Object.defineProperty(exports, "FilteringSpanProcessor", {
|
|
699
815
|
enumerable: true,
|
|
@@ -713,23 +829,23 @@ Object.defineProperty(exports, "SpanNameNormalizingProcessor", {
|
|
|
713
829
|
});
|
|
714
830
|
Object.defineProperty(exports, "AttributeRedactingProcessor", {
|
|
715
831
|
enumerable: true,
|
|
716
|
-
get: function () { return
|
|
832
|
+
get: function () { return chunkCMNGGTQL_cjs.AttributeRedactingProcessor; }
|
|
717
833
|
});
|
|
718
834
|
Object.defineProperty(exports, "REDACTOR_PATTERNS", {
|
|
719
835
|
enumerable: true,
|
|
720
|
-
get: function () { return
|
|
836
|
+
get: function () { return chunkCMNGGTQL_cjs.REDACTOR_PATTERNS; }
|
|
721
837
|
});
|
|
722
838
|
Object.defineProperty(exports, "REDACTOR_PRESETS", {
|
|
723
839
|
enumerable: true,
|
|
724
|
-
get: function () { return
|
|
840
|
+
get: function () { return chunkCMNGGTQL_cjs.REDACTOR_PRESETS; }
|
|
725
841
|
});
|
|
726
842
|
Object.defineProperty(exports, "createAttributeRedactor", {
|
|
727
843
|
enumerable: true,
|
|
728
|
-
get: function () { return
|
|
844
|
+
get: function () { return chunkCMNGGTQL_cjs.createAttributeRedactor; }
|
|
729
845
|
});
|
|
730
846
|
Object.defineProperty(exports, "createRedactedSpan", {
|
|
731
847
|
enumerable: true,
|
|
732
|
-
get: function () { return
|
|
848
|
+
get: function () { return chunkCMNGGTQL_cjs.createRedactedSpan; }
|
|
733
849
|
});
|
|
734
850
|
Object.defineProperty(exports, "formatDuration", {
|
|
735
851
|
enumerable: true,
|
|
@@ -737,47 +853,47 @@ Object.defineProperty(exports, "formatDuration", {
|
|
|
737
853
|
});
|
|
738
854
|
Object.defineProperty(exports, "AUTOTEL_SAMPLING_TAIL_EVALUATED", {
|
|
739
855
|
enumerable: true,
|
|
740
|
-
get: function () { return
|
|
856
|
+
get: function () { return chunkVH77IPJN_cjs.AUTOTEL_SAMPLING_TAIL_EVALUATED; }
|
|
741
857
|
});
|
|
742
858
|
Object.defineProperty(exports, "AUTOTEL_SAMPLING_TAIL_KEEP", {
|
|
743
859
|
enumerable: true,
|
|
744
|
-
get: function () { return
|
|
860
|
+
get: function () { return chunkVH77IPJN_cjs.AUTOTEL_SAMPLING_TAIL_KEEP; }
|
|
745
861
|
});
|
|
746
862
|
Object.defineProperty(exports, "AdaptiveSampler", {
|
|
747
863
|
enumerable: true,
|
|
748
|
-
get: function () { return
|
|
864
|
+
get: function () { return chunkVH77IPJN_cjs.AdaptiveSampler; }
|
|
749
865
|
});
|
|
750
866
|
Object.defineProperty(exports, "AlwaysSampler", {
|
|
751
867
|
enumerable: true,
|
|
752
|
-
get: function () { return
|
|
868
|
+
get: function () { return chunkVH77IPJN_cjs.AlwaysSampler; }
|
|
753
869
|
});
|
|
754
870
|
Object.defineProperty(exports, "NeverSampler", {
|
|
755
871
|
enumerable: true,
|
|
756
|
-
get: function () { return
|
|
872
|
+
get: function () { return chunkVH77IPJN_cjs.NeverSampler; }
|
|
757
873
|
});
|
|
758
874
|
Object.defineProperty(exports, "RandomSampler", {
|
|
759
875
|
enumerable: true,
|
|
760
|
-
get: function () { return
|
|
876
|
+
get: function () { return chunkVH77IPJN_cjs.RandomSampler; }
|
|
761
877
|
});
|
|
762
878
|
Object.defineProperty(exports, "UserIdSampler", {
|
|
763
879
|
enumerable: true,
|
|
764
|
-
get: function () { return
|
|
880
|
+
get: function () { return chunkVH77IPJN_cjs.UserIdSampler; }
|
|
765
881
|
});
|
|
766
882
|
Object.defineProperty(exports, "createLinkFromHeaders", {
|
|
767
883
|
enumerable: true,
|
|
768
|
-
get: function () { return
|
|
884
|
+
get: function () { return chunkVH77IPJN_cjs.createLinkFromHeaders; }
|
|
769
885
|
});
|
|
770
886
|
Object.defineProperty(exports, "extractLinksFromBatch", {
|
|
771
887
|
enumerable: true,
|
|
772
|
-
get: function () { return
|
|
888
|
+
get: function () { return chunkVH77IPJN_cjs.extractLinksFromBatch; }
|
|
773
889
|
});
|
|
774
890
|
Object.defineProperty(exports, "resolveSamplingPreset", {
|
|
775
891
|
enumerable: true,
|
|
776
|
-
get: function () { return
|
|
892
|
+
get: function () { return chunkVH77IPJN_cjs.resolveSamplingPreset; }
|
|
777
893
|
});
|
|
778
894
|
Object.defineProperty(exports, "samplingPresets", {
|
|
779
895
|
enumerable: true,
|
|
780
|
-
get: function () { return
|
|
896
|
+
get: function () { return chunkVH77IPJN_cjs.samplingPresets; }
|
|
781
897
|
});
|
|
782
898
|
Object.defineProperty(exports, "getAutotelTracer", {
|
|
783
899
|
enumerable: true,
|
|
@@ -823,6 +939,7 @@ exports.getStructuredErrorAttributes = getStructuredErrorAttributes;
|
|
|
823
939
|
exports.recordStructuredError = recordStructuredError;
|
|
824
940
|
exports.runWithRequestContext = runWithRequestContext;
|
|
825
941
|
exports.shutdown = shutdown;
|
|
942
|
+
exports.structuredErrorToJSON = structuredErrorToJSON;
|
|
826
943
|
exports.toAttributeValue = toAttributeValue;
|
|
827
944
|
//# sourceMappingURL=index.cjs.map
|
|
828
945
|
//# sourceMappingURL=index.cjs.map
|