autotel 2.25.5 → 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/README.md +47 -1
- 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-ITYASFHQ.cjs → chunk-563EL6O6.cjs} +153 -15
- package/dist/chunk-563EL6O6.cjs.map +1 -0
- package/dist/{chunk-EEJGUBWV.cjs → chunk-6YGUN7IY.cjs} +5 -5
- package/dist/{chunk-EEJGUBWV.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-XB2GITM5.js → chunk-BJ2XPN77.js} +3 -3
- package/dist/{chunk-XB2GITM5.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-OPTGXEVN.js → chunk-HPUGKUMZ.js} +4 -4
- package/dist/{chunk-OPTGXEVN.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-I6JPSD4R.cjs → chunk-OBWXM4NN.cjs} +9 -9
- package/dist/{chunk-I6JPSD4R.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-QDREXAD7.js → chunk-QC5MNKVF.js} +4 -4
- package/dist/{chunk-QDREXAD7.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-CMUM4JQI.js → chunk-U54FTVFH.js} +3 -3
- package/dist/{chunk-CMUM4JQI.js.map → chunk-U54FTVFH.js.map} +1 -1
- package/dist/{chunk-QQLP4M6W.cjs → chunk-UTZR7P7E.cjs} +36 -36
- package/dist/{chunk-QQLP4M6W.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-MNBAXRVG.js → chunk-W35FVJBC.js} +144 -9
- package/dist/chunk-W35FVJBC.js.map +1 -0
- package/dist/{chunk-A5ZUL2RZ.cjs → chunk-WZOKY3PW.cjs} +13 -13
- package/dist/{chunk-A5ZUL2RZ.cjs.map → chunk-WZOKY3PW.cjs.map} +1 -1
- package/dist/{chunk-MN6PZ4AN.cjs → chunk-YEVCD6DR.cjs} +7 -7
- package/dist/{chunk-MN6PZ4AN.cjs.map → chunk-YEVCD6DR.cjs.map} +1 -1
- package/dist/{chunk-WYP6OOCT.js → chunk-YN7USLHW.js} +3 -3
- package/dist/{chunk-WYP6OOCT.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 -96
- 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 +142 -33
- package/dist/index.js.map +1 -1
- package/dist/{init-CIzpC5kZ.d.cts → init-CMuTaFAV.d.cts} +49 -1
- package/dist/{init-C_PiC_Su.d.ts → init-D6JfWEjL.d.ts} +49 -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 +41 -41
- 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/devtools.ts +60 -0
- package/src/hook.mjs +2 -2
- package/src/index.ts +2 -1
- package/src/init.customization.test.ts +81 -0
- package/src/init.ts +188 -3
- package/src/request-logger.test.ts +266 -1
- package/src/request-logger.ts +115 -16
- package/src/shutdown.test.ts +35 -1
- package/src/shutdown.ts +3 -1
- 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-ITYASFHQ.cjs.map +0 -1
- package/dist/chunk-MNBAXRVG.js.map +0 -1
- package/dist/chunk-SNINLBEE.js +0 -167
- package/dist/chunk-SNINLBEE.js.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,13 +124,14 @@ async function shutdown() {
|
|
|
124
124
|
logger.error({ err }, "[autotel] SDK shutdown failed");
|
|
125
125
|
}
|
|
126
126
|
} finally {
|
|
127
|
-
|
|
127
|
+
await chunk563EL6O6_cjs._closeEmbeddedDevtools();
|
|
128
|
+
const eventsQueue = chunkUTZR7P7E_cjs.getEventQueue();
|
|
128
129
|
if (eventsQueue && typeof eventsQueue.cleanup === "function") {
|
|
129
130
|
eventsQueue.cleanup();
|
|
130
131
|
}
|
|
131
|
-
|
|
132
|
+
chunkWZOKY3PW_cjs.resetEvents();
|
|
132
133
|
chunkTC5ZPWM4_cjs.resetMetrics();
|
|
133
|
-
|
|
134
|
+
chunkUTZR7P7E_cjs.resetEventQueue();
|
|
134
135
|
}
|
|
135
136
|
if (shutdownError) {
|
|
136
137
|
throw shutdownError;
|
|
@@ -145,7 +146,7 @@ function registerShutdownHooks() {
|
|
|
145
146
|
if (shuttingDown) return;
|
|
146
147
|
shuttingDown = true;
|
|
147
148
|
if (process.env.NODE_ENV !== "test") {
|
|
148
|
-
|
|
149
|
+
chunk563EL6O6_cjs.getLogger().info(
|
|
149
150
|
{},
|
|
150
151
|
`[autotel] Received ${signal}, flushing telemetry...`
|
|
151
152
|
);
|
|
@@ -153,7 +154,7 @@ function registerShutdownHooks() {
|
|
|
153
154
|
try {
|
|
154
155
|
await shutdown();
|
|
155
156
|
} catch (error) {
|
|
156
|
-
|
|
157
|
+
chunk563EL6O6_cjs.getLogger().error(
|
|
157
158
|
{
|
|
158
159
|
err: error instanceof Error ? error : void 0
|
|
159
160
|
},
|
|
@@ -223,6 +224,7 @@ function flattenToAttributes(fields, prefix = "") {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
// src/structured-error.ts
|
|
227
|
+
var internalKey = /* @__PURE__ */ Symbol.for("autotel.error.internal");
|
|
226
228
|
function createStructuredError(input) {
|
|
227
229
|
const error = new Error(input.message, {
|
|
228
230
|
cause: input.cause
|
|
@@ -234,6 +236,21 @@ function createStructuredError(input) {
|
|
|
234
236
|
if (input.code !== void 0) error.code = input.code;
|
|
235
237
|
if (input.status !== void 0) error.status = input.status;
|
|
236
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
|
+
});
|
|
237
254
|
error.toString = () => {
|
|
238
255
|
const lines = [`${error.name}: ${error.message}`];
|
|
239
256
|
if (error.why) lines.push(` Why: ${error.why}`);
|
|
@@ -241,11 +258,34 @@ function createStructuredError(input) {
|
|
|
241
258
|
if (error.link) lines.push(` Link: ${error.link}`);
|
|
242
259
|
if (error.code !== void 0) lines.push(` Code: ${error.code}`);
|
|
243
260
|
if (error.status !== void 0) lines.push(` Status: ${error.status}`);
|
|
244
|
-
if (error.cause)
|
|
261
|
+
if (error.cause) {
|
|
262
|
+
const cause = error.cause;
|
|
263
|
+
lines.push(` Caused by: ${cause.name}: ${cause.message}`);
|
|
264
|
+
}
|
|
245
265
|
return lines.join("\n");
|
|
246
266
|
};
|
|
247
267
|
return error;
|
|
248
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
|
+
}
|
|
249
289
|
function getStructuredErrorAttributes(error) {
|
|
250
290
|
const structured = error;
|
|
251
291
|
const attributes = {
|
|
@@ -280,6 +320,29 @@ function recordStructuredError(ctx2, error) {
|
|
|
280
320
|
}
|
|
281
321
|
|
|
282
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
|
+
}
|
|
283
346
|
var requestContextStore = new async_hooks.AsyncLocalStorage();
|
|
284
347
|
function runWithRequestContext(ctx2, fn) {
|
|
285
348
|
return requestContextStore.run(ctx2, fn);
|
|
@@ -299,6 +362,8 @@ function resolveContext(ctx2) {
|
|
|
299
362
|
function getRequestLogger(ctx2, options) {
|
|
300
363
|
const activeContext = resolveContext(ctx2);
|
|
301
364
|
let contextState = {};
|
|
365
|
+
let emitted = false;
|
|
366
|
+
let lastSnapshot = null;
|
|
302
367
|
const addLogEvent = (level, message, fields) => {
|
|
303
368
|
const attrs2 = fields ? flattenToAttributes(fields) : void 0;
|
|
304
369
|
activeContext.addEvent(`log.${level}`, {
|
|
@@ -306,44 +371,51 @@ function getRequestLogger(ctx2, options) {
|
|
|
306
371
|
...attrs2
|
|
307
372
|
});
|
|
308
373
|
};
|
|
374
|
+
const sealCheck = (method, keys) => {
|
|
375
|
+
if (emitted) {
|
|
376
|
+
warnPostEmit(
|
|
377
|
+
method,
|
|
378
|
+
`Keys dropped: ${keys.length ? keys.join(", ") : "(empty)"}.`
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
309
382
|
return {
|
|
310
383
|
set(fields) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
};
|
|
384
|
+
sealCheck("log.set()", Object.keys(fields));
|
|
385
|
+
if (emitted) return;
|
|
386
|
+
mergeInto(contextState, fields);
|
|
315
387
|
activeContext.setAttributes(flattenToAttributes(fields));
|
|
316
388
|
},
|
|
317
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;
|
|
318
393
|
addLogEvent("info", message, fields);
|
|
319
394
|
if (fields) {
|
|
320
|
-
contextState
|
|
321
|
-
...contextState,
|
|
322
|
-
...fields
|
|
323
|
-
};
|
|
395
|
+
mergeInto(contextState, fields);
|
|
324
396
|
activeContext.setAttributes(flattenToAttributes(fields));
|
|
325
397
|
}
|
|
326
398
|
},
|
|
327
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;
|
|
328
403
|
addLogEvent("warn", message, fields);
|
|
329
404
|
activeContext.setAttribute("autotel.log.level", "warn");
|
|
330
405
|
if (fields) {
|
|
331
|
-
contextState
|
|
332
|
-
...contextState,
|
|
333
|
-
...fields
|
|
334
|
-
};
|
|
406
|
+
mergeInto(contextState, fields);
|
|
335
407
|
activeContext.setAttributes(flattenToAttributes(fields));
|
|
336
408
|
}
|
|
337
409
|
},
|
|
338
410
|
error(error, fields) {
|
|
411
|
+
const keys = fields ? [...Object.keys(fields), "error"] : ["error"];
|
|
412
|
+
sealCheck("log.error()", keys);
|
|
413
|
+
if (emitted) return;
|
|
339
414
|
const err = typeof error === "string" ? new Error(error) : error;
|
|
340
415
|
recordStructuredError(activeContext, err);
|
|
341
416
|
addLogEvent("error", err.message, fields);
|
|
342
417
|
if (fields) {
|
|
343
|
-
contextState
|
|
344
|
-
...contextState,
|
|
345
|
-
...fields
|
|
346
|
-
};
|
|
418
|
+
mergeInto(contextState, fields);
|
|
347
419
|
activeContext.setAttributes(flattenToAttributes(fields));
|
|
348
420
|
}
|
|
349
421
|
activeContext.setAttribute("autotel.log.level", "error");
|
|
@@ -352,6 +424,10 @@ function getRequestLogger(ctx2, options) {
|
|
|
352
424
|
return { ...contextState };
|
|
353
425
|
},
|
|
354
426
|
emitNow(overrides) {
|
|
427
|
+
if (emitted) {
|
|
428
|
+
warnPostEmit("log.emitNow()", "Ignoring duplicate emit.");
|
|
429
|
+
return lastSnapshot;
|
|
430
|
+
}
|
|
355
431
|
const mergedContext = {
|
|
356
432
|
...contextState,
|
|
357
433
|
...overrides ?? {}
|
|
@@ -373,7 +449,40 @@ function getRequestLogger(ctx2, options) {
|
|
|
373
449
|
console.warn("[autotel] request logger onEmit failed:", error);
|
|
374
450
|
});
|
|
375
451
|
}
|
|
452
|
+
emitted = true;
|
|
453
|
+
lastSnapshot = snapshot;
|
|
376
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
|
+
});
|
|
377
486
|
}
|
|
378
487
|
};
|
|
379
488
|
}
|
|
@@ -384,83 +493,83 @@ Object.defineProperty(exports, "createDrainPipeline", {
|
|
|
384
493
|
});
|
|
385
494
|
Object.defineProperty(exports, "getCurrentWorkflowContext", {
|
|
386
495
|
enumerable: true,
|
|
387
|
-
get: function () { return
|
|
496
|
+
get: function () { return chunk6YGUN7IY_cjs.getCurrentWorkflowContext; }
|
|
388
497
|
});
|
|
389
498
|
Object.defineProperty(exports, "isInWorkflow", {
|
|
390
499
|
enumerable: true,
|
|
391
|
-
get: function () { return
|
|
500
|
+
get: function () { return chunk6YGUN7IY_cjs.isInWorkflow; }
|
|
392
501
|
});
|
|
393
502
|
Object.defineProperty(exports, "traceStep", {
|
|
394
503
|
enumerable: true,
|
|
395
|
-
get: function () { return
|
|
504
|
+
get: function () { return chunk6YGUN7IY_cjs.traceStep; }
|
|
396
505
|
});
|
|
397
506
|
Object.defineProperty(exports, "traceWorkflow", {
|
|
398
507
|
enumerable: true,
|
|
399
|
-
get: function () { return
|
|
508
|
+
get: function () { return chunk6YGUN7IY_cjs.traceWorkflow; }
|
|
400
509
|
});
|
|
401
510
|
Object.defineProperty(exports, "attrs", {
|
|
402
511
|
enumerable: true,
|
|
403
|
-
get: function () { return
|
|
512
|
+
get: function () { return chunkJKIMEPI2_cjs.attrs; }
|
|
404
513
|
});
|
|
405
514
|
Object.defineProperty(exports, "autoRedactPII", {
|
|
406
515
|
enumerable: true,
|
|
407
|
-
get: function () { return
|
|
516
|
+
get: function () { return chunkJKIMEPI2_cjs.autoRedactPII; }
|
|
408
517
|
});
|
|
409
518
|
Object.defineProperty(exports, "dbClient", {
|
|
410
519
|
enumerable: true,
|
|
411
|
-
get: function () { return
|
|
520
|
+
get: function () { return chunkJKIMEPI2_cjs.dbClient; }
|
|
412
521
|
});
|
|
413
522
|
Object.defineProperty(exports, "httpClient", {
|
|
414
523
|
enumerable: true,
|
|
415
|
-
get: function () { return
|
|
524
|
+
get: function () { return chunkJKIMEPI2_cjs.httpClient; }
|
|
416
525
|
});
|
|
417
526
|
Object.defineProperty(exports, "httpServer", {
|
|
418
527
|
enumerable: true,
|
|
419
|
-
get: function () { return
|
|
528
|
+
get: function () { return chunkJKIMEPI2_cjs.httpServer; }
|
|
420
529
|
});
|
|
421
530
|
Object.defineProperty(exports, "identify", {
|
|
422
531
|
enumerable: true,
|
|
423
|
-
get: function () { return
|
|
532
|
+
get: function () { return chunkJKIMEPI2_cjs.identify; }
|
|
424
533
|
});
|
|
425
534
|
Object.defineProperty(exports, "mergeAttrs", {
|
|
426
535
|
enumerable: true,
|
|
427
|
-
get: function () { return
|
|
536
|
+
get: function () { return chunkJKIMEPI2_cjs.mergeAttrs; }
|
|
428
537
|
});
|
|
429
538
|
Object.defineProperty(exports, "mergeServiceResource", {
|
|
430
539
|
enumerable: true,
|
|
431
|
-
get: function () { return
|
|
540
|
+
get: function () { return chunkJKIMEPI2_cjs.mergeServiceResource; }
|
|
432
541
|
});
|
|
433
542
|
Object.defineProperty(exports, "request", {
|
|
434
543
|
enumerable: true,
|
|
435
|
-
get: function () { return
|
|
544
|
+
get: function () { return chunkJKIMEPI2_cjs.request; }
|
|
436
545
|
});
|
|
437
546
|
Object.defineProperty(exports, "safeSetAttributes", {
|
|
438
547
|
enumerable: true,
|
|
439
|
-
get: function () { return
|
|
548
|
+
get: function () { return chunkJKIMEPI2_cjs.safeSetAttributes; }
|
|
440
549
|
});
|
|
441
550
|
Object.defineProperty(exports, "setDevice", {
|
|
442
551
|
enumerable: true,
|
|
443
|
-
get: function () { return
|
|
552
|
+
get: function () { return chunkJKIMEPI2_cjs.setDevice; }
|
|
444
553
|
});
|
|
445
554
|
Object.defineProperty(exports, "setError", {
|
|
446
555
|
enumerable: true,
|
|
447
|
-
get: function () { return
|
|
556
|
+
get: function () { return chunkJKIMEPI2_cjs.setError; }
|
|
448
557
|
});
|
|
449
558
|
Object.defineProperty(exports, "setException", {
|
|
450
559
|
enumerable: true,
|
|
451
|
-
get: function () { return
|
|
560
|
+
get: function () { return chunkJKIMEPI2_cjs.setException; }
|
|
452
561
|
});
|
|
453
562
|
Object.defineProperty(exports, "setSession", {
|
|
454
563
|
enumerable: true,
|
|
455
|
-
get: function () { return
|
|
564
|
+
get: function () { return chunkJKIMEPI2_cjs.setSession; }
|
|
456
565
|
});
|
|
457
566
|
Object.defineProperty(exports, "setUser", {
|
|
458
567
|
enumerable: true,
|
|
459
|
-
get: function () { return
|
|
568
|
+
get: function () { return chunkJKIMEPI2_cjs.setUser; }
|
|
460
569
|
});
|
|
461
570
|
Object.defineProperty(exports, "validateAttribute", {
|
|
462
571
|
enumerable: true,
|
|
463
|
-
get: function () { return
|
|
572
|
+
get: function () { return chunkJKIMEPI2_cjs.validateAttribute; }
|
|
464
573
|
});
|
|
465
574
|
Object.defineProperty(exports, "httpRequestHeaderAttribute", {
|
|
466
575
|
enumerable: true,
|
|
@@ -488,11 +597,11 @@ Object.defineProperty(exports, "parseError", {
|
|
|
488
597
|
});
|
|
489
598
|
Object.defineProperty(exports, "traceConsumer", {
|
|
490
599
|
enumerable: true,
|
|
491
|
-
get: function () { return
|
|
600
|
+
get: function () { return chunkOBWXM4NN_cjs.traceConsumer; }
|
|
492
601
|
});
|
|
493
602
|
Object.defineProperty(exports, "traceProducer", {
|
|
494
603
|
enumerable: true,
|
|
495
|
-
get: function () { return
|
|
604
|
+
get: function () { return chunkOBWXM4NN_cjs.traceProducer; }
|
|
496
605
|
});
|
|
497
606
|
Object.defineProperty(exports, "BusinessBaggage", {
|
|
498
607
|
enumerable: true,
|
|
@@ -536,55 +645,55 @@ Object.defineProperty(exports, "getMeter", {
|
|
|
536
645
|
});
|
|
537
646
|
Object.defineProperty(exports, "traceDB", {
|
|
538
647
|
enumerable: true,
|
|
539
|
-
get: function () { return
|
|
648
|
+
get: function () { return chunkYEVCD6DR_cjs.traceDB; }
|
|
540
649
|
});
|
|
541
650
|
Object.defineProperty(exports, "traceHTTP", {
|
|
542
651
|
enumerable: true,
|
|
543
|
-
get: function () { return
|
|
652
|
+
get: function () { return chunkYEVCD6DR_cjs.traceHTTP; }
|
|
544
653
|
});
|
|
545
654
|
Object.defineProperty(exports, "traceLLM", {
|
|
546
655
|
enumerable: true,
|
|
547
|
-
get: function () { return
|
|
656
|
+
get: function () { return chunkYEVCD6DR_cjs.traceLLM; }
|
|
548
657
|
});
|
|
549
658
|
Object.defineProperty(exports, "traceMessaging", {
|
|
550
659
|
enumerable: true,
|
|
551
|
-
get: function () { return
|
|
660
|
+
get: function () { return chunkYEVCD6DR_cjs.traceMessaging; }
|
|
552
661
|
});
|
|
553
662
|
Object.defineProperty(exports, "ctx", {
|
|
554
663
|
enumerable: true,
|
|
555
|
-
get: function () { return
|
|
664
|
+
get: function () { return chunkUTZR7P7E_cjs.ctx; }
|
|
556
665
|
});
|
|
557
666
|
Object.defineProperty(exports, "getEventQueue", {
|
|
558
667
|
enumerable: true,
|
|
559
|
-
get: function () { return
|
|
668
|
+
get: function () { return chunkUTZR7P7E_cjs.getEventQueue; }
|
|
560
669
|
});
|
|
561
670
|
Object.defineProperty(exports, "instrument", {
|
|
562
671
|
enumerable: true,
|
|
563
|
-
get: function () { return
|
|
672
|
+
get: function () { return chunkUTZR7P7E_cjs.instrument; }
|
|
564
673
|
});
|
|
565
674
|
Object.defineProperty(exports, "span", {
|
|
566
675
|
enumerable: true,
|
|
567
|
-
get: function () { return
|
|
676
|
+
get: function () { return chunkUTZR7P7E_cjs.span; }
|
|
568
677
|
});
|
|
569
678
|
Object.defineProperty(exports, "trace", {
|
|
570
679
|
enumerable: true,
|
|
571
|
-
get: function () { return
|
|
680
|
+
get: function () { return chunkUTZR7P7E_cjs.trace; }
|
|
572
681
|
});
|
|
573
682
|
Object.defineProperty(exports, "track", {
|
|
574
683
|
enumerable: true,
|
|
575
|
-
get: function () { return
|
|
684
|
+
get: function () { return chunkUTZR7P7E_cjs.track; }
|
|
576
685
|
});
|
|
577
686
|
Object.defineProperty(exports, "withBaggage", {
|
|
578
687
|
enumerable: true,
|
|
579
|
-
get: function () { return
|
|
688
|
+
get: function () { return chunkUTZR7P7E_cjs.withBaggage; }
|
|
580
689
|
});
|
|
581
690
|
Object.defineProperty(exports, "withNewContext", {
|
|
582
691
|
enumerable: true,
|
|
583
|
-
get: function () { return
|
|
692
|
+
get: function () { return chunkUTZR7P7E_cjs.withNewContext; }
|
|
584
693
|
});
|
|
585
694
|
Object.defineProperty(exports, "withTracing", {
|
|
586
695
|
enumerable: true,
|
|
587
|
-
get: function () { return
|
|
696
|
+
get: function () { return chunkUTZR7P7E_cjs.withTracing; }
|
|
588
697
|
});
|
|
589
698
|
Object.defineProperty(exports, "createDeterministicTraceId", {
|
|
590
699
|
enumerable: true,
|
|
@@ -632,15 +741,15 @@ Object.defineProperty(exports, "runWithSpan", {
|
|
|
632
741
|
});
|
|
633
742
|
Object.defineProperty(exports, "Event", {
|
|
634
743
|
enumerable: true,
|
|
635
|
-
get: function () { return
|
|
744
|
+
get: function () { return chunkWZOKY3PW_cjs.Event; }
|
|
636
745
|
});
|
|
637
746
|
Object.defineProperty(exports, "getEvents", {
|
|
638
747
|
enumerable: true,
|
|
639
|
-
get: function () { return
|
|
748
|
+
get: function () { return chunkWZOKY3PW_cjs.getEvents; }
|
|
640
749
|
});
|
|
641
750
|
Object.defineProperty(exports, "resetEvents", {
|
|
642
751
|
enumerable: true,
|
|
643
|
-
get: function () { return
|
|
752
|
+
get: function () { return chunkWZOKY3PW_cjs.resetEvents; }
|
|
644
753
|
});
|
|
645
754
|
Object.defineProperty(exports, "getOperationContext", {
|
|
646
755
|
enumerable: true,
|
|
@@ -684,15 +793,23 @@ Object.defineProperty(exports, "defineBaggageSchema", {
|
|
|
684
793
|
});
|
|
685
794
|
Object.defineProperty(exports, "BaggageSpanProcessor", {
|
|
686
795
|
enumerable: true,
|
|
687
|
-
get: function () { return
|
|
796
|
+
get: function () { return chunk563EL6O6_cjs.BaggageSpanProcessor; }
|
|
688
797
|
});
|
|
689
798
|
Object.defineProperty(exports, "createStringRedactor", {
|
|
690
799
|
enumerable: true,
|
|
691
|
-
get: function () { return
|
|
800
|
+
get: function () { return chunk563EL6O6_cjs.createStringRedactor; }
|
|
692
801
|
});
|
|
693
802
|
Object.defineProperty(exports, "init", {
|
|
694
803
|
enumerable: true,
|
|
695
|
-
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; }
|
|
696
813
|
});
|
|
697
814
|
Object.defineProperty(exports, "FilteringSpanProcessor", {
|
|
698
815
|
enumerable: true,
|
|
@@ -712,23 +829,23 @@ Object.defineProperty(exports, "SpanNameNormalizingProcessor", {
|
|
|
712
829
|
});
|
|
713
830
|
Object.defineProperty(exports, "AttributeRedactingProcessor", {
|
|
714
831
|
enumerable: true,
|
|
715
|
-
get: function () { return
|
|
832
|
+
get: function () { return chunkCMNGGTQL_cjs.AttributeRedactingProcessor; }
|
|
716
833
|
});
|
|
717
834
|
Object.defineProperty(exports, "REDACTOR_PATTERNS", {
|
|
718
835
|
enumerable: true,
|
|
719
|
-
get: function () { return
|
|
836
|
+
get: function () { return chunkCMNGGTQL_cjs.REDACTOR_PATTERNS; }
|
|
720
837
|
});
|
|
721
838
|
Object.defineProperty(exports, "REDACTOR_PRESETS", {
|
|
722
839
|
enumerable: true,
|
|
723
|
-
get: function () { return
|
|
840
|
+
get: function () { return chunkCMNGGTQL_cjs.REDACTOR_PRESETS; }
|
|
724
841
|
});
|
|
725
842
|
Object.defineProperty(exports, "createAttributeRedactor", {
|
|
726
843
|
enumerable: true,
|
|
727
|
-
get: function () { return
|
|
844
|
+
get: function () { return chunkCMNGGTQL_cjs.createAttributeRedactor; }
|
|
728
845
|
});
|
|
729
846
|
Object.defineProperty(exports, "createRedactedSpan", {
|
|
730
847
|
enumerable: true,
|
|
731
|
-
get: function () { return
|
|
848
|
+
get: function () { return chunkCMNGGTQL_cjs.createRedactedSpan; }
|
|
732
849
|
});
|
|
733
850
|
Object.defineProperty(exports, "formatDuration", {
|
|
734
851
|
enumerable: true,
|
|
@@ -736,47 +853,47 @@ Object.defineProperty(exports, "formatDuration", {
|
|
|
736
853
|
});
|
|
737
854
|
Object.defineProperty(exports, "AUTOTEL_SAMPLING_TAIL_EVALUATED", {
|
|
738
855
|
enumerable: true,
|
|
739
|
-
get: function () { return
|
|
856
|
+
get: function () { return chunkVH77IPJN_cjs.AUTOTEL_SAMPLING_TAIL_EVALUATED; }
|
|
740
857
|
});
|
|
741
858
|
Object.defineProperty(exports, "AUTOTEL_SAMPLING_TAIL_KEEP", {
|
|
742
859
|
enumerable: true,
|
|
743
|
-
get: function () { return
|
|
860
|
+
get: function () { return chunkVH77IPJN_cjs.AUTOTEL_SAMPLING_TAIL_KEEP; }
|
|
744
861
|
});
|
|
745
862
|
Object.defineProperty(exports, "AdaptiveSampler", {
|
|
746
863
|
enumerable: true,
|
|
747
|
-
get: function () { return
|
|
864
|
+
get: function () { return chunkVH77IPJN_cjs.AdaptiveSampler; }
|
|
748
865
|
});
|
|
749
866
|
Object.defineProperty(exports, "AlwaysSampler", {
|
|
750
867
|
enumerable: true,
|
|
751
|
-
get: function () { return
|
|
868
|
+
get: function () { return chunkVH77IPJN_cjs.AlwaysSampler; }
|
|
752
869
|
});
|
|
753
870
|
Object.defineProperty(exports, "NeverSampler", {
|
|
754
871
|
enumerable: true,
|
|
755
|
-
get: function () { return
|
|
872
|
+
get: function () { return chunkVH77IPJN_cjs.NeverSampler; }
|
|
756
873
|
});
|
|
757
874
|
Object.defineProperty(exports, "RandomSampler", {
|
|
758
875
|
enumerable: true,
|
|
759
|
-
get: function () { return
|
|
876
|
+
get: function () { return chunkVH77IPJN_cjs.RandomSampler; }
|
|
760
877
|
});
|
|
761
878
|
Object.defineProperty(exports, "UserIdSampler", {
|
|
762
879
|
enumerable: true,
|
|
763
|
-
get: function () { return
|
|
880
|
+
get: function () { return chunkVH77IPJN_cjs.UserIdSampler; }
|
|
764
881
|
});
|
|
765
882
|
Object.defineProperty(exports, "createLinkFromHeaders", {
|
|
766
883
|
enumerable: true,
|
|
767
|
-
get: function () { return
|
|
884
|
+
get: function () { return chunkVH77IPJN_cjs.createLinkFromHeaders; }
|
|
768
885
|
});
|
|
769
886
|
Object.defineProperty(exports, "extractLinksFromBatch", {
|
|
770
887
|
enumerable: true,
|
|
771
|
-
get: function () { return
|
|
888
|
+
get: function () { return chunkVH77IPJN_cjs.extractLinksFromBatch; }
|
|
772
889
|
});
|
|
773
890
|
Object.defineProperty(exports, "resolveSamplingPreset", {
|
|
774
891
|
enumerable: true,
|
|
775
|
-
get: function () { return
|
|
892
|
+
get: function () { return chunkVH77IPJN_cjs.resolveSamplingPreset; }
|
|
776
893
|
});
|
|
777
894
|
Object.defineProperty(exports, "samplingPresets", {
|
|
778
895
|
enumerable: true,
|
|
779
|
-
get: function () { return
|
|
896
|
+
get: function () { return chunkVH77IPJN_cjs.samplingPresets; }
|
|
780
897
|
});
|
|
781
898
|
Object.defineProperty(exports, "getAutotelTracer", {
|
|
782
899
|
enumerable: true,
|
|
@@ -822,6 +939,7 @@ exports.getStructuredErrorAttributes = getStructuredErrorAttributes;
|
|
|
822
939
|
exports.recordStructuredError = recordStructuredError;
|
|
823
940
|
exports.runWithRequestContext = runWithRequestContext;
|
|
824
941
|
exports.shutdown = shutdown;
|
|
942
|
+
exports.structuredErrorToJSON = structuredErrorToJSON;
|
|
825
943
|
exports.toAttributeValue = toAttributeValue;
|
|
826
944
|
//# sourceMappingURL=index.cjs.map
|
|
827
945
|
//# sourceMappingURL=index.cjs.map
|