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,8 +1,9 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
|
|
2
|
+
const require_values = require('./values-DApyq53y.cjs');
|
|
2
3
|
const require_tracer_provider = require('./tracer-provider.cjs');
|
|
3
4
|
const require_config = require('./config.cjs');
|
|
4
5
|
const require_sampling = require('./sampling.cjs');
|
|
5
|
-
const require_node_require = require('./node-require-
|
|
6
|
+
const require_node_require = require('./node-require-EifOMikz.cjs');
|
|
6
7
|
const require_tail_sampling_processor = require('./tail-sampling-processor.cjs');
|
|
7
8
|
const require_filtering_span_processor = require('./filtering-span-processor.cjs');
|
|
8
9
|
const require_policy = require('./policy.cjs');
|
|
@@ -10,8 +11,8 @@ const require_span_name_normalizer = require('./span-name-normalizer.cjs');
|
|
|
10
11
|
const require_attribute_redacting_processor = require('./attribute-redacting-processor.cjs');
|
|
11
12
|
const require_pretty_console_exporter = require('./pretty-console-exporter-CMzlrRNg.cjs');
|
|
12
13
|
const require_yaml_config = require('./yaml-config.cjs');
|
|
13
|
-
const require_canonical_log_line_processor = require('./canonical-log-line-processor-
|
|
14
|
-
const require_structured_error = require('./structured-error
|
|
14
|
+
const require_canonical_log_line_processor = require('./canonical-log-line-processor-DolzdawH.cjs');
|
|
15
|
+
const require_structured_error = require('./structured-error--_wXpd_C.cjs');
|
|
15
16
|
const require_metric = require('./metric.cjs');
|
|
16
17
|
let _opentelemetry_sdk_node = require("@opentelemetry/sdk-node");
|
|
17
18
|
let _opentelemetry_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
@@ -67,10 +68,15 @@ var RedactingLogRecordProcessor = class {
|
|
|
67
68
|
this.redact = redact;
|
|
68
69
|
}
|
|
69
70
|
onEmit(logRecord, context) {
|
|
70
|
-
|
|
71
|
-
if (logRecord.
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const body = require_values.asString(logRecord.body);
|
|
72
|
+
if (body) logRecord.body = this.redact(body);
|
|
73
|
+
if (logRecord.attributes) for (const [key, value] of Object.entries(logRecord.attributes)) {
|
|
74
|
+
const text = require_values.asString(value);
|
|
75
|
+
if (text !== void 0) logRecord.attributes[key] = this.redact(text);
|
|
76
|
+
else if (Array.isArray(value)) logRecord.attributes[key] = value.map((item) => {
|
|
77
|
+
const entry = require_values.asString(item);
|
|
78
|
+
return entry === void 0 ? item : this.redact(entry);
|
|
79
|
+
});
|
|
74
80
|
}
|
|
75
81
|
this.wrapped.onEmit(logRecord, context);
|
|
76
82
|
}
|
|
@@ -566,6 +572,11 @@ var TokenBucketRateLimiter = class {
|
|
|
566
572
|
|
|
567
573
|
//#endregion
|
|
568
574
|
//#region src/trace-context.ts
|
|
575
|
+
const spansWithExplicitStatus = /* @__PURE__ */ new WeakSet();
|
|
576
|
+
/** Whether a TraceContext consumer explicitly chose this span's status. */
|
|
577
|
+
function hasExplicitSpanStatus(span) {
|
|
578
|
+
return spansWithExplicitStatus.has(span);
|
|
579
|
+
}
|
|
569
580
|
/**
|
|
570
581
|
* AsyncLocalStorage for storing the active context with baggage
|
|
571
582
|
* This allows setters to update the context and have it persist
|
|
@@ -619,7 +630,7 @@ function updateActiveContext(newContext) {
|
|
|
619
630
|
asyncLocal.enterWith(newContext);
|
|
620
631
|
return;
|
|
621
632
|
}
|
|
622
|
-
if (
|
|
633
|
+
if (require_values.isFunction(manager.with)) manager.with(newContext, () => {});
|
|
623
634
|
}
|
|
624
635
|
/**
|
|
625
636
|
* Create a TraceContext from an OpenTelemetry Span
|
|
@@ -642,15 +653,18 @@ function createTraceContext(span) {
|
|
|
642
653
|
correlationId: spanContext.traceId.slice(0, 16),
|
|
643
654
|
setAttribute: span.setAttribute.bind(span),
|
|
644
655
|
setAttributes: span.setAttributes.bind(span),
|
|
645
|
-
setStatus:
|
|
656
|
+
setStatus: (status) => {
|
|
657
|
+
spansWithExplicitStatus.add(span);
|
|
658
|
+
span.setStatus(status);
|
|
659
|
+
},
|
|
646
660
|
recordException: span.recordException.bind(span),
|
|
647
661
|
addEvent: span.addEvent.bind(span),
|
|
648
662
|
addLink: span.addLink.bind(span),
|
|
649
663
|
addLinks: span.addLinks.bind(span),
|
|
650
664
|
updateName: span.updateName.bind(span),
|
|
651
665
|
isRecording: span.isRecording.bind(span),
|
|
652
|
-
recordError: (
|
|
653
|
-
const err =
|
|
666
|
+
recordError: (cause) => {
|
|
667
|
+
const err = cause instanceof Error ? cause : new Error(String(cause));
|
|
654
668
|
require_structured_error.recordStructuredError(traceCtx, err);
|
|
655
669
|
},
|
|
656
670
|
track: (event, data) => {
|
|
@@ -700,12 +714,11 @@ function createTraceContext(span) {
|
|
|
700
714
|
}
|
|
701
715
|
if (!baggage) return;
|
|
702
716
|
const prefix = namespace ? `${namespace}.` : "";
|
|
703
|
-
const
|
|
704
|
-
for (const [key, entry] of baggage.getAllEntries()) if (namespace && key.startsWith(prefix))
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
return Object.keys(result).length > 0 ? result : void 0;
|
|
717
|
+
const entries = [];
|
|
718
|
+
for (const [key, entry] of baggage.getAllEntries()) if (namespace && key.startsWith(prefix)) entries.push([key.slice(prefix.length), entry.value]);
|
|
719
|
+
else if (!namespace) entries.push([key, entry.value]);
|
|
720
|
+
const result = Object.fromEntries(entries);
|
|
721
|
+
return entries.length > 0 ? result : void 0;
|
|
709
722
|
}),
|
|
710
723
|
setTypedBaggage: ((namespace, value) => {
|
|
711
724
|
const currentContext = getActiveContextWithBaggage();
|
|
@@ -1411,7 +1424,7 @@ var ValidationError = class extends Error {
|
|
|
1411
1424
|
* Throws ValidationError if invalid
|
|
1412
1425
|
*/
|
|
1413
1426
|
function validateEventName(eventName, config = DEFAULT_CONFIG$1) {
|
|
1414
|
-
if (
|
|
1427
|
+
if (require_values.asString(eventName) === void 0) throw new ValidationError(`Event name must be a string, got ${require_values.describeValue(eventName)}`);
|
|
1415
1428
|
const trimmed = eventName.trim();
|
|
1416
1429
|
if (trimmed.length === 0) throw new ValidationError("Event name cannot be empty");
|
|
1417
1430
|
if (trimmed.length > config.maxEventNameLength) throw new ValidationError(`Event name too long (${trimmed.length} chars). Max: ${config.maxEventNameLength}`);
|
|
@@ -1424,14 +1437,14 @@ function validateEventName(eventName, config = DEFAULT_CONFIG$1) {
|
|
|
1424
1437
|
*/
|
|
1425
1438
|
function validateAttributes(attributes, config = DEFAULT_CONFIG$1) {
|
|
1426
1439
|
if (attributes === void 0 || attributes === null) return;
|
|
1427
|
-
if (
|
|
1440
|
+
if (!require_values.asRecord(attributes)) throw new ValidationError("Attributes must be an object");
|
|
1428
1441
|
const keys = Object.keys(attributes);
|
|
1429
1442
|
if (keys.length > config.maxAttributeCount) throw new ValidationError(`Too many attributes (${keys.length}). Max: ${config.maxAttributeCount}`);
|
|
1430
1443
|
const sanitized = {};
|
|
1431
1444
|
for (const key of keys) {
|
|
1432
1445
|
if (key.length > config.maxAttributeKeyLength) throw new ValidationError(`Attribute key too long: "${key.slice(0, 20)}..." (${key.length} chars). Max: ${config.maxAttributeKeyLength}`);
|
|
1433
1446
|
const value = attributes[key];
|
|
1434
|
-
if (
|
|
1447
|
+
if (isSensitiveString(key, value, config)) {
|
|
1435
1448
|
sanitized[key] = "[REDACTED]";
|
|
1436
1449
|
continue;
|
|
1437
1450
|
}
|
|
@@ -1440,29 +1453,35 @@ function validateAttributes(attributes, config = DEFAULT_CONFIG$1) {
|
|
|
1440
1453
|
return sanitized;
|
|
1441
1454
|
}
|
|
1442
1455
|
/**
|
|
1456
|
+
* Whether this key/value pair is a credential to redact. Strings only:
|
|
1457
|
+
* numeric and boolean values are not credentials, and replacing them with the
|
|
1458
|
+
* literal '[REDACTED]' leaks no signal while breaking every consumer that
|
|
1459
|
+
* treats them as a number.
|
|
1460
|
+
*/
|
|
1461
|
+
function isSensitiveString(key, value, config) {
|
|
1462
|
+
return require_values.asString(value) !== void 0 && config.sensitivePatterns.some((pattern) => pattern.test(key));
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1443
1465
|
* Sanitize attribute value (recursive)
|
|
1444
1466
|
*/
|
|
1445
1467
|
function sanitizeValue(value, config, depth) {
|
|
1446
1468
|
if (depth > config.maxNestingDepth) return "[MAX_DEPTH_EXCEEDED]";
|
|
1447
1469
|
if (value === null || value === void 0) return value;
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
1470
|
+
const text = require_values.asString(value);
|
|
1471
|
+
if (text !== void 0) return text.length > config.maxAttributeValueLength ? text.slice(0, config.maxAttributeValueLength) + "..." : text;
|
|
1472
|
+
const scalar = require_values.asNumber(value) ?? require_values.asBoolean(value);
|
|
1473
|
+
if (scalar !== void 0) return scalar;
|
|
1453
1474
|
if (Array.isArray(value)) return value.map((item) => sanitizeValue(item, config, depth + 1));
|
|
1454
|
-
|
|
1455
|
-
|
|
1475
|
+
const record = require_values.asRecord(value);
|
|
1476
|
+
if (record) try {
|
|
1477
|
+
JSON.stringify(record);
|
|
1456
1478
|
const sanitized = {};
|
|
1457
|
-
for (const key
|
|
1458
|
-
const nested = value[key];
|
|
1459
|
-
sanitized[key] = typeof nested === "string" && config.sensitivePatterns.some((pattern) => pattern.test(key)) ? "[REDACTED]" : sanitizeValue(nested, config, depth + 1);
|
|
1460
|
-
}
|
|
1479
|
+
for (const [key, nested] of Object.entries(record)) sanitized[key] = isSensitiveString(key, nested, config) ? "[REDACTED]" : sanitizeValue(nested, config, depth + 1);
|
|
1461
1480
|
return sanitized;
|
|
1462
1481
|
} catch {
|
|
1463
1482
|
return "[CIRCULAR]";
|
|
1464
1483
|
}
|
|
1465
|
-
return `[${
|
|
1484
|
+
return `[${require_values.describeValue(value)}]`;
|
|
1466
1485
|
}
|
|
1467
1486
|
/**
|
|
1468
1487
|
* Validate and sanitize an events event
|
|
@@ -1823,7 +1842,7 @@ function hashValue(value) {
|
|
|
1823
1842
|
* @example Recommended: Configure subscribers in init(), use track() function
|
|
1824
1843
|
* ```typescript
|
|
1825
1844
|
* import { init, track } from 'autotel';
|
|
1826
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1845
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1827
1846
|
*
|
|
1828
1847
|
* init({
|
|
1829
1848
|
* service: 'my-app',
|
|
@@ -1846,7 +1865,7 @@ function hashValue(value) {
|
|
|
1846
1865
|
* @example Override subscribers for specific Event instance
|
|
1847
1866
|
* ```typescript
|
|
1848
1867
|
* import { Event } from 'autotel/event';
|
|
1849
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1868
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1850
1869
|
*
|
|
1851
1870
|
* // Override: use different subscribers for this instance
|
|
1852
1871
|
* const event = new Event('job-application', {
|
|
@@ -1879,7 +1898,7 @@ var Event = class {
|
|
|
1879
1898
|
* @example Recommended: Use track() with init()
|
|
1880
1899
|
* ```typescript
|
|
1881
1900
|
* import { init, track } from 'autotel';
|
|
1882
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1901
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1883
1902
|
*
|
|
1884
1903
|
* init({
|
|
1885
1904
|
* service: 'checkout',
|
|
@@ -1899,7 +1918,7 @@ var Event = class {
|
|
|
1899
1918
|
* @example Override subscribers for this instance
|
|
1900
1919
|
* ```typescript
|
|
1901
1920
|
* import { Event } from 'autotel/event';
|
|
1902
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1921
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1903
1922
|
*
|
|
1904
1923
|
* // Override: use different subscribers for this instance only
|
|
1905
1924
|
* const event = new Event('checkout', {
|
|
@@ -1977,7 +1996,7 @@ var Event = class {
|
|
|
1977
1996
|
if (traceState) {
|
|
1978
1997
|
let traceStateStr = "";
|
|
1979
1998
|
try {
|
|
1980
|
-
if (
|
|
1999
|
+
if (require_values.isFunction(traceState.serialize)) traceStateStr = traceState.serialize();
|
|
1981
2000
|
} catch {}
|
|
1982
2001
|
if (traceStateStr) autotelContext.trace_state = traceStateStr;
|
|
1983
2002
|
}
|
|
@@ -2026,9 +2045,8 @@ var Event = class {
|
|
|
2026
2045
|
const transform = enrichConfig.transform?.[key];
|
|
2027
2046
|
let transformedValue;
|
|
2028
2047
|
if (transform === "hash") transformedValue = hashValue(value);
|
|
2029
|
-
else if (transform ===
|
|
2030
|
-
else
|
|
2031
|
-
else transformedValue = value;
|
|
2048
|
+
else if (transform === void 0 || transform === "plain") transformedValue = value;
|
|
2049
|
+
else transformedValue = transform(value);
|
|
2032
2050
|
const valueBytes = new TextEncoder().encode(transformedValue).length;
|
|
2033
2051
|
if (byteCount + valueBytes > maxBytes) continue;
|
|
2034
2052
|
const enrichedKey = `${prefix}${key}`;
|
|
@@ -2351,14 +2369,16 @@ var Event = class {
|
|
|
2351
2369
|
stepNumber,
|
|
2352
2370
|
attributes: enrichedAttributes
|
|
2353
2371
|
}, "Funnel progression tracked");
|
|
2372
|
+
const stepAttributes = {
|
|
2373
|
+
...enrichedAttributes,
|
|
2374
|
+
step_name: stepName
|
|
2375
|
+
};
|
|
2376
|
+
if (stepNumber !== void 0) stepAttributes.step_number = stepNumber;
|
|
2377
|
+
const stepAsStatus = stepName;
|
|
2354
2378
|
this.collector?.recordFunnelStep({
|
|
2355
2379
|
funnel: funnelName,
|
|
2356
|
-
status:
|
|
2357
|
-
attributes:
|
|
2358
|
-
...enrichedAttributes,
|
|
2359
|
-
step_name: stepName,
|
|
2360
|
-
...stepNumber === void 0 ? {} : { step_number: stepNumber }
|
|
2361
|
-
},
|
|
2380
|
+
status: stepAsStatus,
|
|
2381
|
+
attributes: stepAttributes,
|
|
2362
2382
|
service: this.serviceName,
|
|
2363
2383
|
timestamp: Date.now()
|
|
2364
2384
|
});
|
|
@@ -2366,10 +2386,9 @@ var Event = class {
|
|
|
2366
2386
|
const autotelContext = this.buildAutotelContext();
|
|
2367
2387
|
const finalAttributes = this.enrichFromBaggage(enrichedAttributes);
|
|
2368
2388
|
this.notifySubscribers(async (subscriber) => {
|
|
2369
|
-
await (subscriber.trackFunnelProgression ? subscriber.trackFunnelProgression(funnelName, stepName, stepNumber, finalAttributes, { autotel: autotelContext }) : subscriber.trackFunnelStep(funnelName,
|
|
2389
|
+
await (subscriber.trackFunnelProgression ? subscriber.trackFunnelProgression(funnelName, stepName, stepNumber, finalAttributes, { autotel: autotelContext }) : subscriber.trackFunnelStep(funnelName, stepAsStatus, {
|
|
2370
2390
|
...finalAttributes,
|
|
2371
|
-
|
|
2372
|
-
...stepNumber === void 0 ? {} : { step_number: stepNumber }
|
|
2391
|
+
...stepAttributes
|
|
2373
2392
|
}, { autotel: autotelContext }));
|
|
2374
2393
|
});
|
|
2375
2394
|
}
|
|
@@ -2393,11 +2412,17 @@ var Event = class {
|
|
|
2393
2412
|
*/
|
|
2394
2413
|
trackBatch(events) {
|
|
2395
2414
|
for (const event of events) {
|
|
2396
|
-
const filteredAttributes = event.attributes ?
|
|
2415
|
+
const filteredAttributes = event.attributes ? definedAttributes(event.attributes) : void 0;
|
|
2397
2416
|
this.trackEvent(event.name, filteredAttributes);
|
|
2398
2417
|
}
|
|
2399
2418
|
}
|
|
2400
2419
|
};
|
|
2420
|
+
/** The attributes with the entries that carry nothing left out. */
|
|
2421
|
+
function definedAttributes(input) {
|
|
2422
|
+
const defined = {};
|
|
2423
|
+
for (const [key, value] of Object.entries(input)) if (value !== void 0 && value !== null) defined[key] = value;
|
|
2424
|
+
return defined;
|
|
2425
|
+
}
|
|
2401
2426
|
/**
|
|
2402
2427
|
* Global events instances (singleton pattern)
|
|
2403
2428
|
*/
|
|
@@ -2443,24 +2468,21 @@ const UNREACHABLE_ENDPOINT_CODES = /* @__PURE__ */ new Set([
|
|
|
2443
2468
|
"ENOTFOUND",
|
|
2444
2469
|
"EAI_AGAIN"
|
|
2445
2470
|
]);
|
|
2446
|
-
function errorCode(
|
|
2447
|
-
|
|
2448
|
-
const code = error.code;
|
|
2449
|
-
if (typeof code === "string") return code;
|
|
2450
|
-
}
|
|
2471
|
+
function errorCode(cause) {
|
|
2472
|
+
return require_values.asString(require_values.readProperty(cause, "code"));
|
|
2451
2473
|
}
|
|
2452
2474
|
/**
|
|
2453
2475
|
* True when the error (or every error it wraps) is an unreachable-endpoint
|
|
2454
2476
|
* failure. Traverses `AggregateError.errors` and the `cause` chain, since the
|
|
2455
2477
|
* SDK often wraps the underlying network error.
|
|
2456
2478
|
*/
|
|
2457
|
-
function isUnreachableEndpointError(
|
|
2458
|
-
if (depth > 5 ||
|
|
2459
|
-
if (
|
|
2460
|
-
const code = errorCode(
|
|
2479
|
+
function isUnreachableEndpointError(cause, depth = 0) {
|
|
2480
|
+
if (depth > 5 || require_values.asRecord(cause) === void 0) return false;
|
|
2481
|
+
if (cause instanceof AggregateError) return cause.errors.length > 0 && cause.errors.every((e) => isUnreachableEndpointError(e, depth + 1));
|
|
2482
|
+
const code = errorCode(cause);
|
|
2461
2483
|
if (code && UNREACHABLE_ENDPOINT_CODES.has(code)) return true;
|
|
2462
|
-
const
|
|
2463
|
-
return
|
|
2484
|
+
const wrapped = require_values.readProperty(cause, "cause");
|
|
2485
|
+
return wrapped !== void 0 && wrapped !== cause ? isUnreachableEndpointError(wrapped, depth + 1) : false;
|
|
2464
2486
|
}
|
|
2465
2487
|
/**
|
|
2466
2488
|
* Flush all pending telemetry
|
|
@@ -2561,7 +2583,7 @@ async function shutdown() {
|
|
|
2561
2583
|
uninstallProcessHandlers();
|
|
2562
2584
|
await _closeEmbeddedDevtools();
|
|
2563
2585
|
const eventsQueue = getEventQueue();
|
|
2564
|
-
if (eventsQueue
|
|
2586
|
+
if (require_values.isFunction(eventsQueue?.cleanup)) eventsQueue.cleanup();
|
|
2565
2587
|
resetEvents();
|
|
2566
2588
|
require_metric.resetMetrics();
|
|
2567
2589
|
resetEventQueue();
|
|
@@ -2841,14 +2863,17 @@ function detectHostname() {
|
|
|
2841
2863
|
function getInstrumentationNames(instrumentations) {
|
|
2842
2864
|
const names = /* @__PURE__ */ new Set();
|
|
2843
2865
|
if (!instrumentations) return names;
|
|
2844
|
-
for (const instrumentation of instrumentations)
|
|
2866
|
+
for (const instrumentation of instrumentations) {
|
|
2867
|
+
const className = require_values.asFunction(require_values.readProperty(instrumentation, "constructor"))?.name;
|
|
2868
|
+
if (className) names.add(className);
|
|
2869
|
+
}
|
|
2845
2870
|
return names;
|
|
2846
2871
|
}
|
|
2847
2872
|
/**
|
|
2848
2873
|
* Map common instrumentation class names to their package names
|
|
2849
2874
|
* Used to disable auto-instrumentations when user provides manual configs
|
|
2850
2875
|
*/
|
|
2851
|
-
const INSTRUMENTATION_CLASS_TO_PACKAGE = {
|
|
2876
|
+
const INSTRUMENTATION_CLASS_TO_PACKAGE = new Map(Object.entries({
|
|
2852
2877
|
HttpInstrumentation: "@opentelemetry/instrumentation-http",
|
|
2853
2878
|
HttpsInstrumentation: "@opentelemetry/instrumentation-http",
|
|
2854
2879
|
ExpressInstrumentation: "@opentelemetry/instrumentation-express",
|
|
@@ -2867,7 +2892,7 @@ const INSTRUMENTATION_CLASS_TO_PACKAGE = {
|
|
|
2867
2892
|
PgInstrumentation: "@opentelemetry/instrumentation-pg",
|
|
2868
2893
|
MySQLInstrumentation: "@opentelemetry/instrumentation-mysql",
|
|
2869
2894
|
MySQL2Instrumentation: "@opentelemetry/instrumentation-mysql2"
|
|
2870
|
-
};
|
|
2895
|
+
}));
|
|
2871
2896
|
/**
|
|
2872
2897
|
* Detect if we're running in ESM mode
|
|
2873
2898
|
*/
|
|
@@ -2920,7 +2945,7 @@ function getAutoInstrumentations(integrations, manualInstrumentationNames = /* @
|
|
|
2920
2945
|
const getNodeAutoInstrumentations = _autoInstrumentationsLoader ? _autoInstrumentationsLoader() : loadNodeAutoInstrumentations();
|
|
2921
2946
|
const exclusionConfig = {};
|
|
2922
2947
|
for (const className of manualInstrumentationNames) {
|
|
2923
|
-
const packageName = INSTRUMENTATION_CLASS_TO_PACKAGE
|
|
2948
|
+
const packageName = INSTRUMENTATION_CLASS_TO_PACKAGE.get(className);
|
|
2924
2949
|
if (packageName) exclusionConfig[packageName] = { enabled: false };
|
|
2925
2950
|
}
|
|
2926
2951
|
if (integrations === true) {
|
|
@@ -2964,10 +2989,9 @@ function toOtelSampler(sampler) {
|
|
|
2964
2989
|
};
|
|
2965
2990
|
const shouldTrace = sampler.shouldSample(samplingContext);
|
|
2966
2991
|
const rate = sampler.sampleRate?.(samplingContext);
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
};
|
|
2992
|
+
const result = { decision: shouldTrace ? _opentelemetry_sdk_trace_base.SamplingDecision.RECORD_AND_SAMPLED : _opentelemetry_sdk_trace_base.SamplingDecision.NOT_RECORD };
|
|
2993
|
+
if (shouldTrace && rate !== void 0 && rate > 1) result.attributes = { [require_sampling.AUTOTEL_SAMPLING_RATE]: rate };
|
|
2994
|
+
return result;
|
|
2971
2995
|
},
|
|
2972
2996
|
toString() {
|
|
2973
2997
|
return `AutotelSamplerAdapter`;
|
|
@@ -2984,7 +3008,7 @@ let validationConfig = null;
|
|
|
2984
3008
|
let eventsConfig = null;
|
|
2985
3009
|
let _stringRedactor = null;
|
|
2986
3010
|
function acceptsStringRedactor(subscriber) {
|
|
2987
|
-
return
|
|
3011
|
+
return require_values.isFunction(require_values.readProperty(subscriber, "setStringRedactor")) ? subscriber : void 0;
|
|
2988
3012
|
}
|
|
2989
3013
|
let _optionalRequire = require_node_require.safeRequire;
|
|
2990
3014
|
let _devtoolsClose = null;
|
|
@@ -3015,7 +3039,7 @@ function isLoggerLocked() {
|
|
|
3015
3039
|
*
|
|
3016
3040
|
* @example With events (observe in PostHog, Mixpanel, etc.)
|
|
3017
3041
|
* ```typescript
|
|
3018
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
3042
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
3019
3043
|
*
|
|
3020
3044
|
* init({
|
|
3021
3045
|
* service: 'my-app',
|
|
@@ -3169,9 +3193,7 @@ function init(cfg) {
|
|
|
3169
3193
|
spanProcessors = spanProcessors.map((processor) => new require_attribute_redacting_processor.AttributeRedactingProcessor(processor, { redactor }));
|
|
3170
3194
|
}
|
|
3171
3195
|
if (mergedConfig.attributeRedactor) _stringRedactor = createStringRedactor(mergedConfig.attributeRedactor);
|
|
3172
|
-
if (_stringRedactor && mergedConfig.subscribers)
|
|
3173
|
-
for (const subscriber of mergedConfig.subscribers) if (acceptsStringRedactor(subscriber)) subscriber.setStringRedactor(_stringRedactor);
|
|
3174
|
-
}
|
|
3196
|
+
if (_stringRedactor && mergedConfig.subscribers) for (const subscriber of mergedConfig.subscribers) acceptsStringRedactor(subscriber)?.setStringRedactor(_stringRedactor);
|
|
3175
3197
|
if (mergedConfig.spanNameNormalizer && spanProcessors.length > 0) spanProcessors = spanProcessors.map((processor) => new require_span_name_normalizer.SpanNameNormalizingProcessor(processor, { normalizer: mergedConfig.spanNameNormalizer }));
|
|
3176
3198
|
if (mergedConfig.policies) {
|
|
3177
3199
|
if (typeof mergedConfig.policies === "string") require_policy.watchPolicyFile(mergedConfig.policies);
|
|
@@ -3191,11 +3213,10 @@ function init(cfg) {
|
|
|
3191
3213
|
});
|
|
3192
3214
|
const exportIntervalMillis = readMillisEnv("OTEL_METRIC_EXPORT_INTERVAL");
|
|
3193
3215
|
const exportTimeoutMillis = readMillisEnv("OTEL_METRIC_EXPORT_TIMEOUT");
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
}));
|
|
3216
|
+
const readerOptions = { exporter: metricExporter };
|
|
3217
|
+
if (exportIntervalMillis !== void 0) readerOptions.exportIntervalMillis = exportIntervalMillis;
|
|
3218
|
+
if (exportTimeoutMillis !== void 0) readerOptions.exportTimeoutMillis = exportTimeoutMillis;
|
|
3219
|
+
metricReaders.push(new _opentelemetry_sdk_metrics.PeriodicExportingMetricReader(readerOptions));
|
|
3199
3220
|
}
|
|
3200
3221
|
let logRecordProcessors;
|
|
3201
3222
|
if (configuredLogRecordProcessors && configuredLogRecordProcessors.length > 0) logRecordProcessors = [...configuredLogRecordProcessors];
|
|
@@ -3253,11 +3274,10 @@ function init(cfg) {
|
|
|
3253
3274
|
const traceloop = _optionalRequire("@traceloop/node-server-sdk");
|
|
3254
3275
|
if (traceloop) {
|
|
3255
3276
|
const initOptions = { ...mergedConfig.openllmetry.options };
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
} catch {}
|
|
3277
|
+
const getTracerProvider = require_values.asFunction(require_values.readProperty(sdk, "getTracerProvider"));
|
|
3278
|
+
if (getTracerProvider) initOptions.tracerProvider = getTracerProvider.call(sdk);
|
|
3259
3279
|
if (configuredSpanExporters?.[0]) initOptions.exporter = configuredSpanExporters[0];
|
|
3260
|
-
if (
|
|
3280
|
+
if (require_values.isFunction(traceloop.initialize)) {
|
|
3261
3281
|
traceloop.initialize(initOptions);
|
|
3262
3282
|
logger.info({}, "[autotel] OpenLLMetry initialized successfully");
|
|
3263
3283
|
} else logger.warn({}, "[autotel] OpenLLMetry initialize function not found. Check @traceloop/node-server-sdk version.");
|
|
@@ -3446,6 +3466,12 @@ Object.defineProperty(exports, 'getSdk', {
|
|
|
3446
3466
|
return getSdk;
|
|
3447
3467
|
}
|
|
3448
3468
|
});
|
|
3469
|
+
Object.defineProperty(exports, 'hasExplicitSpanStatus', {
|
|
3470
|
+
enumerable: true,
|
|
3471
|
+
get: function () {
|
|
3472
|
+
return hasExplicitSpanStatus;
|
|
3473
|
+
}
|
|
3474
|
+
});
|
|
3449
3475
|
Object.defineProperty(exports, 'init', {
|
|
3450
3476
|
enumerable: true,
|
|
3451
3477
|
get: function () {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as AttributeRedactorPreset, r as AttributeRedactorConfig } from "./attribute-redacting-processor-
|
|
2
|
-
import { s as Logger } from "./logger-
|
|
3
|
-
import { h as SamplingPreset, p as Sampler } from "./sampling-
|
|
4
|
-
import {
|
|
1
|
+
import { a as AttributeRedactorPreset, r as AttributeRedactorConfig } from "./attribute-redacting-processor-CvBE0z1p.cjs";
|
|
2
|
+
import { s as Logger } from "./logger-S1Fgl0g3.cjs";
|
|
3
|
+
import { h as SamplingPreset, p as Sampler } from "./sampling-CmRdnXUi.cjs";
|
|
4
|
+
import { o as EventSubscriber } from "./event-subscriber-DMACQA-1.cjs";
|
|
5
5
|
import { r as SpanFilterPredicate } from "./filtering-span-processor-BpDagWNa.cjs";
|
|
6
6
|
import { r as Policy } from "./policy-CbpP4tFH.cjs";
|
|
7
7
|
import { r as SpanNameNormalizerConfig } from "./span-name-normalizer-CN1-8C76.cjs";
|
|
8
|
-
import { t as CanonicalLogLineOptions } from "./canonical-log-line-processor-
|
|
8
|
+
import { t as CanonicalLogLineOptions } from "./canonical-log-line-processor-l0Aqe6yp.cjs";
|
|
9
9
|
import { ReadableSpan, SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
10
10
|
import { Attributes } from "@opentelemetry/api";
|
|
11
11
|
import { Resource } from "@opentelemetry/resources";
|
|
@@ -1233,7 +1233,7 @@ declare function isLoggerLocked(): boolean;
|
|
|
1233
1233
|
*
|
|
1234
1234
|
* @example With events (observe in PostHog, Mixpanel, etc.)
|
|
1235
1235
|
* ```typescript
|
|
1236
|
-
* import { PostHogSubscriber } from 'autotel-
|
|
1236
|
+
* import { PostHogSubscriber } from 'autotel-posthog/subscriber';
|
|
1237
1237
|
*
|
|
1238
1238
|
* init({
|
|
1239
1239
|
* service: 'my-app',
|