autotel 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/auto.cjs +2 -2
- package/dist/auto.js +1 -1
- package/dist/correlation-id.cjs +1 -1
- package/dist/correlation-id.js +1 -1
- package/dist/decorators.cjs +1 -1
- package/dist/decorators.js +1 -1
- package/dist/{event-Dlqr4ZNL.cjs → event-BhHREDJk.cjs} +3 -3
- package/dist/{event-Dlqr4ZNL.cjs.map → event-BhHREDJk.cjs.map} +1 -1
- package/dist/{event-_58ryBjh.js → event-ByBTV9M2.js} +3 -3
- package/dist/{event-_58ryBjh.js.map → event-ByBTV9M2.js.map} +1 -1
- package/dist/event.cjs +1 -1
- package/dist/event.js +1 -1
- package/dist/{functional-BGkT8J-h.js → functional-DtI0u4vx.js} +19 -19
- package/dist/functional-DtI0u4vx.js.map +1 -0
- package/dist/{functional-C4CzoVrX.cjs → functional-zpzNLhky.cjs} +4 -4
- package/dist/{functional-C4CzoVrX.cjs.map → functional-zpzNLhky.cjs.map} +1 -1
- package/dist/functional.cjs +1 -1
- package/dist/functional.js +1 -1
- package/dist/http.cjs +1 -1
- package/dist/http.js +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/{init-DJQOdVlN.d.ts → init-B7u-DjxM.d.ts} +57 -2
- package/dist/init-B7u-DjxM.d.ts.map +1 -0
- package/dist/{init-DvapOXCc.cjs → init-BX7AmFRl.cjs} +40 -21
- package/dist/init-BX7AmFRl.cjs.map +1 -0
- package/dist/{init-Ch6t7MNI.js → init-D-jnNMix.js} +39 -20
- package/dist/init-D-jnNMix.js.map +1 -0
- package/dist/{init-CNp-ee80.d.cts → init-DSrRmVnz.d.cts} +57 -2
- package/dist/init-DSrRmVnz.d.cts.map +1 -0
- package/dist/instrumentation.cjs +1 -1
- package/dist/instrumentation.js +1 -1
- package/dist/logger-D3Ej3DII.js +446 -0
- package/dist/logger-D3Ej3DII.js.map +1 -0
- package/dist/logger-thMPLpOG.cjs +487 -0
- package/dist/logger-thMPLpOG.cjs.map +1 -0
- package/dist/logger.cjs +8 -236
- package/dist/logger.js +2 -204
- package/dist/messaging.cjs +1 -1
- package/dist/messaging.js +1 -1
- package/dist/semantic-helpers.cjs +1 -1
- package/dist/semantic-helpers.js +1 -1
- package/dist/{track-3HY4NGV-.cjs → track-D59FfpL0.cjs} +2 -2
- package/dist/{track-3HY4NGV-.cjs.map → track-D59FfpL0.cjs.map} +1 -1
- package/dist/{track-nsKVy-pj.js → track-wc0HafS_.js} +6 -6
- package/dist/track-wc0HafS_.js.map +1 -0
- package/dist/webhook.cjs +1 -1
- package/dist/webhook.js +1 -1
- package/dist/workflow-distributed.cjs +1 -1
- package/dist/workflow-distributed.js +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.js +1 -1
- package/dist/{yaml-config-B3dQ82GR.cjs → yaml-config-Ck2uB0Dp.cjs} +2 -1
- package/dist/yaml-config-Ck2uB0Dp.cjs.map +1 -0
- package/dist/yaml-config.cjs +1 -1
- package/dist/yaml-config.d.cts +7 -1
- package/dist/yaml-config.d.cts.map +1 -1
- package/dist/yaml-config.d.ts +7 -1
- package/dist/yaml-config.d.ts.map +1 -1
- package/dist/yaml-config.js +1 -0
- package/dist/yaml-config.js.map +1 -1
- package/package.json +1 -2
- package/skills/autotel-core/SKILL.md +2 -0
- package/skills/autotel-instrumentation/SKILL.md +25 -0
- package/skills/debug-missing-spans/SKILL.md +3 -1
- package/skills/migrate-to-autotel/SKILL.md +24 -23
- package/skills/review-otel-patterns/SKILL.md +5 -4
- package/dist/functional-BGkT8J-h.js.map +0 -1
- package/dist/init-CNp-ee80.d.cts.map +0 -1
- package/dist/init-Ch6t7MNI.js.map +0 -1
- package/dist/init-DJQOdVlN.d.ts.map +0 -1
- package/dist/init-DvapOXCc.cjs.map +0 -1
- package/dist/logger.cjs.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/track-nsKVy-pj.js.map +0 -1
- package/dist/yaml-config-B3dQ82GR.cjs.map +0 -1
- package/src/attribute-redacting-processor.test.ts +0 -763
- package/src/attribute-redacting-processor.ts +0 -621
- package/src/attributes/attachers.ts +0 -161
- package/src/attributes/builders.ts +0 -529
- package/src/attributes/domains.ts +0 -42
- package/src/attributes/index.ts +0 -81
- package/src/attributes/registry.ts +0 -323
- package/src/attributes/types.ts +0 -211
- package/src/attributes/utils.ts +0 -64
- package/src/attributes/validators.ts +0 -266
- package/src/attributes.test.ts +0 -292
- package/src/auto.ts +0 -67
- package/src/autotel-logger.test.ts +0 -548
- package/src/autotel-logger.ts +0 -364
- package/src/baggage-span-processor.test.ts +0 -202
- package/src/baggage-span-processor.ts +0 -100
- package/src/business-baggage.test.ts +0 -500
- package/src/business-baggage.ts +0 -669
- package/src/circuit-breaker.test.ts +0 -341
- package/src/circuit-breaker.ts +0 -184
- package/src/config.test.ts +0 -94
- package/src/config.ts +0 -172
- package/src/correlated-events.test.ts +0 -151
- package/src/correlated-events.ts +0 -47
- package/src/correlation-id.test.ts +0 -163
- package/src/correlation-id.ts +0 -206
- package/src/db.test.ts +0 -252
- package/src/db.ts +0 -447
- package/src/decorators.test.ts +0 -153
- package/src/decorators.ts +0 -188
- package/src/define-event.test.ts +0 -41
- package/src/define-event.ts +0 -58
- package/src/devtools.ts +0 -60
- package/src/drain-pipeline.test.ts +0 -68
- package/src/drain-pipeline.ts +0 -199
- package/src/drain-toolkit.test.ts +0 -113
- package/src/drain-toolkit.ts +0 -129
- package/src/enricher-toolkit.test.ts +0 -67
- package/src/enricher-toolkit.ts +0 -79
- package/src/enrichers.test.ts +0 -150
- package/src/enrichers.ts +0 -145
- package/src/env-config.test.ts +0 -323
- package/src/env-config.ts +0 -309
- package/src/error-catalog.test.ts +0 -133
- package/src/error-catalog.ts +0 -262
- package/src/event-queue.test.ts +0 -864
- package/src/event-queue.ts +0 -699
- package/src/event-subscriber.ts +0 -262
- package/src/event-testing.ts +0 -197
- package/src/event.test.ts +0 -1104
- package/src/event.ts +0 -988
- package/src/events-config.ts +0 -235
- package/src/exporters.ts +0 -165
- package/src/filtering-span-processor.test.ts +0 -281
- package/src/filtering-span-processor.ts +0 -111
- package/src/flatten-attributes.test.ts +0 -76
- package/src/flatten-attributes.ts +0 -80
- package/src/functional.strict-types.typecheck.ts +0 -53
- package/src/functional.test.ts +0 -1464
- package/src/functional.ts +0 -2539
- package/src/functional.types.test.ts +0 -135
- package/src/hook.mjs +0 -15
- package/src/http.test.ts +0 -485
- package/src/http.ts +0 -424
- package/src/index.ts +0 -433
- package/src/init-auto-redactor.test.ts +0 -53
- package/src/init-redactor.test.ts +0 -8
- package/src/init.customization.test.ts +0 -594
- package/src/init.integrations.test.ts +0 -399
- package/src/init.openllmetry.test.ts +0 -194
- package/src/init.protocol.test.ts +0 -215
- package/src/init.ts +0 -2312
- package/src/instrumentation.test.ts +0 -108
- package/src/instrumentation.ts +0 -319
- package/src/logger.test.ts +0 -125
- package/src/logger.ts +0 -341
- package/src/messaging-adapters.test.ts +0 -595
- package/src/messaging-adapters.ts +0 -583
- package/src/messaging-testing.test.ts +0 -573
- package/src/messaging-testing.ts +0 -935
- package/src/messaging.test.ts +0 -1646
- package/src/messaging.ts +0 -2245
- package/src/metric-helpers.ts +0 -47
- package/src/metric-testing.ts +0 -197
- package/src/metric.ts +0 -446
- package/src/metrics.test.ts +0 -241
- package/src/node-require.ts +0 -123
- package/src/operation-context.ts +0 -93
- package/src/parse-error.test.ts +0 -73
- package/src/parse-error.ts +0 -112
- package/src/posthog-logs.test.ts +0 -115
- package/src/posthog-logs.ts +0 -77
- package/src/pretty-console-exporter.test.ts +0 -545
- package/src/pretty-console-exporter.ts +0 -413
- package/src/pretty-log-formatter.test.ts +0 -123
- package/src/pretty-log-formatter.ts +0 -210
- package/src/processors/canonical-log-line-processor.test.ts +0 -523
- package/src/processors/canonical-log-line-processor.ts +0 -396
- package/src/processors.ts +0 -152
- package/src/rate-limiter.test.ts +0 -199
- package/src/rate-limiter.ts +0 -98
- package/src/redact-values.test.ts +0 -90
- package/src/redact-values.ts +0 -34
- package/src/register.ts +0 -37
- package/src/request-logger.test.ts +0 -545
- package/src/request-logger.ts +0 -342
- package/src/sampling.test.ts +0 -1060
- package/src/sampling.ts +0 -737
- package/src/security-schema.test.ts +0 -45
- package/src/security-schema.ts +0 -107
- package/src/semantic-conventions.ts +0 -15
- package/src/semantic-helpers.test.ts +0 -226
- package/src/semantic-helpers.ts +0 -438
- package/src/shutdown.test.ts +0 -364
- package/src/shutdown.ts +0 -246
- package/src/span-name-normalizer.test.ts +0 -377
- package/src/span-name-normalizer.ts +0 -213
- package/src/stable-hash.ts +0 -27
- package/src/structured-error.test.ts +0 -191
- package/src/structured-error.ts +0 -157
- package/src/stub.integration.test.ts +0 -361
- package/src/tail-sampling-processor.test.ts +0 -230
- package/src/tail-sampling-processor.ts +0 -55
- package/src/test-span-collector.test.ts +0 -234
- package/src/test-span-collector.ts +0 -150
- package/src/testing.ts +0 -705
- package/src/trace-context.test.ts +0 -73
- package/src/trace-context.ts +0 -567
- package/src/trace-helpers.new.test.ts +0 -278
- package/src/trace-helpers.test.ts +0 -290
- package/src/trace-helpers.ts +0 -710
- package/src/trace-hybrid.test.ts +0 -42
- package/src/trace-hybrid.ts +0 -37
- package/src/tracer-provider.test.ts +0 -183
- package/src/tracer-provider.ts +0 -266
- package/src/track.test.ts +0 -154
- package/src/track.ts +0 -216
- package/src/validate.test.ts +0 -287
- package/src/validate.ts +0 -307
- package/src/validation-attributes.ts +0 -43
- package/src/validation.test.ts +0 -330
- package/src/validation.ts +0 -246
- package/src/variable-name-inference.test.ts +0 -178
- package/src/variable-name-inference.ts +0 -242
- package/src/webhook.test.ts +0 -649
- package/src/webhook.ts +0 -637
- package/src/workflow-distributed.test.ts +0 -786
- package/src/workflow-distributed.ts +0 -916
- package/src/workflow.async-safety.integration.test.ts +0 -345
- package/src/workflow.test.ts +0 -647
- package/src/workflow.ts +0 -810
- package/src/yaml-config.test.ts +0 -337
- package/src/yaml-config.ts +0 -342
package/dist/logger.cjs
CHANGED
|
@@ -1,238 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_logger = require('./logger-thMPLpOG.cjs');
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* **BYOL (Bring Your Own Logger):** Pass Pino or Bunyan to `init()` for
|
|
11
|
-
* automatic instrumentation with trace context and OTLP log export.
|
|
12
|
-
*
|
|
13
|
-
* ## Logger Signature
|
|
14
|
-
*
|
|
15
|
-
* Autotel v2.10+ uses **Pino's signature**: `logger.info({ metadata }, 'message')`.
|
|
16
|
-
*
|
|
17
|
-
* ### Backward Compatibility
|
|
18
|
-
*
|
|
19
|
-
* The built-in logger auto-detects legacy Winston-style calls and swaps arguments:
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // Legacy (auto-detected and handled)
|
|
22
|
-
* logger.info('User created', { userId: '123' });
|
|
23
|
-
* // → Internally treated as: logger.info({ userId: '123' }, 'User created')
|
|
24
|
-
* // → Logs warning in development, works silently in production
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* ### Recommended Usage
|
|
28
|
-
*
|
|
29
|
-
* ```typescript
|
|
30
|
-
* // ✅ Pino-style (preferred)
|
|
31
|
-
* logger.info({ userId: '123' }, 'User created');
|
|
32
|
-
*
|
|
33
|
-
* // ✅ Simple message (no metadata)
|
|
34
|
-
* logger.info('Server started');
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* **Note:** If you BYOL (bring your own logger), it must use Pino signature.
|
|
38
|
-
* Winston and other `(message, meta)` loggers are NOT compatible.
|
|
39
|
-
* For Winston, use `@opentelemetry/instrumentation-winston` instead.
|
|
40
|
-
*
|
|
41
|
-
* @example Zero-config (uses built-in logger)
|
|
42
|
-
* ```typescript
|
|
43
|
-
* import { init } from 'autotel';
|
|
44
|
-
*
|
|
45
|
-
* init({ service: 'my-app' });
|
|
46
|
-
* // Internal logs: {"level":"info","service":"my-app","msg":"...","traceId":"..."}
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @example Using built-in logger directly
|
|
50
|
-
* ```typescript
|
|
51
|
-
* import { createBuiltinLogger, runWithLogLevel } from 'autotel/logger';
|
|
52
|
-
*
|
|
53
|
-
* const log = createBuiltinLogger('my-service');
|
|
54
|
-
*
|
|
55
|
-
* // Simple message (no metadata)
|
|
56
|
-
* log.info('Server started');
|
|
57
|
-
*
|
|
58
|
-
* // With metadata (Pino-style: object first, message second)
|
|
59
|
-
* log.info({ userId: '123' }, 'User created');
|
|
60
|
-
* // Output: {"level":"info","service":"my-service","msg":"User created","userId":"123","traceId":"..."}
|
|
61
|
-
*
|
|
62
|
-
* // Dynamic log level per-request
|
|
63
|
-
* runWithLogLevel('debug', () => {
|
|
64
|
-
* log.debug('Debug info for this request only');
|
|
65
|
-
* });
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @example Using Pino (recommended for production, auto-instrumented)
|
|
69
|
-
* ```typescript
|
|
70
|
-
* import pino from 'pino'; // npm install pino
|
|
71
|
-
* import { init } from 'autotel';
|
|
72
|
-
*
|
|
73
|
-
* const logger = pino({ level: 'info' });
|
|
74
|
-
* init({ service: 'my-app', logger });
|
|
75
|
-
*
|
|
76
|
-
* // Logs automatically include traceId/spanId and export via OTLP!
|
|
77
|
-
* logger.info({ userId: '123' }, 'User created');
|
|
78
|
-
* ```
|
|
79
|
-
*
|
|
80
|
-
* @example Using Bunyan (auto-instrumented, same signature as Pino)
|
|
81
|
-
* ```typescript
|
|
82
|
-
* import bunyan from 'bunyan'; // npm install bunyan @opentelemetry/instrumentation-bunyan
|
|
83
|
-
* import { init } from 'autotel';
|
|
84
|
-
* import { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';
|
|
85
|
-
*
|
|
86
|
-
* const logger = bunyan.createLogger({ name: 'my-app' });
|
|
87
|
-
* init({
|
|
88
|
-
* service: 'my-app',
|
|
89
|
-
* logger,
|
|
90
|
-
* instrumentations: [new BunyanInstrumentation()]
|
|
91
|
-
* });
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* @example Custom logger (MUST use Pino-compatible signature)
|
|
95
|
-
* ```typescript
|
|
96
|
-
* // ⚠️ Your custom logger MUST accept (object, message?) signature
|
|
97
|
-
* const logger = {
|
|
98
|
-
* info: (extra, msg) => console.log(msg || '', extra),
|
|
99
|
-
* warn: (extra, msg) => console.warn(msg || '', extra),
|
|
100
|
-
* error: (extra, msg) => console.error(msg || '', extra),
|
|
101
|
-
* debug: (extra, msg) => console.debug(msg || '', extra),
|
|
102
|
-
* };
|
|
103
|
-
* init({ service: 'my-app', logger });
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
|
-
* @example BYOL helper: inject trace context into any logger
|
|
107
|
-
* ```typescript
|
|
108
|
-
* import bunyan from 'bunyan';
|
|
109
|
-
* import { getTraceContext } from 'autotel/logger';
|
|
110
|
-
*
|
|
111
|
-
* const bunyanLogger = bunyan.createLogger({ name: 'myapp' });
|
|
112
|
-
* const ctx = getTraceContext();
|
|
113
|
-
* bunyanLogger.info({ ...ctx, userId: '123' }, 'Creating user');
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
/**
|
|
117
|
-
* Log level constants
|
|
118
|
-
*/
|
|
119
|
-
const LOG_LEVEL = {
|
|
120
|
-
DEBUG: "debug",
|
|
121
|
-
INFO: "info",
|
|
122
|
-
WARN: "warn",
|
|
123
|
-
ERROR: "error"
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* TS5+ Standard Decorator for logging and tracing operations
|
|
127
|
-
* Uses TC39 Stage 3 decorator syntax
|
|
128
|
-
*
|
|
129
|
-
* This is the traditional per-method decorator approach.
|
|
130
|
-
* For zero-boilerplate solution, see @Instrumented class decorator.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* // Simple usage (Pino-style: object first, message second)
|
|
134
|
-
* class OrderService {
|
|
135
|
-
* constructor(private readonly deps: { log: Logger }) {}
|
|
136
|
-
*
|
|
137
|
-
* @LoggedOperation('order.create')
|
|
138
|
-
* async createOrder(data: CreateOrderData) {
|
|
139
|
-
* // ✅ Correct Pino-style logging
|
|
140
|
-
* this.deps.log.info({ orderId: data.id }, 'Creating order');
|
|
141
|
-
* }
|
|
142
|
-
* }
|
|
143
|
-
*
|
|
144
|
-
* // Advanced usage (future-proof for options)
|
|
145
|
-
* @LoggedOperation({ operationName: 'order.create' })
|
|
146
|
-
* async createOrder(data: CreateOrderData) { }
|
|
147
|
-
*/
|
|
148
|
-
function LoggedOperation(operationNameOrOptions) {
|
|
149
|
-
const operationName = typeof operationNameOrOptions === "string" ? operationNameOrOptions : operationNameOrOptions.operationName;
|
|
150
|
-
return function(originalMethod, context) {
|
|
151
|
-
const methodName = String(context.name);
|
|
152
|
-
return async function(...args) {
|
|
153
|
-
const log = this.deps?.log;
|
|
154
|
-
const startTime = performance.now();
|
|
155
|
-
return getConfig().tracer.startActiveSpan(operationName, async (span) => {
|
|
156
|
-
try {
|
|
157
|
-
log?.info({
|
|
158
|
-
operation: operationName,
|
|
159
|
-
method: methodName,
|
|
160
|
-
args
|
|
161
|
-
}, "Operation started");
|
|
162
|
-
const result = await originalMethod.apply(this, args);
|
|
163
|
-
const duration = performance.now() - startTime;
|
|
164
|
-
log?.info({
|
|
165
|
-
operation: operationName,
|
|
166
|
-
method: methodName,
|
|
167
|
-
duration
|
|
168
|
-
}, "Operation completed");
|
|
169
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
170
|
-
span.setAttributes({
|
|
171
|
-
"operation.name": operationName,
|
|
172
|
-
"operation.method": methodName,
|
|
173
|
-
"operation.duration": duration,
|
|
174
|
-
"operation.success": true
|
|
175
|
-
});
|
|
176
|
-
return result;
|
|
177
|
-
} catch (error) {
|
|
178
|
-
const duration = performance.now() - startTime;
|
|
179
|
-
log?.error({
|
|
180
|
-
err: error instanceof Error ? error : void 0,
|
|
181
|
-
operation: operationName,
|
|
182
|
-
method: methodName,
|
|
183
|
-
duration
|
|
184
|
-
}, "Operation failed");
|
|
185
|
-
span.setStatus({
|
|
186
|
-
code: SpanStatusCode.ERROR,
|
|
187
|
-
message: error instanceof Error ? error.message : "Unknown error"
|
|
188
|
-
});
|
|
189
|
-
span.setAttributes({
|
|
190
|
-
"operation.name": operationName,
|
|
191
|
-
"operation.method": methodName,
|
|
192
|
-
"operation.duration": duration,
|
|
193
|
-
"operation.success": false,
|
|
194
|
-
"error.type": error instanceof Error ? error.constructor.name : "Unknown"
|
|
195
|
-
});
|
|
196
|
-
throw error;
|
|
197
|
-
} finally {
|
|
198
|
-
span.end();
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
//#endregion
|
|
206
|
-
exports.LOG_LEVEL = LOG_LEVEL;
|
|
207
|
-
exports.LoggedOperation = LoggedOperation;
|
|
208
|
-
Object.defineProperty(exports, 'autotelLogger', {
|
|
209
|
-
enumerable: true,
|
|
210
|
-
get: function () {
|
|
211
|
-
return autotelLogger;
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
Object.defineProperty(exports, 'createBuiltinLogger', {
|
|
215
|
-
enumerable: true,
|
|
216
|
-
get: function () {
|
|
217
|
-
return createBuiltinLogger;
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
Object.defineProperty(exports, 'getActiveLogLevel', {
|
|
221
|
-
enumerable: true,
|
|
222
|
-
get: function () {
|
|
223
|
-
return getActiveLogLevel;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
Object.defineProperty(exports, 'getTraceContext', {
|
|
227
|
-
enumerable: true,
|
|
228
|
-
get: function () {
|
|
229
|
-
return getTraceContext;
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
Object.defineProperty(exports, 'runWithLogLevel', {
|
|
233
|
-
enumerable: true,
|
|
234
|
-
get: function () {
|
|
235
|
-
return runWithLogLevel;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
//# sourceMappingURL=logger.cjs.map
|
|
4
|
+
exports.LOG_LEVEL = require_logger.LOG_LEVEL;
|
|
5
|
+
exports.LoggedOperation = require_logger.LoggedOperation;
|
|
6
|
+
exports.autotelLogger = require_logger.autotelLogger;
|
|
7
|
+
exports.createBuiltinLogger = require_logger.createBuiltinLogger;
|
|
8
|
+
exports.getActiveLogLevel = require_logger.getActiveLogLevel;
|
|
9
|
+
exports.getTraceContext = require_logger.getTraceContext;
|
|
10
|
+
exports.runWithLogLevel = require_logger.runWithLogLevel;
|
package/dist/logger.js
CHANGED
|
@@ -1,205 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Logger types and utilities for autotel
|
|
4
|
-
*
|
|
5
|
-
* **Zero-Config Option:** Don't provide a logger to `init()` and autotel uses
|
|
6
|
-
* a built-in structured JSON logger with automatic trace context injection.
|
|
7
|
-
*
|
|
8
|
-
* **BYOL (Bring Your Own Logger):** Pass Pino or Bunyan to `init()` for
|
|
9
|
-
* automatic instrumentation with trace context and OTLP log export.
|
|
10
|
-
*
|
|
11
|
-
* ## Logger Signature
|
|
12
|
-
*
|
|
13
|
-
* Autotel v2.10+ uses **Pino's signature**: `logger.info({ metadata }, 'message')`.
|
|
14
|
-
*
|
|
15
|
-
* ### Backward Compatibility
|
|
16
|
-
*
|
|
17
|
-
* The built-in logger auto-detects legacy Winston-style calls and swaps arguments:
|
|
18
|
-
* ```typescript
|
|
19
|
-
* // Legacy (auto-detected and handled)
|
|
20
|
-
* logger.info('User created', { userId: '123' });
|
|
21
|
-
* // → Internally treated as: logger.info({ userId: '123' }, 'User created')
|
|
22
|
-
* // → Logs warning in development, works silently in production
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* ### Recommended Usage
|
|
26
|
-
*
|
|
27
|
-
* ```typescript
|
|
28
|
-
* // ✅ Pino-style (preferred)
|
|
29
|
-
* logger.info({ userId: '123' }, 'User created');
|
|
30
|
-
*
|
|
31
|
-
* // ✅ Simple message (no metadata)
|
|
32
|
-
* logger.info('Server started');
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* **Note:** If you BYOL (bring your own logger), it must use Pino signature.
|
|
36
|
-
* Winston and other `(message, meta)` loggers are NOT compatible.
|
|
37
|
-
* For Winston, use `@opentelemetry/instrumentation-winston` instead.
|
|
38
|
-
*
|
|
39
|
-
* @example Zero-config (uses built-in logger)
|
|
40
|
-
* ```typescript
|
|
41
|
-
* import { init } from 'autotel';
|
|
42
|
-
*
|
|
43
|
-
* init({ service: 'my-app' });
|
|
44
|
-
* // Internal logs: {"level":"info","service":"my-app","msg":"...","traceId":"..."}
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @example Using built-in logger directly
|
|
48
|
-
* ```typescript
|
|
49
|
-
* import { createBuiltinLogger, runWithLogLevel } from 'autotel/logger';
|
|
50
|
-
*
|
|
51
|
-
* const log = createBuiltinLogger('my-service');
|
|
52
|
-
*
|
|
53
|
-
* // Simple message (no metadata)
|
|
54
|
-
* log.info('Server started');
|
|
55
|
-
*
|
|
56
|
-
* // With metadata (Pino-style: object first, message second)
|
|
57
|
-
* log.info({ userId: '123' }, 'User created');
|
|
58
|
-
* // Output: {"level":"info","service":"my-service","msg":"User created","userId":"123","traceId":"..."}
|
|
59
|
-
*
|
|
60
|
-
* // Dynamic log level per-request
|
|
61
|
-
* runWithLogLevel('debug', () => {
|
|
62
|
-
* log.debug('Debug info for this request only');
|
|
63
|
-
* });
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @example Using Pino (recommended for production, auto-instrumented)
|
|
67
|
-
* ```typescript
|
|
68
|
-
* import pino from 'pino'; // npm install pino
|
|
69
|
-
* import { init } from 'autotel';
|
|
70
|
-
*
|
|
71
|
-
* const logger = pino({ level: 'info' });
|
|
72
|
-
* init({ service: 'my-app', logger });
|
|
73
|
-
*
|
|
74
|
-
* // Logs automatically include traceId/spanId and export via OTLP!
|
|
75
|
-
* logger.info({ userId: '123' }, 'User created');
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
|
-
* @example Using Bunyan (auto-instrumented, same signature as Pino)
|
|
79
|
-
* ```typescript
|
|
80
|
-
* import bunyan from 'bunyan'; // npm install bunyan @opentelemetry/instrumentation-bunyan
|
|
81
|
-
* import { init } from 'autotel';
|
|
82
|
-
* import { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';
|
|
83
|
-
*
|
|
84
|
-
* const logger = bunyan.createLogger({ name: 'my-app' });
|
|
85
|
-
* init({
|
|
86
|
-
* service: 'my-app',
|
|
87
|
-
* logger,
|
|
88
|
-
* instrumentations: [new BunyanInstrumentation()]
|
|
89
|
-
* });
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* @example Custom logger (MUST use Pino-compatible signature)
|
|
93
|
-
* ```typescript
|
|
94
|
-
* // ⚠️ Your custom logger MUST accept (object, message?) signature
|
|
95
|
-
* const logger = {
|
|
96
|
-
* info: (extra, msg) => console.log(msg || '', extra),
|
|
97
|
-
* warn: (extra, msg) => console.warn(msg || '', extra),
|
|
98
|
-
* error: (extra, msg) => console.error(msg || '', extra),
|
|
99
|
-
* debug: (extra, msg) => console.debug(msg || '', extra),
|
|
100
|
-
* };
|
|
101
|
-
* init({ service: 'my-app', logger });
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* @example BYOL helper: inject trace context into any logger
|
|
105
|
-
* ```typescript
|
|
106
|
-
* import bunyan from 'bunyan';
|
|
107
|
-
* import { getTraceContext } from 'autotel/logger';
|
|
108
|
-
*
|
|
109
|
-
* const bunyanLogger = bunyan.createLogger({ name: 'myapp' });
|
|
110
|
-
* const ctx = getTraceContext();
|
|
111
|
-
* bunyanLogger.info({ ...ctx, userId: '123' }, 'Creating user');
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
/**
|
|
115
|
-
* Log level constants
|
|
116
|
-
*/
|
|
117
|
-
const LOG_LEVEL = {
|
|
118
|
-
DEBUG: "debug",
|
|
119
|
-
INFO: "info",
|
|
120
|
-
WARN: "warn",
|
|
121
|
-
ERROR: "error"
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* TS5+ Standard Decorator for logging and tracing operations
|
|
125
|
-
* Uses TC39 Stage 3 decorator syntax
|
|
126
|
-
*
|
|
127
|
-
* This is the traditional per-method decorator approach.
|
|
128
|
-
* For zero-boilerplate solution, see @Instrumented class decorator.
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* // Simple usage (Pino-style: object first, message second)
|
|
132
|
-
* class OrderService {
|
|
133
|
-
* constructor(private readonly deps: { log: Logger }) {}
|
|
134
|
-
*
|
|
135
|
-
* @LoggedOperation('order.create')
|
|
136
|
-
* async createOrder(data: CreateOrderData) {
|
|
137
|
-
* // ✅ Correct Pino-style logging
|
|
138
|
-
* this.deps.log.info({ orderId: data.id }, 'Creating order');
|
|
139
|
-
* }
|
|
140
|
-
* }
|
|
141
|
-
*
|
|
142
|
-
* // Advanced usage (future-proof for options)
|
|
143
|
-
* @LoggedOperation({ operationName: 'order.create' })
|
|
144
|
-
* async createOrder(data: CreateOrderData) { }
|
|
145
|
-
*/
|
|
146
|
-
function LoggedOperation(operationNameOrOptions) {
|
|
147
|
-
const operationName = typeof operationNameOrOptions === "string" ? operationNameOrOptions : operationNameOrOptions.operationName;
|
|
148
|
-
return function(originalMethod, context) {
|
|
149
|
-
const methodName = String(context.name);
|
|
150
|
-
return async function(...args) {
|
|
151
|
-
const log = this.deps?.log;
|
|
152
|
-
const startTime = performance.now();
|
|
153
|
-
return getConfig().tracer.startActiveSpan(operationName, async (span) => {
|
|
154
|
-
try {
|
|
155
|
-
log?.info({
|
|
156
|
-
operation: operationName,
|
|
157
|
-
method: methodName,
|
|
158
|
-
args
|
|
159
|
-
}, "Operation started");
|
|
160
|
-
const result = await originalMethod.apply(this, args);
|
|
161
|
-
const duration = performance.now() - startTime;
|
|
162
|
-
log?.info({
|
|
163
|
-
operation: operationName,
|
|
164
|
-
method: methodName,
|
|
165
|
-
duration
|
|
166
|
-
}, "Operation completed");
|
|
167
|
-
span.setStatus({ code: SpanStatusCode.OK });
|
|
168
|
-
span.setAttributes({
|
|
169
|
-
"operation.name": operationName,
|
|
170
|
-
"operation.method": methodName,
|
|
171
|
-
"operation.duration": duration,
|
|
172
|
-
"operation.success": true
|
|
173
|
-
});
|
|
174
|
-
return result;
|
|
175
|
-
} catch (error) {
|
|
176
|
-
const duration = performance.now() - startTime;
|
|
177
|
-
log?.error({
|
|
178
|
-
err: error instanceof Error ? error : void 0,
|
|
179
|
-
operation: operationName,
|
|
180
|
-
method: methodName,
|
|
181
|
-
duration
|
|
182
|
-
}, "Operation failed");
|
|
183
|
-
span.setStatus({
|
|
184
|
-
code: SpanStatusCode.ERROR,
|
|
185
|
-
message: error instanceof Error ? error.message : "Unknown error"
|
|
186
|
-
});
|
|
187
|
-
span.setAttributes({
|
|
188
|
-
"operation.name": operationName,
|
|
189
|
-
"operation.method": methodName,
|
|
190
|
-
"operation.duration": duration,
|
|
191
|
-
"operation.success": false,
|
|
192
|
-
"error.type": error instanceof Error ? error.constructor.name : "Unknown"
|
|
193
|
-
});
|
|
194
|
-
throw error;
|
|
195
|
-
} finally {
|
|
196
|
-
span.end();
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
}
|
|
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";
|
|
202
2
|
|
|
203
|
-
|
|
204
|
-
export { LOG_LEVEL, LoggedOperation, autotelLogger, createBuiltinLogger, getActiveLogLevel, getTraceContext, runWithLogLevel };
|
|
205
|
-
//# sourceMappingURL=logger.js.map
|
|
3
|
+
export { LOG_LEVEL, LoggedOperation, autotelLogger, createBuiltinLogger, getActiveLogLevel, getTraceContext, runWithLogLevel };
|
package/dist/messaging.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_sampling = require('./sampling.cjs');
|
|
3
|
-
const require_functional = require('./functional-
|
|
3
|
+
const require_functional = require('./functional-zpzNLhky.cjs');
|
|
4
4
|
const require_correlated_events = require('./correlated-events-kSwLo3mi.cjs');
|
|
5
5
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
6
6
|
|
package/dist/messaging.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLinkFromHeaders, extractLinksFromBatch } from "./sampling.js";
|
|
2
|
-
import { a as trace$1 } from "./functional-
|
|
2
|
+
import { a as trace$1 } from "./functional-DtI0u4vx.js";
|
|
3
3
|
import { t as emitCorrelatedEvent } from "./correlated-events-Bzh5y-UB.js";
|
|
4
4
|
import { SpanKind, context, propagation } from "@opentelemetry/api";
|
|
5
5
|
|
package/dist/semantic-helpers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_init = require('./init-DvapOXCc.cjs');
|
|
2
1
|
const require_config = require('./config.cjs');
|
|
2
|
+
const require_init = require('./init-BX7AmFRl.cjs');
|
|
3
3
|
const require_structured_error = require('./structured-error-CHg7DoIQ.cjs');
|
|
4
4
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
5
5
|
let node_async_hooks = require("node:async_hooks");
|
|
@@ -1209,4 +1209,4 @@ Object.defineProperty(exports, 'validateEvent', {
|
|
|
1209
1209
|
return validateEvent;
|
|
1210
1210
|
}
|
|
1211
1211
|
});
|
|
1212
|
-
//# sourceMappingURL=track-
|
|
1212
|
+
//# sourceMappingURL=track-D59FfpL0.cjs.map
|