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.
Files changed (166) hide show
  1. package/README.md +30 -23
  2. package/dist/{attribute-redacting-processor-Pk7lAzWd.d.cts → attribute-redacting-processor-CvBE0z1p.d.cts} +33 -1
  3. package/dist/{attribute-redacting-processor-Pk7lAzWd.d.ts → attribute-redacting-processor-CvBE0z1p.d.ts} +33 -1
  4. package/dist/attribute-redacting-processor.cjs +34 -32
  5. package/dist/attribute-redacting-processor.d.cts +1 -1
  6. package/dist/attribute-redacting-processor.d.ts +1 -1
  7. package/dist/attribute-redacting-processor.js +35 -32
  8. package/dist/{attributes-aDmJYral.cjs → attributes-Cxys8tgr.cjs} +34 -35
  9. package/dist/{attributes-B7wix2VG.js → attributes-Dt4YUYbP.js} +34 -35
  10. package/dist/attributes.cjs +1 -1
  11. package/dist/attributes.d.cts +1 -1
  12. package/dist/attributes.d.ts +1 -1
  13. package/dist/attributes.js +1 -1
  14. package/dist/auto.cjs +1 -1
  15. package/dist/auto.js +1 -1
  16. package/dist/business-baggage.cjs +19 -12
  17. package/dist/business-baggage.d.cts +8 -3
  18. package/dist/business-baggage.d.ts +8 -3
  19. package/dist/business-baggage.js +19 -12
  20. package/dist/{canonical-log-line-processor-DxtBGZIi.cjs → canonical-log-line-processor-DolzdawH.cjs} +43 -32
  21. package/dist/{canonical-log-line-processor-B4WgG-VS.d.cts → canonical-log-line-processor-cPB4Axk-.d.ts} +4 -3
  22. package/dist/{canonical-log-line-processor-B0vq_QR6.js → canonical-log-line-processor-hFUmS__K.js} +43 -32
  23. package/dist/{canonical-log-line-processor-CL_J7gb5.d.ts → canonical-log-line-processor-l0Aqe6yp.d.cts} +4 -3
  24. package/dist/config.d.cts +1 -1
  25. package/dist/config.d.ts +1 -1
  26. package/dist/{correlated-events-kSwLo3mi.cjs → correlated-events-CcuknWnU.cjs} +2 -1
  27. package/dist/{correlated-events-Bzh5y-UB.js → correlated-events-DwMMbItg.js} +3 -1
  28. package/dist/correlation-id.cjs +1 -1
  29. package/dist/correlation-id.js +1 -1
  30. package/dist/db.cjs +34 -19
  31. package/dist/db.js +34 -19
  32. package/dist/decorators.cjs +4 -2
  33. package/dist/decorators.d.cts +16 -11
  34. package/dist/decorators.d.ts +16 -11
  35. package/dist/decorators.js +4 -2
  36. package/dist/{define-event-CGG048HE.d.cts → define-event-BNeuKUPv.d.cts} +1 -1
  37. package/dist/{define-event-B2z1SBe7.d.ts → define-event-Bd8f8mST.d.ts} +1 -1
  38. package/dist/diagnostics.cjs +18 -16
  39. package/dist/diagnostics.d.cts +14 -10
  40. package/dist/diagnostics.d.ts +14 -10
  41. package/dist/diagnostics.js +18 -16
  42. package/dist/{event-subscriber-CWh8sTGh.d.cts → event-subscriber-DMACQA-1.d.cts} +19 -9
  43. package/dist/{event-subscriber-CWh8sTGh.d.ts → event-subscriber-DMACQA-1.d.ts} +19 -9
  44. package/dist/event-subscriber.d.cts +2 -2
  45. package/dist/event-subscriber.d.ts +2 -2
  46. package/dist/{event-testing-D0qWfqAy.d.cts → event-testing-CBtnJXE5.d.cts} +1 -1
  47. package/dist/{event-testing-CA2mIx1E.d.ts → event-testing-CkPgV3Ii.d.ts} +1 -1
  48. package/dist/event-testing.d.cts +1 -1
  49. package/dist/event-testing.d.ts +1 -1
  50. package/dist/event.cjs +1 -1
  51. package/dist/event.d.cts +5 -5
  52. package/dist/event.d.ts +5 -5
  53. package/dist/event.js +1 -1
  54. package/dist/exception-fingerprint.cjs +133 -0
  55. package/dist/exception-fingerprint.d.cts +51 -0
  56. package/dist/exception-fingerprint.d.ts +51 -0
  57. package/dist/exception-fingerprint.js +126 -0
  58. package/dist/{functional-e6jw5zQj.d.cts → functional-CJn2zY4o.d.cts} +96 -39
  59. package/dist/{functional-AT22vCw6.d.ts → functional-DXy1cHFF.d.ts} +96 -39
  60. package/dist/{functional-C0uAZq2X.cjs → functional-Da6Yv64r.cjs} +27 -15
  61. package/dist/{functional-DX7Zvag0.js → functional-uSbNnnxK.js} +27 -15
  62. package/dist/functional.cjs +1 -1
  63. package/dist/functional.d.cts +2 -2
  64. package/dist/functional.d.ts +2 -2
  65. package/dist/functional.js +1 -1
  66. package/dist/http.cjs +11 -8
  67. package/dist/http.js +11 -8
  68. package/dist/{index-DolOVX6F.d.ts → index-CwrNAsgk.d.ts} +22 -26
  69. package/dist/{index-BPcxVucm.d.cts → index-DQHf4cNl.d.cts} +22 -26
  70. package/dist/index.cjs +41 -35
  71. package/dist/index.d.cts +45 -30
  72. package/dist/index.d.ts +45 -30
  73. package/dist/index.js +41 -35
  74. package/dist/{init-pPI3JRRf.d.ts → init-BgnYi2sm.d.ts} +6 -6
  75. package/dist/{init-CTtHITlX.cjs → init-D4m5rCmD.cjs} +110 -84
  76. package/dist/{init-ncTMKZ-s.d.cts → init-DrlL1eis.d.cts} +6 -6
  77. package/dist/{init-WHYwyItd.js → init-JtX-KKz_.js} +105 -85
  78. package/dist/instrumentation.cjs +2 -2
  79. package/dist/instrumentation.js +2 -2
  80. package/dist/{logger-D3Ej3DII.js → logger-DdPp__xW.js} +63 -54
  81. package/dist/{logger-CN4xpzMd.d.cts → logger-S1Fgl0g3.d.cts} +0 -20
  82. package/dist/{logger-CN4xpzMd.d.ts → logger-S1Fgl0g3.d.ts} +0 -20
  83. package/dist/{logger-thMPLpOG.cjs → logger-Sm66cjKl.cjs} +63 -54
  84. package/dist/logger.cjs +1 -1
  85. package/dist/logger.d.cts +1 -1
  86. package/dist/logger.d.ts +1 -1
  87. package/dist/logger.js +1 -1
  88. package/dist/messaging-adapters.cjs +26 -12
  89. package/dist/messaging-adapters.d.cts +0 -30
  90. package/dist/messaging-adapters.d.ts +0 -30
  91. package/dist/messaging-adapters.js +26 -12
  92. package/dist/messaging.cjs +37 -34
  93. package/dist/messaging.d.cts +21 -62
  94. package/dist/messaging.d.ts +21 -62
  95. package/dist/messaging.js +37 -34
  96. package/dist/{metric-testing-CpvP3ZIa.d.cts → metric-testing-86WO1wan.d.cts} +1 -1
  97. package/dist/{metric-testing-CWm6UhaR.d.ts → metric-testing-CbCxdPBp.d.ts} +1 -1
  98. package/dist/metric-testing.d.cts +1 -1
  99. package/dist/metric-testing.d.ts +1 -1
  100. package/dist/metric.d.cts +3 -3
  101. package/dist/metric.d.ts +3 -3
  102. package/dist/{node-require-vROmTeJ8.js → node-require-DSPjaw_l.js} +3 -2
  103. package/dist/{node-require-PFqDihze.cjs → node-require-EifOMikz.cjs} +3 -2
  104. package/dist/parse-error.cjs +18 -12
  105. package/dist/parse-error.d.cts +2 -1
  106. package/dist/parse-error.d.ts +2 -1
  107. package/dist/parse-error.js +19 -12
  108. package/dist/policy.cjs +0 -0
  109. package/dist/policy.js +0 -0
  110. package/dist/processors.cjs +1 -1
  111. package/dist/processors.d.cts +1 -1
  112. package/dist/processors.d.ts +1 -1
  113. package/dist/processors.js +1 -1
  114. package/dist/{sampling-BR9fkSwx.d.cts → sampling-CM5S2Lp3.d.ts} +5 -6
  115. package/dist/{sampling-CP3e7-Yr.d.ts → sampling-CmRdnXUi.d.cts} +5 -6
  116. package/dist/sampling.cjs +3 -2
  117. package/dist/sampling.d.cts +1 -1
  118. package/dist/sampling.d.ts +1 -1
  119. package/dist/sampling.js +3 -2
  120. package/dist/semantic-helpers.cjs +9 -9
  121. package/dist/semantic-helpers.d.cts +1 -1
  122. package/dist/semantic-helpers.d.ts +1 -1
  123. package/dist/semantic-helpers.js +9 -9
  124. package/dist/{stable-hash-ChFBIhNt.js → stable-hash-BkoAYVks.js} +4 -3
  125. package/dist/{stable-hash-CS9BxvVQ.cjs → stable-hash-C0pOegH_.cjs} +4 -3
  126. package/dist/{structured-error-CHg7DoIQ.cjs → structured-error--_wXpd_C.cjs} +34 -25
  127. package/dist/{structured-error-9--cxBay.js → structured-error-YIuka-FE.js} +34 -25
  128. package/dist/test-span-collector.cjs +15 -8
  129. package/dist/test-span-collector.js +15 -8
  130. package/dist/testing.cjs +16 -18
  131. package/dist/testing.d.cts +7 -6
  132. package/dist/testing.d.ts +7 -6
  133. package/dist/testing.js +16 -18
  134. package/dist/{trace-context-IuyoPyNq.d.cts → trace-context-C1Cn1q0y.d.cts} +8 -7
  135. package/dist/{trace-context-IuyoPyNq.d.ts → trace-context-f89xPJbK.d.ts} +8 -7
  136. package/dist/trace-helpers.cjs +16 -13
  137. package/dist/trace-helpers.d.cts +9 -4
  138. package/dist/trace-helpers.d.ts +9 -4
  139. package/dist/trace-helpers.js +16 -13
  140. package/dist/tracer-provider.cjs +8 -12
  141. package/dist/tracer-provider.js +8 -12
  142. package/dist/validate.cjs +22 -20
  143. package/dist/validate.d.cts +3 -2
  144. package/dist/validate.d.ts +3 -2
  145. package/dist/validate.js +22 -20
  146. package/dist/values-BenyvWKz.js +141 -0
  147. package/dist/values-CeMH-mYG.d.cts +8 -0
  148. package/dist/values-CeMH-mYG.d.ts +8 -0
  149. package/dist/values-DApyq53y.cjs +267 -0
  150. package/dist/webhook.cjs +3 -3
  151. package/dist/webhook.d.cts +1 -1
  152. package/dist/webhook.d.ts +1 -1
  153. package/dist/webhook.js +3 -3
  154. package/dist/workflow-distributed.cjs +9 -7
  155. package/dist/workflow-distributed.d.cts +9 -8
  156. package/dist/workflow-distributed.d.ts +9 -8
  157. package/dist/workflow-distributed.js +9 -7
  158. package/dist/workflow.cjs +26 -17
  159. package/dist/workflow.d.cts +1 -28
  160. package/dist/workflow.d.ts +1 -28
  161. package/dist/workflow.js +26 -17
  162. package/dist/yaml-config.cjs +26 -11
  163. package/dist/yaml-config.d.cts +9 -3
  164. package/dist/yaml-config.d.ts +9 -3
  165. package/dist/yaml-config.js +26 -11
  166. package/package.json +6 -1
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_values = require('./values-DApyq53y.cjs');
2
3
  let _opentelemetry_api = require("@opentelemetry/api");
3
4
 
4
5
  //#region src/test-span-collector.ts
@@ -66,17 +67,23 @@ var TestSpanCollector = class {
66
67
  function hrTimeToMs(hr) {
67
68
  return hr[0] * 1e3 + hr[1] / 1e6;
68
69
  }
69
- function isSerializable(v) {
70
- if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") return true;
71
- if (Array.isArray(v) && v.length > 0) {
72
- const t = typeof v[0];
73
- return (t === "string" || t === "number" || t === "boolean") && v.every((e) => typeof e === t);
74
- }
75
- return false;
70
+ /**
71
+ * An attribute value in the form that survives a round trip through JSON: a
72
+ * scalar, or a list whose entries are all the same kind of scalar. Anything
73
+ * else - a mixed list, an empty one - is left out of the serialized span.
74
+ */
75
+ function asSerializable(value) {
76
+ const scalar = require_values.asScalar(value);
77
+ if (scalar !== void 0) return scalar;
78
+ if (!Array.isArray(value) || value.length === 0) return void 0;
79
+ return require_values.asStringArray(value) ?? require_values.asNumberArray(value) ?? require_values.asBooleanArray(value);
76
80
  }
77
81
  function serializeSpan(span) {
78
82
  const attrs = {};
79
- for (const [k, v] of Object.entries(span.attributes)) if (isSerializable(v)) attrs[k] = v;
83
+ for (const [k, v] of Object.entries(span.attributes)) {
84
+ const serializable = asSerializable(v);
85
+ if (serializable !== void 0) attrs[k] = serializable;
86
+ }
80
87
  return {
81
88
  spanId: span.spanContext().spanId,
82
89
  parentSpanId: span.parentSpanContext?.spanId || void 0,
@@ -1,3 +1,4 @@
1
+ import { a as asNumberArray, c as asScalar, n as asBooleanArray, u as asStringArray } from "./values-BenyvWKz.js";
1
2
  import { SpanStatusCode } from "@opentelemetry/api";
2
3
 
3
4
  //#region src/test-span-collector.ts
@@ -65,17 +66,23 @@ var TestSpanCollector = class {
65
66
  function hrTimeToMs(hr) {
66
67
  return hr[0] * 1e3 + hr[1] / 1e6;
67
68
  }
68
- function isSerializable(v) {
69
- if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") return true;
70
- if (Array.isArray(v) && v.length > 0) {
71
- const t = typeof v[0];
72
- return (t === "string" || t === "number" || t === "boolean") && v.every((e) => typeof e === t);
73
- }
74
- return false;
69
+ /**
70
+ * An attribute value in the form that survives a round trip through JSON: a
71
+ * scalar, or a list whose entries are all the same kind of scalar. Anything
72
+ * else - a mixed list, an empty one - is left out of the serialized span.
73
+ */
74
+ function asSerializable(value) {
75
+ const scalar = asScalar(value);
76
+ if (scalar !== void 0) return scalar;
77
+ if (!Array.isArray(value) || value.length === 0) return void 0;
78
+ return asStringArray(value) ?? asNumberArray(value) ?? asBooleanArray(value);
75
79
  }
76
80
  function serializeSpan(span) {
77
81
  const attrs = {};
78
- for (const [k, v] of Object.entries(span.attributes)) if (isSerializable(v)) attrs[k] = v;
82
+ for (const [k, v] of Object.entries(span.attributes)) {
83
+ const serializable = asSerializable(v);
84
+ if (serializable !== void 0) attrs[k] = serializable;
85
+ }
79
86
  return {
80
87
  spanId: span.spanContext().spanId,
81
88
  parentSpanId: span.parentSpanContext?.spanId || void 0,
package/dist/testing.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
3
+ const require_values = require('./values-DApyq53y.cjs');
3
4
  const require_config = require('./config.cjs');
4
5
  const require_event_testing = require('./event-testing.cjs');
5
6
  const require_test_span_collector = require('./test-span-collector.cjs');
@@ -100,7 +101,7 @@ function createTraceCollector() {
100
101
  return this;
101
102
  },
102
103
  addEvent(name, attributesOrStartTime, startTime) {
103
- const attributes = attributesOrStartTime && !Array.isArray(attributesOrStartTime) && typeof attributesOrStartTime === "object" ? attributesOrStartTime : void 0;
104
+ const attributes = require_values.asRecord(attributesOrStartTime);
104
105
  spanData.events.push({
105
106
  name,
106
107
  attributes
@@ -149,14 +150,10 @@ function createTraceCollector() {
149
150
  return createMockSpan(name, startTime, parent, options);
150
151
  },
151
152
  startActiveSpan(name, optionsOrFn, contextOrFn, fn) {
152
- const callback = (() => {
153
- if (typeof optionsOrFn === "function") return optionsOrFn;
154
- if (typeof contextOrFn === "function") return contextOrFn;
155
- if (fn) return fn;
156
- throw new Error("startActiveSpan requires a callback");
157
- })();
153
+ const callback = typeof optionsOrFn === "function" ? optionsOrFn : typeof contextOrFn === "function" ? contextOrFn : fn;
154
+ if (!callback) throw new Error("startActiveSpan requires a callback");
158
155
  const startTime = performance.now();
159
- const suppliedContext = typeof optionsOrFn === "function" ? _opentelemetry_api.context.active() : typeof contextOrFn === "function" || contextOrFn === void 0 ? _opentelemetry_api.context.active() : contextOrFn;
156
+ const suppliedContext = typeof optionsOrFn === "function" || typeof contextOrFn === "function" || contextOrFn === void 0 ? _opentelemetry_api.context.active() : contextOrFn;
160
157
  const parent = _opentelemetry_api.trace.getSpan(suppliedContext)?.spanContext() ?? activeMockSpanStorage.getStore()?.spanContext();
161
158
  const mockSpan = createMockSpan(name, startTime, parent, typeof optionsOrFn === "function" ? void 0 : optionsOrFn);
162
159
  const ctx = _opentelemetry_api.trace.setSpan(suppliedContext, mockSpan);
@@ -329,15 +326,15 @@ function createMockLogger() {
329
326
  const logs = [];
330
327
  const createLogMethod = (level) => {
331
328
  return (objOrMsg, msg) => {
332
- if (typeof objOrMsg === "string") logs.push({
333
- level,
334
- message: objOrMsg,
335
- extra: void 0
336
- });
337
- else logs.push({
329
+ const message = require_values.asString(objOrMsg);
330
+ logs.push(message === void 0 ? {
338
331
  level,
339
332
  message: msg || "",
340
- extra: objOrMsg
333
+ extra: require_values.asRecord(objOrMsg)
334
+ } : {
335
+ level,
336
+ message,
337
+ extra: void 0
341
338
  });
342
339
  };
343
340
  };
@@ -346,16 +343,17 @@ function createMockLogger() {
346
343
  warn: createLogMethod("warn"),
347
344
  debug: createLogMethod("debug"),
348
345
  error(objOrMsg, msg) {
349
- if (typeof objOrMsg === "string") {
346
+ const message = require_values.asString(objOrMsg);
347
+ if (message !== void 0) {
350
348
  logs.push({
351
349
  level: "error",
352
- message: objOrMsg,
350
+ message,
353
351
  extra: void 0,
354
352
  error: void 0
355
353
  });
356
354
  return;
357
355
  }
358
- const { err, ...rest } = objOrMsg;
356
+ const { err, ...rest } = require_values.asRecord(objOrMsg) ?? {};
359
357
  logs.push({
360
358
  level: "error",
361
359
  message: msg || "",
@@ -1,5 +1,6 @@
1
- import { s as Logger } from "./logger-CN4xpzMd.cjs";
2
- import { a as EventsValue, c as createEventCollector, i as EventsOutcome, n as EventData, o as assertEventTracked, r as EventsFunnelStep, s as assertOutcomeTracked, t as EventCollector } from "./event-testing-D0qWfqAy.cjs";
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.cjs";
2
+ import { s as Logger } from "./logger-S1Fgl0g3.cjs";
3
+ import { a as EventsValue, c as createEventCollector, i as EventsOutcome, n as EventData, o as assertEventTracked, r as EventsFunnelStep, s as assertOutcomeTracked, t as EventCollector } from "./event-testing-CBtnJXE5.cjs";
3
4
  import { SerializedSpan, TestSpanCollector, serializeSpan } from "./test-span-collector.cjs";
4
5
  import { Attributes, Link, SpanKind, SpanStatus, SpanStatusCode } from "@opentelemetry/api";
5
6
  //#region src/testing.d.ts
@@ -60,7 +61,7 @@ interface SpanMatch {
60
61
  spanId?: string;
61
62
  parentSpanId?: string;
62
63
  kind?: SpanKind;
63
- attributes?: Record<string, unknown>;
64
+ attributes?: Attributes;
64
65
  }
65
66
  /**
66
67
  * In-memory trace collector for testing
@@ -71,7 +72,7 @@ interface TraceCollector {
71
72
  /** Get spans matching a name */
72
73
  getSpansByName(name: string): TestSpan[];
73
74
  /** Get spans matching attributes */
74
- getSpansByAttributes(attributes: Record<string, unknown>): TestSpan[];
75
+ getSpansByAttributes(attributes: Attributes): TestSpan[];
75
76
  /** Get spans belonging to a trace */
76
77
  getSpansByTraceId(traceId: string): TestSpan[];
77
78
  /** Get spans without a recorded parent */
@@ -135,7 +136,7 @@ declare function assertTraceCreated(collector: TraceCollector, operationName: st
135
136
  minCount?: number;
136
137
  maxCount?: number;
137
138
  status?: SpanStatusCode;
138
- attributes?: Record<string, unknown>;
139
+ attributes?: Attributes;
139
140
  }): void;
140
141
  /**
141
142
  * Assert that no errors were logged
@@ -199,7 +200,7 @@ interface LogCollector {
199
200
  interface LogEntry {
200
201
  level: 'info' | 'warn' | 'error' | 'debug';
201
202
  message: string;
202
- extra?: Record<string, unknown>;
203
+ extra?: UnknownRecord;
203
204
  error?: Error;
204
205
  }
205
206
  /**
package/dist/testing.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { s as Logger } from "./logger-CN4xpzMd.js";
2
- import { a as EventsValue, c as createEventCollector, i as EventsOutcome, n as EventData, o as assertEventTracked, r as EventsFunnelStep, s as assertOutcomeTracked, t as EventCollector } from "./event-testing-CA2mIx1E.js";
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.js";
2
+ import { s as Logger } from "./logger-S1Fgl0g3.js";
3
+ import { a as EventsValue, c as createEventCollector, i as EventsOutcome, n as EventData, o as assertEventTracked, r as EventsFunnelStep, s as assertOutcomeTracked, t as EventCollector } from "./event-testing-CkPgV3Ii.js";
3
4
  import { SerializedSpan, TestSpanCollector, serializeSpan } from "./test-span-collector.js";
4
5
  import { Attributes, Link, SpanKind, SpanStatus, SpanStatusCode } from "@opentelemetry/api";
5
6
  //#region src/testing.d.ts
@@ -60,7 +61,7 @@ interface SpanMatch {
60
61
  spanId?: string;
61
62
  parentSpanId?: string;
62
63
  kind?: SpanKind;
63
- attributes?: Record<string, unknown>;
64
+ attributes?: Attributes;
64
65
  }
65
66
  /**
66
67
  * In-memory trace collector for testing
@@ -71,7 +72,7 @@ interface TraceCollector {
71
72
  /** Get spans matching a name */
72
73
  getSpansByName(name: string): TestSpan[];
73
74
  /** Get spans matching attributes */
74
- getSpansByAttributes(attributes: Record<string, unknown>): TestSpan[];
75
+ getSpansByAttributes(attributes: Attributes): TestSpan[];
75
76
  /** Get spans belonging to a trace */
76
77
  getSpansByTraceId(traceId: string): TestSpan[];
77
78
  /** Get spans without a recorded parent */
@@ -135,7 +136,7 @@ declare function assertTraceCreated(collector: TraceCollector, operationName: st
135
136
  minCount?: number;
136
137
  maxCount?: number;
137
138
  status?: SpanStatusCode;
138
- attributes?: Record<string, unknown>;
139
+ attributes?: Attributes;
139
140
  }): void;
140
141
  /**
141
142
  * Assert that no errors were logged
@@ -199,7 +200,7 @@ interface LogCollector {
199
200
  interface LogEntry {
200
201
  level: 'info' | 'warn' | 'error' | 'debug';
201
202
  message: string;
202
- extra?: Record<string, unknown>;
203
+ extra?: UnknownRecord;
203
204
  error?: Error;
204
205
  }
205
206
  /**
package/dist/testing.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { l as asString, s as asRecord } from "./values-BenyvWKz.js";
1
2
  import { configure } from "./config.js";
2
3
  import { assertEventTracked, assertOutcomeTracked, createEventCollector } from "./event-testing.js";
3
4
  import { TestSpanCollector, serializeSpan } from "./test-span-collector.js";
@@ -97,7 +98,7 @@ function createTraceCollector() {
97
98
  return this;
98
99
  },
99
100
  addEvent(name, attributesOrStartTime, startTime) {
100
- const attributes = attributesOrStartTime && !Array.isArray(attributesOrStartTime) && typeof attributesOrStartTime === "object" ? attributesOrStartTime : void 0;
101
+ const attributes = asRecord(attributesOrStartTime);
101
102
  spanData.events.push({
102
103
  name,
103
104
  attributes
@@ -146,14 +147,10 @@ function createTraceCollector() {
146
147
  return createMockSpan(name, startTime, parent, options);
147
148
  },
148
149
  startActiveSpan(name, optionsOrFn, contextOrFn, fn) {
149
- const callback = (() => {
150
- if (typeof optionsOrFn === "function") return optionsOrFn;
151
- if (typeof contextOrFn === "function") return contextOrFn;
152
- if (fn) return fn;
153
- throw new Error("startActiveSpan requires a callback");
154
- })();
150
+ const callback = typeof optionsOrFn === "function" ? optionsOrFn : typeof contextOrFn === "function" ? contextOrFn : fn;
151
+ if (!callback) throw new Error("startActiveSpan requires a callback");
155
152
  const startTime = performance.now();
156
- const suppliedContext = typeof optionsOrFn === "function" ? context.active() : typeof contextOrFn === "function" || contextOrFn === void 0 ? context.active() : contextOrFn;
153
+ const suppliedContext = typeof optionsOrFn === "function" || typeof contextOrFn === "function" || contextOrFn === void 0 ? context.active() : contextOrFn;
157
154
  const parent = trace.getSpan(suppliedContext)?.spanContext() ?? activeMockSpanStorage.getStore()?.spanContext();
158
155
  const mockSpan = createMockSpan(name, startTime, parent, typeof optionsOrFn === "function" ? void 0 : optionsOrFn);
159
156
  const ctx = trace.setSpan(suppliedContext, mockSpan);
@@ -326,15 +323,15 @@ function createMockLogger() {
326
323
  const logs = [];
327
324
  const createLogMethod = (level) => {
328
325
  return (objOrMsg, msg) => {
329
- if (typeof objOrMsg === "string") logs.push({
330
- level,
331
- message: objOrMsg,
332
- extra: void 0
333
- });
334
- else logs.push({
326
+ const message = asString(objOrMsg);
327
+ logs.push(message === void 0 ? {
335
328
  level,
336
329
  message: msg || "",
337
- extra: objOrMsg
330
+ extra: asRecord(objOrMsg)
331
+ } : {
332
+ level,
333
+ message,
334
+ extra: void 0
338
335
  });
339
336
  };
340
337
  };
@@ -343,16 +340,17 @@ function createMockLogger() {
343
340
  warn: createLogMethod("warn"),
344
341
  debug: createLogMethod("debug"),
345
342
  error(objOrMsg, msg) {
346
- if (typeof objOrMsg === "string") {
343
+ const message = asString(objOrMsg);
344
+ if (message !== void 0) {
347
345
  logs.push({
348
346
  level: "error",
349
- message: objOrMsg,
347
+ message,
350
348
  extra: void 0,
351
349
  error: void 0
352
350
  });
353
351
  return;
354
352
  }
355
- const { err, ...rest } = objOrMsg;
353
+ const { err, ...rest } = asRecord(objOrMsg) ?? {};
356
354
  logs.push({
357
355
  level: "error",
358
356
  message: msg || "",
@@ -1,3 +1,4 @@
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.cjs";
1
2
  import { AttributeValue, Attributes, BaggageEntry, Context, Link, Span, SpanStatusCode } from "@opentelemetry/api";
2
3
  import { AsyncLocalStorage } from "node:async_hooks";
3
4
  //#region src/trace-context.d.ts
@@ -44,21 +45,21 @@ interface SpanMethods {
44
45
  * Replaces the deprecated `recordException` (OTEP 4430). Accepts `unknown`
45
46
  * so it can be called directly with the value caught from a `catch` block.
46
47
  */
47
- recordError(error: unknown): void;
48
+ recordError(cause: unknown): void;
48
49
  /**
49
50
  * Emit a tracked event correlated to this span. Equivalent to the standalone
50
51
  * `track(event, data)` but reads naturally on `ctx`. Replaces the deprecated
51
52
  * `ctx.addEvent` (OTEP 4430) — events become correlated logs rather than
52
53
  * span events.
53
54
  */
54
- track<Events extends Record<string, unknown> = Record<string, unknown>>(event: keyof Events & string, data?: Events[keyof Events & string]): void;
55
+ track<Events extends UnknownRecord = UnknownRecord>(event: keyof Events & string, data?: Events[keyof Events & string]): void;
55
56
  }
56
57
  /**
57
58
  * Baggage methods available on trace context
58
59
  *
59
60
  * @template TBaggage - Optional type for typed baggage (defaults to undefined for untyped)
60
61
  */
61
- interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined = undefined> {
62
+ interface BaggageMethods<TBaggage extends UnknownRecord | undefined = undefined> {
62
63
  /**
63
64
  * Get a baggage entry by key
64
65
  * @param key - Baggage key
@@ -104,14 +105,14 @@ interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined =
104
105
  *
105
106
  * @internal
106
107
  */
107
- getTypedBaggage?: TBaggage extends Record<string, unknown> ? <T extends TBaggage>(namespace?: string) => Partial<T> | undefined : never;
108
+ getTypedBaggage?: TBaggage extends UnknownRecord ? <T extends TBaggage>(namespace?: string) => Partial<T> | undefined : never;
108
109
  /**
109
110
  * Set typed baggage (only available when TBaggage is defined)
110
111
  * This is used internally by defineBaggageSchema()
111
112
  *
112
113
  * @internal
113
114
  */
114
- setTypedBaggage?: TBaggage extends Record<string, unknown> ? <T extends TBaggage>(namespace: string | undefined, value: Partial<T>) => void : never;
115
+ setTypedBaggage?: TBaggage extends UnknownRecord ? <T extends TBaggage>(namespace: string | undefined, value: Partial<T>) => void : never;
115
116
  }
116
117
  /**
117
118
  * Complete trace context that merges base context, span methods, and baggage methods
@@ -140,7 +141,7 @@ interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined =
140
141
  * });
141
142
  * ```
142
143
  */
143
- type TraceContext<TBaggage extends Record<string, unknown> | undefined = undefined> = TraceContextBase & SpanMethods & BaggageMethods<TBaggage>;
144
+ type TraceContext<TBaggage extends UnknownRecord | undefined = undefined> = TraceContextBase & SpanMethods & BaggageMethods<TBaggage>;
144
145
  /**
145
146
  * Define a typed baggage schema for type-safe baggage operations
146
147
  *
@@ -179,7 +180,7 @@ type TraceContext<TBaggage extends Record<string, unknown> | undefined = undefin
179
180
  * });
180
181
  * ```
181
182
  */
182
- declare function defineBaggageSchema<T extends Record<string, unknown>>(namespace?: string): {
183
+ declare function defineBaggageSchema<T extends UnknownRecord>(namespace?: string): {
183
184
  /**
184
185
  * Get typed baggage from context
185
186
  * @param ctx - Trace context
@@ -1,3 +1,4 @@
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.js";
1
2
  import { AttributeValue, Attributes, BaggageEntry, Context, Link, Span, SpanStatusCode } from "@opentelemetry/api";
2
3
  import { AsyncLocalStorage } from "node:async_hooks";
3
4
  //#region src/trace-context.d.ts
@@ -44,21 +45,21 @@ interface SpanMethods {
44
45
  * Replaces the deprecated `recordException` (OTEP 4430). Accepts `unknown`
45
46
  * so it can be called directly with the value caught from a `catch` block.
46
47
  */
47
- recordError(error: unknown): void;
48
+ recordError(cause: unknown): void;
48
49
  /**
49
50
  * Emit a tracked event correlated to this span. Equivalent to the standalone
50
51
  * `track(event, data)` but reads naturally on `ctx`. Replaces the deprecated
51
52
  * `ctx.addEvent` (OTEP 4430) — events become correlated logs rather than
52
53
  * span events.
53
54
  */
54
- track<Events extends Record<string, unknown> = Record<string, unknown>>(event: keyof Events & string, data?: Events[keyof Events & string]): void;
55
+ track<Events extends UnknownRecord = UnknownRecord>(event: keyof Events & string, data?: Events[keyof Events & string]): void;
55
56
  }
56
57
  /**
57
58
  * Baggage methods available on trace context
58
59
  *
59
60
  * @template TBaggage - Optional type for typed baggage (defaults to undefined for untyped)
60
61
  */
61
- interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined = undefined> {
62
+ interface BaggageMethods<TBaggage extends UnknownRecord | undefined = undefined> {
62
63
  /**
63
64
  * Get a baggage entry by key
64
65
  * @param key - Baggage key
@@ -104,14 +105,14 @@ interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined =
104
105
  *
105
106
  * @internal
106
107
  */
107
- getTypedBaggage?: TBaggage extends Record<string, unknown> ? <T extends TBaggage>(namespace?: string) => Partial<T> | undefined : never;
108
+ getTypedBaggage?: TBaggage extends UnknownRecord ? <T extends TBaggage>(namespace?: string) => Partial<T> | undefined : never;
108
109
  /**
109
110
  * Set typed baggage (only available when TBaggage is defined)
110
111
  * This is used internally by defineBaggageSchema()
111
112
  *
112
113
  * @internal
113
114
  */
114
- setTypedBaggage?: TBaggage extends Record<string, unknown> ? <T extends TBaggage>(namespace: string | undefined, value: Partial<T>) => void : never;
115
+ setTypedBaggage?: TBaggage extends UnknownRecord ? <T extends TBaggage>(namespace: string | undefined, value: Partial<T>) => void : never;
115
116
  }
116
117
  /**
117
118
  * Complete trace context that merges base context, span methods, and baggage methods
@@ -140,7 +141,7 @@ interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined =
140
141
  * });
141
142
  * ```
142
143
  */
143
- type TraceContext<TBaggage extends Record<string, unknown> | undefined = undefined> = TraceContextBase & SpanMethods & BaggageMethods<TBaggage>;
144
+ type TraceContext<TBaggage extends UnknownRecord | undefined = undefined> = TraceContextBase & SpanMethods & BaggageMethods<TBaggage>;
144
145
  /**
145
146
  * Define a typed baggage schema for type-safe baggage operations
146
147
  *
@@ -179,7 +180,7 @@ type TraceContext<TBaggage extends Record<string, unknown> | undefined = undefin
179
180
  * });
180
181
  * ```
181
182
  */
182
- declare function defineBaggageSchema<T extends Record<string, unknown>>(namespace?: string): {
183
+ declare function defineBaggageSchema<T extends UnknownRecord>(namespace?: string): {
183
184
  /**
184
185
  * Get typed baggage from context
185
186
  * @param ctx - Trace context
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_node_require = require('./node-require-PFqDihze.cjs');
2
+ const require_values = require('./values-DApyq53y.cjs');
3
+ const require_node_require = require('./node-require-EifOMikz.cjs');
3
4
  let _opentelemetry_api = require("@opentelemetry/api");
4
5
 
5
6
  //#region src/trace-helpers.ts
@@ -379,10 +380,9 @@ function runWithSpan(span, fn) {
379
380
  * }
380
381
  * ```
381
382
  */
382
- function finalizeSpan(span, error) {
383
- if (error) {
384
- if (error instanceof Error) span.recordException(error);
385
- else span.recordException(new Error(String(error)));
383
+ function finalizeSpan(span, cause) {
384
+ if (cause) {
385
+ span.recordException(require_values.toError(cause));
386
386
  span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
387
387
  } else span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
388
388
  span.end();
@@ -593,21 +593,24 @@ function flattenMetadata(metadata, prefix = "metadata") {
593
593
  for (const [key, value] of Object.entries(obj)) {
594
594
  if (value == null) continue;
595
595
  const attributeKey = `${currentPrefix}.${key}`;
596
- if (typeof value === "string") {
597
- flattened[attributeKey] = value;
596
+ const text = require_values.asString(value);
597
+ if (text !== void 0) {
598
+ flattened[attributeKey] = text;
598
599
  continue;
599
600
  }
600
- if (typeof value === "number" || typeof value === "boolean") {
601
- flattened[attributeKey] = String(value);
601
+ const scalar = require_values.asNumber(value) ?? require_values.asBoolean(value);
602
+ if (scalar !== void 0) {
603
+ flattened[attributeKey] = String(scalar);
602
604
  continue;
603
605
  }
604
- if (typeof value === "object" && value !== null && value.constructor === Object) {
605
- if (seen.has(value)) {
606
+ const nested = require_values.asPlainRecord(value);
607
+ if (nested !== void 0) {
608
+ if (seen.has(nested)) {
606
609
  flattened[attributeKey] = "<circular-reference>";
607
610
  continue;
608
611
  }
609
- seen.add(value);
610
- flatten(value, attributeKey);
612
+ seen.add(nested);
613
+ flatten(nested, attributeKey);
611
614
  continue;
612
615
  }
613
616
  try {
@@ -1,3 +1,4 @@
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.cjs";
1
2
  import { Context, Span, Tracer } from "@opentelemetry/api";
2
3
  //#region src/trace-helpers.d.ts
3
4
  /**
@@ -78,7 +79,7 @@ declare function getTraceContext(): TraceContext | null;
78
79
  * // { userId: '123' } - no trace fields added
79
80
  * ```
80
81
  */
81
- declare function enrichWithTraceContext<T extends Record<string, unknown>>(obj: T): T;
82
+ declare function enrichWithTraceContext<T extends UnknownRecord>(obj: T): T;
82
83
  /**
83
84
  * Check if currently in a trace context
84
85
  *
@@ -303,7 +304,7 @@ declare function runWithSpan<T>(span: Span, fn: () => T): T;
303
304
  * }
304
305
  * ```
305
306
  */
306
- declare function finalizeSpan(span: Span, error?: unknown): void;
307
+ declare function finalizeSpan(span: Span, cause?: unknown): void;
307
308
  /**
308
309
  * Creates a deterministic trace ID from a seed string.
309
310
  *
@@ -495,6 +496,10 @@ declare function createDeterministicTraceId(seed: string): Promise<string>;
495
496
  * // => 'https://grafana.example.com/explore?traceId=abc123'
496
497
  */
497
498
  declare function resolveTraceUrl(template: string | undefined, traceId: string): string | undefined;
498
- declare function flattenMetadata(metadata: Record<string, unknown>, prefix?: string): Record<string, string>;
499
+ /** Flattened metadata: every leaf rendered as the string an attribute holds. */
500
+ interface FlatMetadata {
501
+ [key: string]: string;
502
+ }
503
+ declare function flattenMetadata(metadata: UnknownRecord, prefix?: string): FlatMetadata;
499
504
  //#endregion
500
- export { TraceContext, createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan, setSpanName };
505
+ export { FlatMetadata, TraceContext, createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan, setSpanName };
@@ -1,3 +1,4 @@
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.js";
1
2
  import { Context, Span, Tracer } from "@opentelemetry/api";
2
3
  //#region src/trace-helpers.d.ts
3
4
  /**
@@ -78,7 +79,7 @@ declare function getTraceContext(): TraceContext | null;
78
79
  * // { userId: '123' } - no trace fields added
79
80
  * ```
80
81
  */
81
- declare function enrichWithTraceContext<T extends Record<string, unknown>>(obj: T): T;
82
+ declare function enrichWithTraceContext<T extends UnknownRecord>(obj: T): T;
82
83
  /**
83
84
  * Check if currently in a trace context
84
85
  *
@@ -303,7 +304,7 @@ declare function runWithSpan<T>(span: Span, fn: () => T): T;
303
304
  * }
304
305
  * ```
305
306
  */
306
- declare function finalizeSpan(span: Span, error?: unknown): void;
307
+ declare function finalizeSpan(span: Span, cause?: unknown): void;
307
308
  /**
308
309
  * Creates a deterministic trace ID from a seed string.
309
310
  *
@@ -495,6 +496,10 @@ declare function createDeterministicTraceId(seed: string): Promise<string>;
495
496
  * // => 'https://grafana.example.com/explore?traceId=abc123'
496
497
  */
497
498
  declare function resolveTraceUrl(template: string | undefined, traceId: string): string | undefined;
498
- declare function flattenMetadata(metadata: Record<string, unknown>, prefix?: string): Record<string, string>;
499
+ /** Flattened metadata: every leaf rendered as the string an attribute holds. */
500
+ interface FlatMetadata {
501
+ [key: string]: string;
502
+ }
503
+ declare function flattenMetadata(metadata: UnknownRecord, prefix?: string): FlatMetadata;
499
504
  //#endregion
500
- export { TraceContext, createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan, setSpanName };
505
+ export { FlatMetadata, TraceContext, createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan, setSpanName };
@@ -1,4 +1,5 @@
1
- import { t as requireModule } from "./node-require-vROmTeJ8.js";
1
+ import { i as asNumber, l as asString, o as asPlainRecord, t as asBoolean, x as toError } from "./values-BenyvWKz.js";
2
+ import { t as requireModule } from "./node-require-DSPjaw_l.js";
2
3
  import { SpanStatusCode, context, trace } from "@opentelemetry/api";
3
4
 
4
5
  //#region src/trace-helpers.ts
@@ -378,10 +379,9 @@ function runWithSpan(span, fn) {
378
379
  * }
379
380
  * ```
380
381
  */
381
- function finalizeSpan(span, error) {
382
- if (error) {
383
- if (error instanceof Error) span.recordException(error);
384
- else span.recordException(new Error(String(error)));
382
+ function finalizeSpan(span, cause) {
383
+ if (cause) {
384
+ span.recordException(toError(cause));
385
385
  span.setStatus({ code: SpanStatusCode.ERROR });
386
386
  } else span.setStatus({ code: SpanStatusCode.OK });
387
387
  span.end();
@@ -592,21 +592,24 @@ function flattenMetadata(metadata, prefix = "metadata") {
592
592
  for (const [key, value] of Object.entries(obj)) {
593
593
  if (value == null) continue;
594
594
  const attributeKey = `${currentPrefix}.${key}`;
595
- if (typeof value === "string") {
596
- flattened[attributeKey] = value;
595
+ const text = asString(value);
596
+ if (text !== void 0) {
597
+ flattened[attributeKey] = text;
597
598
  continue;
598
599
  }
599
- if (typeof value === "number" || typeof value === "boolean") {
600
- flattened[attributeKey] = String(value);
600
+ const scalar = asNumber(value) ?? asBoolean(value);
601
+ if (scalar !== void 0) {
602
+ flattened[attributeKey] = String(scalar);
601
603
  continue;
602
604
  }
603
- if (typeof value === "object" && value !== null && value.constructor === Object) {
604
- if (seen.has(value)) {
605
+ const nested = asPlainRecord(value);
606
+ if (nested !== void 0) {
607
+ if (seen.has(nested)) {
605
608
  flattened[attributeKey] = "<circular-reference>";
606
609
  continue;
607
610
  }
608
- seen.add(value);
609
- flatten(value, attributeKey);
611
+ seen.add(nested);
612
+ flatten(nested, attributeKey);
610
613
  continue;
611
614
  }
612
615
  try {