autotel 6.5.0 → 7.0.0
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 +30 -23
- package/dist/{attribute-redacting-processor-Pk7lAzWd.d.cts → attribute-redacting-processor-CvBE0z1p.d.cts} +33 -1
- package/dist/{attribute-redacting-processor-Pk7lAzWd.d.ts → attribute-redacting-processor-CvBE0z1p.d.ts} +33 -1
- package/dist/attribute-redacting-processor.cjs +34 -32
- package/dist/attribute-redacting-processor.d.cts +1 -1
- package/dist/attribute-redacting-processor.d.ts +1 -1
- package/dist/attribute-redacting-processor.js +35 -32
- package/dist/{attributes-aDmJYral.cjs → attributes-Cxys8tgr.cjs} +34 -35
- package/dist/{attributes-B7wix2VG.js → attributes-Dt4YUYbP.js} +34 -35
- package/dist/attributes.cjs +1 -1
- package/dist/attributes.d.cts +1 -1
- package/dist/attributes.d.ts +1 -1
- package/dist/attributes.js +1 -1
- package/dist/auto.cjs +1 -1
- package/dist/auto.js +1 -1
- package/dist/business-baggage.cjs +19 -12
- package/dist/business-baggage.d.cts +8 -3
- package/dist/business-baggage.d.ts +8 -3
- package/dist/business-baggage.js +19 -12
- package/dist/{canonical-log-line-processor-DxtBGZIi.cjs → canonical-log-line-processor-DolzdawH.cjs} +43 -32
- package/dist/{canonical-log-line-processor-B4WgG-VS.d.cts → canonical-log-line-processor-cPB4Axk-.d.ts} +4 -3
- package/dist/{canonical-log-line-processor-B0vq_QR6.js → canonical-log-line-processor-hFUmS__K.js} +43 -32
- package/dist/{canonical-log-line-processor-CL_J7gb5.d.ts → canonical-log-line-processor-l0Aqe6yp.d.cts} +4 -3
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{correlated-events-kSwLo3mi.cjs → correlated-events-CcuknWnU.cjs} +2 -1
- package/dist/{correlated-events-Bzh5y-UB.js → correlated-events-DwMMbItg.js} +3 -1
- package/dist/correlation-id.cjs +1 -1
- package/dist/correlation-id.js +1 -1
- package/dist/db.cjs +34 -19
- package/dist/db.js +34 -19
- package/dist/decorators.cjs +4 -2
- package/dist/decorators.d.cts +16 -11
- package/dist/decorators.d.ts +16 -11
- package/dist/decorators.js +4 -2
- package/dist/{define-event-CGG048HE.d.cts → define-event-BNeuKUPv.d.cts} +1 -1
- package/dist/{define-event-B2z1SBe7.d.ts → define-event-Bd8f8mST.d.ts} +1 -1
- package/dist/diagnostics.cjs +18 -16
- package/dist/diagnostics.d.cts +14 -10
- package/dist/diagnostics.d.ts +14 -10
- package/dist/diagnostics.js +18 -16
- package/dist/{event-subscriber-CWh8sTGh.d.cts → event-subscriber-DMACQA-1.d.cts} +19 -9
- package/dist/{event-subscriber-CWh8sTGh.d.ts → event-subscriber-DMACQA-1.d.ts} +19 -9
- package/dist/event-subscriber.d.cts +2 -2
- package/dist/event-subscriber.d.ts +2 -2
- package/dist/{event-testing-D0qWfqAy.d.cts → event-testing-CBtnJXE5.d.cts} +1 -1
- package/dist/{event-testing-CA2mIx1E.d.ts → event-testing-CkPgV3Ii.d.ts} +1 -1
- package/dist/event-testing.d.cts +1 -1
- package/dist/event-testing.d.ts +1 -1
- package/dist/event.cjs +1 -1
- package/dist/event.d.cts +5 -5
- package/dist/event.d.ts +5 -5
- package/dist/event.js +1 -1
- package/dist/exception-fingerprint.cjs +133 -0
- package/dist/exception-fingerprint.d.cts +51 -0
- package/dist/exception-fingerprint.d.ts +51 -0
- package/dist/exception-fingerprint.js +126 -0
- package/dist/{functional-e6jw5zQj.d.cts → functional-CJn2zY4o.d.cts} +96 -39
- package/dist/{functional-AT22vCw6.d.ts → functional-DXy1cHFF.d.ts} +96 -39
- package/dist/{functional-C0uAZq2X.cjs → functional-Da6Yv64r.cjs} +27 -15
- package/dist/{functional-DX7Zvag0.js → functional-uSbNnnxK.js} +27 -15
- package/dist/functional.cjs +1 -1
- package/dist/functional.d.cts +2 -2
- package/dist/functional.d.ts +2 -2
- package/dist/functional.js +1 -1
- package/dist/http.cjs +11 -8
- package/dist/http.js +11 -8
- package/dist/{index-DolOVX6F.d.ts → index-CwrNAsgk.d.ts} +22 -26
- package/dist/{index-BPcxVucm.d.cts → index-DQHf4cNl.d.cts} +22 -26
- package/dist/index.cjs +41 -35
- package/dist/index.d.cts +45 -30
- package/dist/index.d.ts +45 -30
- package/dist/index.js +41 -35
- package/dist/{init-pPI3JRRf.d.ts → init-BgnYi2sm.d.ts} +6 -6
- package/dist/{init-CTtHITlX.cjs → init-D4m5rCmD.cjs} +110 -84
- package/dist/{init-ncTMKZ-s.d.cts → init-DrlL1eis.d.cts} +6 -6
- package/dist/{init-WHYwyItd.js → init-JtX-KKz_.js} +105 -85
- package/dist/instrumentation.cjs +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{logger-D3Ej3DII.js → logger-DdPp__xW.js} +63 -54
- package/dist/{logger-CN4xpzMd.d.cts → logger-S1Fgl0g3.d.cts} +0 -20
- package/dist/{logger-CN4xpzMd.d.ts → logger-S1Fgl0g3.d.ts} +0 -20
- package/dist/{logger-thMPLpOG.cjs → logger-Sm66cjKl.cjs} +63 -54
- package/dist/logger.cjs +1 -1
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +1 -1
- package/dist/messaging-adapters.cjs +26 -12
- package/dist/messaging-adapters.d.cts +0 -30
- package/dist/messaging-adapters.d.ts +0 -30
- package/dist/messaging-adapters.js +26 -12
- package/dist/messaging.cjs +37 -34
- package/dist/messaging.d.cts +21 -62
- package/dist/messaging.d.ts +21 -62
- package/dist/messaging.js +37 -34
- package/dist/{metric-testing-CpvP3ZIa.d.cts → metric-testing-86WO1wan.d.cts} +1 -1
- package/dist/{metric-testing-CWm6UhaR.d.ts → metric-testing-CbCxdPBp.d.ts} +1 -1
- package/dist/metric-testing.d.cts +1 -1
- package/dist/metric-testing.d.ts +1 -1
- package/dist/metric.d.cts +3 -3
- package/dist/metric.d.ts +3 -3
- package/dist/{node-require-vROmTeJ8.js → node-require-DSPjaw_l.js} +3 -2
- package/dist/{node-require-PFqDihze.cjs → node-require-EifOMikz.cjs} +3 -2
- package/dist/parse-error.cjs +18 -12
- package/dist/parse-error.d.cts +2 -1
- package/dist/parse-error.d.ts +2 -1
- package/dist/parse-error.js +19 -12
- package/dist/policy.cjs +0 -0
- package/dist/policy.js +0 -0
- package/dist/processors.cjs +1 -1
- package/dist/processors.d.cts +1 -1
- package/dist/processors.d.ts +1 -1
- package/dist/processors.js +1 -1
- package/dist/{sampling-BR9fkSwx.d.cts → sampling-CM5S2Lp3.d.ts} +5 -6
- package/dist/{sampling-CP3e7-Yr.d.ts → sampling-CmRdnXUi.d.cts} +5 -6
- package/dist/sampling.cjs +3 -2
- package/dist/sampling.d.cts +1 -1
- package/dist/sampling.d.ts +1 -1
- package/dist/sampling.js +3 -2
- package/dist/semantic-helpers.cjs +9 -9
- package/dist/semantic-helpers.d.cts +1 -1
- package/dist/semantic-helpers.d.ts +1 -1
- package/dist/semantic-helpers.js +9 -9
- package/dist/{stable-hash-ChFBIhNt.js → stable-hash-BkoAYVks.js} +4 -3
- package/dist/{stable-hash-CS9BxvVQ.cjs → stable-hash-C0pOegH_.cjs} +4 -3
- package/dist/{structured-error-CHg7DoIQ.cjs → structured-error--_wXpd_C.cjs} +34 -25
- package/dist/{structured-error-9--cxBay.js → structured-error-YIuka-FE.js} +34 -25
- package/dist/test-span-collector.cjs +15 -8
- package/dist/test-span-collector.js +15 -8
- package/dist/testing.cjs +16 -18
- package/dist/testing.d.cts +7 -6
- package/dist/testing.d.ts +7 -6
- package/dist/testing.js +16 -18
- package/dist/{trace-context-IuyoPyNq.d.cts → trace-context-C1Cn1q0y.d.cts} +8 -7
- package/dist/{trace-context-IuyoPyNq.d.ts → trace-context-f89xPJbK.d.ts} +8 -7
- package/dist/trace-helpers.cjs +16 -13
- package/dist/trace-helpers.d.cts +9 -4
- package/dist/trace-helpers.d.ts +9 -4
- package/dist/trace-helpers.js +16 -13
- package/dist/tracer-provider.cjs +8 -12
- package/dist/tracer-provider.js +8 -12
- package/dist/validate.cjs +22 -20
- package/dist/validate.d.cts +3 -2
- package/dist/validate.d.ts +3 -2
- package/dist/validate.js +22 -20
- package/dist/values-BenyvWKz.js +141 -0
- package/dist/values-CeMH-mYG.d.cts +8 -0
- package/dist/values-CeMH-mYG.d.ts +8 -0
- package/dist/values-DApyq53y.cjs +267 -0
- package/dist/webhook.cjs +3 -3
- package/dist/webhook.d.cts +1 -1
- package/dist/webhook.d.ts +1 -1
- package/dist/webhook.js +3 -3
- package/dist/workflow-distributed.cjs +9 -7
- package/dist/workflow-distributed.d.cts +9 -8
- package/dist/workflow-distributed.d.ts +9 -8
- package/dist/workflow-distributed.js +9 -7
- package/dist/workflow.cjs +26 -17
- package/dist/workflow.d.cts +1 -28
- package/dist/workflow.d.ts +1 -28
- package/dist/workflow.js +26 -17
- package/dist/yaml-config.cjs +26 -11
- package/dist/yaml-config.d.cts +9 -3
- package/dist/yaml-config.d.ts +9 -3
- package/dist/yaml-config.js +26 -11
- package/package.json +6 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { _ as readProperty, f as describeValue, h as isFunction, i as asNumber, l as asString, r as asFunction, s as asRecord, t as asBoolean } from "./values-BenyvWKz.js";
|
|
1
2
|
import { getForceFlushableProvider } from "./tracer-provider.js";
|
|
2
3
|
import { getConfig as getConfig$1 } from "./config.js";
|
|
3
4
|
import { AUTOTEL_SAMPLING_RATE, resolveSamplingPreset, samplingPresets } from "./sampling.js";
|
|
4
|
-
import { n as safeRequire, t as requireModule } from "./node-require-
|
|
5
|
+
import { n as safeRequire, t as requireModule } from "./node-require-DSPjaw_l.js";
|
|
5
6
|
import { TailSamplingSpanProcessor } from "./tail-sampling-processor.js";
|
|
6
7
|
import { FilteringSpanProcessor } from "./filtering-span-processor.js";
|
|
7
8
|
import { PolicyLogRecordProcessor, policySpanFilter, setPolicies, watchPolicyFile } from "./policy.js";
|
|
@@ -9,8 +10,8 @@ import { SpanNameNormalizingProcessor } from "./span-name-normalizer.js";
|
|
|
9
10
|
import { AttributeRedactingProcessor, REDACTOR_PRESETS, normalizeAttributeRedactorConfig } from "./attribute-redacting-processor.js";
|
|
10
11
|
import { t as PrettyConsoleExporter } from "./pretty-console-exporter-DqKl_q9z.js";
|
|
11
12
|
import { loadYamlConfig } from "./yaml-config.js";
|
|
12
|
-
import { t as CanonicalLogLineProcessor } from "./canonical-log-line-processor-
|
|
13
|
-
import { r as recordStructuredError } from "./structured-error-
|
|
13
|
+
import { t as CanonicalLogLineProcessor } from "./canonical-log-line-processor-hFUmS__K.js";
|
|
14
|
+
import { r as recordStructuredError } from "./structured-error-YIuka-FE.js";
|
|
14
15
|
import { resetMetrics } from "./metric.js";
|
|
15
16
|
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
16
17
|
import { AlwaysOffSampler, AlwaysOnSampler, BatchSpanProcessor, ConsoleSpanExporter, ParentBasedSampler, SamplingDecision, SimpleSpanProcessor, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
|
|
@@ -65,10 +66,15 @@ var RedactingLogRecordProcessor = class {
|
|
|
65
66
|
this.redact = redact;
|
|
66
67
|
}
|
|
67
68
|
onEmit(logRecord, context) {
|
|
68
|
-
|
|
69
|
-
if (logRecord.
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const body = asString(logRecord.body);
|
|
70
|
+
if (body) logRecord.body = this.redact(body);
|
|
71
|
+
if (logRecord.attributes) for (const [key, value] of Object.entries(logRecord.attributes)) {
|
|
72
|
+
const text = asString(value);
|
|
73
|
+
if (text !== void 0) logRecord.attributes[key] = this.redact(text);
|
|
74
|
+
else if (Array.isArray(value)) logRecord.attributes[key] = value.map((item) => {
|
|
75
|
+
const entry = asString(item);
|
|
76
|
+
return entry === void 0 ? item : this.redact(entry);
|
|
77
|
+
});
|
|
72
78
|
}
|
|
73
79
|
this.wrapped.onEmit(logRecord, context);
|
|
74
80
|
}
|
|
@@ -564,6 +570,11 @@ var TokenBucketRateLimiter = class {
|
|
|
564
570
|
|
|
565
571
|
//#endregion
|
|
566
572
|
//#region src/trace-context.ts
|
|
573
|
+
const spansWithExplicitStatus = /* @__PURE__ */ new WeakSet();
|
|
574
|
+
/** Whether a TraceContext consumer explicitly chose this span's status. */
|
|
575
|
+
function hasExplicitSpanStatus(span) {
|
|
576
|
+
return spansWithExplicitStatus.has(span);
|
|
577
|
+
}
|
|
567
578
|
/**
|
|
568
579
|
* AsyncLocalStorage for storing the active context with baggage
|
|
569
580
|
* This allows setters to update the context and have it persist
|
|
@@ -617,7 +628,7 @@ function updateActiveContext(newContext) {
|
|
|
617
628
|
asyncLocal.enterWith(newContext);
|
|
618
629
|
return;
|
|
619
630
|
}
|
|
620
|
-
if (
|
|
631
|
+
if (isFunction(manager.with)) manager.with(newContext, () => {});
|
|
621
632
|
}
|
|
622
633
|
/**
|
|
623
634
|
* Create a TraceContext from an OpenTelemetry Span
|
|
@@ -640,15 +651,18 @@ function createTraceContext(span) {
|
|
|
640
651
|
correlationId: spanContext.traceId.slice(0, 16),
|
|
641
652
|
setAttribute: span.setAttribute.bind(span),
|
|
642
653
|
setAttributes: span.setAttributes.bind(span),
|
|
643
|
-
setStatus:
|
|
654
|
+
setStatus: (status) => {
|
|
655
|
+
spansWithExplicitStatus.add(span);
|
|
656
|
+
span.setStatus(status);
|
|
657
|
+
},
|
|
644
658
|
recordException: span.recordException.bind(span),
|
|
645
659
|
addEvent: span.addEvent.bind(span),
|
|
646
660
|
addLink: span.addLink.bind(span),
|
|
647
661
|
addLinks: span.addLinks.bind(span),
|
|
648
662
|
updateName: span.updateName.bind(span),
|
|
649
663
|
isRecording: span.isRecording.bind(span),
|
|
650
|
-
recordError: (
|
|
651
|
-
const err =
|
|
664
|
+
recordError: (cause) => {
|
|
665
|
+
const err = cause instanceof Error ? cause : new Error(String(cause));
|
|
652
666
|
recordStructuredError(traceCtx, err);
|
|
653
667
|
},
|
|
654
668
|
track: (event, data) => {
|
|
@@ -698,12 +712,11 @@ function createTraceContext(span) {
|
|
|
698
712
|
}
|
|
699
713
|
if (!baggage) return;
|
|
700
714
|
const prefix = namespace ? `${namespace}.` : "";
|
|
701
|
-
const
|
|
702
|
-
for (const [key, entry] of baggage.getAllEntries()) if (namespace && key.startsWith(prefix))
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
return Object.keys(result).length > 0 ? result : void 0;
|
|
715
|
+
const entries = [];
|
|
716
|
+
for (const [key, entry] of baggage.getAllEntries()) if (namespace && key.startsWith(prefix)) entries.push([key.slice(prefix.length), entry.value]);
|
|
717
|
+
else if (!namespace) entries.push([key, entry.value]);
|
|
718
|
+
const result = Object.fromEntries(entries);
|
|
719
|
+
return entries.length > 0 ? result : void 0;
|
|
707
720
|
}),
|
|
708
721
|
setTypedBaggage: ((namespace, value) => {
|
|
709
722
|
const currentContext = getActiveContextWithBaggage();
|
|
@@ -1409,7 +1422,7 @@ var ValidationError = class extends Error {
|
|
|
1409
1422
|
* Throws ValidationError if invalid
|
|
1410
1423
|
*/
|
|
1411
1424
|
function validateEventName(eventName, config = DEFAULT_CONFIG$1) {
|
|
1412
|
-
if (
|
|
1425
|
+
if (asString(eventName) === void 0) throw new ValidationError(`Event name must be a string, got ${describeValue(eventName)}`);
|
|
1413
1426
|
const trimmed = eventName.trim();
|
|
1414
1427
|
if (trimmed.length === 0) throw new ValidationError("Event name cannot be empty");
|
|
1415
1428
|
if (trimmed.length > config.maxEventNameLength) throw new ValidationError(`Event name too long (${trimmed.length} chars). Max: ${config.maxEventNameLength}`);
|
|
@@ -1422,14 +1435,14 @@ function validateEventName(eventName, config = DEFAULT_CONFIG$1) {
|
|
|
1422
1435
|
*/
|
|
1423
1436
|
function validateAttributes(attributes, config = DEFAULT_CONFIG$1) {
|
|
1424
1437
|
if (attributes === void 0 || attributes === null) return;
|
|
1425
|
-
if (
|
|
1438
|
+
if (!asRecord(attributes)) throw new ValidationError("Attributes must be an object");
|
|
1426
1439
|
const keys = Object.keys(attributes);
|
|
1427
1440
|
if (keys.length > config.maxAttributeCount) throw new ValidationError(`Too many attributes (${keys.length}). Max: ${config.maxAttributeCount}`);
|
|
1428
1441
|
const sanitized = {};
|
|
1429
1442
|
for (const key of keys) {
|
|
1430
1443
|
if (key.length > config.maxAttributeKeyLength) throw new ValidationError(`Attribute key too long: "${key.slice(0, 20)}..." (${key.length} chars). Max: ${config.maxAttributeKeyLength}`);
|
|
1431
1444
|
const value = attributes[key];
|
|
1432
|
-
if (
|
|
1445
|
+
if (isSensitiveString(key, value, config)) {
|
|
1433
1446
|
sanitized[key] = "[REDACTED]";
|
|
1434
1447
|
continue;
|
|
1435
1448
|
}
|
|
@@ -1438,29 +1451,35 @@ function validateAttributes(attributes, config = DEFAULT_CONFIG$1) {
|
|
|
1438
1451
|
return sanitized;
|
|
1439
1452
|
}
|
|
1440
1453
|
/**
|
|
1454
|
+
* Whether this key/value pair is a credential to redact. Strings only:
|
|
1455
|
+
* numeric and boolean values are not credentials, and replacing them with the
|
|
1456
|
+
* literal '[REDACTED]' leaks no signal while breaking every consumer that
|
|
1457
|
+
* treats them as a number.
|
|
1458
|
+
*/
|
|
1459
|
+
function isSensitiveString(key, value, config) {
|
|
1460
|
+
return asString(value) !== void 0 && config.sensitivePatterns.some((pattern) => pattern.test(key));
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1441
1463
|
* Sanitize attribute value (recursive)
|
|
1442
1464
|
*/
|
|
1443
1465
|
function sanitizeValue(value, config, depth) {
|
|
1444
1466
|
if (depth > config.maxNestingDepth) return "[MAX_DEPTH_EXCEEDED]";
|
|
1445
1467
|
if (value === null || value === void 0) return value;
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
1468
|
+
const text = asString(value);
|
|
1469
|
+
if (text !== void 0) return text.length > config.maxAttributeValueLength ? text.slice(0, config.maxAttributeValueLength) + "..." : text;
|
|
1470
|
+
const scalar = asNumber(value) ?? asBoolean(value);
|
|
1471
|
+
if (scalar !== void 0) return scalar;
|
|
1451
1472
|
if (Array.isArray(value)) return value.map((item) => sanitizeValue(item, config, depth + 1));
|
|
1452
|
-
|
|
1453
|
-
|
|
1473
|
+
const record = asRecord(value);
|
|
1474
|
+
if (record) try {
|
|
1475
|
+
JSON.stringify(record);
|
|
1454
1476
|
const sanitized = {};
|
|
1455
|
-
for (const key
|
|
1456
|
-
const nested = value[key];
|
|
1457
|
-
sanitized[key] = typeof nested === "string" && config.sensitivePatterns.some((pattern) => pattern.test(key)) ? "[REDACTED]" : sanitizeValue(nested, config, depth + 1);
|
|
1458
|
-
}
|
|
1477
|
+
for (const [key, nested] of Object.entries(record)) sanitized[key] = isSensitiveString(key, nested, config) ? "[REDACTED]" : sanitizeValue(nested, config, depth + 1);
|
|
1459
1478
|
return sanitized;
|
|
1460
1479
|
} catch {
|
|
1461
1480
|
return "[CIRCULAR]";
|
|
1462
1481
|
}
|
|
1463
|
-
return `[${
|
|
1482
|
+
return `[${describeValue(value)}]`;
|
|
1464
1483
|
}
|
|
1465
1484
|
/**
|
|
1466
1485
|
* Validate and sanitize an events event
|
|
@@ -1821,7 +1840,7 @@ function hashValue(value) {
|
|
|
1821
1840
|
* @example Recommended: Configure subscribers in init(), use track() function
|
|
1822
1841
|
* ```typescript
|
|
1823
1842
|
* import { init, track } from 'autotel';
|
|
1824
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1843
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1825
1844
|
*
|
|
1826
1845
|
* init({
|
|
1827
1846
|
* service: 'my-app',
|
|
@@ -1844,7 +1863,7 @@ function hashValue(value) {
|
|
|
1844
1863
|
* @example Override subscribers for specific Event instance
|
|
1845
1864
|
* ```typescript
|
|
1846
1865
|
* import { Event } from 'autotel/event';
|
|
1847
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1866
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1848
1867
|
*
|
|
1849
1868
|
* // Override: use different subscribers for this instance
|
|
1850
1869
|
* const event = new Event('job-application', {
|
|
@@ -1877,7 +1896,7 @@ var Event = class {
|
|
|
1877
1896
|
* @example Recommended: Use track() with init()
|
|
1878
1897
|
* ```typescript
|
|
1879
1898
|
* import { init, track } from 'autotel';
|
|
1880
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1899
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1881
1900
|
*
|
|
1882
1901
|
* init({
|
|
1883
1902
|
* service: 'checkout',
|
|
@@ -1897,7 +1916,7 @@ var Event = class {
|
|
|
1897
1916
|
* @example Override subscribers for this instance
|
|
1898
1917
|
* ```typescript
|
|
1899
1918
|
* import { Event } from 'autotel/event';
|
|
1900
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1919
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1901
1920
|
*
|
|
1902
1921
|
* // Override: use different subscribers for this instance only
|
|
1903
1922
|
* const event = new Event('checkout', {
|
|
@@ -1975,7 +1994,7 @@ var Event = class {
|
|
|
1975
1994
|
if (traceState) {
|
|
1976
1995
|
let traceStateStr = "";
|
|
1977
1996
|
try {
|
|
1978
|
-
if (
|
|
1997
|
+
if (isFunction(traceState.serialize)) traceStateStr = traceState.serialize();
|
|
1979
1998
|
} catch {}
|
|
1980
1999
|
if (traceStateStr) autotelContext.trace_state = traceStateStr;
|
|
1981
2000
|
}
|
|
@@ -2024,9 +2043,8 @@ var Event = class {
|
|
|
2024
2043
|
const transform = enrichConfig.transform?.[key];
|
|
2025
2044
|
let transformedValue;
|
|
2026
2045
|
if (transform === "hash") transformedValue = hashValue(value);
|
|
2027
|
-
else if (transform ===
|
|
2028
|
-
else
|
|
2029
|
-
else transformedValue = value;
|
|
2046
|
+
else if (transform === void 0 || transform === "plain") transformedValue = value;
|
|
2047
|
+
else transformedValue = transform(value);
|
|
2030
2048
|
const valueBytes = new TextEncoder().encode(transformedValue).length;
|
|
2031
2049
|
if (byteCount + valueBytes > maxBytes) continue;
|
|
2032
2050
|
const enrichedKey = `${prefix}${key}`;
|
|
@@ -2349,14 +2367,16 @@ var Event = class {
|
|
|
2349
2367
|
stepNumber,
|
|
2350
2368
|
attributes: enrichedAttributes
|
|
2351
2369
|
}, "Funnel progression tracked");
|
|
2370
|
+
const stepAttributes = {
|
|
2371
|
+
...enrichedAttributes,
|
|
2372
|
+
step_name: stepName
|
|
2373
|
+
};
|
|
2374
|
+
if (stepNumber !== void 0) stepAttributes.step_number = stepNumber;
|
|
2375
|
+
const stepAsStatus = stepName;
|
|
2352
2376
|
this.collector?.recordFunnelStep({
|
|
2353
2377
|
funnel: funnelName,
|
|
2354
|
-
status:
|
|
2355
|
-
attributes:
|
|
2356
|
-
...enrichedAttributes,
|
|
2357
|
-
step_name: stepName,
|
|
2358
|
-
...stepNumber === void 0 ? {} : { step_number: stepNumber }
|
|
2359
|
-
},
|
|
2378
|
+
status: stepAsStatus,
|
|
2379
|
+
attributes: stepAttributes,
|
|
2360
2380
|
service: this.serviceName,
|
|
2361
2381
|
timestamp: Date.now()
|
|
2362
2382
|
});
|
|
@@ -2364,10 +2384,9 @@ var Event = class {
|
|
|
2364
2384
|
const autotelContext = this.buildAutotelContext();
|
|
2365
2385
|
const finalAttributes = this.enrichFromBaggage(enrichedAttributes);
|
|
2366
2386
|
this.notifySubscribers(async (subscriber) => {
|
|
2367
|
-
await (subscriber.trackFunnelProgression ? subscriber.trackFunnelProgression(funnelName, stepName, stepNumber, finalAttributes, { autotel: autotelContext }) : subscriber.trackFunnelStep(funnelName,
|
|
2387
|
+
await (subscriber.trackFunnelProgression ? subscriber.trackFunnelProgression(funnelName, stepName, stepNumber, finalAttributes, { autotel: autotelContext }) : subscriber.trackFunnelStep(funnelName, stepAsStatus, {
|
|
2368
2388
|
...finalAttributes,
|
|
2369
|
-
|
|
2370
|
-
...stepNumber === void 0 ? {} : { step_number: stepNumber }
|
|
2389
|
+
...stepAttributes
|
|
2371
2390
|
}, { autotel: autotelContext }));
|
|
2372
2391
|
});
|
|
2373
2392
|
}
|
|
@@ -2391,11 +2410,17 @@ var Event = class {
|
|
|
2391
2410
|
*/
|
|
2392
2411
|
trackBatch(events) {
|
|
2393
2412
|
for (const event of events) {
|
|
2394
|
-
const filteredAttributes = event.attributes ?
|
|
2413
|
+
const filteredAttributes = event.attributes ? definedAttributes(event.attributes) : void 0;
|
|
2395
2414
|
this.trackEvent(event.name, filteredAttributes);
|
|
2396
2415
|
}
|
|
2397
2416
|
}
|
|
2398
2417
|
};
|
|
2418
|
+
/** The attributes with the entries that carry nothing left out. */
|
|
2419
|
+
function definedAttributes(input) {
|
|
2420
|
+
const defined = {};
|
|
2421
|
+
for (const [key, value] of Object.entries(input)) if (value !== void 0 && value !== null) defined[key] = value;
|
|
2422
|
+
return defined;
|
|
2423
|
+
}
|
|
2399
2424
|
/**
|
|
2400
2425
|
* Global events instances (singleton pattern)
|
|
2401
2426
|
*/
|
|
@@ -2441,24 +2466,21 @@ const UNREACHABLE_ENDPOINT_CODES = /* @__PURE__ */ new Set([
|
|
|
2441
2466
|
"ENOTFOUND",
|
|
2442
2467
|
"EAI_AGAIN"
|
|
2443
2468
|
]);
|
|
2444
|
-
function errorCode(
|
|
2445
|
-
|
|
2446
|
-
const code = error.code;
|
|
2447
|
-
if (typeof code === "string") return code;
|
|
2448
|
-
}
|
|
2469
|
+
function errorCode(cause) {
|
|
2470
|
+
return asString(readProperty(cause, "code"));
|
|
2449
2471
|
}
|
|
2450
2472
|
/**
|
|
2451
2473
|
* True when the error (or every error it wraps) is an unreachable-endpoint
|
|
2452
2474
|
* failure. Traverses `AggregateError.errors` and the `cause` chain, since the
|
|
2453
2475
|
* SDK often wraps the underlying network error.
|
|
2454
2476
|
*/
|
|
2455
|
-
function isUnreachableEndpointError(
|
|
2456
|
-
if (depth > 5 ||
|
|
2457
|
-
if (
|
|
2458
|
-
const code = errorCode(
|
|
2477
|
+
function isUnreachableEndpointError(cause, depth = 0) {
|
|
2478
|
+
if (depth > 5 || asRecord(cause) === void 0) return false;
|
|
2479
|
+
if (cause instanceof AggregateError) return cause.errors.length > 0 && cause.errors.every((e) => isUnreachableEndpointError(e, depth + 1));
|
|
2480
|
+
const code = errorCode(cause);
|
|
2459
2481
|
if (code && UNREACHABLE_ENDPOINT_CODES.has(code)) return true;
|
|
2460
|
-
const
|
|
2461
|
-
return
|
|
2482
|
+
const wrapped = readProperty(cause, "cause");
|
|
2483
|
+
return wrapped !== void 0 && wrapped !== cause ? isUnreachableEndpointError(wrapped, depth + 1) : false;
|
|
2462
2484
|
}
|
|
2463
2485
|
/**
|
|
2464
2486
|
* Flush all pending telemetry
|
|
@@ -2559,7 +2581,7 @@ async function shutdown() {
|
|
|
2559
2581
|
uninstallProcessHandlers();
|
|
2560
2582
|
await _closeEmbeddedDevtools();
|
|
2561
2583
|
const eventsQueue = getEventQueue();
|
|
2562
|
-
if (eventsQueue
|
|
2584
|
+
if (isFunction(eventsQueue?.cleanup)) eventsQueue.cleanup();
|
|
2563
2585
|
resetEvents();
|
|
2564
2586
|
resetMetrics();
|
|
2565
2587
|
resetEventQueue();
|
|
@@ -2839,14 +2861,17 @@ function detectHostname() {
|
|
|
2839
2861
|
function getInstrumentationNames(instrumentations) {
|
|
2840
2862
|
const names = /* @__PURE__ */ new Set();
|
|
2841
2863
|
if (!instrumentations) return names;
|
|
2842
|
-
for (const instrumentation of instrumentations)
|
|
2864
|
+
for (const instrumentation of instrumentations) {
|
|
2865
|
+
const className = asFunction(readProperty(instrumentation, "constructor"))?.name;
|
|
2866
|
+
if (className) names.add(className);
|
|
2867
|
+
}
|
|
2843
2868
|
return names;
|
|
2844
2869
|
}
|
|
2845
2870
|
/**
|
|
2846
2871
|
* Map common instrumentation class names to their package names
|
|
2847
2872
|
* Used to disable auto-instrumentations when user provides manual configs
|
|
2848
2873
|
*/
|
|
2849
|
-
const INSTRUMENTATION_CLASS_TO_PACKAGE = {
|
|
2874
|
+
const INSTRUMENTATION_CLASS_TO_PACKAGE = new Map(Object.entries({
|
|
2850
2875
|
HttpInstrumentation: "@opentelemetry/instrumentation-http",
|
|
2851
2876
|
HttpsInstrumentation: "@opentelemetry/instrumentation-http",
|
|
2852
2877
|
ExpressInstrumentation: "@opentelemetry/instrumentation-express",
|
|
@@ -2865,7 +2890,7 @@ const INSTRUMENTATION_CLASS_TO_PACKAGE = {
|
|
|
2865
2890
|
PgInstrumentation: "@opentelemetry/instrumentation-pg",
|
|
2866
2891
|
MySQLInstrumentation: "@opentelemetry/instrumentation-mysql",
|
|
2867
2892
|
MySQL2Instrumentation: "@opentelemetry/instrumentation-mysql2"
|
|
2868
|
-
};
|
|
2893
|
+
}));
|
|
2869
2894
|
/**
|
|
2870
2895
|
* Detect if we're running in ESM mode
|
|
2871
2896
|
*/
|
|
@@ -2918,7 +2943,7 @@ function getAutoInstrumentations(integrations, manualInstrumentationNames = /* @
|
|
|
2918
2943
|
const getNodeAutoInstrumentations = _autoInstrumentationsLoader ? _autoInstrumentationsLoader() : loadNodeAutoInstrumentations();
|
|
2919
2944
|
const exclusionConfig = {};
|
|
2920
2945
|
for (const className of manualInstrumentationNames) {
|
|
2921
|
-
const packageName = INSTRUMENTATION_CLASS_TO_PACKAGE
|
|
2946
|
+
const packageName = INSTRUMENTATION_CLASS_TO_PACKAGE.get(className);
|
|
2922
2947
|
if (packageName) exclusionConfig[packageName] = { enabled: false };
|
|
2923
2948
|
}
|
|
2924
2949
|
if (integrations === true) {
|
|
@@ -2962,10 +2987,9 @@ function toOtelSampler(sampler) {
|
|
|
2962
2987
|
};
|
|
2963
2988
|
const shouldTrace = sampler.shouldSample(samplingContext);
|
|
2964
2989
|
const rate = sampler.sampleRate?.(samplingContext);
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
};
|
|
2990
|
+
const result = { decision: shouldTrace ? SamplingDecision.RECORD_AND_SAMPLED : SamplingDecision.NOT_RECORD };
|
|
2991
|
+
if (shouldTrace && rate !== void 0 && rate > 1) result.attributes = { [AUTOTEL_SAMPLING_RATE]: rate };
|
|
2992
|
+
return result;
|
|
2969
2993
|
},
|
|
2970
2994
|
toString() {
|
|
2971
2995
|
return `AutotelSamplerAdapter`;
|
|
@@ -2982,7 +3006,7 @@ let validationConfig = null;
|
|
|
2982
3006
|
let eventsConfig = null;
|
|
2983
3007
|
let _stringRedactor = null;
|
|
2984
3008
|
function acceptsStringRedactor(subscriber) {
|
|
2985
|
-
return
|
|
3009
|
+
return isFunction(readProperty(subscriber, "setStringRedactor")) ? subscriber : void 0;
|
|
2986
3010
|
}
|
|
2987
3011
|
let _optionalRequire = safeRequire;
|
|
2988
3012
|
let _devtoolsClose = null;
|
|
@@ -3013,7 +3037,7 @@ function isLoggerLocked() {
|
|
|
3013
3037
|
*
|
|
3014
3038
|
* @example With events (observe in PostHog, Mixpanel, etc.)
|
|
3015
3039
|
* ```typescript
|
|
3016
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
3040
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
3017
3041
|
*
|
|
3018
3042
|
* init({
|
|
3019
3043
|
* service: 'my-app',
|
|
@@ -3167,9 +3191,7 @@ function init(cfg) {
|
|
|
3167
3191
|
spanProcessors = spanProcessors.map((processor) => new AttributeRedactingProcessor(processor, { redactor }));
|
|
3168
3192
|
}
|
|
3169
3193
|
if (mergedConfig.attributeRedactor) _stringRedactor = createStringRedactor(mergedConfig.attributeRedactor);
|
|
3170
|
-
if (_stringRedactor && mergedConfig.subscribers)
|
|
3171
|
-
for (const subscriber of mergedConfig.subscribers) if (acceptsStringRedactor(subscriber)) subscriber.setStringRedactor(_stringRedactor);
|
|
3172
|
-
}
|
|
3194
|
+
if (_stringRedactor && mergedConfig.subscribers) for (const subscriber of mergedConfig.subscribers) acceptsStringRedactor(subscriber)?.setStringRedactor(_stringRedactor);
|
|
3173
3195
|
if (mergedConfig.spanNameNormalizer && spanProcessors.length > 0) spanProcessors = spanProcessors.map((processor) => new SpanNameNormalizingProcessor(processor, { normalizer: mergedConfig.spanNameNormalizer }));
|
|
3174
3196
|
if (mergedConfig.policies) {
|
|
3175
3197
|
if (typeof mergedConfig.policies === "string") watchPolicyFile(mergedConfig.policies);
|
|
@@ -3189,11 +3211,10 @@ function init(cfg) {
|
|
|
3189
3211
|
});
|
|
3190
3212
|
const exportIntervalMillis = readMillisEnv("OTEL_METRIC_EXPORT_INTERVAL");
|
|
3191
3213
|
const exportTimeoutMillis = readMillisEnv("OTEL_METRIC_EXPORT_TIMEOUT");
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
}));
|
|
3214
|
+
const readerOptions = { exporter: metricExporter };
|
|
3215
|
+
if (exportIntervalMillis !== void 0) readerOptions.exportIntervalMillis = exportIntervalMillis;
|
|
3216
|
+
if (exportTimeoutMillis !== void 0) readerOptions.exportTimeoutMillis = exportTimeoutMillis;
|
|
3217
|
+
metricReaders.push(new PeriodicExportingMetricReader(readerOptions));
|
|
3197
3218
|
}
|
|
3198
3219
|
let logRecordProcessors;
|
|
3199
3220
|
if (configuredLogRecordProcessors && configuredLogRecordProcessors.length > 0) logRecordProcessors = [...configuredLogRecordProcessors];
|
|
@@ -3251,11 +3272,10 @@ function init(cfg) {
|
|
|
3251
3272
|
const traceloop = _optionalRequire("@traceloop/node-server-sdk");
|
|
3252
3273
|
if (traceloop) {
|
|
3253
3274
|
const initOptions = { ...mergedConfig.openllmetry.options };
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
} catch {}
|
|
3275
|
+
const getTracerProvider = asFunction(readProperty(sdk, "getTracerProvider"));
|
|
3276
|
+
if (getTracerProvider) initOptions.tracerProvider = getTracerProvider.call(sdk);
|
|
3257
3277
|
if (configuredSpanExporters?.[0]) initOptions.exporter = configuredSpanExporters[0];
|
|
3258
|
-
if (
|
|
3278
|
+
if (isFunction(traceloop.initialize)) {
|
|
3259
3279
|
traceloop.initialize(initOptions);
|
|
3260
3280
|
logger.info({}, "[autotel] OpenLLMetry initialized successfully");
|
|
3261
3281
|
} else logger.warn({}, "[autotel] OpenLLMetry initialize function not found. Check @traceloop/node-server-sdk version.");
|
|
@@ -3330,4 +3350,4 @@ function getSdk() {
|
|
|
3330
3350
|
}
|
|
3331
3351
|
|
|
3332
3352
|
//#endregion
|
|
3333
|
-
export {
|
|
3353
|
+
export { createStringRedactor as A, setCorrelationId as C, getActiveContextWithBaggage as D, defineBaggageSchema as E, getContextStorage as O, runWithCorrelationId as S, createTraceContext as T, CORRELATION_ID_BAGGAGE_KEY as _, isInitialized as a, getCorrelationStorage as b, flush as c, getEvents as d, resetEvents as f, track as g, getEventQueue as h, init as i, BaggageSpanProcessor as j, hasExplicitSpanStatus as k, shutdown as l, runInOperationContext as m, getLogger as n, isLoggerLocked as o, getOperationContext as p, getSdk as r, lockLogger as s, getConfig as t, Event as u, generateCorrelationId as v, setCorrelationIdInBaggage as w, getOrCreateCorrelationId as x, getCorrelationId as y };
|
package/dist/instrumentation.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_init = require('./init-
|
|
3
|
-
const require_node_require = require('./node-require-
|
|
2
|
+
const require_init = require('./init-D4m5rCmD.cjs');
|
|
3
|
+
const require_node_require = require('./node-require-EifOMikz.cjs');
|
|
4
4
|
const require_tail_sampling_processor = require('./tail-sampling-processor.cjs');
|
|
5
5
|
let _opentelemetry_sdk_node = require("@opentelemetry/sdk-node");
|
|
6
6
|
let _opentelemetry_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
package/dist/instrumentation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as getLogger } from "./init-
|
|
2
|
-
import { n as safeRequire, t as requireModule } from "./node-require-
|
|
1
|
+
import { n as getLogger } from "./init-JtX-KKz_.js";
|
|
2
|
+
import { n as safeRequire, t as requireModule } from "./node-require-DSPjaw_l.js";
|
|
3
3
|
import { TailSamplingSpanProcessor } from "./tail-sampling-processor.js";
|
|
4
4
|
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
5
5
|
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { l as asString, s as asRecord } from "./values-BenyvWKz.js";
|
|
1
2
|
import { getConfig } from "./config.js";
|
|
2
3
|
import { SpanStatusCode, context, createContextKey, trace } from "@opentelemetry/api";
|
|
3
4
|
|
|
@@ -121,20 +122,47 @@ function getTraceContext() {
|
|
|
121
122
|
* });
|
|
122
123
|
* ```
|
|
123
124
|
*/
|
|
125
|
+
/**
|
|
126
|
+
* The fields a log line carries for its error, following Pino's `err`
|
|
127
|
+
* convention: an Error is spread into message/stack/name, anything else is
|
|
128
|
+
* kept as it was given.
|
|
129
|
+
*/
|
|
130
|
+
function errorFields(extra) {
|
|
131
|
+
if (!extra) return {};
|
|
132
|
+
const { err, ...rest } = extra;
|
|
133
|
+
if (err instanceof Error) return {
|
|
134
|
+
error: err.message,
|
|
135
|
+
stack: err.stack,
|
|
136
|
+
name: err.name,
|
|
137
|
+
...rest
|
|
138
|
+
};
|
|
139
|
+
return err === void 0 ? rest : {
|
|
140
|
+
err,
|
|
141
|
+
...rest
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Warn once per call about a Winston-style invocation, in development only -
|
|
146
|
+
* the arguments are swapped either way, so this is guidance, not an error.
|
|
147
|
+
*/
|
|
148
|
+
function warnLegacyPattern(level, secondArg, recommended) {
|
|
149
|
+
if (process.env.NODE_ENV === "production") return;
|
|
150
|
+
console.warn(`[autotel] Legacy logger pattern detected: logger.${level}('message', ${secondArg}). Autotel recommends Pino signature: logger.${level}(${recommended}, 'message'). Auto-swapping arguments for compatibility.`);
|
|
151
|
+
}
|
|
124
152
|
function createBuiltinLogger(service, options) {
|
|
125
153
|
const defaultLevel = options?.level || "info";
|
|
126
154
|
const pretty = options?.pretty || false;
|
|
127
|
-
const levelPriority =
|
|
128
|
-
none
|
|
129
|
-
debug
|
|
130
|
-
info
|
|
131
|
-
warn
|
|
132
|
-
error
|
|
133
|
-
|
|
155
|
+
const levelPriority = /* @__PURE__ */ new Map([
|
|
156
|
+
["none", -1],
|
|
157
|
+
["debug", 0],
|
|
158
|
+
["info", 1],
|
|
159
|
+
["warn", 2],
|
|
160
|
+
["error", 3]
|
|
161
|
+
]);
|
|
134
162
|
const shouldLog = (level) => {
|
|
135
163
|
const activeLevel = getActiveLogLevel() ?? defaultLevel;
|
|
136
164
|
if (activeLevel === "none") return false;
|
|
137
|
-
return levelPriority
|
|
165
|
+
return (levelPriority.get(level) ?? 0) >= (levelPriority.get(activeLevel) ?? 0);
|
|
138
166
|
};
|
|
139
167
|
const log = (level, msg, attrs) => {
|
|
140
168
|
if (!shouldLog(level)) return;
|
|
@@ -154,11 +182,18 @@ function createBuiltinLogger(service, options) {
|
|
|
154
182
|
};
|
|
155
183
|
const createLogMethod = (level) => {
|
|
156
184
|
return (extraOrMessage, message) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
log(level,
|
|
160
|
-
|
|
161
|
-
|
|
185
|
+
const firstAsMessage = asString(extraOrMessage);
|
|
186
|
+
if (firstAsMessage === void 0) {
|
|
187
|
+
log(level, asString(message) ?? "", asRecord(extraOrMessage));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const legacyExtra = asRecord(message);
|
|
191
|
+
if (!legacyExtra) {
|
|
192
|
+
log(level, firstAsMessage);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
warnLegacyPattern(level, "metadata", "{ ...metadata }");
|
|
196
|
+
log(level, firstAsMessage, legacyExtra);
|
|
162
197
|
};
|
|
163
198
|
};
|
|
164
199
|
return {
|
|
@@ -166,49 +201,23 @@ function createBuiltinLogger(service, options) {
|
|
|
166
201
|
warn: createLogMethod("warn"),
|
|
167
202
|
debug: createLogMethod("debug"),
|
|
168
203
|
error: (extraOrMessage, message) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (err instanceof Error) errorAttrs = {
|
|
184
|
-
error: err.message,
|
|
185
|
-
stack: err.stack,
|
|
186
|
-
name: err.name,
|
|
187
|
-
...rest
|
|
188
|
-
};
|
|
189
|
-
else if (err !== void 0) errorAttrs = {
|
|
190
|
-
err,
|
|
191
|
-
...rest
|
|
192
|
-
};
|
|
193
|
-
log("error", extraOrMessage, errorAttrs);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
log("error", extraOrMessage);
|
|
204
|
+
const firstAsMessage = asString(extraOrMessage);
|
|
205
|
+
if (firstAsMessage === void 0) {
|
|
206
|
+
log("error", asString(message) ?? "", errorFields(asRecord(extraOrMessage)));
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (message instanceof Error) {
|
|
210
|
+
warnLegacyPattern("error", "error", "{ err: error }");
|
|
211
|
+
log("error", firstAsMessage, errorFields({ err: message }));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const legacyExtra = asRecord(message);
|
|
215
|
+
if (legacyExtra) {
|
|
216
|
+
warnLegacyPattern("error", "metadata", "{ ...metadata }");
|
|
217
|
+
log("error", firstAsMessage, errorFields(legacyExtra));
|
|
197
218
|
return;
|
|
198
219
|
}
|
|
199
|
-
|
|
200
|
-
let errorAttrs = rest;
|
|
201
|
-
if (err instanceof Error) errorAttrs = {
|
|
202
|
-
error: err.message,
|
|
203
|
-
stack: err.stack,
|
|
204
|
-
name: err.name,
|
|
205
|
-
...rest
|
|
206
|
-
};
|
|
207
|
-
else if (err !== void 0) errorAttrs = {
|
|
208
|
-
err,
|
|
209
|
-
...rest
|
|
210
|
-
};
|
|
211
|
-
log("error", message || "", errorAttrs);
|
|
220
|
+
log("error", firstAsMessage);
|
|
212
221
|
}
|
|
213
222
|
};
|
|
214
223
|
}
|
|
@@ -49,26 +49,6 @@ interface BuiltinLoggerOptions {
|
|
|
49
49
|
/** Pretty print for development. Default: false (JSON output) */
|
|
50
50
|
pretty?: boolean;
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Create a lightweight structured logger
|
|
54
|
-
*
|
|
55
|
-
* @param service - Service name for logging
|
|
56
|
-
* @param options - Optional configuration
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* const log = createBuiltinLogger('user-service');
|
|
61
|
-
*
|
|
62
|
-
* log.info('Creating user', { email: 'test@example.com' });
|
|
63
|
-
* // Output: {"level":"info","service":"user-service","msg":"Creating user",
|
|
64
|
-
* // "email":"test@example.com","traceId":"...","spanId":"..."}
|
|
65
|
-
*
|
|
66
|
-
* // Dynamic log level control per-request
|
|
67
|
-
* runWithLogLevel('debug', () => {
|
|
68
|
-
* log.debug('This will be logged even if logger was created with level: "info"');
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
52
|
declare function createBuiltinLogger(service: string, options?: BuiltinLoggerOptions): Logger;
|
|
73
53
|
/**
|
|
74
54
|
* Pino-like factory function for creating an autotel logger
|