autotel 6.4.1 → 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-AT22vCw6.d.ts → functional-CJn2zY4o.d.cts} +96 -39
  59. package/dist/{functional-e6jw5zQj.d.cts → functional-DXy1cHFF.d.ts} +96 -39
  60. package/dist/{functional-qZxRcIBp.cjs → functional-Da6Yv64r.cjs} +27 -15
  61. package/dist/{functional-0o9xSedq.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-CsODvlau.d.ts → init-BgnYi2sm.d.ts} +94 -90
  75. package/dist/{init-BnxHAi2M.cjs → init-D4m5rCmD.cjs} +142 -123
  76. package/dist/{init-Cc7-vvzj.d.cts → init-DrlL1eis.d.cts} +94 -90
  77. package/dist/{init-BxfZ3Vbw.js → init-JtX-KKz_.js} +137 -124
  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,3 +1,4 @@
1
+ import { l as asString, s as asRecord } from "./values-BenyvWKz.js";
1
2
  import { getConfig } from "./config.js";
2
3
  import { SpanStatusCode, context, createContextKey, trace } from "@opentelemetry/api";
3
4
 
@@ -121,20 +122,47 @@ function getTraceContext() {
121
122
  * });
122
123
  * ```
123
124
  */
125
+ /**
126
+ * The fields a log line carries for its error, following Pino's `err`
127
+ * convention: an Error is spread into message/stack/name, anything else is
128
+ * kept as it was given.
129
+ */
130
+ function errorFields(extra) {
131
+ if (!extra) return {};
132
+ const { err, ...rest } = extra;
133
+ if (err instanceof Error) return {
134
+ error: err.message,
135
+ stack: err.stack,
136
+ name: err.name,
137
+ ...rest
138
+ };
139
+ return err === void 0 ? rest : {
140
+ err,
141
+ ...rest
142
+ };
143
+ }
144
+ /**
145
+ * Warn once per call about a Winston-style invocation, in development only -
146
+ * the arguments are swapped either way, so this is guidance, not an error.
147
+ */
148
+ function warnLegacyPattern(level, secondArg, recommended) {
149
+ if (process.env.NODE_ENV === "production") return;
150
+ console.warn(`[autotel] Legacy logger pattern detected: logger.${level}('message', ${secondArg}). Autotel recommends Pino signature: logger.${level}(${recommended}, 'message'). Auto-swapping arguments for compatibility.`);
151
+ }
124
152
  function createBuiltinLogger(service, options) {
125
153
  const defaultLevel = options?.level || "info";
126
154
  const pretty = options?.pretty || false;
127
- const levelPriority = {
128
- none: -1,
129
- debug: 0,
130
- info: 1,
131
- warn: 2,
132
- error: 3
133
- };
155
+ const levelPriority = /* @__PURE__ */ new Map([
156
+ ["none", -1],
157
+ ["debug", 0],
158
+ ["info", 1],
159
+ ["warn", 2],
160
+ ["error", 3]
161
+ ]);
134
162
  const shouldLog = (level) => {
135
163
  const activeLevel = getActiveLogLevel() ?? defaultLevel;
136
164
  if (activeLevel === "none") return false;
137
- return levelPriority[level] >= levelPriority[activeLevel];
165
+ return (levelPriority.get(level) ?? 0) >= (levelPriority.get(activeLevel) ?? 0);
138
166
  };
139
167
  const log = (level, msg, attrs) => {
140
168
  if (!shouldLog(level)) return;
@@ -154,11 +182,18 @@ function createBuiltinLogger(service, options) {
154
182
  };
155
183
  const createLogMethod = (level) => {
156
184
  return (extraOrMessage, message) => {
157
- if (typeof extraOrMessage === "string") if (message !== void 0 && typeof message === "object") {
158
- if (process.env.NODE_ENV !== "production") console.warn(`[autotel] Legacy logger pattern detected: logger.${level}('message', metadata). Autotel recommends Pino signature: logger.${level}({ ...metadata }, 'message'). Auto-swapping arguments for compatibility.`);
159
- log(level, extraOrMessage, message);
160
- } else log(level, extraOrMessage);
161
- else log(level, message || "", extraOrMessage);
185
+ const firstAsMessage = asString(extraOrMessage);
186
+ if (firstAsMessage === void 0) {
187
+ log(level, asString(message) ?? "", asRecord(extraOrMessage));
188
+ return;
189
+ }
190
+ const legacyExtra = asRecord(message);
191
+ if (!legacyExtra) {
192
+ log(level, firstAsMessage);
193
+ return;
194
+ }
195
+ warnLegacyPattern(level, "metadata", "{ ...metadata }");
196
+ log(level, firstAsMessage, legacyExtra);
162
197
  };
163
198
  };
164
199
  return {
@@ -166,49 +201,23 @@ function createBuiltinLogger(service, options) {
166
201
  warn: createLogMethod("warn"),
167
202
  debug: createLogMethod("debug"),
168
203
  error: (extraOrMessage, message) => {
169
- if (typeof extraOrMessage === "string") {
170
- if (message instanceof Error) {
171
- if (process.env.NODE_ENV !== "production") console.warn("[autotel] Legacy logger pattern detected: logger.error('message', error). Autotel recommends Pino signature: logger.error({ err: error }, 'message'). Auto-swapping arguments for compatibility.");
172
- log("error", extraOrMessage, {
173
- error: message.message,
174
- stack: message.stack,
175
- name: message.name
176
- });
177
- return;
178
- }
179
- if (message !== void 0 && typeof message === "object") {
180
- if (process.env.NODE_ENV !== "production") console.warn("[autotel] Legacy logger pattern detected: logger.error('message', metadata). Autotel recommends Pino signature: logger.error({ ...metadata }, 'message'). Auto-swapping arguments for compatibility.");
181
- const { err, ...rest } = message;
182
- let errorAttrs = rest;
183
- if (err instanceof Error) errorAttrs = {
184
- error: err.message,
185
- stack: err.stack,
186
- name: err.name,
187
- ...rest
188
- };
189
- else if (err !== void 0) errorAttrs = {
190
- err,
191
- ...rest
192
- };
193
- log("error", extraOrMessage, errorAttrs);
194
- return;
195
- }
196
- log("error", extraOrMessage);
204
+ const firstAsMessage = asString(extraOrMessage);
205
+ if (firstAsMessage === void 0) {
206
+ log("error", asString(message) ?? "", errorFields(asRecord(extraOrMessage)));
207
+ return;
208
+ }
209
+ if (message instanceof Error) {
210
+ warnLegacyPattern("error", "error", "{ err: error }");
211
+ log("error", firstAsMessage, errorFields({ err: message }));
212
+ return;
213
+ }
214
+ const legacyExtra = asRecord(message);
215
+ if (legacyExtra) {
216
+ warnLegacyPattern("error", "metadata", "{ ...metadata }");
217
+ log("error", firstAsMessage, errorFields(legacyExtra));
197
218
  return;
198
219
  }
199
- const { err, ...rest } = extraOrMessage;
200
- let errorAttrs = rest;
201
- if (err instanceof Error) errorAttrs = {
202
- error: err.message,
203
- stack: err.stack,
204
- name: err.name,
205
- ...rest
206
- };
207
- else if (err !== void 0) errorAttrs = {
208
- err,
209
- ...rest
210
- };
211
- log("error", message || "", errorAttrs);
220
+ log("error", firstAsMessage);
212
221
  }
213
222
  };
214
223
  }
@@ -49,26 +49,6 @@ interface BuiltinLoggerOptions {
49
49
  /** Pretty print for development. Default: false (JSON output) */
50
50
  pretty?: boolean;
51
51
  }
52
- /**
53
- * Create a lightweight structured logger
54
- *
55
- * @param service - Service name for logging
56
- * @param options - Optional configuration
57
- *
58
- * @example
59
- * ```typescript
60
- * const log = createBuiltinLogger('user-service');
61
- *
62
- * log.info('Creating user', { email: 'test@example.com' });
63
- * // Output: {"level":"info","service":"user-service","msg":"Creating user",
64
- * // "email":"test@example.com","traceId":"...","spanId":"..."}
65
- *
66
- * // Dynamic log level control per-request
67
- * runWithLogLevel('debug', () => {
68
- * log.debug('This will be logged even if logger was created with level: "info"');
69
- * });
70
- * ```
71
- */
72
52
  declare function createBuiltinLogger(service: string, options?: BuiltinLoggerOptions): Logger;
73
53
  /**
74
54
  * Pino-like factory function for creating an autotel logger
@@ -49,26 +49,6 @@ interface BuiltinLoggerOptions {
49
49
  /** Pretty print for development. Default: false (JSON output) */
50
50
  pretty?: boolean;
51
51
  }
52
- /**
53
- * Create a lightweight structured logger
54
- *
55
- * @param service - Service name for logging
56
- * @param options - Optional configuration
57
- *
58
- * @example
59
- * ```typescript
60
- * const log = createBuiltinLogger('user-service');
61
- *
62
- * log.info('Creating user', { email: 'test@example.com' });
63
- * // Output: {"level":"info","service":"user-service","msg":"Creating user",
64
- * // "email":"test@example.com","traceId":"...","spanId":"..."}
65
- *
66
- * // Dynamic log level control per-request
67
- * runWithLogLevel('debug', () => {
68
- * log.debug('This will be logged even if logger was created with level: "info"');
69
- * });
70
- * ```
71
- */
72
52
  declare function createBuiltinLogger(service: string, options?: BuiltinLoggerOptions): Logger;
73
53
  /**
74
54
  * Pino-like factory function for creating an autotel logger
@@ -1,3 +1,4 @@
1
+ const require_values = require('./values-DApyq53y.cjs');
1
2
  const require_config = require('./config.cjs');
2
3
  let _opentelemetry_api = require("@opentelemetry/api");
3
4
 
@@ -121,20 +122,47 @@ function getTraceContext() {
121
122
  * });
122
123
  * ```
123
124
  */
125
+ /**
126
+ * The fields a log line carries for its error, following Pino's `err`
127
+ * convention: an Error is spread into message/stack/name, anything else is
128
+ * kept as it was given.
129
+ */
130
+ function errorFields(extra) {
131
+ if (!extra) return {};
132
+ const { err, ...rest } = extra;
133
+ if (err instanceof Error) return {
134
+ error: err.message,
135
+ stack: err.stack,
136
+ name: err.name,
137
+ ...rest
138
+ };
139
+ return err === void 0 ? rest : {
140
+ err,
141
+ ...rest
142
+ };
143
+ }
144
+ /**
145
+ * Warn once per call about a Winston-style invocation, in development only -
146
+ * the arguments are swapped either way, so this is guidance, not an error.
147
+ */
148
+ function warnLegacyPattern(level, secondArg, recommended) {
149
+ if (process.env.NODE_ENV === "production") return;
150
+ console.warn(`[autotel] Legacy logger pattern detected: logger.${level}('message', ${secondArg}). Autotel recommends Pino signature: logger.${level}(${recommended}, 'message'). Auto-swapping arguments for compatibility.`);
151
+ }
124
152
  function createBuiltinLogger(service, options) {
125
153
  const defaultLevel = options?.level || "info";
126
154
  const pretty = options?.pretty || false;
127
- const levelPriority = {
128
- none: -1,
129
- debug: 0,
130
- info: 1,
131
- warn: 2,
132
- error: 3
133
- };
155
+ const levelPriority = /* @__PURE__ */ new Map([
156
+ ["none", -1],
157
+ ["debug", 0],
158
+ ["info", 1],
159
+ ["warn", 2],
160
+ ["error", 3]
161
+ ]);
134
162
  const shouldLog = (level) => {
135
163
  const activeLevel = getActiveLogLevel() ?? defaultLevel;
136
164
  if (activeLevel === "none") return false;
137
- return levelPriority[level] >= levelPriority[activeLevel];
165
+ return (levelPriority.get(level) ?? 0) >= (levelPriority.get(activeLevel) ?? 0);
138
166
  };
139
167
  const log = (level, msg, attrs) => {
140
168
  if (!shouldLog(level)) return;
@@ -154,11 +182,18 @@ function createBuiltinLogger(service, options) {
154
182
  };
155
183
  const createLogMethod = (level) => {
156
184
  return (extraOrMessage, message) => {
157
- if (typeof extraOrMessage === "string") if (message !== void 0 && typeof message === "object") {
158
- if (process.env.NODE_ENV !== "production") console.warn(`[autotel] Legacy logger pattern detected: logger.${level}('message', metadata). Autotel recommends Pino signature: logger.${level}({ ...metadata }, 'message'). Auto-swapping arguments for compatibility.`);
159
- log(level, extraOrMessage, message);
160
- } else log(level, extraOrMessage);
161
- else log(level, message || "", extraOrMessage);
185
+ const firstAsMessage = require_values.asString(extraOrMessage);
186
+ if (firstAsMessage === void 0) {
187
+ log(level, require_values.asString(message) ?? "", require_values.asRecord(extraOrMessage));
188
+ return;
189
+ }
190
+ const legacyExtra = require_values.asRecord(message);
191
+ if (!legacyExtra) {
192
+ log(level, firstAsMessage);
193
+ return;
194
+ }
195
+ warnLegacyPattern(level, "metadata", "{ ...metadata }");
196
+ log(level, firstAsMessage, legacyExtra);
162
197
  };
163
198
  };
164
199
  return {
@@ -166,49 +201,23 @@ function createBuiltinLogger(service, options) {
166
201
  warn: createLogMethod("warn"),
167
202
  debug: createLogMethod("debug"),
168
203
  error: (extraOrMessage, message) => {
169
- if (typeof extraOrMessage === "string") {
170
- if (message instanceof Error) {
171
- if (process.env.NODE_ENV !== "production") console.warn("[autotel] Legacy logger pattern detected: logger.error('message', error). Autotel recommends Pino signature: logger.error({ err: error }, 'message'). Auto-swapping arguments for compatibility.");
172
- log("error", extraOrMessage, {
173
- error: message.message,
174
- stack: message.stack,
175
- name: message.name
176
- });
177
- return;
178
- }
179
- if (message !== void 0 && typeof message === "object") {
180
- if (process.env.NODE_ENV !== "production") console.warn("[autotel] Legacy logger pattern detected: logger.error('message', metadata). Autotel recommends Pino signature: logger.error({ ...metadata }, 'message'). Auto-swapping arguments for compatibility.");
181
- const { err, ...rest } = message;
182
- let errorAttrs = rest;
183
- if (err instanceof Error) errorAttrs = {
184
- error: err.message,
185
- stack: err.stack,
186
- name: err.name,
187
- ...rest
188
- };
189
- else if (err !== void 0) errorAttrs = {
190
- err,
191
- ...rest
192
- };
193
- log("error", extraOrMessage, errorAttrs);
194
- return;
195
- }
196
- log("error", extraOrMessage);
204
+ const firstAsMessage = require_values.asString(extraOrMessage);
205
+ if (firstAsMessage === void 0) {
206
+ log("error", require_values.asString(message) ?? "", errorFields(require_values.asRecord(extraOrMessage)));
207
+ return;
208
+ }
209
+ if (message instanceof Error) {
210
+ warnLegacyPattern("error", "error", "{ err: error }");
211
+ log("error", firstAsMessage, errorFields({ err: message }));
212
+ return;
213
+ }
214
+ const legacyExtra = require_values.asRecord(message);
215
+ if (legacyExtra) {
216
+ warnLegacyPattern("error", "metadata", "{ ...metadata }");
217
+ log("error", firstAsMessage, errorFields(legacyExtra));
197
218
  return;
198
219
  }
199
- const { err, ...rest } = extraOrMessage;
200
- let errorAttrs = rest;
201
- if (err instanceof Error) errorAttrs = {
202
- error: err.message,
203
- stack: err.stack,
204
- name: err.name,
205
- ...rest
206
- };
207
- else if (err !== void 0) errorAttrs = {
208
- err,
209
- ...rest
210
- };
211
- log("error", message || "", errorAttrs);
220
+ log("error", firstAsMessage);
212
221
  }
213
222
  };
214
223
  }
package/dist/logger.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_logger = require('./logger-thMPLpOG.cjs');
2
+ const require_logger = require('./logger-Sm66cjKl.cjs');
3
3
 
4
4
  exports.LOG_LEVEL = require_logger.LOG_LEVEL;
5
5
  exports.LoggedOperation = require_logger.LoggedOperation;
package/dist/logger.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as LoggedOperation, c as LoggerConfig, d as BuiltinLoggerOptions, f as autotelLogger, g as runWithLogLevel, h as getTraceContext, i as LogLevel, l as PinoLogger, m as getActiveLogLevel, n as LOG_LEVEL, o as LoggedOperationOptions, p as createBuiltinLogger, r as LogFn, s as Logger, t as ILogger, u as BuiltinLogLevel } from "./logger-CN4xpzMd.cjs";
1
+ import { a as LoggedOperation, c as LoggerConfig, d as BuiltinLoggerOptions, f as autotelLogger, g as runWithLogLevel, h as getTraceContext, i as LogLevel, l as PinoLogger, m as getActiveLogLevel, n as LOG_LEVEL, o as LoggedOperationOptions, p as createBuiltinLogger, r as LogFn, s as Logger, t as ILogger, u as BuiltinLogLevel } from "./logger-S1Fgl0g3.cjs";
2
2
  export { type BuiltinLogLevel, type BuiltinLoggerOptions, ILogger, LOG_LEVEL, LogFn, LogLevel, LoggedOperation, LoggedOperationOptions, Logger, LoggerConfig, type PinoLogger, autotelLogger, createBuiltinLogger, getActiveLogLevel, getTraceContext, runWithLogLevel };
package/dist/logger.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as LoggedOperation, c as LoggerConfig, d as BuiltinLoggerOptions, f as autotelLogger, g as runWithLogLevel, h as getTraceContext, i as LogLevel, l as PinoLogger, m as getActiveLogLevel, n as LOG_LEVEL, o as LoggedOperationOptions, p as createBuiltinLogger, r as LogFn, s as Logger, t as ILogger, u as BuiltinLogLevel } from "./logger-CN4xpzMd.js";
1
+ import { a as LoggedOperation, c as LoggerConfig, d as BuiltinLoggerOptions, f as autotelLogger, g as runWithLogLevel, h as getTraceContext, i as LogLevel, l as PinoLogger, m as getActiveLogLevel, n as LOG_LEVEL, o as LoggedOperationOptions, p as createBuiltinLogger, r as LogFn, s as Logger, t as ILogger, u as BuiltinLogLevel } from "./logger-S1Fgl0g3.js";
2
2
  export { type BuiltinLogLevel, type BuiltinLoggerOptions, ILogger, LOG_LEVEL, LogFn, LogLevel, LoggedOperation, LoggedOperationOptions, Logger, LoggerConfig, type PinoLogger, autotelLogger, createBuiltinLogger, getActiveLogLevel, getTraceContext, runWithLogLevel };
package/dist/logger.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as getActiveLogLevel, i as createBuiltinLogger, n as LoggedOperation, o as getTraceContext, r as autotelLogger, s as runWithLogLevel, t as LOG_LEVEL } from "./logger-D3Ej3DII.js";
1
+ import { a as getActiveLogLevel, i as createBuiltinLogger, n as LoggedOperation, o as getTraceContext, r as autotelLogger, s as runWithLogLevel, t as LOG_LEVEL } from "./logger-DdPp__xW.js";
2
2
 
3
3
  export { LOG_LEVEL, LoggedOperation, autotelLogger, createBuiltinLogger, getActiveLogLevel, getTraceContext, runWithLogLevel };
@@ -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/messaging-adapters.ts
@@ -32,24 +33,31 @@ let _opentelemetry_api = require("@opentelemetry/api");
32
33
  * });
33
34
  * ```
34
35
  */
36
+ /** Set an attribute when the value is a string worth recording. */
37
+ function setIfString(attrs, key, value) {
38
+ const text = require_values.asString(value);
39
+ if (text) attrs[key] = text;
40
+ }
35
41
  const natsAdapter = {
36
42
  producer: { customAttributes: (_ctx, args) => {
37
- const msg = args[0];
43
+ const msg = require_values.asRecord(args[0]);
38
44
  const attrs = {};
39
- if (msg?.subject) attrs["nats.subject"] = msg.subject;
40
- if (msg?.replyTo) attrs["nats.reply_to"] = msg.replyTo;
41
- if (msg?.stream) attrs["nats.stream"] = msg.stream;
45
+ setIfString(attrs, "nats.subject", msg?.subject);
46
+ setIfString(attrs, "nats.reply_to", msg?.replyTo);
47
+ setIfString(attrs, "nats.stream", msg?.stream);
42
48
  return attrs;
43
49
  } },
44
50
  consumer: {
45
51
  headersFrom: (msg) => {
46
- const headers = msg.headers;
52
+ const headers = require_values.asRecord(require_values.readProperty(msg, "headers"));
47
53
  if (!headers) return;
48
- if (typeof headers.toJSON === "function") {
49
- const json = headers.toJSON();
50
- if (json && typeof json === "object") return json;
54
+ const toJSON = require_values.asFunction(headers.toJSON);
55
+ if (toJSON) {
56
+ const json = require_values.asRecord(toJSON.call(headers));
57
+ if (json) return json;
51
58
  }
52
- if (typeof headers.get === "function") {
59
+ const get = require_values.asFunction(headers.get);
60
+ if (get) {
53
61
  const result = {};
54
62
  for (const key of [
55
63
  "traceparent",
@@ -60,14 +68,20 @@ const natsAdapter = {
60
68
  "x-b3-sampled",
61
69
  "b3"
62
70
  ]) {
63
- const value = headers.get(key);
71
+ const value = require_values.asString(get.call(headers, key));
64
72
  if (value) result[key] = value;
65
73
  }
66
74
  if (Object.keys(result).length > 0) return result;
67
75
  }
68
- if (typeof headers.entries === "function") {
76
+ const entries = require_values.asFunction(headers.entries);
77
+ if (entries) {
69
78
  const result = {};
70
- for (const [key, value] of headers.entries()) if (typeof key === "string" && typeof value === "string") result[key] = value;
79
+ const pairs = entries.call(headers);
80
+ for (const [key, value] of pairs) {
81
+ const name = require_values.asString(key);
82
+ const text = require_values.asString(value);
83
+ if (name !== void 0 && text !== void 0) result[name] = text;
84
+ }
71
85
  if (Object.keys(result).length > 0) return result;
72
86
  }
73
87
  },
@@ -38,36 +38,6 @@ interface MessagingAdapter {
38
38
  producer?: ProducerAdapter;
39
39
  consumer?: ConsumerAdapter;
40
40
  }
41
- /**
42
- * NATS JetStream adapter
43
- *
44
- * Captures NATS-specific attributes following NATS observability conventions.
45
- *
46
- * @example Producer
47
- * ```typescript
48
- * const publishOrder = traceProducer({
49
- * system: 'nats',
50
- * destination: 'orders.created',
51
- * ...natsAdapter.producer,
52
- * })(ctx => async (subject, payload, opts) => {
53
- * const headers = ctx.getTraceHeaders();
54
- * await nc.publish(subject, payload, { headers });
55
- * });
56
- * ```
57
- *
58
- * @example Consumer
59
- * ```typescript
60
- * const processOrder = traceConsumer({
61
- * system: 'nats',
62
- * destination: 'orders.created',
63
- * consumerGroup: 'order-processor',
64
- * ...natsAdapter.consumer,
65
- * })(ctx => async (msg: JsMsg) => {
66
- * await handleOrder(msg.data);
67
- * msg.ack();
68
- * });
69
- * ```
70
- */
71
41
  declare const natsAdapter: MessagingAdapter;
72
42
  /**
73
43
  * Temporal adapter
@@ -38,36 +38,6 @@ interface MessagingAdapter {
38
38
  producer?: ProducerAdapter;
39
39
  consumer?: ConsumerAdapter;
40
40
  }
41
- /**
42
- * NATS JetStream adapter
43
- *
44
- * Captures NATS-specific attributes following NATS observability conventions.
45
- *
46
- * @example Producer
47
- * ```typescript
48
- * const publishOrder = traceProducer({
49
- * system: 'nats',
50
- * destination: 'orders.created',
51
- * ...natsAdapter.producer,
52
- * })(ctx => async (subject, payload, opts) => {
53
- * const headers = ctx.getTraceHeaders();
54
- * await nc.publish(subject, payload, { headers });
55
- * });
56
- * ```
57
- *
58
- * @example Consumer
59
- * ```typescript
60
- * const processOrder = traceConsumer({
61
- * system: 'nats',
62
- * destination: 'orders.created',
63
- * consumerGroup: 'order-processor',
64
- * ...natsAdapter.consumer,
65
- * })(ctx => async (msg: JsMsg) => {
66
- * await handleOrder(msg.data);
67
- * msg.ack();
68
- * });
69
- * ```
70
- */
71
41
  declare const natsAdapter: MessagingAdapter;
72
42
  /**
73
43
  * Temporal adapter
@@ -1,3 +1,4 @@
1
+ import { _ as readProperty, l as asString, r as asFunction, s as asRecord } from "./values-BenyvWKz.js";
1
2
  import { TraceFlags } from "@opentelemetry/api";
2
3
 
3
4
  //#region src/messaging-adapters.ts
@@ -31,24 +32,31 @@ import { TraceFlags } from "@opentelemetry/api";
31
32
  * });
32
33
  * ```
33
34
  */
35
+ /** Set an attribute when the value is a string worth recording. */
36
+ function setIfString(attrs, key, value) {
37
+ const text = asString(value);
38
+ if (text) attrs[key] = text;
39
+ }
34
40
  const natsAdapter = {
35
41
  producer: { customAttributes: (_ctx, args) => {
36
- const msg = args[0];
42
+ const msg = asRecord(args[0]);
37
43
  const attrs = {};
38
- if (msg?.subject) attrs["nats.subject"] = msg.subject;
39
- if (msg?.replyTo) attrs["nats.reply_to"] = msg.replyTo;
40
- if (msg?.stream) attrs["nats.stream"] = msg.stream;
44
+ setIfString(attrs, "nats.subject", msg?.subject);
45
+ setIfString(attrs, "nats.reply_to", msg?.replyTo);
46
+ setIfString(attrs, "nats.stream", msg?.stream);
41
47
  return attrs;
42
48
  } },
43
49
  consumer: {
44
50
  headersFrom: (msg) => {
45
- const headers = msg.headers;
51
+ const headers = asRecord(readProperty(msg, "headers"));
46
52
  if (!headers) return;
47
- if (typeof headers.toJSON === "function") {
48
- const json = headers.toJSON();
49
- if (json && typeof json === "object") return json;
53
+ const toJSON = asFunction(headers.toJSON);
54
+ if (toJSON) {
55
+ const json = asRecord(toJSON.call(headers));
56
+ if (json) return json;
50
57
  }
51
- if (typeof headers.get === "function") {
58
+ const get = asFunction(headers.get);
59
+ if (get) {
52
60
  const result = {};
53
61
  for (const key of [
54
62
  "traceparent",
@@ -59,14 +67,20 @@ const natsAdapter = {
59
67
  "x-b3-sampled",
60
68
  "b3"
61
69
  ]) {
62
- const value = headers.get(key);
70
+ const value = asString(get.call(headers, key));
63
71
  if (value) result[key] = value;
64
72
  }
65
73
  if (Object.keys(result).length > 0) return result;
66
74
  }
67
- if (typeof headers.entries === "function") {
75
+ const entries = asFunction(headers.entries);
76
+ if (entries) {
68
77
  const result = {};
69
- for (const [key, value] of headers.entries()) if (typeof key === "string" && typeof value === "string") result[key] = value;
78
+ const pairs = entries.call(headers);
79
+ for (const [key, value] of pairs) {
80
+ const name = asString(key);
81
+ const text = asString(value);
82
+ if (name !== void 0 && text !== void 0) result[name] = text;
83
+ }
70
84
  if (Object.keys(result).length > 0) return result;
71
85
  }
72
86
  },