duron 0.3.0-beta.10 → 0.3.0-beta.12

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 (90) hide show
  1. package/dist/action-job.d.ts +33 -2
  2. package/dist/action-job.d.ts.map +1 -1
  3. package/dist/action-job.js +87 -22
  4. package/dist/action-manager.d.ts +44 -2
  5. package/dist/action-manager.d.ts.map +1 -1
  6. package/dist/action-manager.js +64 -3
  7. package/dist/action.d.ts +146 -3
  8. package/dist/action.d.ts.map +1 -1
  9. package/dist/action.js +131 -0
  10. package/dist/adapters/adapter.d.ts +365 -8
  11. package/dist/adapters/adapter.d.ts.map +1 -1
  12. package/dist/adapters/adapter.js +221 -15
  13. package/dist/adapters/postgres/base.d.ts +174 -5
  14. package/dist/adapters/postgres/base.d.ts.map +1 -1
  15. package/dist/adapters/postgres/base.js +349 -66
  16. package/dist/adapters/postgres/pglite.d.ts +37 -0
  17. package/dist/adapters/postgres/pglite.d.ts.map +1 -1
  18. package/dist/adapters/postgres/pglite.js +38 -0
  19. package/dist/adapters/postgres/postgres.d.ts +35 -0
  20. package/dist/adapters/postgres/postgres.d.ts.map +1 -1
  21. package/dist/adapters/postgres/postgres.js +42 -0
  22. package/dist/adapters/postgres/schema.d.ts +118 -35
  23. package/dist/adapters/postgres/schema.d.ts.map +1 -1
  24. package/dist/adapters/postgres/schema.default.d.ts +119 -36
  25. package/dist/adapters/postgres/schema.default.d.ts.map +1 -1
  26. package/dist/adapters/postgres/schema.default.js +2 -2
  27. package/dist/adapters/postgres/schema.js +55 -22
  28. package/dist/adapters/schemas.d.ts +107 -80
  29. package/dist/adapters/schemas.d.ts.map +1 -1
  30. package/dist/adapters/schemas.js +131 -26
  31. package/dist/client.d.ts +315 -9
  32. package/dist/client.d.ts.map +1 -1
  33. package/dist/client.js +391 -21
  34. package/dist/constants.js +6 -0
  35. package/dist/errors.d.ts +119 -0
  36. package/dist/errors.d.ts.map +1 -1
  37. package/dist/errors.js +111 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/server.d.ts +91 -37
  41. package/dist/server.d.ts.map +1 -1
  42. package/dist/server.js +81 -25
  43. package/dist/step-manager.d.ts +111 -4
  44. package/dist/step-manager.d.ts.map +1 -1
  45. package/dist/step-manager.js +340 -69
  46. package/dist/telemetry/adapter.d.ts +322 -0
  47. package/dist/telemetry/adapter.d.ts.map +1 -1
  48. package/dist/telemetry/adapter.js +145 -0
  49. package/dist/telemetry/index.d.ts +1 -4
  50. package/dist/telemetry/index.d.ts.map +1 -1
  51. package/dist/telemetry/index.js +2 -4
  52. package/dist/telemetry/local-span-exporter.d.ts +56 -0
  53. package/dist/telemetry/local-span-exporter.d.ts.map +1 -0
  54. package/dist/telemetry/local-span-exporter.js +118 -0
  55. package/dist/telemetry/local.d.ts +48 -0
  56. package/dist/telemetry/local.d.ts.map +1 -1
  57. package/dist/telemetry/local.js +102 -0
  58. package/dist/telemetry/noop.d.ts +10 -0
  59. package/dist/telemetry/noop.d.ts.map +1 -1
  60. package/dist/telemetry/noop.js +43 -0
  61. package/dist/telemetry/opentelemetry.d.ts +23 -0
  62. package/dist/telemetry/opentelemetry.d.ts.map +1 -1
  63. package/dist/telemetry/opentelemetry.js +39 -0
  64. package/dist/utils/p-retry.d.ts +5 -0
  65. package/dist/utils/p-retry.d.ts.map +1 -1
  66. package/dist/utils/p-retry.js +8 -0
  67. package/dist/utils/wait-for-abort.d.ts +1 -0
  68. package/dist/utils/wait-for-abort.d.ts.map +1 -1
  69. package/dist/utils/wait-for-abort.js +1 -0
  70. package/migrations/postgres/{20260119153838_flimsy_thor_girl → 20260120154151_mean_magdalene}/migration.sql +27 -19
  71. package/migrations/postgres/{20260119153838_flimsy_thor_girl → 20260120154151_mean_magdalene}/snapshot.json +172 -65
  72. package/package.json +7 -2
  73. package/src/action-job.ts +32 -28
  74. package/src/action-manager.ts +5 -5
  75. package/src/action.ts +7 -7
  76. package/src/adapters/adapter.ts +54 -54
  77. package/src/adapters/postgres/base.ts +140 -77
  78. package/src/adapters/postgres/schema.default.ts +2 -2
  79. package/src/adapters/postgres/schema.ts +47 -23
  80. package/src/adapters/schemas.ts +83 -36
  81. package/src/client.ts +195 -42
  82. package/src/index.ts +1 -0
  83. package/src/server.ts +37 -37
  84. package/src/step-manager.ts +170 -86
  85. package/src/telemetry/index.ts +2 -20
  86. package/src/telemetry/local-span-exporter.ts +148 -0
  87. package/src/telemetry/adapter.ts +0 -642
  88. package/src/telemetry/local.ts +0 -429
  89. package/src/telemetry/noop.ts +0 -141
  90. package/src/telemetry/opentelemetry.ts +0 -453
@@ -1,20 +1,48 @@
1
1
  import type { Logger } from 'pino';
2
2
  import type { Adapter } from '../adapters/adapter.js';
3
+ /**
4
+ * Interface representing the minimal Duron client required by telemetry adapters.
5
+ * This avoids circular dependencies by using a minimal interface.
6
+ */
3
7
  export interface TelemetryClient {
8
+ /**
9
+ * The database adapter instance.
10
+ */
4
11
  database: Adapter;
5
12
  }
13
+ /**
14
+ * Span represents a trace span for job or step execution.
15
+ */
6
16
  export interface Span {
17
+ /**
18
+ * Unique identifier for this span.
19
+ */
7
20
  id: string;
21
+ /**
22
+ * The job ID this span belongs to.
23
+ */
8
24
  jobId: string;
25
+ /**
26
+ * The step ID this span belongs to (null for job spans).
27
+ */
9
28
  stepId: string | null;
29
+ /**
30
+ * Parent span ID for nested spans.
31
+ */
10
32
  parentSpanId: string | null;
11
33
  }
34
+ /**
35
+ * Options for starting a job span.
36
+ */
12
37
  export interface StartJobSpanOptions {
13
38
  jobId: string;
14
39
  actionName: string;
15
40
  groupKey: string;
16
41
  input?: any;
17
42
  }
43
+ /**
44
+ * Options for starting a step span.
45
+ */
18
46
  export interface StartStepSpanOptions {
19
47
  jobId: string;
20
48
  stepId: string;
@@ -22,14 +50,23 @@ export interface StartStepSpanOptions {
22
50
  parentSpan?: Span;
23
51
  parentStepId: string | null;
24
52
  }
53
+ /**
54
+ * Options for ending a span.
55
+ */
25
56
  export interface EndSpanOptions {
26
57
  status: 'ok' | 'error' | 'cancelled';
27
58
  error?: any;
28
59
  }
60
+ /**
61
+ * Options for starting a database span.
62
+ */
29
63
  export interface StartDatabaseSpanOptions {
30
64
  operation: string;
31
65
  query?: string;
32
66
  }
67
+ /**
68
+ * Options for recording a metric.
69
+ */
33
70
  export interface RecordMetricOptions {
34
71
  jobId: string;
35
72
  stepId?: string;
@@ -37,71 +74,356 @@ export interface RecordMetricOptions {
37
74
  value: number;
38
75
  attributes?: Record<string, any>;
39
76
  }
77
+ /**
78
+ * Options for adding a span event.
79
+ */
40
80
  export interface AddSpanEventOptions {
41
81
  span: Span;
42
82
  name: string;
43
83
  attributes?: Record<string, any>;
44
84
  }
85
+ /**
86
+ * Options for adding a span attribute.
87
+ */
45
88
  export interface AddSpanAttributeOptions {
46
89
  span: Span;
47
90
  key: string;
48
91
  value: string | number | boolean;
49
92
  }
93
+ /**
94
+ * Options for starting a custom span with the tracer.
95
+ */
50
96
  export interface StartSpanOptions {
97
+ /**
98
+ * Span kind (internal, client, server, producer, consumer).
99
+ * @default 'internal'
100
+ */
51
101
  kind?: 'internal' | 'client' | 'server' | 'producer' | 'consumer';
102
+ /**
103
+ * Initial attributes for the span.
104
+ */
52
105
  attributes?: Record<string, string | number | boolean>;
106
+ /**
107
+ * Parent span to use for context propagation.
108
+ * If not provided, uses the current active context.
109
+ */
53
110
  parentSpan?: TracerSpan;
54
111
  }
112
+ /**
113
+ * A span created by the Tracer for manual instrumentation.
114
+ */
55
115
  export interface TracerSpan {
116
+ /**
117
+ * Set an attribute on the span.
118
+ *
119
+ * @param key - The attribute key
120
+ * @param value - The attribute value
121
+ */
56
122
  setAttribute(key: string, value: string | number | boolean): void;
123
+ /**
124
+ * Set multiple attributes on the span.
125
+ *
126
+ * @param attributes - The attributes to set
127
+ */
57
128
  setAttributes(attributes: Record<string, string | number | boolean>): void;
129
+ /**
130
+ * Add an event to the span.
131
+ *
132
+ * @param name - The event name
133
+ * @param attributes - Optional event attributes
134
+ */
58
135
  addEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
136
+ /**
137
+ * Record an exception on the span.
138
+ *
139
+ * @param error - The error to record
140
+ */
59
141
  recordException(error: Error): void;
142
+ /**
143
+ * Set the span status to OK.
144
+ */
60
145
  setStatusOk(): void;
146
+ /**
147
+ * Set the span status to error.
148
+ *
149
+ * @param message - Optional error message
150
+ */
61
151
  setStatusError(message?: string): void;
152
+ /**
153
+ * End the span.
154
+ * After calling this, no more operations can be performed on the span.
155
+ */
62
156
  end(): void;
157
+ /**
158
+ * Check if this span is recording.
159
+ */
63
160
  isRecording(): boolean;
64
161
  }
162
+ /**
163
+ * A Tracer provides methods for creating spans.
164
+ * Similar to OpenTelemetry's Tracer interface.
165
+ */
65
166
  export interface Tracer {
167
+ /**
168
+ * The name of this tracer.
169
+ */
66
170
  readonly name: string;
171
+ /**
172
+ * Start a new span.
173
+ *
174
+ * @param name - The name of the span
175
+ * @param options - Optional span configuration
176
+ * @returns A TracerSpan for manual instrumentation
177
+ */
67
178
  startSpan(name: string, options?: StartSpanOptions): TracerSpan;
68
179
  }
180
+ /**
181
+ * Observe context provided to action and step handlers.
182
+ */
69
183
  export interface ObserveContext {
184
+ /**
185
+ * Record a custom metric.
186
+ *
187
+ * @param name - The metric name (e.g., 'ai.tokens.total', 'processing.duration_ms')
188
+ * @param value - The metric value
189
+ * @param attributes - Optional attributes for the metric
190
+ */
70
191
  recordMetric(name: string, value: number, attributes?: Record<string, any>): void;
192
+ /**
193
+ * Add an attribute to the current span.
194
+ *
195
+ * @param key - The attribute key
196
+ * @param value - The attribute value
197
+ */
71
198
  addSpanAttribute(key: string, value: string | number | boolean): void;
199
+ /**
200
+ * Add an event to the current span.
201
+ *
202
+ * @param name - The event name
203
+ * @param attributes - Optional event attributes
204
+ */
72
205
  addSpanEvent(name: string, attributes?: Record<string, any>): void;
206
+ /**
207
+ * Get a tracer for manual instrumentation.
208
+ * Similar to OpenTelemetry's `trace.getTracer()` method.
209
+ *
210
+ * @param name - The name of the tracer (typically your service or library name)
211
+ * @returns A Tracer for creating custom spans
212
+ *
213
+ * @example
214
+ * ```typescript
215
+ * const tracer = ctx.observe.getTracer('my-service')
216
+ *
217
+ * const span = tracer.startSpan('external-api-call', {
218
+ * kind: 'client',
219
+ * attributes: { 'api.endpoint': '/users' }
220
+ * })
221
+ *
222
+ * try {
223
+ * const result = await fetch('https://api.example.com/users')
224
+ * span.setStatusOk()
225
+ * return result
226
+ * } catch (error) {
227
+ * span.recordException(error)
228
+ * span.setStatusError(error.message)
229
+ * throw error
230
+ * } finally {
231
+ * span.end()
232
+ * }
233
+ * ```
234
+ */
73
235
  getTracer(name: string): Tracer;
74
236
  }
237
+ /**
238
+ * Abstract base class for telemetry adapters.
239
+ * All telemetry adapters must extend this class and implement its abstract methods.
240
+ */
75
241
  export declare abstract class TelemetryAdapter {
76
242
  #private;
243
+ /**
244
+ * Start the telemetry adapter.
245
+ * Performs any necessary initialization.
246
+ *
247
+ * @returns Promise resolving to `true` if started successfully, `false` otherwise
248
+ */
77
249
  start(): Promise<boolean>;
250
+ /**
251
+ * Stop the telemetry adapter.
252
+ * Performs cleanup.
253
+ *
254
+ * @returns Promise resolving to `true` if stopped successfully, `false` otherwise
255
+ */
78
256
  stop(): Promise<boolean>;
257
+ /**
258
+ * Set the logger instance for this adapter.
259
+ *
260
+ * @param logger - The logger instance to use for logging
261
+ */
79
262
  setLogger(logger: Logger): void;
263
+ /**
264
+ * Get the logger instance for this adapter.
265
+ *
266
+ * @returns The logger instance, or `null` if not set
267
+ */
80
268
  get logger(): Logger | null;
269
+ /**
270
+ * Set the Duron client instance for this adapter.
271
+ * This is called automatically by the Duron client during initialization.
272
+ *
273
+ * @param client - The Duron client instance
274
+ */
81
275
  setClient(client: TelemetryClient): void;
276
+ /**
277
+ * Get the Duron client instance.
278
+ * Available to subclasses for accessing the database adapter.
279
+ *
280
+ * @returns The Duron client instance, or `null` if not set
281
+ */
82
282
  protected get client(): TelemetryClient | null;
283
+ /**
284
+ * Start a span for job execution.
285
+ *
286
+ * @param options - Options for the job span
287
+ * @returns The created span
288
+ */
83
289
  startJobSpan(options: StartJobSpanOptions): Promise<Span>;
290
+ /**
291
+ * End a job span.
292
+ *
293
+ * @param span - The span to end
294
+ * @param options - End options including status and error
295
+ */
84
296
  endJobSpan(span: Span, options: EndSpanOptions): Promise<void>;
297
+ /**
298
+ * Start a span for step execution.
299
+ *
300
+ * @param options - Options for the step span
301
+ * @returns The created span
302
+ */
85
303
  startStepSpan(options: StartStepSpanOptions): Promise<Span>;
304
+ /**
305
+ * End a step span.
306
+ *
307
+ * @param span - The span to end
308
+ * @param options - End options including status and error
309
+ */
86
310
  endStepSpan(span: Span, options: EndSpanOptions): Promise<void>;
311
+ /**
312
+ * Start a span for database operation (optional tracing).
313
+ *
314
+ * @param options - Options for the database span
315
+ * @returns The created span, or null if database tracing is disabled
316
+ */
87
317
  startDatabaseSpan(options: StartDatabaseSpanOptions): Promise<Span | null>;
318
+ /**
319
+ * End a database span.
320
+ *
321
+ * @param span - The span to end
322
+ * @param options - End options including status and error
323
+ */
88
324
  endDatabaseSpan(span: Span | null, options: EndSpanOptions): Promise<void>;
325
+ /**
326
+ * Record a metric.
327
+ *
328
+ * @param options - Options for recording the metric
329
+ */
89
330
  recordMetric(options: RecordMetricOptions): Promise<void>;
331
+ /**
332
+ * Add an event to a span.
333
+ *
334
+ * @param options - Options for the span event
335
+ */
90
336
  addSpanEvent(options: AddSpanEventOptions): Promise<void>;
337
+ /**
338
+ * Add an attribute to a span.
339
+ *
340
+ * @param options - Options for the span attribute
341
+ */
91
342
  addSpanAttribute(options: AddSpanAttributeOptions): Promise<void>;
343
+ /**
344
+ * Get a tracer for manual instrumentation.
345
+ * Similar to OpenTelemetry's `trace.getTracer()` method.
346
+ *
347
+ * @param name - The name of the tracer (typically your service or library name)
348
+ * @returns A Tracer for creating custom spans
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * const tracer = telemetry.getTracer('my-service')
353
+ *
354
+ * const span = tracer.startSpan('process-order', {
355
+ * attributes: { 'order.id': orderId }
356
+ * })
357
+ *
358
+ * try {
359
+ * // Do some work
360
+ * span.addEvent('order.validated')
361
+ * span.setStatusOk()
362
+ * } catch (error) {
363
+ * span.recordException(error)
364
+ * span.setStatusError(error.message)
365
+ * } finally {
366
+ * span.end()
367
+ * }
368
+ * ```
369
+ */
92
370
  getTracer(name: string): Tracer;
371
+ /**
372
+ * Create an observe context for action/step handlers.
373
+ *
374
+ * @param jobId - The job ID
375
+ * @param stepId - The step ID (optional)
376
+ * @param span - The current span
377
+ * @returns ObserveContext for use in handlers
378
+ */
93
379
  createObserveContext(jobId: string, stepId: string | null, span: Span): ObserveContext;
380
+ /**
381
+ * Start the adapter.
382
+ */
94
383
  protected abstract _start(): Promise<void>;
384
+ /**
385
+ * Stop the adapter.
386
+ */
95
387
  protected abstract _stop(): Promise<void>;
388
+ /**
389
+ * Internal method to start a job span.
390
+ */
96
391
  protected abstract _startJobSpan(options: StartJobSpanOptions): Promise<Span>;
392
+ /**
393
+ * Internal method to end a job span.
394
+ */
97
395
  protected abstract _endJobSpan(span: Span, options: EndSpanOptions): Promise<void>;
396
+ /**
397
+ * Internal method to start a step span.
398
+ */
98
399
  protected abstract _startStepSpan(options: StartStepSpanOptions): Promise<Span>;
400
+ /**
401
+ * Internal method to end a step span.
402
+ */
99
403
  protected abstract _endStepSpan(span: Span, options: EndSpanOptions): Promise<void>;
404
+ /**
405
+ * Internal method to start a database span.
406
+ */
100
407
  protected abstract _startDatabaseSpan(options: StartDatabaseSpanOptions): Promise<Span | null>;
408
+ /**
409
+ * Internal method to end a database span.
410
+ */
101
411
  protected abstract _endDatabaseSpan(span: Span, options: EndSpanOptions): Promise<void>;
412
+ /**
413
+ * Internal method to record a metric.
414
+ */
102
415
  protected abstract _recordMetric(options: RecordMetricOptions): Promise<void>;
416
+ /**
417
+ * Internal method to add a span event.
418
+ */
103
419
  protected abstract _addSpanEvent(options: AddSpanEventOptions): Promise<void>;
420
+ /**
421
+ * Internal method to add a span attribute.
422
+ */
104
423
  protected abstract _addSpanAttribute(options: AddSpanAttributeOptions): Promise<void>;
424
+ /**
425
+ * Internal method to get a tracer for manual instrumentation.
426
+ */
105
427
  protected abstract _getTracer(name: string): Tracer;
106
428
  }
107
429
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/telemetry/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAUrD,MAAM,WAAW,eAAe;IAI9B,QAAQ,EAAE,OAAO,CAAA;CAClB;AAKD,MAAM,WAAW,IAAI;IAInB,EAAE,EAAE,MAAM,CAAA;IAKV,KAAK,EAAE,MAAM,CAAA;IAKb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAKrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAKD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,GAAG,CAAA;CACZ;AAKD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,IAAI,CAAA;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAKD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,IAAI,GAAG,OAAO,GAAG,WAAW,CAAA;IACpC,KAAK,CAAC,EAAE,GAAG,CAAA;CACZ;AAKD,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,M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YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnF;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAE9F;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAEvF;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7E;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7E;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAErF;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CACpD"}
@@ -1,3 +1,10 @@
1
+ // ============================================================================
2
+ // Abstract Telemetry Adapter
3
+ // ============================================================================
4
+ /**
5
+ * Abstract base class for telemetry adapters.
6
+ * All telemetry adapters must extend this class and implement its abstract methods.
7
+ */
1
8
  export class TelemetryAdapter {
2
9
  #logger = null;
3
10
  #client = null;
@@ -5,6 +12,15 @@ export class TelemetryAdapter {
5
12
  #stopped = false;
6
13
  #starting = null;
7
14
  #stopping = null;
15
+ // ============================================================================
16
+ // Lifecycle Methods
17
+ // ============================================================================
18
+ /**
19
+ * Start the telemetry adapter.
20
+ * Performs any necessary initialization.
21
+ *
22
+ * @returns Promise resolving to `true` if started successfully, `false` otherwise
23
+ */
8
24
  async start() {
9
25
  try {
10
26
  if (this.#stopping || this.#stopped) {
@@ -29,6 +45,12 @@ export class TelemetryAdapter {
29
45
  throw error;
30
46
  }
31
47
  }
48
+ /**
49
+ * Stop the telemetry adapter.
50
+ * Performs cleanup.
51
+ *
52
+ * @returns Promise resolving to `true` if stopped successfully, `false` otherwise
53
+ */
32
54
  async stop() {
33
55
  try {
34
56
  if (this.#stopped) {
@@ -50,59 +72,182 @@ export class TelemetryAdapter {
50
72
  throw error;
51
73
  }
52
74
  }
75
+ // ============================================================================
76
+ // Configuration Methods
77
+ // ============================================================================
78
+ /**
79
+ * Set the logger instance for this adapter.
80
+ *
81
+ * @param logger - The logger instance to use for logging
82
+ */
53
83
  setLogger(logger) {
54
84
  this.#logger = logger;
55
85
  }
86
+ /**
87
+ * Get the logger instance for this adapter.
88
+ *
89
+ * @returns The logger instance, or `null` if not set
90
+ */
56
91
  get logger() {
57
92
  return this.#logger;
58
93
  }
94
+ /**
95
+ * Set the Duron client instance for this adapter.
96
+ * This is called automatically by the Duron client during initialization.
97
+ *
98
+ * @param client - The Duron client instance
99
+ */
59
100
  setClient(client) {
60
101
  this.#client = client;
61
102
  }
103
+ /**
104
+ * Get the Duron client instance.
105
+ * Available to subclasses for accessing the database adapter.
106
+ *
107
+ * @returns The Duron client instance, or `null` if not set
108
+ */
62
109
  get client() {
63
110
  return this.#client;
64
111
  }
112
+ // ============================================================================
113
+ // Span Methods
114
+ // ============================================================================
115
+ /**
116
+ * Start a span for job execution.
117
+ *
118
+ * @param options - Options for the job span
119
+ * @returns The created span
120
+ */
65
121
  async startJobSpan(options) {
66
122
  await this.start();
67
123
  return this._startJobSpan(options);
68
124
  }
125
+ /**
126
+ * End a job span.
127
+ *
128
+ * @param span - The span to end
129
+ * @param options - End options including status and error
130
+ */
69
131
  async endJobSpan(span, options) {
70
132
  await this.start();
71
133
  return this._endJobSpan(span, options);
72
134
  }
135
+ /**
136
+ * Start a span for step execution.
137
+ *
138
+ * @param options - Options for the step span
139
+ * @returns The created span
140
+ */
73
141
  async startStepSpan(options) {
74
142
  await this.start();
75
143
  return this._startStepSpan(options);
76
144
  }
145
+ /**
146
+ * End a step span.
147
+ *
148
+ * @param span - The span to end
149
+ * @param options - End options including status and error
150
+ */
77
151
  async endStepSpan(span, options) {
78
152
  await this.start();
79
153
  return this._endStepSpan(span, options);
80
154
  }
155
+ /**
156
+ * Start a span for database operation (optional tracing).
157
+ *
158
+ * @param options - Options for the database span
159
+ * @returns The created span, or null if database tracing is disabled
160
+ */
81
161
  async startDatabaseSpan(options) {
82
162
  await this.start();
83
163
  return this._startDatabaseSpan(options);
84
164
  }
165
+ /**
166
+ * End a database span.
167
+ *
168
+ * @param span - The span to end
169
+ * @param options - End options including status and error
170
+ */
85
171
  async endDatabaseSpan(span, options) {
86
172
  if (!span)
87
173
  return;
88
174
  await this.start();
89
175
  return this._endDatabaseSpan(span, options);
90
176
  }
177
+ // ============================================================================
178
+ // Metrics Methods
179
+ // ============================================================================
180
+ /**
181
+ * Record a metric.
182
+ *
183
+ * @param options - Options for recording the metric
184
+ */
91
185
  async recordMetric(options) {
92
186
  await this.start();
93
187
  return this._recordMetric(options);
94
188
  }
189
+ /**
190
+ * Add an event to a span.
191
+ *
192
+ * @param options - Options for the span event
193
+ */
95
194
  async addSpanEvent(options) {
96
195
  await this.start();
97
196
  return this._addSpanEvent(options);
98
197
  }
198
+ /**
199
+ * Add an attribute to a span.
200
+ *
201
+ * @param options - Options for the span attribute
202
+ */
99
203
  async addSpanAttribute(options) {
100
204
  await this.start();
101
205
  return this._addSpanAttribute(options);
102
206
  }
207
+ // ============================================================================
208
+ // Tracer Methods
209
+ // ============================================================================
210
+ /**
211
+ * Get a tracer for manual instrumentation.
212
+ * Similar to OpenTelemetry's `trace.getTracer()` method.
213
+ *
214
+ * @param name - The name of the tracer (typically your service or library name)
215
+ * @returns A Tracer for creating custom spans
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * const tracer = telemetry.getTracer('my-service')
220
+ *
221
+ * const span = tracer.startSpan('process-order', {
222
+ * attributes: { 'order.id': orderId }
223
+ * })
224
+ *
225
+ * try {
226
+ * // Do some work
227
+ * span.addEvent('order.validated')
228
+ * span.setStatusOk()
229
+ * } catch (error) {
230
+ * span.recordException(error)
231
+ * span.setStatusError(error.message)
232
+ * } finally {
233
+ * span.end()
234
+ * }
235
+ * ```
236
+ */
103
237
  getTracer(name) {
104
238
  return this._getTracer(name);
105
239
  }
240
+ // ============================================================================
241
+ // Context Methods
242
+ // ============================================================================
243
+ /**
244
+ * Create an observe context for action/step handlers.
245
+ *
246
+ * @param jobId - The job ID
247
+ * @param stepId - The step ID (optional)
248
+ * @param span - The current span
249
+ * @returns ObserveContext for use in handlers
250
+ */
106
251
  createObserveContext(jobId, stepId, span) {
107
252
  return {
108
253
  recordMetric: (name, value, attributes) => {
@@ -1,5 +1,2 @@
1
- export { type AddSpanAttributeOptions, type AddSpanEventOptions, type EndSpanOptions, type ObserveContext, type RecordMetricOptions, type Span, type StartDatabaseSpanOptions, type StartJobSpanOptions, type StartSpanOptions, type StartStepSpanOptions, TelemetryAdapter, type Tracer, type TracerSpan, } from './adapter.js';
2
- export { LocalTelemetryAdapter, type LocalTelemetryAdapterOptions, localTelemetryAdapter } from './local.js';
3
- export { NoopTelemetryAdapter, noopTelemetryAdapter } from './noop.js';
4
- export { OpenTelemetryAdapter, type OpenTelemetryAdapterOptions, openTelemetryAdapter } from './opentelemetry.js';
1
+ export { LocalSpanExporter, type LocalSpanExporterOptions } from './local-span-exporter.js';
5
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,MAAM,EACX,KAAK,UAAU,GAChB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,qBAAqB,EAAE,KAAK,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAC5G,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,EAAE,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,0BAA0B,CAAA"}
@@ -1,4 +1,2 @@
1
- export { TelemetryAdapter, } from './adapter.js';
2
- export { LocalTelemetryAdapter, localTelemetryAdapter } from './local.js';
3
- export { NoopTelemetryAdapter, noopTelemetryAdapter } from './noop.js';
4
- export { OpenTelemetryAdapter, openTelemetryAdapter } from './opentelemetry.js';
1
+ // OpenTelemetry-based span exporter for local database persistence
2
+ export { LocalSpanExporter } from './local-span-exporter.js';