vestig 0.4.0 → 0.6.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/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +44 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +50 -0
- package/dist/logger.js.map +1 -1
- package/dist/tracing/context.d.ts +56 -0
- package/dist/tracing/context.d.ts.map +1 -0
- package/dist/tracing/context.js +96 -0
- package/dist/tracing/context.js.map +1 -0
- package/dist/tracing/functions.d.ts +111 -0
- package/dist/tracing/functions.d.ts.map +1 -0
- package/dist/tracing/functions.js +162 -0
- package/dist/tracing/functions.js.map +1 -0
- package/dist/tracing/index.d.ts +37 -0
- package/dist/tracing/index.d.ts.map +1 -0
- package/dist/tracing/index.js +39 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/span.d.ts +37 -0
- package/dist/tracing/span.d.ts.map +1 -0
- package/dist/tracing/span.js +127 -0
- package/dist/tracing/span.js.map +1 -0
- package/dist/tracing/types.d.ts +100 -0
- package/dist/tracing/types.d.ts.map +1 -0
- package/dist/tracing/types.js +8 -0
- package/dist/tracing/types.js.map +1 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createLogger, LoggerImpl } from './logger';
|
|
2
|
-
export type { Logger, LoggerConfig, LogLevel, LogEntry, LogMetadata, LogContext, Transport, TransportConfig, BatchTransportConfig, HTTPTransportConfig, FileTransportConfig, DatadogTransportConfig, SerializedError, Runtime, FieldMatcher, SanitizePattern, SanitizeConfig, SanitizePreset, } from './types';
|
|
2
|
+
export type { Logger, LoggerConfig, LogLevel, LogEntry, LogMetadata, LogContext, Transport, TransportConfig, BatchTransportConfig, HTTPTransportConfig, FileTransportConfig, DatadogTransportConfig, SerializedError, Runtime, FieldMatcher, SanitizePattern, SanitizeConfig, SanitizePreset, Span, SpanCallback, SpanEvent, SpanOptions, SpanStatus, SpanSyncCallback, } from './types';
|
|
3
3
|
export { RUNTIME, CAPABILITIES, IS_NODE, IS_BUN, IS_EDGE, IS_BROWSER, IS_WORKER, IS_SERVER, } from './runtime';
|
|
4
4
|
export type { RuntimeCapabilities } from './runtime';
|
|
5
5
|
export { LOG_LEVELS, shouldLog, parseLogLevel } from './levels';
|
|
@@ -15,6 +15,7 @@ export { BatchTransport } from './transports/batch';
|
|
|
15
15
|
export { HTTPTransport, HTTPTransportError } from './transports/http';
|
|
16
16
|
export { FileTransport } from './transports/file';
|
|
17
17
|
export { DatadogTransport, DatadogTransportError } from './transports/datadog';
|
|
18
|
+
export { span, spanSync, startSpan, endSpan, getActiveSpan, withActiveSpan, SpanImpl, clearActiveSpans, getActiveSpanStackDepth, withSpanContext, withSpanContextAsync, } from './tracing';
|
|
18
19
|
/**
|
|
19
20
|
* Default logger instance with auto-configuration
|
|
20
21
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACnD,YAAY,EACX,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,OAAO,EAEP,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACnD,YAAY,EACX,MAAM,EACN,YAAY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AE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAG9E,OAAO,EACN,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,aAAa,EACb,cAAc,EACd,QAAQ,EAER,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,GACpB,MAAM,WAAW,CAAA;AAKlB;;GAEG;AACH,eAAO,MAAM,GAAG,0BAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,10 @@ export { BatchTransport } from './transports/batch';
|
|
|
18
18
|
export { HTTPTransport, HTTPTransportError } from './transports/http';
|
|
19
19
|
export { FileTransport } from './transports/file';
|
|
20
20
|
export { DatadogTransport, DatadogTransportError } from './transports/datadog';
|
|
21
|
+
// Tracing - standalone functions and utilities
|
|
22
|
+
export { span, spanSync, startSpan, endSpan, getActiveSpan, withActiveSpan, SpanImpl,
|
|
23
|
+
// Context utilities (for advanced use cases)
|
|
24
|
+
clearActiveSpans, getActiveSpanStackDepth, withSpanContext, withSpanContextAsync, } from './tracing';
|
|
21
25
|
// Default logger instance (convenience)
|
|
22
26
|
import { createLogger } from './logger';
|
|
23
27
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA8BnD,oBAAoB;AACpB,OAAO,EACN,OAAO,EACP,YAAY,EACZ,OAAO,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AEvC;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,YAAY,EAAE,CAAA"}
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SpanCallback, type SpanOptions, type SpanSyncCallback } from './tracing';
|
|
1
2
|
import type { LogLevel, LogMetadata, Logger, LoggerConfig, Transport } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Core logger implementation
|
|
@@ -74,6 +75,49 @@ export declare class LoggerImpl implements Logger {
|
|
|
74
75
|
* Destroy all transports (call on shutdown)
|
|
75
76
|
*/
|
|
76
77
|
destroy(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Create and run a span for an async operation
|
|
80
|
+
*
|
|
81
|
+
* The span name will be prefixed with the logger's namespace if present.
|
|
82
|
+
* This provides automatic instrumentation context for your operations.
|
|
83
|
+
*
|
|
84
|
+
* @param name - Human-readable name for the operation
|
|
85
|
+
* @param fn - Async function to execute within the span
|
|
86
|
+
* @param options - Optional span configuration
|
|
87
|
+
* @returns The result of the function
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const db = log.child('database')
|
|
92
|
+
* const result = await db.span('query', async (span) => {
|
|
93
|
+
* span.setAttribute('table', 'users')
|
|
94
|
+
* return await executeQuery()
|
|
95
|
+
* })
|
|
96
|
+
* // Span name will be 'database:query'
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
span<T>(name: string, fn: SpanCallback<T>, options?: SpanOptions): Promise<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Create and run a span for a synchronous operation
|
|
102
|
+
*
|
|
103
|
+
* Similar to `span()` but for synchronous code.
|
|
104
|
+
*
|
|
105
|
+
* @param name - Human-readable name for the operation
|
|
106
|
+
* @param fn - Synchronous function to execute within the span
|
|
107
|
+
* @param options - Optional span configuration
|
|
108
|
+
* @returns The result of the function
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const parser = log.child('parser')
|
|
113
|
+
* const data = parser.spanSync('parse-json', (span) => {
|
|
114
|
+
* span.setAttribute('size', content.length)
|
|
115
|
+
* return JSON.parse(content)
|
|
116
|
+
* })
|
|
117
|
+
* // Span name will be 'parser:parse-json'
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
spanSync<T>(name: string, fn: SpanSyncCallback<T>, options?: SpanOptions): T;
|
|
77
121
|
}
|
|
78
122
|
/**
|
|
79
123
|
* Create a new logger instance
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGX,QAAQ,EACR,WAAW,EACX,MAAM,EACN,YAAY,EACZ,SAAS,EACT,MAAM,SAAS,CAAA;AAsDhB;;GAEG;AACH,qBAAa,UAAW,YAAW,MAAM;IACxC,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,QAAQ,CAAqC;IACrD,OAAO,CAAC,WAAW,CAAQ;gBAEf,MAAM,CAAC,EAAE,YAAY;IAYjC;;OAEG;IACH,OAAO,CAAC,GAAG;IAkDX;;OAEG;IACH,OAAO,CAAC,YAAY;IAUpB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI;IACpD,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAK/B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI;IACpD,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAK/B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI;IACnD,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE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EG;IACH,OAAO,IAAI,IAAI;IAIf;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAgBxC;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAetC;;OAEG;IACH,aAAa,IAAI,SAAS,SAAS,EAAE;IAIrC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,IAAI,CAAC,CAAC,EACX,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,EACnB,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,CAAC,CAAC;IAKb;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,CAAC;CAI5E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE1D"}
|
package/dist/logger.js
CHANGED
|
@@ -3,6 +3,7 @@ import { getContext } from './context';
|
|
|
3
3
|
import { LOG_LEVELS, shouldLog } from './levels';
|
|
4
4
|
import { RUNTIME } from './runtime';
|
|
5
5
|
import { ConsoleTransport } from './transports/console';
|
|
6
|
+
import { span as spanFn, spanSync as spanSyncFn, } from './tracing';
|
|
6
7
|
import { isError, serializeError } from './utils/error';
|
|
7
8
|
import { sanitize } from './utils/sanitize';
|
|
8
9
|
/**
|
|
@@ -257,6 +258,55 @@ export class LoggerImpl {
|
|
|
257
258
|
this.transports = [];
|
|
258
259
|
this.initialized = false;
|
|
259
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Create and run a span for an async operation
|
|
263
|
+
*
|
|
264
|
+
* The span name will be prefixed with the logger's namespace if present.
|
|
265
|
+
* This provides automatic instrumentation context for your operations.
|
|
266
|
+
*
|
|
267
|
+
* @param name - Human-readable name for the operation
|
|
268
|
+
* @param fn - Async function to execute within the span
|
|
269
|
+
* @param options - Optional span configuration
|
|
270
|
+
* @returns The result of the function
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* const db = log.child('database')
|
|
275
|
+
* const result = await db.span('query', async (span) => {
|
|
276
|
+
* span.setAttribute('table', 'users')
|
|
277
|
+
* return await executeQuery()
|
|
278
|
+
* })
|
|
279
|
+
* // Span name will be 'database:query'
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
async span(name, fn, options) {
|
|
283
|
+
const fullName = this.config.namespace ? `${this.config.namespace}:${name}` : name;
|
|
284
|
+
return spanFn(fullName, fn, options);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Create and run a span for a synchronous operation
|
|
288
|
+
*
|
|
289
|
+
* Similar to `span()` but for synchronous code.
|
|
290
|
+
*
|
|
291
|
+
* @param name - Human-readable name for the operation
|
|
292
|
+
* @param fn - Synchronous function to execute within the span
|
|
293
|
+
* @param options - Optional span configuration
|
|
294
|
+
* @returns The result of the function
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const parser = log.child('parser')
|
|
299
|
+
* const data = parser.spanSync('parse-json', (span) => {
|
|
300
|
+
* span.setAttribute('size', content.length)
|
|
301
|
+
* return JSON.parse(content)
|
|
302
|
+
* })
|
|
303
|
+
* // Span name will be 'parser:parse-json'
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
spanSync(name, fn, options) {
|
|
307
|
+
const fullName = this.config.namespace ? `${this.config.namespace}:${name}` : name;
|
|
308
|
+
return spanSyncFn(fullName, fn, options);
|
|
309
|
+
}
|
|
260
310
|
}
|
|
261
311
|
/**
|
|
262
312
|
* Create a new logger instance
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EACN,IAAI,IAAI,MAAM,EACd,QAAQ,IAAI,UAAU,GAKtB,MAAM,WAAW,CAAA;AAUlB,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C;;GAEG;AACH,SAAS,UAAU,CAAC,IAAe;IAClC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;IACrC,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IAErB,6CAA6C;IAC7C,I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CAAA;IACrC,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAI,IAAY,EAAE,EAAuB,EAAE,OAAqB;QACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;QAClF,OAAO,UAAU,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAqB;IACjD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Span } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Push a span onto the active span stack
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare function pushSpan(span: Span): void;
|
|
7
|
+
/**
|
|
8
|
+
* Pop a span from the active span stack
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function popSpan(): Span | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Get the currently active span (the one at the top of the stack)
|
|
14
|
+
*
|
|
15
|
+
* @returns The active span, or undefined if no span is active
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const active = getActiveSpan()
|
|
20
|
+
* if (active) {
|
|
21
|
+
* active.addEvent('checkpoint', { step: 3 })
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function getActiveSpan(): Span | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Clear all active spans
|
|
28
|
+
* Mainly useful for testing
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export declare function clearActiveSpans(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get the current stack depth
|
|
34
|
+
* Mainly useful for testing
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare function getActiveSpanStackDepth(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Run a function with the given span as active
|
|
40
|
+
*
|
|
41
|
+
* This pushes the span onto the stack, runs the function,
|
|
42
|
+
* and pops the span when done (even if an error occurs).
|
|
43
|
+
*
|
|
44
|
+
* It also propagates the trace context through the async
|
|
45
|
+
* context system so that logs within the span will have
|
|
46
|
+
* the correct traceId and spanId.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function withSpanContext<T>(span: Span, fn: () => T): T;
|
|
51
|
+
/**
|
|
52
|
+
* Async version of withSpanContext
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export declare function withSpanContextAsync<T>(span: Span, fn: () => Promise<T>): Promise<T>;
|
|
56
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/tracing/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAWnC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAEzC;AAED;;;GAGG;AACH,wBAAgB,OAAO,IAAI,IAAI,GAAG,SAAS,CAE1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,IAAI,IAAI,GAAG,SAAS,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAU7D;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,EAC3C,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,CAAC,CAAC,CAUZ"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { withContext } from '../context';
|
|
2
|
+
/**
|
|
3
|
+
* Active span stack for tracking nested spans
|
|
4
|
+
*
|
|
5
|
+
* In environments with AsyncLocalStorage, we also propagate
|
|
6
|
+
* the span context through the async context system for
|
|
7
|
+
* proper correlation with logs.
|
|
8
|
+
*/
|
|
9
|
+
let activeSpanStack = [];
|
|
10
|
+
/**
|
|
11
|
+
* Push a span onto the active span stack
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export function pushSpan(span) {
|
|
15
|
+
activeSpanStack.push(span);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Pop a span from the active span stack
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export function popSpan() {
|
|
22
|
+
return activeSpanStack.pop();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the currently active span (the one at the top of the stack)
|
|
26
|
+
*
|
|
27
|
+
* @returns The active span, or undefined if no span is active
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const active = getActiveSpan()
|
|
32
|
+
* if (active) {
|
|
33
|
+
* active.addEvent('checkpoint', { step: 3 })
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function getActiveSpan() {
|
|
38
|
+
return activeSpanStack[activeSpanStack.length - 1];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Clear all active spans
|
|
42
|
+
* Mainly useful for testing
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export function clearActiveSpans() {
|
|
46
|
+
activeSpanStack = [];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get the current stack depth
|
|
50
|
+
* Mainly useful for testing
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export function getActiveSpanStackDepth() {
|
|
54
|
+
return activeSpanStack.length;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Run a function with the given span as active
|
|
58
|
+
*
|
|
59
|
+
* This pushes the span onto the stack, runs the function,
|
|
60
|
+
* and pops the span when done (even if an error occurs).
|
|
61
|
+
*
|
|
62
|
+
* It also propagates the trace context through the async
|
|
63
|
+
* context system so that logs within the span will have
|
|
64
|
+
* the correct traceId and spanId.
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export function withSpanContext(span, fn) {
|
|
69
|
+
// Propagate trace context to the logging system
|
|
70
|
+
return withContext({ traceId: span.traceId, spanId: span.spanId }, () => {
|
|
71
|
+
pushSpan(span);
|
|
72
|
+
try {
|
|
73
|
+
return fn();
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
popSpan();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Async version of withSpanContext
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export async function withSpanContextAsync(span, fn) {
|
|
85
|
+
// Propagate trace context to the logging system
|
|
86
|
+
return withContext({ traceId: span.traceId, spanId: span.spanId }, async () => {
|
|
87
|
+
pushSpan(span);
|
|
88
|
+
try {
|
|
89
|
+
return await fn();
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
popSpan();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/tracing/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGxC;;;;;;GAMG;AACH,IAAI,eAAe,GAAW,EAAE,CAAA;AA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CAAA;QACV,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Span, SpanCallback, SpanOptions, SpanSyncCallback } from './types';
|
|
2
|
+
export { getActiveSpan } from './context';
|
|
3
|
+
/**
|
|
4
|
+
* Create and run a span for an async operation
|
|
5
|
+
*
|
|
6
|
+
* This is the recommended way to create spans. It automatically:
|
|
7
|
+
* - Creates a new span with proper parent/child relationship
|
|
8
|
+
* - Sets status to 'ok' on success or 'error' on exception
|
|
9
|
+
* - Ends the span when the operation completes
|
|
10
|
+
* - Propagates trace context to nested operations
|
|
11
|
+
*
|
|
12
|
+
* @param name - Human-readable name for the operation
|
|
13
|
+
* @param fn - Async function to execute within the span
|
|
14
|
+
* @param options - Optional span configuration
|
|
15
|
+
* @returns The result of the function
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const result = await span('checkout', async (s) => {
|
|
20
|
+
* s.setAttribute('userId', user.id)
|
|
21
|
+
* s.setAttribute('cartItems', cart.length)
|
|
22
|
+
*
|
|
23
|
+
* s.addEvent('validating-cart')
|
|
24
|
+
* await validateCart(cart)
|
|
25
|
+
*
|
|
26
|
+
* s.addEvent('processing-payment')
|
|
27
|
+
* const payment = await processPayment(cart.total)
|
|
28
|
+
*
|
|
29
|
+
* return { orderId: payment.orderId }
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function span<T>(name: string, fn: SpanCallback<T>, options?: SpanOptions): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Create and run a span for a synchronous operation
|
|
36
|
+
*
|
|
37
|
+
* Similar to `span()` but for synchronous code.
|
|
38
|
+
*
|
|
39
|
+
* @param name - Human-readable name for the operation
|
|
40
|
+
* @param fn - Synchronous function to execute within the span
|
|
41
|
+
* @param options - Optional span configuration
|
|
42
|
+
* @returns The result of the function
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const parsed = spanSync('parse-config', (s) => {
|
|
47
|
+
* s.setAttribute('configPath', path)
|
|
48
|
+
* return JSON.parse(configContent)
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function spanSync<T>(name: string, fn: SpanSyncCallback<T>, options?: SpanOptions): T;
|
|
53
|
+
/**
|
|
54
|
+
* Manually start a new span
|
|
55
|
+
*
|
|
56
|
+
* Use this for cases where you need more control over span lifecycle.
|
|
57
|
+
* Remember to call `endSpan()` when done!
|
|
58
|
+
*
|
|
59
|
+
* For most cases, prefer using `span()` which handles the lifecycle automatically.
|
|
60
|
+
*
|
|
61
|
+
* @param name - Human-readable name for the operation
|
|
62
|
+
* @param options - Optional span configuration
|
|
63
|
+
* @returns The created span
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const s = startSpan('long-operation')
|
|
68
|
+
* try {
|
|
69
|
+
* s.setAttribute('phase', 'init')
|
|
70
|
+
* await initialize()
|
|
71
|
+
*
|
|
72
|
+
* s.setAttribute('phase', 'process')
|
|
73
|
+
* await process()
|
|
74
|
+
*
|
|
75
|
+
* s.setStatus('ok')
|
|
76
|
+
* } catch (error) {
|
|
77
|
+
* s.setStatus('error', error.message)
|
|
78
|
+
* throw error
|
|
79
|
+
* } finally {
|
|
80
|
+
* endSpan(s)
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function startSpan(name: string, options?: SpanOptions): Span;
|
|
85
|
+
/**
|
|
86
|
+
* End a manually started span
|
|
87
|
+
*
|
|
88
|
+
* This ends the span and removes it from the active span stack.
|
|
89
|
+
* Should be called in a finally block to ensure cleanup.
|
|
90
|
+
*
|
|
91
|
+
* @param span - The span to end
|
|
92
|
+
*/
|
|
93
|
+
export declare function endSpan(spanToEnd: Span): void;
|
|
94
|
+
/**
|
|
95
|
+
* Execute a function if there's an active span
|
|
96
|
+
*
|
|
97
|
+
* Convenience function to safely interact with the current span
|
|
98
|
+
* without having to check for undefined.
|
|
99
|
+
*
|
|
100
|
+
* @param fn - Function to execute with the active span
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // Add an event to the current span if one exists
|
|
105
|
+
* withActiveSpan(span => {
|
|
106
|
+
* span.addEvent('database-query', { query: 'SELECT...' })
|
|
107
|
+
* })
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function withActiveSpan(fn: (span: Span) => void): void;
|
|
111
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/tracing/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAWhF,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAC3B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,EACnB,OAAO,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,CAAC,CAAC,CAkBZ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACzB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACvB,OAAO,CAAC,EAAE,WAAW,GACnB,CAAC,CAiBH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAInE;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAG7C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI,CAK7D"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { SpanImpl } from './span';
|
|
2
|
+
import { getActiveSpan, pushSpan, popSpan, withSpanContext, withSpanContextAsync, } from './context';
|
|
3
|
+
// Re-export for convenience
|
|
4
|
+
export { getActiveSpan } from './context';
|
|
5
|
+
/**
|
|
6
|
+
* Create and run a span for an async operation
|
|
7
|
+
*
|
|
8
|
+
* This is the recommended way to create spans. It automatically:
|
|
9
|
+
* - Creates a new span with proper parent/child relationship
|
|
10
|
+
* - Sets status to 'ok' on success or 'error' on exception
|
|
11
|
+
* - Ends the span when the operation completes
|
|
12
|
+
* - Propagates trace context to nested operations
|
|
13
|
+
*
|
|
14
|
+
* @param name - Human-readable name for the operation
|
|
15
|
+
* @param fn - Async function to execute within the span
|
|
16
|
+
* @param options - Optional span configuration
|
|
17
|
+
* @returns The result of the function
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const result = await span('checkout', async (s) => {
|
|
22
|
+
* s.setAttribute('userId', user.id)
|
|
23
|
+
* s.setAttribute('cartItems', cart.length)
|
|
24
|
+
*
|
|
25
|
+
* s.addEvent('validating-cart')
|
|
26
|
+
* await validateCart(cart)
|
|
27
|
+
*
|
|
28
|
+
* s.addEvent('processing-payment')
|
|
29
|
+
* const payment = await processPayment(cart.total)
|
|
30
|
+
*
|
|
31
|
+
* return { orderId: payment.orderId }
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export async function span(name, fn, options) {
|
|
36
|
+
const s = new SpanImpl(name, options);
|
|
37
|
+
return withSpanContextAsync(s, async () => {
|
|
38
|
+
try {
|
|
39
|
+
const result = await fn(s);
|
|
40
|
+
// Only set status to 'ok' if it wasn't explicitly set
|
|
41
|
+
if (s.status === 'unset') {
|
|
42
|
+
s.setStatus('ok');
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
s.setStatus('error', error instanceof Error ? error.message : String(error));
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
s.end();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create and run a span for a synchronous operation
|
|
57
|
+
*
|
|
58
|
+
* Similar to `span()` but for synchronous code.
|
|
59
|
+
*
|
|
60
|
+
* @param name - Human-readable name for the operation
|
|
61
|
+
* @param fn - Synchronous function to execute within the span
|
|
62
|
+
* @param options - Optional span configuration
|
|
63
|
+
* @returns The result of the function
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const parsed = spanSync('parse-config', (s) => {
|
|
68
|
+
* s.setAttribute('configPath', path)
|
|
69
|
+
* return JSON.parse(configContent)
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function spanSync(name, fn, options) {
|
|
74
|
+
const s = new SpanImpl(name, options);
|
|
75
|
+
return withSpanContext(s, () => {
|
|
76
|
+
try {
|
|
77
|
+
const result = fn(s);
|
|
78
|
+
if (s.status === 'unset') {
|
|
79
|
+
s.setStatus('ok');
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
s.setStatus('error', error instanceof Error ? error.message : String(error));
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
s.end();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Manually start a new span
|
|
94
|
+
*
|
|
95
|
+
* Use this for cases where you need more control over span lifecycle.
|
|
96
|
+
* Remember to call `endSpan()` when done!
|
|
97
|
+
*
|
|
98
|
+
* For most cases, prefer using `span()` which handles the lifecycle automatically.
|
|
99
|
+
*
|
|
100
|
+
* @param name - Human-readable name for the operation
|
|
101
|
+
* @param options - Optional span configuration
|
|
102
|
+
* @returns The created span
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const s = startSpan('long-operation')
|
|
107
|
+
* try {
|
|
108
|
+
* s.setAttribute('phase', 'init')
|
|
109
|
+
* await initialize()
|
|
110
|
+
*
|
|
111
|
+
* s.setAttribute('phase', 'process')
|
|
112
|
+
* await process()
|
|
113
|
+
*
|
|
114
|
+
* s.setStatus('ok')
|
|
115
|
+
* } catch (error) {
|
|
116
|
+
* s.setStatus('error', error.message)
|
|
117
|
+
* throw error
|
|
118
|
+
* } finally {
|
|
119
|
+
* endSpan(s)
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export function startSpan(name, options) {
|
|
124
|
+
const s = new SpanImpl(name, options);
|
|
125
|
+
pushSpan(s);
|
|
126
|
+
return s;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* End a manually started span
|
|
130
|
+
*
|
|
131
|
+
* This ends the span and removes it from the active span stack.
|
|
132
|
+
* Should be called in a finally block to ensure cleanup.
|
|
133
|
+
*
|
|
134
|
+
* @param span - The span to end
|
|
135
|
+
*/
|
|
136
|
+
export function endSpan(spanToEnd) {
|
|
137
|
+
spanToEnd.end();
|
|
138
|
+
popSpan();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Execute a function if there's an active span
|
|
142
|
+
*
|
|
143
|
+
* Convenience function to safely interact with the current span
|
|
144
|
+
* without having to check for undefined.
|
|
145
|
+
*
|
|
146
|
+
* @param fn - Function to execute with the active span
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* // Add an event to the current span if one exists
|
|
151
|
+
* withActiveSpan(span => {
|
|
152
|
+
* span.addEvent('database-query', { query: 'SELECT...' })
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export function withActiveSpan(fn) {
|
|
157
|
+
const active = getActiveSpan();
|
|
158
|
+
if (active) {
|
|
159
|
+
fn(active);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/tracing/functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EACN,aAAa,EACb,QAAQ,EACR,OAAO,EACP,eAAe,EACf,oBAAoB,GACpB,MAAM,WAAW,CAAA;AAElB,4BAA4B;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACzB,IAAY,EACZ,EAAmB,EACnB,OAAqB;IAErB,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAErC,OAAO,oBAAoB,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE;QACzC,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;YAC1B,sDAAsD;YACtD,IAAI,CAAC,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBAC1B,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YAClB,CAAC;YACD,OAAO,MAAM,CAAA;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CA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AA;AACV,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,EAAwB;IACtD,MAAM,MAAM,GAAG,aAAa,EAAE,CAAA;IAC9B,IAAI,MAAM,EAAE,CAAC;QACZ,EAAE,CAAC,MAAM,CAAC,CAAA;IACX,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vestig Tracing Module
|
|
3
|
+
*
|
|
4
|
+
* Native tracing support for vestig. Create spans to track
|
|
5
|
+
* operations and their relationships, with automatic correlation
|
|
6
|
+
* to logs.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { span, getActiveSpan } from 'vestig'
|
|
11
|
+
*
|
|
12
|
+
* // Automatic span lifecycle management (recommended)
|
|
13
|
+
* await span('api:request', async (s) => {
|
|
14
|
+
* s.setAttribute('method', 'GET')
|
|
15
|
+
*
|
|
16
|
+
* // Nested spans automatically become children
|
|
17
|
+
* await span('db:query', async (child) => {
|
|
18
|
+
* child.setAttribute('table', 'users')
|
|
19
|
+
* return await db.query('SELECT * FROM users')
|
|
20
|
+
* })
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* // Manual control when needed
|
|
24
|
+
* const s = startSpan('background-job')
|
|
25
|
+
* try {
|
|
26
|
+
* await doWork()
|
|
27
|
+
* s.setStatus('ok')
|
|
28
|
+
* } finally {
|
|
29
|
+
* endSpan(s)
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type { Span, SpanEvent, SpanOptions, SpanStatus, SpanCallback, SpanSyncCallback } from './types';
|
|
34
|
+
export { SpanImpl } from './span';
|
|
35
|
+
export { span, spanSync, startSpan, endSpan, getActiveSpan, withActiveSpan, } from './functions';
|
|
36
|
+
export { clearActiveSpans, getActiveSpanStackDepth, withSpanContext, withSpanContextAsync, } from './context';
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tracing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAGvG,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGjC,OAAO,EACN,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,aAAa,EACb,cAAc,GACd,MAAM,aAAa,CAAA;AAGpB,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,GACpB,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vestig Tracing Module
|
|
3
|
+
*
|
|
4
|
+
* Native tracing support for vestig. Create spans to track
|
|
5
|
+
* operations and their relationships, with automatic correlation
|
|
6
|
+
* to logs.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { span, getActiveSpan } from 'vestig'
|
|
11
|
+
*
|
|
12
|
+
* // Automatic span lifecycle management (recommended)
|
|
13
|
+
* await span('api:request', async (s) => {
|
|
14
|
+
* s.setAttribute('method', 'GET')
|
|
15
|
+
*
|
|
16
|
+
* // Nested spans automatically become children
|
|
17
|
+
* await span('db:query', async (child) => {
|
|
18
|
+
* child.setAttribute('table', 'users')
|
|
19
|
+
* return await db.query('SELECT * FROM users')
|
|
20
|
+
* })
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* // Manual control when needed
|
|
24
|
+
* const s = startSpan('background-job')
|
|
25
|
+
* try {
|
|
26
|
+
* await doWork()
|
|
27
|
+
* s.setStatus('ok')
|
|
28
|
+
* } finally {
|
|
29
|
+
* endSpan(s)
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
// Span class (for instanceof checks)
|
|
34
|
+
export { SpanImpl } from './span';
|
|
35
|
+
// Functions
|
|
36
|
+
export { span, spanSync, startSpan, endSpan, getActiveSpan, withActiveSpan, } from './functions';
|
|
37
|
+
// Context utilities (for advanced use cases)
|
|
38
|
+
export { clearActiveSpans, getActiveSpanStackDepth, withSpanContext, withSpanContextAsync, } from './context';
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tracing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,qCAAqC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEjC,YAAY;AACZ,OAAO,EACN,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,aAAa,EACb,cAAc,GACd,MAAM,aAAa,CAAA;AAEpB,6CAA6C;AAC7C,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,GACpB,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Span, SpanEvent, SpanOptions, SpanStatus } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Internal implementation of the Span interface
|
|
4
|
+
*/
|
|
5
|
+
export declare class SpanImpl implements Span {
|
|
6
|
+
readonly spanId: string;
|
|
7
|
+
readonly traceId: string;
|
|
8
|
+
readonly parentSpanId?: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly startTime: number;
|
|
11
|
+
private _status;
|
|
12
|
+
private _statusMessage?;
|
|
13
|
+
private _endTime?;
|
|
14
|
+
private _ended;
|
|
15
|
+
private _attributes;
|
|
16
|
+
private _events;
|
|
17
|
+
constructor(name: string, options?: SpanOptions);
|
|
18
|
+
get status(): SpanStatus;
|
|
19
|
+
set status(value: SpanStatus);
|
|
20
|
+
get statusMessage(): string | undefined;
|
|
21
|
+
set statusMessage(value: string | undefined);
|
|
22
|
+
get endTime(): number | undefined;
|
|
23
|
+
get duration(): number | undefined;
|
|
24
|
+
get ended(): boolean;
|
|
25
|
+
get attributes(): Record<string, unknown>;
|
|
26
|
+
get events(): readonly SpanEvent[];
|
|
27
|
+
setAttribute(key: string, value: unknown): void;
|
|
28
|
+
setAttributes(attrs: Record<string, unknown>): void;
|
|
29
|
+
addEvent(name: string, attributes?: Record<string, unknown>): void;
|
|
30
|
+
setStatus(status: SpanStatus, message?: string): void;
|
|
31
|
+
end(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Convert span to a plain object for logging/export
|
|
34
|
+
*/
|
|
35
|
+
toJSON(): Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=span.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../src/tracing/span.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGvE;;GAEG;AACH,qBAAa,QAAS,YAAW,IAAI;IAEpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAG1B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,cAAc,CAAC,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,CAAQ;IACzB,OAAO,CAAC,MAAM,CAAQ;IAGtB,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,OAAO,CAAkB;gBAErB,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;IAqB/C,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,UAAU,EAI3B;IAED,IAAI,aAAa,IAAI,MAAM,GAAG,SAAS,CAEtC;IAED,IAAI,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAI1C;IAED,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,IAAI,QAAQ,IAAI,MAAM,GAAG,SAAS,CAGjC;IAED,IAAI,KAAK,IAAI,OAAO,CAEnB;IAID,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAExC;IAED,IAAI,MAAM,IAAI,SAAS,SAAS,EAAE,CAEjC;IAID,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAK/C,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAKnD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAelE,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAOrD,GAAG,IAAI,IAAI;IASX;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAejC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { getContext } from '../context';
|
|
2
|
+
import { generateSpanId, generateTraceId } from '../context/correlation';
|
|
3
|
+
import { getActiveSpan } from './context';
|
|
4
|
+
/**
|
|
5
|
+
* Internal implementation of the Span interface
|
|
6
|
+
*/
|
|
7
|
+
export class SpanImpl {
|
|
8
|
+
// Identity (readonly)
|
|
9
|
+
spanId;
|
|
10
|
+
traceId;
|
|
11
|
+
parentSpanId;
|
|
12
|
+
name;
|
|
13
|
+
startTime;
|
|
14
|
+
// Mutable state (private backing fields)
|
|
15
|
+
_status = 'unset';
|
|
16
|
+
_statusMessage;
|
|
17
|
+
_endTime;
|
|
18
|
+
_ended = false;
|
|
19
|
+
// Collections
|
|
20
|
+
_attributes = {};
|
|
21
|
+
_events = [];
|
|
22
|
+
constructor(name, options) {
|
|
23
|
+
this.name = name;
|
|
24
|
+
this.startTime = performance.now();
|
|
25
|
+
// Determine parent span: explicit > active > none
|
|
26
|
+
const parent = options?.parentSpan ?? getActiveSpan();
|
|
27
|
+
// Get trace context: parent > async context > generate new
|
|
28
|
+
const ctx = getContext();
|
|
29
|
+
this.traceId = parent?.traceId ?? ctx?.traceId ?? generateTraceId();
|
|
30
|
+
this.spanId = generateSpanId();
|
|
31
|
+
this.parentSpanId = parent?.spanId;
|
|
32
|
+
// Apply initial attributes if provided
|
|
33
|
+
if (options?.attributes) {
|
|
34
|
+
this._attributes = { ...options.attributes };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// === Status accessors ===
|
|
38
|
+
get status() {
|
|
39
|
+
return this._status;
|
|
40
|
+
}
|
|
41
|
+
set status(value) {
|
|
42
|
+
if (!this._ended) {
|
|
43
|
+
this._status = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
get statusMessage() {
|
|
47
|
+
return this._statusMessage;
|
|
48
|
+
}
|
|
49
|
+
set statusMessage(value) {
|
|
50
|
+
if (!this._ended) {
|
|
51
|
+
this._statusMessage = value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
get endTime() {
|
|
55
|
+
return this._endTime;
|
|
56
|
+
}
|
|
57
|
+
get duration() {
|
|
58
|
+
if (this._endTime === undefined)
|
|
59
|
+
return undefined;
|
|
60
|
+
return this._endTime - this.startTime;
|
|
61
|
+
}
|
|
62
|
+
get ended() {
|
|
63
|
+
return this._ended;
|
|
64
|
+
}
|
|
65
|
+
// === Collections accessors ===
|
|
66
|
+
get attributes() {
|
|
67
|
+
return { ...this._attributes };
|
|
68
|
+
}
|
|
69
|
+
get events() {
|
|
70
|
+
return [...this._events];
|
|
71
|
+
}
|
|
72
|
+
// === API Methods ===
|
|
73
|
+
setAttribute(key, value) {
|
|
74
|
+
if (this._ended)
|
|
75
|
+
return;
|
|
76
|
+
this._attributes[key] = value;
|
|
77
|
+
}
|
|
78
|
+
setAttributes(attrs) {
|
|
79
|
+
if (this._ended)
|
|
80
|
+
return;
|
|
81
|
+
Object.assign(this._attributes, attrs);
|
|
82
|
+
}
|
|
83
|
+
addEvent(name, attributes) {
|
|
84
|
+
if (this._ended)
|
|
85
|
+
return;
|
|
86
|
+
const event = {
|
|
87
|
+
name,
|
|
88
|
+
timestamp: new Date().toISOString(),
|
|
89
|
+
};
|
|
90
|
+
if (attributes && Object.keys(attributes).length > 0) {
|
|
91
|
+
event.attributes = { ...attributes };
|
|
92
|
+
}
|
|
93
|
+
this._events.push(event);
|
|
94
|
+
}
|
|
95
|
+
setStatus(status, message) {
|
|
96
|
+
if (this._ended)
|
|
97
|
+
return;
|
|
98
|
+
this._status = status;
|
|
99
|
+
this._statusMessage = message;
|
|
100
|
+
}
|
|
101
|
+
end() {
|
|
102
|
+
if (this._ended)
|
|
103
|
+
return;
|
|
104
|
+
this._endTime = performance.now();
|
|
105
|
+
this._ended = true;
|
|
106
|
+
}
|
|
107
|
+
// === Serialization ===
|
|
108
|
+
/**
|
|
109
|
+
* Convert span to a plain object for logging/export
|
|
110
|
+
*/
|
|
111
|
+
toJSON() {
|
|
112
|
+
return {
|
|
113
|
+
spanId: this.spanId,
|
|
114
|
+
traceId: this.traceId,
|
|
115
|
+
parentSpanId: this.parentSpanId,
|
|
116
|
+
name: this.name,
|
|
117
|
+
startTime: this.startTime,
|
|
118
|
+
endTime: this._endTime,
|
|
119
|
+
duration: this.duration,
|
|
120
|
+
status: this._status,
|
|
121
|
+
statusMessage: this._statusMessage,
|
|
122
|
+
attributes: this._attributes,
|
|
123
|
+
events: this._events,
|
|
124
|
+
};
|
|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IAAI,CAAC,OAAO;SACpB,CAAA;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracing types for vestig
|
|
3
|
+
*
|
|
4
|
+
* These types are designed to be compatible with W3C Trace Context
|
|
5
|
+
* and can be easily mapped to OpenTelemetry spans in the future.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Span status indicating the outcome of the operation
|
|
9
|
+
*/
|
|
10
|
+
export type SpanStatus = 'unset' | 'ok' | 'error';
|
|
11
|
+
/**
|
|
12
|
+
* An event that occurred during a span's lifetime
|
|
13
|
+
*/
|
|
14
|
+
export interface SpanEvent {
|
|
15
|
+
/** Event name */
|
|
16
|
+
name: string;
|
|
17
|
+
/** ISO timestamp when the event occurred */
|
|
18
|
+
timestamp: string;
|
|
19
|
+
/** Optional attributes for the event */
|
|
20
|
+
attributes?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A span represents a single operation within a trace
|
|
24
|
+
*
|
|
25
|
+
* Spans can be nested to form a tree structure representing
|
|
26
|
+
* the call hierarchy of your application.
|
|
27
|
+
*/
|
|
28
|
+
export interface Span {
|
|
29
|
+
/** Unique identifier for this span (16 hex chars) */
|
|
30
|
+
readonly spanId: string;
|
|
31
|
+
/** Trace identifier shared by all spans in a trace (32 hex chars) */
|
|
32
|
+
readonly traceId: string;
|
|
33
|
+
/** Parent span ID if this is a child span */
|
|
34
|
+
readonly parentSpanId?: string;
|
|
35
|
+
/** Human-readable name describing this operation */
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** Start time in milliseconds (from performance.now()) */
|
|
38
|
+
readonly startTime: number;
|
|
39
|
+
/** Current status of the span */
|
|
40
|
+
status: SpanStatus;
|
|
41
|
+
/** Optional message describing the status (especially for errors) */
|
|
42
|
+
statusMessage?: string;
|
|
43
|
+
/** End time in milliseconds (set when span.end() is called) */
|
|
44
|
+
endTime?: number;
|
|
45
|
+
/** Duration in milliseconds (endTime - startTime) */
|
|
46
|
+
duration?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Set a single attribute on the span
|
|
49
|
+
* @param key - Attribute name
|
|
50
|
+
* @param value - Attribute value
|
|
51
|
+
*/
|
|
52
|
+
setAttribute(key: string, value: unknown): void;
|
|
53
|
+
/**
|
|
54
|
+
* Set multiple attributes at once
|
|
55
|
+
* @param attrs - Object with attribute key-value pairs
|
|
56
|
+
*/
|
|
57
|
+
setAttributes(attrs: Record<string, unknown>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Add an event to the span
|
|
60
|
+
* Events are timestamped markers that occur during the span's lifetime
|
|
61
|
+
* @param name - Event name
|
|
62
|
+
* @param attributes - Optional event attributes
|
|
63
|
+
*/
|
|
64
|
+
addEvent(name: string, attributes?: Record<string, unknown>): void;
|
|
65
|
+
/**
|
|
66
|
+
* Set the span's status
|
|
67
|
+
* @param status - 'ok' for success, 'error' for failure
|
|
68
|
+
* @param message - Optional message describing the status
|
|
69
|
+
*/
|
|
70
|
+
setStatus(status: SpanStatus, message?: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* End the span, recording its duration
|
|
73
|
+
* After calling end(), the span should not be modified
|
|
74
|
+
*/
|
|
75
|
+
end(): void;
|
|
76
|
+
/** All attributes set on this span */
|
|
77
|
+
readonly attributes: Record<string, unknown>;
|
|
78
|
+
/** All events recorded on this span */
|
|
79
|
+
readonly events: readonly SpanEvent[];
|
|
80
|
+
/** Whether the span has ended */
|
|
81
|
+
readonly ended: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Options for creating a new span
|
|
85
|
+
*/
|
|
86
|
+
export interface SpanOptions {
|
|
87
|
+
/** Initial attributes to set on the span */
|
|
88
|
+
attributes?: Record<string, unknown>;
|
|
89
|
+
/** Explicit parent span (if not using the current active span) */
|
|
90
|
+
parentSpan?: Span;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Function signature for async span callback
|
|
94
|
+
*/
|
|
95
|
+
export type SpanCallback<T> = (span: Span) => T | Promise<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Function signature for sync span callback
|
|
98
|
+
*/
|
|
99
|
+
export type SpanSyncCallback<T> = (span: Span) => T;
|
|
100
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tracing/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,CAAA;AAEjD;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC;AAED;;;;;GAKG;AACH,MAAM,WAAW,IAAI;IAGpB,qDAAqD;IACrD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAI1B,iCAAiC;IACjC,MAAM,EAAE,UAAU,CAAA;IAClB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IAIjB;;;;OAIG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;IAE/C;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAEnD;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAElE;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAErD;;;OAGG;IACH,GAAG,IAAI,IAAI,CAAA;IAIX,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5C,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;IAIrC,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,kEAAkE;IAClE,UAAU,CAAC,EAAE,IAAI,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAE5D;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tracing/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/types.d.ts
CHANGED
|
@@ -191,6 +191,7 @@ export interface DatadogTransportConfig extends BatchTransportConfig {
|
|
|
191
191
|
/** Additional tags */
|
|
192
192
|
tags?: string[];
|
|
193
193
|
}
|
|
194
|
+
export type { Span, SpanCallback, SpanEvent, SpanOptions, SpanStatus, SpanSyncCallback, } from './tracing/types';
|
|
194
195
|
/**
|
|
195
196
|
* Logger interface
|
|
196
197
|
*/
|
|
@@ -220,5 +221,25 @@ export interface Logger {
|
|
|
220
221
|
getTransports(): readonly Transport[];
|
|
221
222
|
/** Destroy all transports (call on shutdown) */
|
|
222
223
|
destroy(): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Create and run a span for an async operation
|
|
226
|
+
*
|
|
227
|
+
* The span name will be prefixed with the logger's namespace if present.
|
|
228
|
+
*
|
|
229
|
+
* @param name - Human-readable name for the operation
|
|
230
|
+
* @param fn - Async function to execute within the span
|
|
231
|
+
* @param options - Optional span configuration
|
|
232
|
+
* @returns The result of the function
|
|
233
|
+
*/
|
|
234
|
+
span<T>(name: string, fn: import('./tracing/types').SpanCallback<T>, options?: import('./tracing/types').SpanOptions): Promise<T>;
|
|
235
|
+
/**
|
|
236
|
+
* Create and run a span for a synchronous operation
|
|
237
|
+
*
|
|
238
|
+
* @param name - Human-readable name for the operation
|
|
239
|
+
* @param fn - Synchronous function to execute within the span
|
|
240
|
+
* @param options - Optional span configuration
|
|
241
|
+
* @returns The result of the function
|
|
242
|
+
*/
|
|
243
|
+
spanSync<T>(name: string, fn: import('./tracing/types').SpanSyncCallback<T>, options?: import('./tracing/types').SpanOptions): T;
|
|
223
244
|
}
|
|
224
245
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAEpE;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GA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