autotel 7.7.1 → 7.8.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.
Files changed (111) hide show
  1. package/dist/analysis.cjs +0 -1
  2. package/dist/{attribute-redacting-processor-CvBE0z1p.d.ts → attribute-redacting-processor-rkV_WL-k.d.ts} +2 -2
  3. package/dist/attribute-redacting-processor.cjs +1 -1
  4. package/dist/attribute-redacting-processor.d.ts +1 -1
  5. package/dist/{attributes-De9Fx0b4.js → attributes-CuGx6cOI.js} +21 -11
  6. package/dist/{attributes-DkptT2Ck.cjs → attributes-Ii3jDPsW.cjs} +23 -13
  7. package/dist/attributes.cjs +1 -1
  8. package/dist/attributes.d.ts +1 -1
  9. package/dist/attributes.js +1 -1
  10. package/dist/auto.cjs +2 -2
  11. package/dist/auto.js +1 -1
  12. package/dist/business-baggage.cjs +1 -1
  13. package/dist/{canonical-log-line-processor-Bvgb1lE4.cjs → canonical-log-line-processor-BU03jJeA.cjs} +1 -1
  14. package/dist/{canonical-log-line-processor-Yq4cXcD5.d.ts → canonical-log-line-processor-Bwrt_L4c.d.ts} +1 -1
  15. package/dist/{correlated-events-9RRdfyWR.cjs → correlated-events-DE_4A3oD.cjs} +1 -1
  16. package/dist/correlation-id.cjs +1 -1
  17. package/dist/correlation-id.js +1 -1
  18. package/dist/db.cjs +1 -1
  19. package/dist/decorators.cjs +2 -2
  20. package/dist/decorators.d.cts +1 -1
  21. package/dist/decorators.d.ts +1 -1
  22. package/dist/decorators.js +1 -1
  23. package/dist/diagnostics.cjs +3 -3
  24. package/dist/diagnostics.js +1 -1
  25. package/dist/drain-pipeline.cjs +0 -1
  26. package/dist/enrichers.cjs +0 -1
  27. package/dist/event-testing.cjs +0 -1
  28. package/dist/event.cjs +1 -1
  29. package/dist/event.js +1 -1
  30. package/dist/evidence.cjs +0 -1
  31. package/dist/exception-fingerprint.cjs +1 -1
  32. package/dist/{filtering-span-processor-BpDagWNa.d.ts → filtering-span-processor-vkewzbqB.d.ts} +2 -2
  33. package/dist/filtering-span-processor.cjs +0 -1
  34. package/dist/filtering-span-processor.d.ts +1 -1
  35. package/dist/{functional-S9IJNlBn.js → functional-CC2BFGAO.js} +9 -9
  36. package/dist/{functional-C4mjgtJb.d.cts → functional-DPZTpGh6.d.cts} +2 -2
  37. package/dist/{functional-DN_ztd9C.d.ts → functional-SeRUabkE.d.ts} +2 -2
  38. package/dist/{functional-UIJ0CaTV.cjs → functional-u5Qwjray.cjs} +3 -3
  39. package/dist/functional.cjs +1 -1
  40. package/dist/functional.d.cts +1 -1
  41. package/dist/functional.d.ts +1 -1
  42. package/dist/functional.js +1 -1
  43. package/dist/http.cjs +2 -2
  44. package/dist/http.js +1 -1
  45. package/dist/{index-o_6YjZhV.d.ts → index-B9aRLp6c.d.ts} +1 -1
  46. package/dist/index.cjs +10 -10
  47. package/dist/index.d.cts +3 -3
  48. package/dist/index.d.ts +10 -10
  49. package/dist/index.js +3 -3
  50. package/dist/{init-BYXDCfRL.cjs → init-21HWbm7_.cjs} +194 -39
  51. package/dist/{init-Dyq6WtsO.js → init-8SISAGdE.js} +190 -35
  52. package/dist/{init-WwjD-kQu.d.cts → init-COfMwKbc.d.cts} +38 -10
  53. package/dist/{init-CKSMbJUG.d.ts → init-CnoRlJqS.d.ts} +43 -15
  54. package/dist/instrumentation.cjs +9 -8
  55. package/dist/instrumentation.js +8 -7
  56. package/dist/{logger-CSdZkxbh.cjs → logger-DLjHQAus.cjs} +1 -1
  57. package/dist/logger.cjs +1 -1
  58. package/dist/messaging-adapters.cjs +1 -1
  59. package/dist/messaging-testing.cjs +0 -1
  60. package/dist/messaging.cjs +8 -7
  61. package/dist/messaging.js +5 -4
  62. package/dist/metric-testing.cjs +0 -1
  63. package/dist/{node-require-B_IVapV3.cjs → node-require-BPsB09eC.cjs} +2 -2
  64. package/dist/parse-error.cjs +1 -1
  65. package/dist/{policy-C4QcZnqv.d.ts → policy-DNw_0qUq.d.ts} +1 -1
  66. package/dist/policy.cjs +0 -0
  67. package/dist/policy.d.ts +1 -1
  68. package/dist/processors.cjs +1 -1
  69. package/dist/processors.d.ts +1 -1
  70. package/dist/register.cjs +1 -1
  71. package/dist/{registry-DIoklBz5.cjs → registry-B3ZJmUtU.cjs} +0 -1
  72. package/dist/{rolldown-runtime-C_NdSu1c.cjs → rolldown-runtime-C24Yb2bl.cjs} +1 -2
  73. package/dist/{sampling-DBng4Foa.d.ts → sampling-CZi7OM9u.d.ts} +13 -13
  74. package/dist/{sampling-Er217Mge.d.cts → sampling-DENUjT_8.d.cts} +13 -13
  75. package/dist/sampling.cjs +1 -1
  76. package/dist/sampling.d.cts +1 -1
  77. package/dist/sampling.d.ts +1 -1
  78. package/dist/sampling.js +1 -1
  79. package/dist/security-schema.cjs +0 -1
  80. package/dist/semantic-conventions.cjs +1 -1
  81. package/dist/semantic-helpers.cjs +3 -3
  82. package/dist/semantic-helpers.js +1 -1
  83. package/dist/{span-name-normalizer-CN1-8C76.d.ts → span-name-normalizer-DHcg1bSP.d.ts} +2 -2
  84. package/dist/span-name-normalizer.cjs +0 -1
  85. package/dist/span-name-normalizer.d.ts +1 -1
  86. package/dist/{stable-hash-C9F6xjzx.cjs → stable-hash-sLi1o4jj.cjs} +2 -2
  87. package/dist/{structured-error-BAXhglRE.cjs → structured-error-DynjWTTu.cjs} +1 -1
  88. package/dist/tail-sampling-processor.cjs +1 -1
  89. package/dist/tail-sampling-processor.d.ts +2 -2
  90. package/dist/tail-sampling-processor.js +1 -1
  91. package/dist/test-span-collector.cjs +1 -1
  92. package/dist/testing.cjs +3 -3
  93. package/dist/testing.d.ts +1 -1
  94. package/dist/testing.js +1 -1
  95. package/dist/{trace-factory-validation-Dc8epn87.cjs → trace-factory-validation-CHU1WcjK.cjs} +0 -1
  96. package/dist/trace-helpers.cjs +2 -2
  97. package/dist/tracer-provider.cjs +1 -1
  98. package/dist/validate.cjs +3 -3
  99. package/dist/validation-attributes.cjs +0 -1
  100. package/dist/{values-tm4bi0FF.cjs → values-AxGpgYBA.cjs} +0 -1
  101. package/dist/webhook.cjs +16 -13
  102. package/dist/webhook.js +14 -11
  103. package/dist/workflow-distributed.cjs +4 -6
  104. package/dist/workflow-distributed.js +2 -4
  105. package/dist/workflow.cjs +7 -6
  106. package/dist/workflow.js +3 -2
  107. package/dist/yaml-config.cjs +1 -1
  108. package/dist/yaml-config.d.cts +2 -2
  109. package/dist/yaml-config.d.ts +2 -2
  110. package/dist/yaml-config.js +1 -1
  111. package/package.json +2 -1
@@ -10,21 +10,170 @@ import { AttributeRedactingProcessor, REDACTOR_PRESETS, normalizeAttributeRedact
10
10
  import { t as PrettyConsoleExporter } from "./pretty-console-exporter-DqKl_q9z.js";
11
11
  import { t as CanonicalLogLineProcessor } from "./canonical-log-line-processor-BQ6NeZAk.js";
12
12
  import { resetMetrics } from "./metric.js";
13
- import { NodeSDK } from "@opentelemetry/sdk-node";
14
- import { AlwaysOffSampler, AlwaysOnSampler, BatchSpanProcessor, ConsoleSpanExporter, ParentBasedSampler, SamplingDecision, SimpleSpanProcessor, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
15
- import { resourceFromAttributes } from "@opentelemetry/resources";
13
+ import { DiagConsoleLogger, DiagLogLevel, TraceFlags, context, diag, metrics, propagation, trace } from "@opentelemetry/api";
14
+ import { logs } from "@opentelemetry/api-logs";
15
+ import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
16
+ import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator } from "@opentelemetry/core";
17
+ import { registerInstrumentations } from "@opentelemetry/instrumentation";
18
+ import { detectResources, envDetector, hostDetector, processDetector, resourceFromAttributes } from "@opentelemetry/resources";
19
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
20
+ import { BatchLogRecordProcessor, LoggerProvider } from "@opentelemetry/sdk-logs";
21
+ import { MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
22
+ import { AlwaysOffSampler, AlwaysOnSampler, BasicTracerProvider, BatchSpanProcessor, ConsoleSpanExporter, ParentBasedSampler, SamplingDecision, SimpleSpanProcessor, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
16
23
  import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
17
- import { TraceFlags, context, propagation, trace } from "@opentelemetry/api";
18
24
  import * as nodeAsyncHooks from "node:async_hooks";
19
- import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
20
- import { BatchLogRecordProcessor } from "@opentelemetry/sdk-logs";
21
25
  import * as nodeFs from "node:fs";
22
26
  import path from "node:path";
23
27
  import { constants } from "node:os";
24
28
  import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
25
29
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
26
- import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
27
30
 
31
+ //#region src/sdk.ts
32
+ /**
33
+ * The SDK behind `init()`: builds and registers the tracer, meter and logger
34
+ * providers from components autotel has already resolved.
35
+ *
36
+ * This replaces `@opentelemetry/sdk-node`'s `NodeSDK`. That class did the same
37
+ * registration, but it statically imports every exporter the `OTEL_*_EXPORTER`
38
+ * variables could name — OTLP over gRPC (`@grpc/grpc-js`, `protobufjs`),
39
+ * Prometheus, the YAML file-config loader — so any bundle that contained
40
+ * `init()` shipped ~1 MB of exporters it never used. autotel resolves its own
41
+ * exporters up front, so all it ever needed from `NodeSDK` was `start()`.
42
+ *
43
+ * Kept from `NodeSDK`, because code and tests rely on them:
44
+ * - `OTEL_SDK_DISABLED=true` makes `start()` a no-op.
45
+ * - `OTEL_LOG_LEVEL` installs the console diag logger.
46
+ * - Resource: `envDetector`, `processDetector` and `hostDetector` are merged
47
+ * in, then `serviceName` is applied last so the resolved autotel value
48
+ * wins (`OTEL_NODE_RESOURCE_DETECTORS=none` turns detection off).
49
+ * - Context manager: `AsyncLocalStorageContextManager`.
50
+ * - Propagator: W3C trace context + baggage, or `OTEL_PROPAGATORS`.
51
+ * - Providers are only registered when they have something to do; an empty
52
+ * `spanProcessors` list still registers a tracer provider, so context keeps
53
+ * propagating even when nothing is exported.
54
+ *
55
+ * Not kept: building an exporter from `OTEL_TRACES_EXPORTER` /
56
+ * `OTEL_LOGS_EXPORTER` / `OTEL_METRICS_EXPORTER`. autotel always passes its own
57
+ * processors, so the traces and metrics variables never reached `NodeSDK`
58
+ * anyway; `OTEL_LOGS_EXPORTER=none` still switches logs off, and `otlp` gets
59
+ * the OTLP/HTTP log exporter. gRPC and Prometheus are no longer reachable from
60
+ * the environment — pass an exporter through `init()` instead.
61
+ */
62
+ const DIAG_LEVELS = {
63
+ ALL: DiagLogLevel.ALL,
64
+ VERBOSE: DiagLogLevel.VERBOSE,
65
+ DEBUG: DiagLogLevel.DEBUG,
66
+ INFO: DiagLogLevel.INFO,
67
+ WARN: DiagLogLevel.WARN,
68
+ ERROR: DiagLogLevel.ERROR,
69
+ NONE: DiagLogLevel.NONE
70
+ };
71
+ function envFlag(name) {
72
+ return (process.env[name] ?? "").trim().toLowerCase() === "true";
73
+ }
74
+ function propagatorFromEnv() {
75
+ const raw = process.env.OTEL_PROPAGATORS?.trim();
76
+ if (!raw) return void 0;
77
+ const names = raw.split(",").map((n) => n.trim().toLowerCase()).filter(Boolean);
78
+ if (names.includes("none")) return new CompositePropagator({ propagators: [] });
79
+ const propagators = [];
80
+ for (const name of names) if (name === "tracecontext") propagators.push(new W3CTraceContextPropagator());
81
+ else if (name === "baggage") propagators.push(new W3CBaggagePropagator());
82
+ else diag.warn(`[autotel] OTEL_PROPAGATORS names "${name}", which needs a propagator package autotel does not bundle; pass one via init({ propagator }).`);
83
+ return propagators.length > 0 ? new CompositePropagator({ propagators }) : void 0;
84
+ }
85
+ function defaultPropagator() {
86
+ return new CompositePropagator({ propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()] });
87
+ }
88
+ var AutotelSdk = class {
89
+ options;
90
+ disabled;
91
+ tracerProvider;
92
+ meterProvider;
93
+ loggerProvider;
94
+ constructor(options = {}) {
95
+ this.options = options;
96
+ this.disabled = envFlag("OTEL_SDK_DISABLED");
97
+ const level = process.env.OTEL_LOG_LEVEL?.trim().toUpperCase();
98
+ if (level && DIAG_LEVELS[level] !== void 0) diag.setLogger(new DiagConsoleLogger(), { logLevel: DIAG_LEVELS[level] });
99
+ }
100
+ start() {
101
+ if (this.disabled) return;
102
+ const o = this.options;
103
+ const instrumentations = (o.instrumentations ?? []).flat();
104
+ registerInstrumentations({ instrumentations });
105
+ context.setGlobalContextManager(new AsyncLocalStorageContextManager().enable());
106
+ if (o.textMapPropagator !== null) propagation.setGlobalPropagator(o.textMapPropagator ?? propagatorFromEnv() ?? defaultPropagator());
107
+ const resource = this.resolveResource();
108
+ if (o.metricReaders && o.metricReaders.length > 0) {
109
+ this.meterProvider = new MeterProvider({
110
+ resource,
111
+ readers: o.metricReaders
112
+ });
113
+ metrics.setGlobalMeterProvider(this.meterProvider);
114
+ for (const instrumentation of instrumentations) instrumentation.setMeterProvider(this.meterProvider);
115
+ }
116
+ this.tracerProvider = new BasicTracerProvider({
117
+ resource,
118
+ spanProcessors: o.spanProcessors ?? [],
119
+ ...o.sampler && { sampler: o.sampler }
120
+ });
121
+ trace.setGlobalTracerProvider(this.tracerProvider);
122
+ const logProcessors = this.resolveLogProcessors();
123
+ if (logProcessors) {
124
+ this.loggerProvider = new LoggerProvider({
125
+ resource,
126
+ processors: logProcessors
127
+ });
128
+ logs.setGlobalLoggerProvider(this.loggerProvider);
129
+ }
130
+ }
131
+ getTracerProvider() {
132
+ return this.tracerProvider;
133
+ }
134
+ async shutdown() {
135
+ await Promise.allSettled([
136
+ this.tracerProvider?.forceFlush(),
137
+ this.loggerProvider?.forceFlush(),
138
+ this.meterProvider?.forceFlush()
139
+ ]);
140
+ await Promise.all([
141
+ this.tracerProvider?.shutdown(),
142
+ this.loggerProvider?.shutdown(),
143
+ this.meterProvider?.shutdown()
144
+ ]);
145
+ }
146
+ resolveResource() {
147
+ const o = this.options;
148
+ let resource = o.resource ?? resourceFromAttributes({});
149
+ const detectorsEnv = process.env.OTEL_NODE_RESOURCE_DETECTORS?.trim();
150
+ if (o.autoDetectResources ?? detectorsEnv?.toLowerCase() !== "none") {
151
+ const detectors = o.resourceDetectors ?? [
152
+ envDetector,
153
+ processDetector,
154
+ hostDetector
155
+ ];
156
+ resource = resource.merge(detectResources({ detectors }));
157
+ }
158
+ if (o.serviceName !== void 0) resource = resource.merge(resourceFromAttributes({ [ATTR_SERVICE_NAME]: o.serviceName }));
159
+ return resource;
160
+ }
161
+ /**
162
+ * `init()` passes a list when it configured logs itself and `undefined` to
163
+ * defer to `OTEL_LOGS_EXPORTER`. Only `otlp` (over HTTP) and `none`/unset
164
+ * are honoured there; any other value is named in a warning.
165
+ */
166
+ resolveLogProcessors() {
167
+ const configured = this.options.logRecordProcessors;
168
+ if (configured) return configured;
169
+ const fromEnv = process.env.OTEL_LOGS_EXPORTER?.trim().toLowerCase();
170
+ if (!fromEnv || fromEnv === "none") return void 0;
171
+ if (fromEnv === "otlp") return [new BatchLogRecordProcessor({ exporter: new OTLPLogExporter() })];
172
+ diag.warn(`[autotel] OTEL_LOGS_EXPORTER=${fromEnv} is not supported without sdk-node; pass a log exporter via init() instead.`);
173
+ }
174
+ };
175
+
176
+ //#endregion
28
177
  //#region src/rate-limiter.ts
29
178
  /**
30
179
  * Token bucket rate limiter
@@ -510,28 +659,30 @@ var EventQueue = class {
510
659
  */
511
660
  async sendWithRetry(events, retriesLeft, subscribersByEventIndex) {
512
661
  const failedDeliveries = await this.sendToSubscribers(events, subscribersByEventIndex);
513
- if (failedDeliveries.length > 0) if (retriesLeft > 0) {
514
- const failedEventIndicesOrdered = [...new Set(failedDeliveries.map((f) => f.eventIndex))].toSorted((a, b) => a - b);
515
- const eventsToRetry = failedEventIndicesOrdered.map((i) => events[i]);
516
- const failedSubscribersByRetryIndex = /* @__PURE__ */ new Map();
517
- for (const [j, origIndex] of failedEventIndicesOrdered.entries()) {
518
- const set = /* @__PURE__ */ new Set();
519
- for (const { eventIndex, subscriberName } of failedDeliveries) if (eventIndex === origIndex) set.add(subscriberName);
520
- failedSubscribersByRetryIndex.set(j, set);
521
- }
522
- const delay = Math.pow(2, this.config.maxRetries - retriesLeft) * 1e3;
523
- await new Promise((resolve) => setTimeout(resolve, delay));
524
- return this.sendWithRetry(eventsToRetry, retriesLeft - 1, failedSubscribersByRetryIndex);
525
- } else {
526
- for (const { eventIndex, subscriberName, error } of failedDeliveries) {
527
- const event = events[eventIndex];
528
- if (event) this.recordFailed(event, subscriberName, error);
662
+ if (failedDeliveries.length > 0) {
663
+ if (retriesLeft > 0) {
664
+ const failedEventIndicesOrdered = [...new Set(failedDeliveries.map((f) => f.eventIndex))].toSorted((a, b) => a - b);
665
+ const eventsToRetry = failedEventIndicesOrdered.map((i) => events[i]);
666
+ const failedSubscribersByRetryIndex = /* @__PURE__ */ new Map();
667
+ for (const [j, origIndex] of failedEventIndicesOrdered.entries()) {
668
+ const set = /* @__PURE__ */ new Set();
669
+ for (const { eventIndex, subscriberName } of failedDeliveries) if (eventIndex === origIndex) set.add(subscriberName);
670
+ failedSubscribersByRetryIndex.set(j, set);
671
+ }
672
+ const delay = Math.pow(2, this.config.maxRetries - retriesLeft) * 1e3;
673
+ await new Promise((resolve) => setTimeout(resolve, delay));
674
+ return this.sendWithRetry(eventsToRetry, retriesLeft - 1, failedSubscribersByRetryIndex);
675
+ } else {
676
+ for (const { eventIndex, subscriberName, error } of failedDeliveries) {
677
+ const event = events[eventIndex];
678
+ if (event) this.recordFailed(event, subscriberName, error);
679
+ }
680
+ const failedSubscriberNames = [...new Set(failedDeliveries.map((f) => f.subscriberName))];
681
+ getLogger().error({
682
+ failedSubscribers: failedSubscriberNames,
683
+ retriesAttempted: this.config.maxRetries
684
+ }, "[autotel] Failed to send events after retries");
529
685
  }
530
- const failedSubscriberNames = [...new Set(failedDeliveries.map((f) => f.subscriberName))];
531
- getLogger().error({
532
- failedSubscribers: failedSubscriberNames,
533
- retriesAttempted: this.config.maxRetries
534
- }, "[autotel] Failed to send events after retries");
535
686
  }
536
687
  }
537
688
  /**
@@ -888,7 +1039,8 @@ function getOrCreateQueue() {
888
1039
  function track(event, data, options) {
889
1040
  const queue = getOrCreateQueue();
890
1041
  if (!queue) return;
891
- const validated = validateEvent(event, data, getValidationConfig() || void 0);
1042
+ const validationConfig = getValidationConfig();
1043
+ const validated = validateEvent(event, data, validationConfig || void 0);
892
1044
  const span = trace.getActiveSpan();
893
1045
  const enrichedData = span ? {
894
1046
  ...validated.attributes,
@@ -2990,7 +3142,8 @@ var Event = class {
2990
3142
  * ```
2991
3143
  */
2992
3144
  trackEvent(eventName, attributes) {
2993
- const validated = validateEvent(eventName, attributes, getValidationConfig() || void 0);
3145
+ const validationConfig = getValidationConfig();
3146
+ const validated = validateEvent(eventName, attributes, validationConfig || void 0);
2994
3147
  const enrichedAttributes = this.enrichWithTelemetryContext(validated.attributes);
2995
3148
  this.logger?.info({
2996
3149
  event: validated.eventName,
@@ -4052,7 +4205,8 @@ function init(cfg) {
4052
4205
  if (devtoolsConfig.enabled && mergedConfig.logs === void 0) mergedConfig.logs = true;
4053
4206
  const silent = mergedConfig.silent ?? false;
4054
4207
  const minLevel = mergedConfig.minLevel ?? "info";
4055
- logger = wrapLogger(mergedConfig.logger || silentLogger, silent, minLevel);
4208
+ const baseLogger = mergedConfig.logger || silentLogger;
4209
+ logger = wrapLogger(baseLogger, silent, minLevel);
4056
4210
  if (initialized) logger.warn({}, "[autotel] init() called again - last config wins. This may cause unexpected behavior.");
4057
4211
  config = mergedConfig;
4058
4212
  validationConfig = mergedConfig.validation || null;
@@ -4165,10 +4319,11 @@ function init(cfg) {
4165
4319
  if (logsEnabled) {
4166
4320
  for (const destination of otlpDestinations) {
4167
4321
  if (!destinationSupportsSignal(destination, "logs")) continue;
4168
- let processor = new BatchLogRecordProcessor({ exporter: createLogExporter(destination.protocol, {
4322
+ const logExporter = createLogExporter(destination.protocol, {
4169
4323
  url: formatEndpointUrl(destination.endpoint, "logs", destination.protocol),
4170
4324
  headers: destination.headers
4171
- }) });
4325
+ });
4326
+ let processor = new BatchLogRecordProcessor({ exporter: logExporter });
4172
4327
  if (_stringRedactor) processor = new RedactingLogRecordProcessor(processor, _stringRedactor);
4173
4328
  if (!logRecordProcessors) logRecordProcessors = [];
4174
4329
  logRecordProcessors.push(processor);
@@ -4210,8 +4365,8 @@ function init(cfg) {
4210
4365
  if (metricReaders.length > 0) sdkOptions.metricReaders = metricReaders;
4211
4366
  if (logRecordProcessors && logRecordProcessors.length > 0) sdkOptions.logRecordProcessors = logRecordProcessors;
4212
4367
  else if (!process.env.OTEL_LOGS_EXPORTER) sdkOptions.logRecordProcessors = [];
4213
- sdk = mergedConfig.sdkFactory ? mergedConfig.sdkFactory(sdkOptions) : new NodeSDK(sdkOptions);
4214
- if (!sdk) throw new Error("[autotel] sdkFactory must return a NodeSDK instance");
4368
+ sdk = mergedConfig.sdkFactory ? mergedConfig.sdkFactory(sdkOptions) : new AutotelSdk(sdkOptions);
4369
+ if (!sdk) throw new Error("[autotel] sdkFactory must return an SDK instance");
4215
4370
  sdk.start();
4216
4371
  if (mergedConfig.openllmetry?.enabled) {
4217
4372
  const traceloop = _optionalRequire("@traceloop/node-server-sdk");
@@ -1,17 +1,43 @@
1
1
  import { a as AttributeRedactorPreset, r as AttributeRedactorConfig } from "./attribute-redacting-processor-CvBE0z1p.cjs";
2
2
  import { s as Logger } from "./logger-S1Fgl0g3.cjs";
3
- import { g as SamplingPreset, m as Sampler } from "./sampling-Er217Mge.cjs";
3
+ import { g as SamplingPreset, m as Sampler$1 } from "./sampling-DENUjT_8.cjs";
4
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-C4QcZnqv.cjs";
7
7
  import { r as SpanNameNormalizerConfig } from "./span-name-normalizer-CN1-8C76.cjs";
8
8
  import { t as CanonicalLogLineOptions } from "./canonical-log-line-processor-C0Z_N4oL.cjs";
9
- import { ReadableSpan, SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-base";
10
- import { Attributes } from "@opentelemetry/api";
11
- import { Resource } from "@opentelemetry/resources";
12
- import { NodeSDK, NodeSDKConfiguration } from "@opentelemetry/sdk-node";
13
- import { MetricReader } from "@opentelemetry/sdk-metrics";
9
+ import { BasicTracerProvider, ReadableSpan, SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-base";
10
+ import { Attributes, Sampler, TextMapPropagator } from "@opentelemetry/api";
11
+ import { Resource, ResourceDetector } from "@opentelemetry/resources";
12
+ import { Instrumentation } from "@opentelemetry/instrumentation";
14
13
  import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
14
+ import { IMetricReader, MetricReader } from "@opentelemetry/sdk-metrics";
15
+ //#region src/sdk.d.ts
16
+ /**
17
+ * What `init()` hands the SDK. Field names match `NodeSDKConfiguration` so a
18
+ * `sdkFactory` written against the old shape still receives what it expects.
19
+ */
20
+ interface AutotelSdkOptions {
21
+ resource?: Resource;
22
+ serviceName?: string;
23
+ sampler?: Sampler;
24
+ instrumentations?: (Instrumentation | Instrumentation[])[];
25
+ spanProcessors?: SpanProcessor[];
26
+ metricReaders?: IMetricReader[];
27
+ logRecordProcessors?: LogRecordProcessor[];
28
+ /** `null` leaves whatever propagator is already registered alone. */
29
+ textMapPropagator?: TextMapPropagator | null;
30
+ /** Off by default only via `OTEL_NODE_RESOURCE_DETECTORS=none`. */
31
+ autoDetectResources?: boolean;
32
+ resourceDetectors?: ResourceDetector[];
33
+ }
34
+ /** The surface autotel needs from an SDK handle; `NodeSDK` satisfies it too. */
35
+ interface AutotelSdkLike {
36
+ start(): void;
37
+ shutdown(): Promise<void>;
38
+ getTracerProvider?(): BasicTracerProvider | undefined;
39
+ }
40
+ //#endregion
15
41
  //#region src/validation.d.ts
16
42
  interface ValidationConfig {
17
43
  /** Max event name length (default: 100) */
@@ -432,7 +458,7 @@ interface AutotelConfig {
432
458
  * })
433
459
  * ```
434
460
  */
435
- instrumentations?: NodeSDKConfiguration['instrumentations'];
461
+ instrumentations?: AutotelSdkOptions['instrumentations'];
436
462
  /**
437
463
  * Simple names for auto-instrumentation.
438
464
  * Uses @opentelemetry/auto-instrumentations-node (peer dependency).
@@ -756,9 +782,11 @@ interface AutotelConfig {
756
782
  */
757
783
  protocol?: AutotelProtocol;
758
784
  /**
759
- * Optional factory to build a customised NodeSDK instance from our defaults.
785
+ * Optional factory to build a customised SDK from our defaults. The options
786
+ * use `NodeSDKConfiguration`'s field names, so `new NodeSDK(defaults)` from
787
+ * `@opentelemetry/sdk-node` is a valid return value.
760
788
  */
761
- sdkFactory?: (defaults: Partial<NodeSDKConfiguration>) => NodeSDK;
789
+ sdkFactory?: (defaults: AutotelSdkOptions) => AutotelSdkLike;
762
790
  /**
763
791
  * Infrastructure metrics configuration
764
792
  * - true: always enabled (default)
@@ -794,7 +822,7 @@ interface AutotelConfig {
794
822
  */
795
823
  logs?: boolean | 'auto';
796
824
  /** Sampling strategy - takes precedence over `sampling` preset */
797
- sampler?: Sampler;
825
+ sampler?: Sampler$1;
798
826
  /**
799
827
  * Sampling preset shorthand — resolves to a pre-configured sampler.
800
828
  * If both `sampler` and `sampling` are provided, `sampler` takes precedence.
@@ -1,17 +1,43 @@
1
- import { a as AttributeRedactorPreset, r as AttributeRedactorConfig } from "./attribute-redacting-processor-CvBE0z1p.js";
1
+ import { a as AttributeRedactorPreset, r as AttributeRedactorConfig } from "./attribute-redacting-processor-rkV_WL-k.js";
2
2
  import { s as Logger } from "./logger-S1Fgl0g3.js";
3
- import { g as SamplingPreset, m as Sampler } from "./sampling-DBng4Foa.js";
3
+ import { g as SamplingPreset, m as Sampler$1 } from "./sampling-CZi7OM9u.js";
4
4
  import { o as EventSubscriber } from "./event-subscriber-DMACQA-1.js";
5
- import { r as SpanFilterPredicate } from "./filtering-span-processor-BpDagWNa.js";
6
- import { r as Policy } from "./policy-C4QcZnqv.js";
7
- import { r as SpanNameNormalizerConfig } from "./span-name-normalizer-CN1-8C76.js";
8
- import { t as CanonicalLogLineOptions } from "./canonical-log-line-processor-Yq4cXcD5.js";
9
- import { NodeSDK, NodeSDKConfiguration } from "@opentelemetry/sdk-node";
10
- import { ReadableSpan, SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-base";
11
- import { Resource } from "@opentelemetry/resources";
12
- import { Attributes } from "@opentelemetry/api";
13
- import { MetricReader } from "@opentelemetry/sdk-metrics";
5
+ import { r as SpanFilterPredicate } from "./filtering-span-processor-vkewzbqB.js";
6
+ import { r as Policy } from "./policy-DNw_0qUq.js";
7
+ import { r as SpanNameNormalizerConfig } from "./span-name-normalizer-DHcg1bSP.js";
8
+ import { t as CanonicalLogLineOptions } from "./canonical-log-line-processor-Bwrt_L4c.js";
9
+ import { Attributes, Sampler, TextMapPropagator } from "@opentelemetry/api";
10
+ import { Instrumentation } from "@opentelemetry/instrumentation";
11
+ import { Resource, ResourceDetector } from "@opentelemetry/resources";
14
12
  import { LogRecordProcessor } from "@opentelemetry/sdk-logs";
13
+ import { IMetricReader, MetricReader } from "@opentelemetry/sdk-metrics";
14
+ import { BasicTracerProvider, ReadableSpan, SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace-base";
15
+ //#region src/sdk.d.ts
16
+ /**
17
+ * What `init()` hands the SDK. Field names match `NodeSDKConfiguration` so a
18
+ * `sdkFactory` written against the old shape still receives what it expects.
19
+ */
20
+ interface AutotelSdkOptions {
21
+ resource?: Resource;
22
+ serviceName?: string;
23
+ sampler?: Sampler;
24
+ instrumentations?: (Instrumentation | Instrumentation[])[];
25
+ spanProcessors?: SpanProcessor[];
26
+ metricReaders?: IMetricReader[];
27
+ logRecordProcessors?: LogRecordProcessor[];
28
+ /** `null` leaves whatever propagator is already registered alone. */
29
+ textMapPropagator?: TextMapPropagator | null;
30
+ /** Off by default only via `OTEL_NODE_RESOURCE_DETECTORS=none`. */
31
+ autoDetectResources?: boolean;
32
+ resourceDetectors?: ResourceDetector[];
33
+ }
34
+ /** The surface autotel needs from an SDK handle; `NodeSDK` satisfies it too. */
35
+ interface AutotelSdkLike {
36
+ start(): void;
37
+ shutdown(): Promise<void>;
38
+ getTracerProvider?(): BasicTracerProvider | undefined;
39
+ }
40
+ //#endregion
15
41
  //#region src/validation.d.ts
16
42
  interface ValidationConfig {
17
43
  /** Max event name length (default: 100) */
@@ -432,7 +458,7 @@ interface AutotelConfig {
432
458
  * })
433
459
  * ```
434
460
  */
435
- instrumentations?: NodeSDKConfiguration['instrumentations'];
461
+ instrumentations?: AutotelSdkOptions['instrumentations'];
436
462
  /**
437
463
  * Simple names for auto-instrumentation.
438
464
  * Uses @opentelemetry/auto-instrumentations-node (peer dependency).
@@ -756,9 +782,11 @@ interface AutotelConfig {
756
782
  */
757
783
  protocol?: AutotelProtocol;
758
784
  /**
759
- * Optional factory to build a customised NodeSDK instance from our defaults.
785
+ * Optional factory to build a customised SDK from our defaults. The options
786
+ * use `NodeSDKConfiguration`'s field names, so `new NodeSDK(defaults)` from
787
+ * `@opentelemetry/sdk-node` is a valid return value.
760
788
  */
761
- sdkFactory?: (defaults: Partial<NodeSDKConfiguration>) => NodeSDK;
789
+ sdkFactory?: (defaults: AutotelSdkOptions) => AutotelSdkLike;
762
790
  /**
763
791
  * Infrastructure metrics configuration
764
792
  * - true: always enabled (default)
@@ -794,7 +822,7 @@ interface AutotelConfig {
794
822
  */
795
823
  logs?: boolean | 'auto';
796
824
  /** Sampling strategy - takes precedence over `sampling` preset */
797
- sampler?: Sampler;
825
+ sampler?: Sampler$1;
798
826
  /**
799
827
  * Sampling preset shorthand — resolves to a pre-configured sampler.
800
828
  * If both `sampler` and `sampling` are provided, `sampler` takes precedence.
@@ -1,14 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_init = require('./init-BYXDCfRL.cjs');
3
- const require_node_require = require('./node-require-B_IVapV3.cjs');
4
- let _opentelemetry_sdk_node = require("@opentelemetry/sdk-node");
5
- let _opentelemetry_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
2
+ const require_init = require('./init-21HWbm7_.cjs');
3
+ const require_node_require = require('./node-require-BPsB09eC.cjs');
6
4
  let _opentelemetry_resources = require("@opentelemetry/resources");
7
- let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
5
+ let _opentelemetry_exporter_logs_otlp_http = require("@opentelemetry/exporter-logs-otlp-http");
8
6
  let _opentelemetry_sdk_logs = require("@opentelemetry/sdk-logs");
7
+ let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
8
+ let _opentelemetry_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
9
9
  let _opentelemetry_exporter_metrics_otlp_http = require("@opentelemetry/exporter-metrics-otlp-http");
10
10
  let _opentelemetry_exporter_trace_otlp_http = require("@opentelemetry/exporter-trace-otlp-http");
11
- let _opentelemetry_exporter_logs_otlp_http = require("@opentelemetry/exporter-logs-otlp-http");
11
+ let _opentelemetry_sdk_node = require("@opentelemetry/sdk-node");
12
12
  let _opentelemetry_semantic_conventions_incubating = require("@opentelemetry/semantic-conventions/incubating");
13
13
 
14
14
  //#region src/instrumentation.ts
@@ -120,10 +120,11 @@ async function initInstrumentation(config) {
120
120
  });
121
121
  let instrumentations = config.instrumentations || [];
122
122
  if (config.selectiveInstrumentation === false) instrumentations = [require_node_require.requireModule("@opentelemetry/auto-instrumentations-node").getNodeAutoInstrumentations()];
123
- const spanProcessor = new require_init.TailSamplingSpanProcessor(new _opentelemetry_sdk_trace_base.BatchSpanProcessor(new _opentelemetry_exporter_trace_otlp_http.OTLPTraceExporter({
123
+ const traceExporter = new _opentelemetry_exporter_trace_otlp_http.OTLPTraceExporter({
124
124
  url: `${config.otlpEndpoint || "http://localhost:4318"}/v1/traces`,
125
125
  headers: otlpHeaders
126
- })));
126
+ });
127
+ const spanProcessor = new require_init.TailSamplingSpanProcessor(new _opentelemetry_sdk_trace_base.BatchSpanProcessor(traceExporter));
127
128
  const sdk = new _opentelemetry_sdk_node.NodeSDK({
128
129
  resource,
129
130
  spanProcessor,
@@ -1,13 +1,13 @@
1
- import { r as getLogger, x as TailSamplingSpanProcessor } from "./init-Dyq6WtsO.js";
1
+ import { r as getLogger, x as TailSamplingSpanProcessor } from "./init-8SISAGdE.js";
2
2
  import { n as safeRequire, t as requireModule } from "./node-require-CkK_xzL-.js";
3
- import { NodeSDK } from "@opentelemetry/sdk-node";
4
- import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
5
3
  import { detectResources, hostDetector, processDetector, resourceFromAttributes } from "@opentelemetry/resources";
6
- import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
4
+ import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
7
5
  import { BatchLogRecordProcessor } from "@opentelemetry/sdk-logs";
6
+ import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
7
+ import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
8
8
  import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
9
9
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
10
- import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
10
+ import { NodeSDK } from "@opentelemetry/sdk-node";
11
11
  import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from "@opentelemetry/semantic-conventions/incubating";
12
12
 
13
13
  //#region src/instrumentation.ts
@@ -119,10 +119,11 @@ async function initInstrumentation(config) {
119
119
  });
120
120
  let instrumentations = config.instrumentations || [];
121
121
  if (config.selectiveInstrumentation === false) instrumentations = [requireModule("@opentelemetry/auto-instrumentations-node").getNodeAutoInstrumentations()];
122
- const spanProcessor = new TailSamplingSpanProcessor(new BatchSpanProcessor(new OTLPTraceExporter({
122
+ const traceExporter = new OTLPTraceExporter({
123
123
  url: `${config.otlpEndpoint || "http://localhost:4318"}/v1/traces`,
124
124
  headers: otlpHeaders
125
- })));
125
+ });
126
+ const spanProcessor = new TailSamplingSpanProcessor(new BatchSpanProcessor(traceExporter));
126
127
  const sdk = new NodeSDK({
127
128
  resource,
128
129
  spanProcessor,
@@ -1,4 +1,4 @@
1
- const require_values = require('./values-tm4bi0FF.cjs');
1
+ const require_values = require('./values-AxGpgYBA.cjs');
2
2
  const require_config = require('./config.cjs');
3
3
  let _opentelemetry_api = require("@opentelemetry/api");
4
4
 
package/dist/logger.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_logger = require('./logger-CSdZkxbh.cjs');
2
+ const require_logger = require('./logger-DLjHQAus.cjs');
3
3
 
4
4
  exports.LOG_LEVEL = require_logger.LOG_LEVEL;
5
5
  exports.LoggedOperation = require_logger.LoggedOperation;
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_values = require('./values-tm4bi0FF.cjs');
2
+ const require_values = require('./values-AxGpgYBA.cjs');
3
3
  let _opentelemetry_api = require("@opentelemetry/api");
4
4
 
5
5
  //#region src/messaging-adapters.ts
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/messaging-testing.ts
4
3
  /**
5
4
  * Generate a random hex string
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_values = require('./values-tm4bi0FF.cjs');
3
- const require_init = require('./init-BYXDCfRL.cjs');
4
- const require_functional = require('./functional-UIJ0CaTV.cjs');
5
- const require_correlated_events = require('./correlated-events-9RRdfyWR.cjs');
6
- const require_trace_factory_validation = require('./trace-factory-validation-Dc8epn87.cjs');
2
+ const require_init = require('./init-21HWbm7_.cjs');
3
+ const require_values = require('./values-AxGpgYBA.cjs');
4
+ const require_functional = require('./functional-u5Qwjray.cjs');
5
+ const require_correlated_events = require('./correlated-events-DE_4A3oD.cjs');
6
+ const require_trace_factory_validation = require('./trace-factory-validation-CHU1WcjK.cjs');
7
7
  let _opentelemetry_api = require("@opentelemetry/api");
8
8
 
9
9
  //#region src/messaging.ts
@@ -362,11 +362,12 @@ function extendContextForConsumer(baseCtx, config, linkStorage, orderingState, g
362
362
  context: options.originalDLQSpanContext,
363
363
  attributes: { "messaging.link.source": "dlq_replay" }
364
364
  }]);
365
- require_correlated_events.emitCorrelatedEvent(baseCtx, "dlq_replay", {
365
+ const eventAttrs = {
366
366
  "messaging.replay": true,
367
367
  ...options?.replayAttempt !== void 0 && { "messaging.replay.attempt": options.replayAttempt },
368
368
  ...options?.dlqDwellTimeMs !== void 0 && { "messaging.replay.dwell_time_ms": options.dlqDwellTimeMs }
369
- });
369
+ };
370
+ require_correlated_events.emitCorrelatedEvent(baseCtx, "dlq_replay", eventAttrs);
370
371
  },
371
372
  recordRetry(attemptNumber, maxAttempts) {
372
373
  baseCtx.setAttribute("messaging.retry.count", attemptNumber);
package/dist/messaging.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { F as createLinkFromHeaders, L as extractLinksFromBatch } from "./init-8SISAGdE.js";
1
2
  import { _ as readProperty, b as toAttributeValue, c as asScalar, g as nonEmptyString, h as isFunction, s as asRecord, v as resolveValue, y as splitNameOrOptions } from "./values-xBtdXtjA.js";
2
- import { F as createLinkFromHeaders, L as extractLinksFromBatch } from "./init-Dyq6WtsO.js";
3
- import { l as withTracing } from "./functional-S9IJNlBn.js";
3
+ import { l as withTracing } from "./functional-CC2BFGAO.js";
4
4
  import { t as emitCorrelatedEvent } from "./correlated-events-BfpH5uS-.js";
5
5
  import { t as assertTraceFactory } from "./trace-factory-validation-BjVAinz6.js";
6
6
  import { SpanKind, context, propagation } from "@opentelemetry/api";
@@ -361,11 +361,12 @@ function extendContextForConsumer(baseCtx, config, linkStorage, orderingState, g
361
361
  context: options.originalDLQSpanContext,
362
362
  attributes: { "messaging.link.source": "dlq_replay" }
363
363
  }]);
364
- emitCorrelatedEvent(baseCtx, "dlq_replay", {
364
+ const eventAttrs = {
365
365
  "messaging.replay": true,
366
366
  ...options?.replayAttempt !== void 0 && { "messaging.replay.attempt": options.replayAttempt },
367
367
  ...options?.dlqDwellTimeMs !== void 0 && { "messaging.replay.dwell_time_ms": options.dlqDwellTimeMs }
368
- });
368
+ };
369
+ emitCorrelatedEvent(baseCtx, "dlq_replay", eventAttrs);
369
370
  },
370
371
  recordRetry(attemptNumber, maxAttempts) {
371
372
  baseCtx.setAttribute("messaging.retry.count", attemptNumber);
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
2
  //#region src/metric-testing.ts
4
3
  /**
5
4
  * Create an in-memory metrics collector for testing
@@ -1,5 +1,5 @@
1
- const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
2
- const require_values = require('./values-tm4bi0FF.cjs');
1
+ const require_rolldown_runtime = require('./rolldown-runtime-C24Yb2bl.cjs');
2
+ const require_values = require('./values-AxGpgYBA.cjs');
3
3
  let node_module = require("node:module");
4
4
  node_module = require_rolldown_runtime.__toESM(node_module, 1);
5
5
 
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_values = require('./values-tm4bi0FF.cjs');
2
+ const require_values = require('./values-AxGpgYBA.cjs');
3
3
 
4
4
  //#region src/parse-error.ts
5
5
  /** An HTTP-ish status, however the library that threw chose to spell it. */
@@ -1,6 +1,6 @@
1
- import { ReadableSpan } from "@opentelemetry/sdk-trace-base";
2
1
  import { Context } from "@opentelemetry/api";
3
2
  import { LogRecordProcessor, SdkLogRecord } from "@opentelemetry/sdk-logs";
3
+ import { ReadableSpan } from "@opentelemetry/sdk-trace-base";
4
4
  //#region src/policy.d.ts
5
5
  /** A path into an attribute. `"ccn"` and `["ccn"]` are equivalent. */
6
6
  type AttributePath = string | string[];
package/dist/policy.cjs CHANGED
Binary file