autotel 3.7.0 → 4.1.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 (132) hide show
  1. package/README.md +26 -1
  2. package/dist/{attributes-ksn4HVbd.js → attributes-CmYpdqCN.js} +2 -11
  3. package/dist/attributes-CmYpdqCN.js.map +1 -0
  4. package/dist/{attributes-D3etyRVc.cjs → attributes-PZ5doLgw.cjs} +2 -11
  5. package/dist/attributes-PZ5doLgw.cjs.map +1 -0
  6. package/dist/attributes.cjs +1 -1
  7. package/dist/attributes.d.cts +2 -2
  8. package/dist/attributes.d.ts +2 -2
  9. package/dist/attributes.js +1 -1
  10. package/dist/auto.cjs +2 -2
  11. package/dist/auto.js +1 -1
  12. package/dist/correlation-id.cjs +1 -1
  13. package/dist/correlation-id.js +1 -1
  14. package/dist/decorators.cjs +1 -1
  15. package/dist/decorators.js +1 -1
  16. package/dist/{event-Dlqr4ZNL.cjs → event-BhHREDJk.cjs} +3 -3
  17. package/dist/{event-Dlqr4ZNL.cjs.map → event-BhHREDJk.cjs.map} +1 -1
  18. package/dist/{event-_58ryBjh.js → event-ByBTV9M2.js} +3 -3
  19. package/dist/{event-_58ryBjh.js.map → event-ByBTV9M2.js.map} +1 -1
  20. package/dist/event.cjs +1 -1
  21. package/dist/event.js +1 -1
  22. package/dist/{functional-BGkT8J-h.js → functional-DtI0u4vx.js} +19 -19
  23. package/dist/functional-DtI0u4vx.js.map +1 -0
  24. package/dist/{functional-C4CzoVrX.cjs → functional-zpzNLhky.cjs} +4 -4
  25. package/dist/{functional-C4CzoVrX.cjs.map → functional-zpzNLhky.cjs.map} +1 -1
  26. package/dist/functional.cjs +1 -1
  27. package/dist/functional.js +1 -1
  28. package/dist/http.cjs +1 -1
  29. package/dist/http.js +1 -1
  30. package/dist/{index-CX0aG1Uh.d.ts → index-Ck06vlW2.d.ts} +2 -32
  31. package/dist/index-Ck06vlW2.d.ts.map +1 -0
  32. package/dist/{index-DIWZFKUS.d.cts → index-eKuioqT1.d.cts} +2 -32
  33. package/dist/index-eKuioqT1.d.cts.map +1 -0
  34. package/dist/index.cjs +7 -351
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +4 -172
  37. package/dist/index.d.cts.map +1 -1
  38. package/dist/index.d.ts +4 -172
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +9 -338
  41. package/dist/index.js.map +1 -1
  42. package/dist/{init-DJQOdVlN.d.ts → init-B7u-DjxM.d.ts} +57 -2
  43. package/dist/init-B7u-DjxM.d.ts.map +1 -0
  44. package/dist/{init-DvapOXCc.cjs → init-BX7AmFRl.cjs} +40 -21
  45. package/dist/init-BX7AmFRl.cjs.map +1 -0
  46. package/dist/{init-Ch6t7MNI.js → init-D-jnNMix.js} +39 -20
  47. package/dist/init-D-jnNMix.js.map +1 -0
  48. package/dist/{init-CNp-ee80.d.cts → init-DSrRmVnz.d.cts} +57 -2
  49. package/dist/init-DSrRmVnz.d.cts.map +1 -0
  50. package/dist/instrumentation.cjs +1 -1
  51. package/dist/instrumentation.js +1 -1
  52. package/dist/logger-D3Ej3DII.js +446 -0
  53. package/dist/logger-D3Ej3DII.js.map +1 -0
  54. package/dist/logger-thMPLpOG.cjs +487 -0
  55. package/dist/logger-thMPLpOG.cjs.map +1 -0
  56. package/dist/logger.cjs +8 -236
  57. package/dist/logger.js +2 -204
  58. package/dist/messaging.cjs +1 -1
  59. package/dist/messaging.js +1 -1
  60. package/dist/{registry-DfXA3R1L.js → registry-DVSmWg6Y.js} +2 -11
  61. package/dist/registry-DVSmWg6Y.js.map +1 -0
  62. package/dist/{registry-JZg2J3RZ.cjs → registry-DYgvb62e.cjs} +1 -16
  63. package/dist/registry-DYgvb62e.cjs.map +1 -0
  64. package/dist/semantic-conventions.cjs +1 -1
  65. package/dist/semantic-conventions.js +1 -1
  66. package/dist/semantic-helpers.cjs +1 -114
  67. package/dist/semantic-helpers.cjs.map +1 -1
  68. package/dist/semantic-helpers.d.cts +1 -114
  69. package/dist/semantic-helpers.d.cts.map +1 -1
  70. package/dist/semantic-helpers.d.ts +1 -114
  71. package/dist/semantic-helpers.d.ts.map +1 -1
  72. package/dist/semantic-helpers.js +2 -114
  73. package/dist/semantic-helpers.js.map +1 -1
  74. package/dist/{track-3HY4NGV-.cjs → track-D59FfpL0.cjs} +2 -2
  75. package/dist/{track-3HY4NGV-.cjs.map → track-D59FfpL0.cjs.map} +1 -1
  76. package/dist/{track-nsKVy-pj.js → track-wc0HafS_.js} +6 -6
  77. package/dist/track-wc0HafS_.js.map +1 -0
  78. package/dist/webhook.cjs +1 -1
  79. package/dist/webhook.js +1 -1
  80. package/dist/workflow-distributed.cjs +1 -1
  81. package/dist/workflow-distributed.js +1 -1
  82. package/dist/workflow.cjs +1 -1
  83. package/dist/workflow.js +1 -1
  84. package/dist/{yaml-config-B3dQ82GR.cjs → yaml-config-Ck2uB0Dp.cjs} +2 -1
  85. package/dist/yaml-config-Ck2uB0Dp.cjs.map +1 -0
  86. package/dist/yaml-config.cjs +1 -1
  87. package/dist/yaml-config.d.cts +7 -1
  88. package/dist/yaml-config.d.cts.map +1 -1
  89. package/dist/yaml-config.d.ts +7 -1
  90. package/dist/yaml-config.d.ts.map +1 -1
  91. package/dist/yaml-config.js +1 -0
  92. package/dist/yaml-config.js.map +1 -1
  93. package/package.json +1 -1
  94. package/skills/analyze-traces/SKILL.md +14 -12
  95. package/skills/autotel-core/SKILL.md +2 -0
  96. package/skills/autotel-instrumentation/SKILL.md +25 -0
  97. package/skills/debug-missing-spans/SKILL.md +3 -1
  98. package/skills/migrate-to-autotel/SKILL.md +24 -23
  99. package/skills/review-otel-patterns/SKILL.md +9 -6
  100. package/skills/tune-sampling/SKILL.md +8 -3
  101. package/src/attributes/builders.ts +2 -20
  102. package/src/attributes/index.ts +0 -1
  103. package/src/attributes/registry.ts +2 -9
  104. package/src/attributes/types.ts +0 -8
  105. package/src/index.ts +4 -41
  106. package/src/init.customization.test.ts +71 -0
  107. package/src/init.ts +167 -40
  108. package/src/semantic-helpers.test.ts +2 -87
  109. package/src/semantic-helpers.ts +0 -146
  110. package/src/yaml-config.test.ts +36 -0
  111. package/src/yaml-config.ts +10 -1
  112. package/dist/attributes-D3etyRVc.cjs.map +0 -1
  113. package/dist/attributes-ksn4HVbd.js.map +0 -1
  114. package/dist/functional-BGkT8J-h.js.map +0 -1
  115. package/dist/index-CX0aG1Uh.d.ts.map +0 -1
  116. package/dist/index-DIWZFKUS.d.cts.map +0 -1
  117. package/dist/init-CNp-ee80.d.cts.map +0 -1
  118. package/dist/init-Ch6t7MNI.js.map +0 -1
  119. package/dist/init-DJQOdVlN.d.ts.map +0 -1
  120. package/dist/init-DvapOXCc.cjs.map +0 -1
  121. package/dist/logger.cjs.map +0 -1
  122. package/dist/logger.js.map +0 -1
  123. package/dist/registry-DfXA3R1L.js.map +0 -1
  124. package/dist/registry-JZg2J3RZ.cjs.map +0 -1
  125. package/dist/track-nsKVy-pj.js.map +0 -1
  126. package/dist/yaml-config-B3dQ82GR.cjs.map +0 -1
  127. package/src/gen-ai-cost.test.ts +0 -81
  128. package/src/gen-ai-cost.ts +0 -145
  129. package/src/gen-ai-events.test.ts +0 -135
  130. package/src/gen-ai-events.ts +0 -208
  131. package/src/gen-ai-metrics.test.ts +0 -96
  132. package/src/gen-ai-metrics.ts +0 -128
@@ -0,0 +1,487 @@
1
+ const require_config = require('./config.cjs');
2
+ let _opentelemetry_api = require("@opentelemetry/api");
3
+
4
+ //#region src/autotel-logger.ts
5
+ /**
6
+ * Zero-dependency structured logger for autotel
7
+ *
8
+ * This logger provides:
9
+ * - Structured JSON logging (production) or pretty print (development)
10
+ * - Auto trace context injection (traceId, spanId, correlationId)
11
+ * - Dynamic log level control (per-request via OTel context)
12
+ * - Level support (debug, info, warn, error, none)
13
+ * - Zero additional dependencies (uses @opentelemetry/api, already a dep)
14
+ *
15
+ * Uses Pino-compatible signature supporting both patterns:
16
+ * - `log.info('simple message')` - string-only
17
+ * - `log.info({ userId: '123' }, 'message')` - object first with optional message
18
+ *
19
+ * Used as the default fallback when users don't provide Pino/Bunyan.
20
+ * Can also be used directly: import { createBuiltinLogger } from 'autotel/logger'
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { createBuiltinLogger, runWithLogLevel } from 'autotel/logger';
25
+ *
26
+ * const log = createBuiltinLogger('my-service');
27
+ *
28
+ * // Simple message (no metadata)
29
+ * log.info('Server started');
30
+ *
31
+ * // With metadata (Pino-style: object first, message second)
32
+ * log.info({ userId: '123' }, 'User created');
33
+ * // Output: {"level":"info","service":"my-service","msg":"User created","userId":"123","traceId":"..."}
34
+ *
35
+ * // Dynamic log level per-request
36
+ * runWithLogLevel('debug', () => {
37
+ * log.debug('This will log even if default level is "info"');
38
+ * });
39
+ * ```
40
+ */
41
+ /**
42
+ * Context key for storing active log level (enables per-request log levels)
43
+ */
44
+ const LOG_LEVEL_KEY = (0, _opentelemetry_api.createContextKey)("autotel-log-level");
45
+ /**
46
+ * Get the active log level from context (if set)
47
+ * Falls back to undefined if no log level is set in context
48
+ */
49
+ function getActiveLogLevel() {
50
+ return _opentelemetry_api.context.active().getValue(LOG_LEVEL_KEY);
51
+ }
52
+ /**
53
+ * Run a function with a specific log level
54
+ * The log level is stored in OpenTelemetry context and applies to all logger calls within the callback
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Enable debug logging for a specific request
59
+ * runWithLogLevel('debug', () => {
60
+ * log.debug('This will be logged');
61
+ * processRequest();
62
+ * });
63
+ *
64
+ * // Disable logging temporarily
65
+ * runWithLogLevel('none', () => {
66
+ * log.info('This will NOT be logged');
67
+ * });
68
+ * ```
69
+ */
70
+ function runWithLogLevel(level, callback) {
71
+ const ctx = _opentelemetry_api.context.active().setValue(LOG_LEVEL_KEY, level);
72
+ return _opentelemetry_api.context.with(ctx, callback);
73
+ }
74
+ /**
75
+ * Get current trace context from active span
76
+ * Returns null if no active span exists
77
+ */
78
+ function getTraceContextInternal() {
79
+ const span = _opentelemetry_api.trace.getActiveSpan();
80
+ if (!span) return null;
81
+ const ctx = span.spanContext();
82
+ return {
83
+ traceId: ctx.traceId,
84
+ spanId: ctx.spanId,
85
+ correlationId: ctx.traceId.slice(0, 16)
86
+ };
87
+ }
88
+ /**
89
+ * Helper to get trace context (useful for BYOL - Bring Your Own Logger)
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * import bunyan from 'bunyan';
94
+ * import { getTraceContext } from 'autotel/logger';
95
+ *
96
+ * const bunyanLogger = bunyan.createLogger({ name: 'myapp' });
97
+ * const ctx = getTraceContext();
98
+ * bunyanLogger.info({ ...ctx, email: 'test@example.com' }, 'Creating user');
99
+ * ```
100
+ */
101
+ function getTraceContext() {
102
+ return getTraceContextInternal();
103
+ }
104
+ /**
105
+ * Create a lightweight structured logger
106
+ *
107
+ * @param service - Service name for logging
108
+ * @param options - Optional configuration
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const log = createBuiltinLogger('user-service');
113
+ *
114
+ * log.info('Creating user', { email: 'test@example.com' });
115
+ * // Output: {"level":"info","service":"user-service","msg":"Creating user",
116
+ * // "email":"test@example.com","traceId":"...","spanId":"..."}
117
+ *
118
+ * // Dynamic log level control per-request
119
+ * runWithLogLevel('debug', () => {
120
+ * log.debug('This will be logged even if logger was created with level: "info"');
121
+ * });
122
+ * ```
123
+ */
124
+ function createBuiltinLogger(service, options) {
125
+ const defaultLevel = options?.level || "info";
126
+ const pretty = options?.pretty || false;
127
+ const levelPriority = {
128
+ none: -1,
129
+ debug: 0,
130
+ info: 1,
131
+ warn: 2,
132
+ error: 3
133
+ };
134
+ const shouldLog = (level) => {
135
+ const activeLevel = getActiveLogLevel() ?? defaultLevel;
136
+ if (activeLevel === "none") return false;
137
+ return levelPriority[level] >= levelPriority[activeLevel];
138
+ };
139
+ const log = (level, msg, attrs) => {
140
+ if (!shouldLog(level)) return;
141
+ const ctx = getTraceContextInternal();
142
+ const logEntry = {
143
+ level,
144
+ service,
145
+ msg,
146
+ ...attrs,
147
+ ...ctx,
148
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
149
+ };
150
+ if (pretty) {
151
+ const traceInfo = ctx ? ` [${ctx.traceId.slice(0, 8)}.../${ctx.spanId.slice(0, 8)}...]` : "";
152
+ console.log(`[${level.toUpperCase()}]${traceInfo} ${service}: ${msg}`, attrs || "");
153
+ } else console.log(JSON.stringify(logEntry));
154
+ };
155
+ const createLogMethod = (level) => {
156
+ 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);
162
+ };
163
+ };
164
+ return {
165
+ info: createLogMethod("info"),
166
+ warn: createLogMethod("warn"),
167
+ debug: createLogMethod("debug"),
168
+ 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);
197
+ return;
198
+ }
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);
212
+ }
213
+ };
214
+ }
215
+ /**
216
+ * Pino-like factory function for creating an autotel logger
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * import { autotelLogger } from 'autotel/logger';
221
+ *
222
+ * const log = autotelLogger();
223
+ *
224
+ * // Simple message
225
+ * log.info('Server started');
226
+ *
227
+ * // With metadata (Pino-style: object first, message second)
228
+ * log.info({ userId: '123' }, 'User created');
229
+ *
230
+ * // With options
231
+ * const devLog = autotelLogger({ service: 'my-app', level: 'debug', pretty: true });
232
+ * ```
233
+ */
234
+ function autotelLogger(options) {
235
+ return createBuiltinLogger(options?.service || "app", {
236
+ level: options?.level,
237
+ pretty: options?.pretty
238
+ });
239
+ }
240
+
241
+ //#endregion
242
+ //#region src/logger.ts
243
+ /**
244
+ * Logger types and utilities for autotel
245
+ *
246
+ * **Zero-Config Option:** Don't provide a logger to `init()` and autotel uses
247
+ * a built-in structured JSON logger with automatic trace context injection.
248
+ *
249
+ * **BYOL (Bring Your Own Logger):** Pass Pino or Bunyan to `init()` for
250
+ * automatic instrumentation with trace context and OTLP log export.
251
+ *
252
+ * ## Logger Signature
253
+ *
254
+ * Autotel v2.10+ uses **Pino's signature**: `logger.info({ metadata }, 'message')`.
255
+ *
256
+ * ### Backward Compatibility
257
+ *
258
+ * The built-in logger auto-detects legacy Winston-style calls and swaps arguments:
259
+ * ```typescript
260
+ * // Legacy (auto-detected and handled)
261
+ * logger.info('User created', { userId: '123' });
262
+ * // → Internally treated as: logger.info({ userId: '123' }, 'User created')
263
+ * // → Logs warning in development, works silently in production
264
+ * ```
265
+ *
266
+ * ### Recommended Usage
267
+ *
268
+ * ```typescript
269
+ * // ✅ Pino-style (preferred)
270
+ * logger.info({ userId: '123' }, 'User created');
271
+ *
272
+ * // ✅ Simple message (no metadata)
273
+ * logger.info('Server started');
274
+ * ```
275
+ *
276
+ * **Note:** If you BYOL (bring your own logger), it must use Pino signature.
277
+ * Winston and other `(message, meta)` loggers are NOT compatible.
278
+ * For Winston, use `@opentelemetry/instrumentation-winston` instead.
279
+ *
280
+ * @example Zero-config (uses built-in logger)
281
+ * ```typescript
282
+ * import { init } from 'autotel';
283
+ *
284
+ * init({ service: 'my-app' });
285
+ * // Internal logs: {"level":"info","service":"my-app","msg":"...","traceId":"..."}
286
+ * ```
287
+ *
288
+ * @example Using built-in logger directly
289
+ * ```typescript
290
+ * import { createBuiltinLogger, runWithLogLevel } from 'autotel/logger';
291
+ *
292
+ * const log = createBuiltinLogger('my-service');
293
+ *
294
+ * // Simple message (no metadata)
295
+ * log.info('Server started');
296
+ *
297
+ * // With metadata (Pino-style: object first, message second)
298
+ * log.info({ userId: '123' }, 'User created');
299
+ * // Output: {"level":"info","service":"my-service","msg":"User created","userId":"123","traceId":"..."}
300
+ *
301
+ * // Dynamic log level per-request
302
+ * runWithLogLevel('debug', () => {
303
+ * log.debug('Debug info for this request only');
304
+ * });
305
+ * ```
306
+ *
307
+ * @example Using Pino (recommended for production, auto-instrumented)
308
+ * ```typescript
309
+ * import pino from 'pino'; // npm install pino
310
+ * import { init } from 'autotel';
311
+ *
312
+ * const logger = pino({ level: 'info' });
313
+ * init({ service: 'my-app', logger });
314
+ *
315
+ * // Logs automatically include traceId/spanId and export via OTLP!
316
+ * logger.info({ userId: '123' }, 'User created');
317
+ * ```
318
+ *
319
+ * @example Using Bunyan (auto-instrumented, same signature as Pino)
320
+ * ```typescript
321
+ * import bunyan from 'bunyan'; // npm install bunyan @opentelemetry/instrumentation-bunyan
322
+ * import { init } from 'autotel';
323
+ * import { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';
324
+ *
325
+ * const logger = bunyan.createLogger({ name: 'my-app' });
326
+ * init({
327
+ * service: 'my-app',
328
+ * logger,
329
+ * instrumentations: [new BunyanInstrumentation()]
330
+ * });
331
+ * ```
332
+ *
333
+ * @example Custom logger (MUST use Pino-compatible signature)
334
+ * ```typescript
335
+ * // ⚠️ Your custom logger MUST accept (object, message?) signature
336
+ * const logger = {
337
+ * info: (extra, msg) => console.log(msg || '', extra),
338
+ * warn: (extra, msg) => console.warn(msg || '', extra),
339
+ * error: (extra, msg) => console.error(msg || '', extra),
340
+ * debug: (extra, msg) => console.debug(msg || '', extra),
341
+ * };
342
+ * init({ service: 'my-app', logger });
343
+ * ```
344
+ *
345
+ * @example BYOL helper: inject trace context into any logger
346
+ * ```typescript
347
+ * import bunyan from 'bunyan';
348
+ * import { getTraceContext } from 'autotel/logger';
349
+ *
350
+ * const bunyanLogger = bunyan.createLogger({ name: 'myapp' });
351
+ * const ctx = getTraceContext();
352
+ * bunyanLogger.info({ ...ctx, userId: '123' }, 'Creating user');
353
+ * ```
354
+ */
355
+ /**
356
+ * Log level constants
357
+ */
358
+ const LOG_LEVEL = {
359
+ DEBUG: "debug",
360
+ INFO: "info",
361
+ WARN: "warn",
362
+ ERROR: "error"
363
+ };
364
+ /**
365
+ * TS5+ Standard Decorator for logging and tracing operations
366
+ * Uses TC39 Stage 3 decorator syntax
367
+ *
368
+ * This is the traditional per-method decorator approach.
369
+ * For zero-boilerplate solution, see @Instrumented class decorator.
370
+ *
371
+ * @example
372
+ * // Simple usage (Pino-style: object first, message second)
373
+ * class OrderService {
374
+ * constructor(private readonly deps: { log: Logger }) {}
375
+ *
376
+ * @LoggedOperation('order.create')
377
+ * async createOrder(data: CreateOrderData) {
378
+ * // ✅ Correct Pino-style logging
379
+ * this.deps.log.info({ orderId: data.id }, 'Creating order');
380
+ * }
381
+ * }
382
+ *
383
+ * // Advanced usage (future-proof for options)
384
+ * @LoggedOperation({ operationName: 'order.create' })
385
+ * async createOrder(data: CreateOrderData) { }
386
+ */
387
+ function LoggedOperation(operationNameOrOptions) {
388
+ const operationName = typeof operationNameOrOptions === "string" ? operationNameOrOptions : operationNameOrOptions.operationName;
389
+ return function(originalMethod, context) {
390
+ const methodName = String(context.name);
391
+ return async function(...args) {
392
+ const log = this.deps?.log;
393
+ const startTime = performance.now();
394
+ return require_config.getConfig().tracer.startActiveSpan(operationName, async (span) => {
395
+ try {
396
+ log?.info({
397
+ operation: operationName,
398
+ method: methodName,
399
+ args
400
+ }, "Operation started");
401
+ const result = await originalMethod.apply(this, args);
402
+ const duration = performance.now() - startTime;
403
+ log?.info({
404
+ operation: operationName,
405
+ method: methodName,
406
+ duration
407
+ }, "Operation completed");
408
+ span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
409
+ span.setAttributes({
410
+ "operation.name": operationName,
411
+ "operation.method": methodName,
412
+ "operation.duration": duration,
413
+ "operation.success": true
414
+ });
415
+ return result;
416
+ } catch (error) {
417
+ const duration = performance.now() - startTime;
418
+ log?.error({
419
+ err: error instanceof Error ? error : void 0,
420
+ operation: operationName,
421
+ method: methodName,
422
+ duration
423
+ }, "Operation failed");
424
+ span.setStatus({
425
+ code: _opentelemetry_api.SpanStatusCode.ERROR,
426
+ message: error instanceof Error ? error.message : "Unknown error"
427
+ });
428
+ span.setAttributes({
429
+ "operation.name": operationName,
430
+ "operation.method": methodName,
431
+ "operation.duration": duration,
432
+ "operation.success": false,
433
+ "error.type": error instanceof Error ? error.constructor.name : "Unknown"
434
+ });
435
+ throw error;
436
+ } finally {
437
+ span.end();
438
+ }
439
+ });
440
+ };
441
+ };
442
+ }
443
+
444
+ //#endregion
445
+ Object.defineProperty(exports, 'LOG_LEVEL', {
446
+ enumerable: true,
447
+ get: function () {
448
+ return LOG_LEVEL;
449
+ }
450
+ });
451
+ Object.defineProperty(exports, 'LoggedOperation', {
452
+ enumerable: true,
453
+ get: function () {
454
+ return LoggedOperation;
455
+ }
456
+ });
457
+ Object.defineProperty(exports, 'autotelLogger', {
458
+ enumerable: true,
459
+ get: function () {
460
+ return autotelLogger;
461
+ }
462
+ });
463
+ Object.defineProperty(exports, 'createBuiltinLogger', {
464
+ enumerable: true,
465
+ get: function () {
466
+ return createBuiltinLogger;
467
+ }
468
+ });
469
+ Object.defineProperty(exports, 'getActiveLogLevel', {
470
+ enumerable: true,
471
+ get: function () {
472
+ return getActiveLogLevel;
473
+ }
474
+ });
475
+ Object.defineProperty(exports, 'getTraceContext', {
476
+ enumerable: true,
477
+ get: function () {
478
+ return getTraceContext;
479
+ }
480
+ });
481
+ Object.defineProperty(exports, 'runWithLogLevel', {
482
+ enumerable: true,
483
+ get: function () {
484
+ return runWithLogLevel;
485
+ }
486
+ });
487
+ //# sourceMappingURL=logger-thMPLpOG.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-thMPLpOG.cjs","names":["api_context","trace","extra","getConfig","SpanStatusCode"],"sources":["../src/autotel-logger.ts","../src/logger.ts"],"sourcesContent":["/**\n * Zero-dependency structured logger for autotel\n *\n * This logger provides:\n * - Structured JSON logging (production) or pretty print (development)\n * - Auto trace context injection (traceId, spanId, correlationId)\n * - Dynamic log level control (per-request via OTel context)\n * - Level support (debug, info, warn, error, none)\n * - Zero additional dependencies (uses @opentelemetry/api, already a dep)\n *\n * Uses Pino-compatible signature supporting both patterns:\n * - `log.info('simple message')` - string-only\n * - `log.info({ userId: '123' }, 'message')` - object first with optional message\n *\n * Used as the default fallback when users don't provide Pino/Bunyan.\n * Can also be used directly: import { createBuiltinLogger } from 'autotel/logger'\n *\n * @example\n * ```typescript\n * import { createBuiltinLogger, runWithLogLevel } from 'autotel/logger';\n *\n * const log = createBuiltinLogger('my-service');\n *\n * // Simple message (no metadata)\n * log.info('Server started');\n *\n * // With metadata (Pino-style: object first, message second)\n * log.info({ userId: '123' }, 'User created');\n * // Output: {\"level\":\"info\",\"service\":\"my-service\",\"msg\":\"User created\",\"userId\":\"123\",\"traceId\":\"...\"}\n *\n * // Dynamic log level per-request\n * runWithLogLevel('debug', () => {\n * log.debug('This will log even if default level is \"info\"');\n * });\n * ```\n */\n\nimport {\n trace,\n context as api_context,\n createContextKey,\n} from '@opentelemetry/api';\nimport type { Logger } from './logger';\n\nexport type BuiltinLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';\n\n/**\n * Context key for storing active log level (enables per-request log levels)\n */\nconst LOG_LEVEL_KEY = createContextKey('autotel-log-level');\n\n/**\n * Get the active log level from context (if set)\n * Falls back to undefined if no log level is set in context\n */\nexport function getActiveLogLevel(): BuiltinLogLevel | undefined {\n return api_context.active().getValue(LOG_LEVEL_KEY) as\n | BuiltinLogLevel\n | undefined;\n}\n\n/**\n * Run a function with a specific log level\n * The log level is stored in OpenTelemetry context and applies to all logger calls within the callback\n *\n * @example\n * ```typescript\n * // Enable debug logging for a specific request\n * runWithLogLevel('debug', () => {\n * log.debug('This will be logged');\n * processRequest();\n * });\n *\n * // Disable logging temporarily\n * runWithLogLevel('none', () => {\n * log.info('This will NOT be logged');\n * });\n * ```\n */\nexport function runWithLogLevel<T>(\n level: BuiltinLogLevel,\n callback: () => T,\n): T {\n const ctx = api_context.active().setValue(LOG_LEVEL_KEY, level);\n return api_context.with(ctx, callback);\n}\n\n/**\n * Get current trace context from active span\n * Returns null if no active span exists\n */\nfunction getTraceContextInternal(): {\n traceId: string;\n spanId: string;\n correlationId: string;\n} | null {\n const span = trace.getActiveSpan();\n if (!span) return null;\n\n const ctx = span.spanContext();\n return {\n traceId: ctx.traceId,\n spanId: ctx.spanId,\n correlationId: ctx.traceId.slice(0, 16), // First 16 chars for grouping\n };\n}\n\n/**\n * Helper to get trace context (useful for BYOL - Bring Your Own Logger)\n *\n * @example\n * ```typescript\n * import bunyan from 'bunyan';\n * import { getTraceContext } from 'autotel/logger';\n *\n * const bunyanLogger = bunyan.createLogger({ name: 'myapp' });\n * const ctx = getTraceContext();\n * bunyanLogger.info({ ...ctx, email: 'test@example.com' }, 'Creating user');\n * ```\n */\nexport function getTraceContext() {\n return getTraceContextInternal();\n}\n\nexport interface BuiltinLoggerOptions {\n /** Minimum log level. Default: 'info' */\n level?: BuiltinLogLevel;\n /** Pretty print for development. Default: false (JSON output) */\n pretty?: boolean;\n}\n\n/**\n * Create a lightweight structured logger\n *\n * @param service - Service name for logging\n * @param options - Optional configuration\n *\n * @example\n * ```typescript\n * const log = createBuiltinLogger('user-service');\n *\n * log.info('Creating user', { email: 'test@example.com' });\n * // Output: {\"level\":\"info\",\"service\":\"user-service\",\"msg\":\"Creating user\",\n * // \"email\":\"test@example.com\",\"traceId\":\"...\",\"spanId\":\"...\"}\n *\n * // Dynamic log level control per-request\n * runWithLogLevel('debug', () => {\n * log.debug('This will be logged even if logger was created with level: \"info\"');\n * });\n * ```\n */\nexport function createBuiltinLogger(\n service: string,\n options?: BuiltinLoggerOptions,\n): Logger {\n const defaultLevel = options?.level || 'info';\n const pretty = options?.pretty || false;\n\n const levelPriority: Record<BuiltinLogLevel, number> = {\n none: -1,\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n };\n\n const shouldLog = (level: BuiltinLogLevel): boolean => {\n // Priority: context level > options level > 'info' default\n const activeLevel = getActiveLogLevel() ?? defaultLevel;\n\n // 'none' means suppress all logging\n if (activeLevel === 'none') return false;\n\n return levelPriority[level] >= levelPriority[activeLevel];\n };\n\n const log = (\n level: 'info' | 'error' | 'warn' | 'debug',\n msg: string,\n attrs?: Record<string, unknown>,\n ) => {\n if (!shouldLog(level)) return;\n\n const ctx = getTraceContextInternal();\n const logEntry: Record<string, unknown> = {\n level,\n service,\n msg,\n ...attrs,\n ...ctx, // Auto-inject traceId, spanId, correlationId\n timestamp: new Date().toISOString(),\n };\n\n if (pretty) {\n // Pretty print for development\n const traceInfo = ctx\n ? ` [${ctx.traceId.slice(0, 8)}.../${ctx.spanId.slice(0, 8)}...]`\n : '';\n console.log(\n `[${level.toUpperCase()}]${traceInfo} ${service}: ${msg}`,\n attrs || '',\n );\n } else {\n // Structured JSON for production\n console.log(JSON.stringify(logEntry));\n }\n };\n\n // Pino-compatible signature: supports both:\n // - logger.info('message') - string-only\n // - logger.info({ extra }, 'message') - Pino style with metadata\n // Also auto-detects and handles legacy Winston-style: logger.info('message', { extra })\n const createLogMethod = (level: 'info' | 'warn' | 'debug') => {\n return (\n extraOrMessage: Record<string, unknown> | string,\n message?: string | Record<string, unknown>,\n ) => {\n if (typeof extraOrMessage === 'string') {\n // First arg is string - could be:\n // 1. String-only: logger.info('message')\n // 2. Legacy Winston-style: logger.info('message', { extra })\n if (message !== undefined && typeof message === 'object') {\n // Legacy Winston-style detected - auto-swap for backward compatibility\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `[autotel] Legacy logger pattern detected: logger.${level}('message', metadata). ` +\n `Autotel recommends Pino signature: logger.${level}({ ...metadata }, 'message'). ` +\n `Auto-swapping arguments for compatibility.`,\n );\n }\n // Swap: treat first arg as message, second as metadata\n log(level, extraOrMessage, message as Record<string, unknown>);\n } else {\n // Pure string-only call: logger.info('message')\n log(level, extraOrMessage);\n }\n } else {\n // Pino style: logger.info({ extra }, 'message')\n log(level, (message as string) || '', extraOrMessage);\n }\n };\n };\n\n return {\n info: createLogMethod('info'),\n warn: createLogMethod('warn'),\n debug: createLogMethod('debug'),\n\n error: (\n extraOrMessage: Record<string, unknown> | string,\n message?: string | Record<string, unknown> | Error,\n ) => {\n if (typeof extraOrMessage === 'string') {\n // First arg is string - could be:\n // 1. String-only: logger.error('message')\n // 2. Legacy: logger.error('message', error) - Error as second arg\n // 3. Legacy: logger.error('message', { extra }) - object as second arg\n\n // Handle legacy logger.error('message', error) pattern\n if (message instanceof Error) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `[autotel] Legacy logger pattern detected: logger.error('message', error). ` +\n `Autotel recommends Pino signature: logger.error({ err: error }, 'message'). ` +\n `Auto-swapping arguments for compatibility.`,\n );\n }\n log('error', extraOrMessage, {\n error: message.message,\n stack: message.stack,\n name: message.name,\n });\n return;\n }\n\n // Handle legacy logger.error('message', { extra }) pattern\n if (message !== undefined && typeof message === 'object') {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `[autotel] Legacy logger pattern detected: logger.error('message', metadata). ` +\n `Autotel recommends Pino signature: logger.error({ ...metadata }, 'message'). ` +\n `Auto-swapping arguments for compatibility.`,\n );\n }\n // Swap: treat first arg as message, second as metadata (handle err extraction)\n const extra = message as Record<string, unknown>;\n const { err, ...rest } = extra as Record<string, unknown> & {\n err?: unknown;\n };\n let errorAttrs: Record<string, unknown> = rest;\n if (err instanceof Error) {\n errorAttrs = {\n error: err.message,\n stack: err.stack,\n name: err.name,\n ...rest,\n };\n } else if (err !== undefined) {\n errorAttrs = { err, ...rest };\n }\n log('error', extraOrMessage, errorAttrs);\n return;\n }\n\n // Pure string-only call: logger.error('message')\n log('error', extraOrMessage);\n return;\n }\n\n // Pino style: logger.error({ err, ...extra }, 'message')\n // Extract err from extra if present (Pino convention)\n const { err, ...rest } = extraOrMessage as Record<string, unknown> & {\n err?: unknown;\n };\n let errorAttrs: Record<string, unknown> = rest;\n if (err instanceof Error) {\n // err is an Error - extract message, stack, name for structured logging\n errorAttrs = {\n error: err.message,\n stack: err.stack,\n name: err.name,\n ...rest,\n };\n } else if (err !== undefined) {\n // err is not an Error but exists - preserve it as-is\n errorAttrs = {\n err,\n ...rest,\n };\n }\n log('error', (message as string) || '', errorAttrs);\n },\n };\n}\n\n/**\n * Pino-like factory function for creating an autotel logger\n *\n * @example\n * ```typescript\n * import { autotelLogger } from 'autotel/logger';\n *\n * const log = autotelLogger();\n *\n * // Simple message\n * log.info('Server started');\n *\n * // With metadata (Pino-style: object first, message second)\n * log.info({ userId: '123' }, 'User created');\n *\n * // With options\n * const devLog = autotelLogger({ service: 'my-app', level: 'debug', pretty: true });\n * ```\n */\nexport function autotelLogger(options?: {\n service?: string;\n level?: BuiltinLogLevel;\n pretty?: boolean;\n}): Logger {\n return createBuiltinLogger(options?.service || 'app', {\n level: options?.level,\n pretty: options?.pretty,\n });\n}\n","/**\n * Logger types and utilities for autotel\n *\n * **Zero-Config Option:** Don't provide a logger to `init()` and autotel uses\n * a built-in structured JSON logger with automatic trace context injection.\n *\n * **BYOL (Bring Your Own Logger):** Pass Pino or Bunyan to `init()` for\n * automatic instrumentation with trace context and OTLP log export.\n *\n * ## Logger Signature\n *\n * Autotel v2.10+ uses **Pino's signature**: `logger.info({ metadata }, 'message')`.\n *\n * ### Backward Compatibility\n *\n * The built-in logger auto-detects legacy Winston-style calls and swaps arguments:\n * ```typescript\n * // Legacy (auto-detected and handled)\n * logger.info('User created', { userId: '123' });\n * // → Internally treated as: logger.info({ userId: '123' }, 'User created')\n * // → Logs warning in development, works silently in production\n * ```\n *\n * ### Recommended Usage\n *\n * ```typescript\n * // ✅ Pino-style (preferred)\n * logger.info({ userId: '123' }, 'User created');\n *\n * // ✅ Simple message (no metadata)\n * logger.info('Server started');\n * ```\n *\n * **Note:** If you BYOL (bring your own logger), it must use Pino signature.\n * Winston and other `(message, meta)` loggers are NOT compatible.\n * For Winston, use `@opentelemetry/instrumentation-winston` instead.\n *\n * @example Zero-config (uses built-in logger)\n * ```typescript\n * import { init } from 'autotel';\n *\n * init({ service: 'my-app' });\n * // Internal logs: {\"level\":\"info\",\"service\":\"my-app\",\"msg\":\"...\",\"traceId\":\"...\"}\n * ```\n *\n * @example Using built-in logger directly\n * ```typescript\n * import { createBuiltinLogger, runWithLogLevel } from 'autotel/logger';\n *\n * const log = createBuiltinLogger('my-service');\n *\n * // Simple message (no metadata)\n * log.info('Server started');\n *\n * // With metadata (Pino-style: object first, message second)\n * log.info({ userId: '123' }, 'User created');\n * // Output: {\"level\":\"info\",\"service\":\"my-service\",\"msg\":\"User created\",\"userId\":\"123\",\"traceId\":\"...\"}\n *\n * // Dynamic log level per-request\n * runWithLogLevel('debug', () => {\n * log.debug('Debug info for this request only');\n * });\n * ```\n *\n * @example Using Pino (recommended for production, auto-instrumented)\n * ```typescript\n * import pino from 'pino'; // npm install pino\n * import { init } from 'autotel';\n *\n * const logger = pino({ level: 'info' });\n * init({ service: 'my-app', logger });\n *\n * // Logs automatically include traceId/spanId and export via OTLP!\n * logger.info({ userId: '123' }, 'User created');\n * ```\n *\n * @example Using Bunyan (auto-instrumented, same signature as Pino)\n * ```typescript\n * import bunyan from 'bunyan'; // npm install bunyan @opentelemetry/instrumentation-bunyan\n * import { init } from 'autotel';\n * import { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';\n *\n * const logger = bunyan.createLogger({ name: 'my-app' });\n * init({\n * service: 'my-app',\n * logger,\n * instrumentations: [new BunyanInstrumentation()]\n * });\n * ```\n *\n * @example Custom logger (MUST use Pino-compatible signature)\n * ```typescript\n * // ⚠️ Your custom logger MUST accept (object, message?) signature\n * const logger = {\n * info: (extra, msg) => console.log(msg || '', extra),\n * warn: (extra, msg) => console.warn(msg || '', extra),\n * error: (extra, msg) => console.error(msg || '', extra),\n * debug: (extra, msg) => console.debug(msg || '', extra),\n * };\n * init({ service: 'my-app', logger });\n * ```\n *\n * @example BYOL helper: inject trace context into any logger\n * ```typescript\n * import bunyan from 'bunyan';\n * import { getTraceContext } from 'autotel/logger';\n *\n * const bunyanLogger = bunyan.createLogger({ name: 'myapp' });\n * const ctx = getTraceContext();\n * bunyanLogger.info({ ...ctx, userId: '123' }, 'Creating user');\n * ```\n */\n\nimport { SpanStatusCode } from '@opentelemetry/api';\nimport { getConfig } from './config';\n\n// ============================================================================\n// Logger Types\n// ============================================================================\n\n/**\n * Log level constants\n */\nexport const LOG_LEVEL = {\n DEBUG: 'debug',\n INFO: 'info',\n WARN: 'warn',\n ERROR: 'error',\n} as const;\n\nexport type LogLevel = (typeof LOG_LEVEL)[keyof typeof LOG_LEVEL];\n\n/**\n * Logger configuration (for reference - not needed with BYOL approach)\n */\nexport interface LoggerConfig {\n service: string;\n level?: LogLevel;\n pretty?: boolean;\n redact?: string[] | false;\n}\n\n/**\n * Pino-compatible log function signature\n *\n * Matches Pino's actual LogFn type which supports:\n * - `(msg: string)` - simple string message\n * - `(obj: object, msg?: string)` - object first with optional message\n *\n * @example\n * ```typescript\n * logger.info('User logged in');\n * logger.info({ userId: '123' }, 'User created');\n * logger.error({ err: error }, 'Operation failed');\n * ```\n */\nexport interface LogFn {\n (msg: string): void;\n (obj: Record<string, unknown>, msg?: string): void;\n}\n\n/**\n * Simple logger interface - Pino/Bunyan-compatible\n *\n * Uses Pino's LogFn signature which supports both:\n * - `logger.info('message')` - simple string message\n * - `logger.info({ extra }, 'message')` - object first with optional message\n *\n * This is compatible with Pino, Bunyan, and any logger following this pattern.\n *\n * @example Using Pino (just works!)\n * ```typescript\n * import pino from 'pino';\n * const logger = pino({ level: 'info' });\n * init({ service: 'my-app', logger });\n * ```\n *\n * @example Direct usage\n * ```typescript\n * logger.info('Simple message');\n * logger.info({ userId: '123' }, 'User created');\n * logger.error({ err: error }, 'Operation failed');\n * ```\n */\nexport interface Logger {\n info: LogFn;\n warn: LogFn;\n error: LogFn;\n debug: LogFn;\n}\n\n/**\n * Alias for Logger interface (backwards compatibility)\n * @deprecated Use Logger instead\n */\nexport type ILogger = Logger;\n\n/**\n * Pino logger type - re-exported for convenience\n *\n * Note: This is a type-only export. To use Pino, install it as a peer dependency:\n * `npm install pino`\n */\nexport type { Logger as PinoLogger } from 'pino';\n\n// ============================================================================\n// LoggedOperation Decorator\n// ============================================================================\n\nexport interface LoggedOperationOptions {\n /** Operation name for tracing (e.g., 'user.createUser') */\n operationName: string;\n}\n\n/**\n * TS5+ Standard Decorator for logging and tracing operations\n * Uses TC39 Stage 3 decorator syntax\n *\n * This is the traditional per-method decorator approach.\n * For zero-boilerplate solution, see @Instrumented class decorator.\n *\n * @example\n * // Simple usage (Pino-style: object first, message second)\n * class OrderService {\n * constructor(private readonly deps: { log: Logger }) {}\n *\n * @LoggedOperation('order.create')\n * async createOrder(data: CreateOrderData) {\n * // ✅ Correct Pino-style logging\n * this.deps.log.info({ orderId: data.id }, 'Creating order');\n * }\n * }\n *\n * // Advanced usage (future-proof for options)\n * @LoggedOperation({ operationName: 'order.create' })\n * async createOrder(data: CreateOrderData) { }\n */\nexport function LoggedOperation(\n operationNameOrOptions: string | LoggedOperationOptions,\n) {\n const operationName =\n typeof operationNameOrOptions === 'string'\n ? operationNameOrOptions\n : operationNameOrOptions.operationName;\n\n return function <This, Args extends unknown[], Return>(\n originalMethod: (this: This, ...args: Args) => Promise<Return>,\n context: ClassMethodDecoratorContext<\n This,\n (this: This, ...args: Args) => Promise<Return>\n >,\n ) {\n const methodName = String(context.name);\n\n return async function (this: This, ...args: Args): Promise<Return> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const log = (this as any).deps?.log;\n const startTime = performance.now();\n\n const config = getConfig();\n const tracer = config.tracer;\n\n return tracer.startActiveSpan(operationName, async (span) => {\n try {\n log?.info(\n {\n operation: operationName,\n method: methodName,\n args,\n },\n 'Operation started',\n );\n\n const result = await originalMethod.apply(this, args);\n\n const duration = performance.now() - startTime;\n log?.info(\n {\n operation: operationName,\n method: methodName,\n duration,\n },\n 'Operation completed',\n );\n\n span.setStatus({ code: SpanStatusCode.OK });\n span.setAttributes({\n 'operation.name': operationName,\n 'operation.method': methodName,\n 'operation.duration': duration,\n 'operation.success': true,\n });\n\n return result;\n } catch (error) {\n const duration = performance.now() - startTime;\n log?.error(\n {\n err: error instanceof Error ? error : undefined,\n operation: operationName,\n method: methodName,\n duration,\n },\n 'Operation failed',\n );\n\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error instanceof Error ? error.message : 'Unknown error',\n });\n span.setAttributes({\n 'operation.name': operationName,\n 'operation.method': methodName,\n 'operation.duration': duration,\n 'operation.success': false,\n 'error.type':\n error instanceof Error ? error.constructor.name : 'Unknown',\n });\n\n throw error;\n } finally {\n span.end();\n }\n });\n };\n };\n}\n\n// ============================================================================\n// Built-in Logger (re-exports)\n// ============================================================================\n\nexport {\n autotelLogger,\n createBuiltinLogger,\n runWithLogLevel,\n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