autotel-plugins 0.19.25 → 0.19.27

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.
@@ -1,5 +1,19 @@
1
1
  import { SpanLink, Span, Context } from 'autotel';
2
- export { C as CORRELATION_ID_HEADER, t as SEMATTRS_LINKED_TRACE_ID_COUNT, u as SEMATTRS_LINKED_TRACE_ID_HASH, w as SEMATTRS_MESSAGING_CONSUMER_ID, x as SEMATTRS_MESSAGING_DESTINATION_NAME, I as SEMATTRS_MESSAGING_MESSAGE_CONVERSATION_ID, J as SEMATTRS_MESSAGING_MESSAGE_ID, L as SEMATTRS_MESSAGING_OPERATION_NAME, M as SEMATTRS_MESSAGING_RABBITMQ_ACK_RESULT, N as SEMATTRS_MESSAGING_RABBITMQ_DESTINATION_EXCHANGE, O as SEMATTRS_MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY, P as SEMATTRS_MESSAGING_RABBITMQ_REQUEUE, Q as SEMATTRS_MESSAGING_SYSTEM } from './constants-DKKe2D25.js';
2
+ export {
3
+ C as CORRELATION_ID_HEADER,
4
+ t as SEMATTRS_LINKED_TRACE_ID_COUNT,
5
+ u as SEMATTRS_LINKED_TRACE_ID_HASH,
6
+ w as SEMATTRS_MESSAGING_CONSUMER_ID,
7
+ x as SEMATTRS_MESSAGING_DESTINATION_NAME,
8
+ I as SEMATTRS_MESSAGING_MESSAGE_CONVERSATION_ID,
9
+ J as SEMATTRS_MESSAGING_MESSAGE_ID,
10
+ L as SEMATTRS_MESSAGING_OPERATION_NAME,
11
+ M as SEMATTRS_MESSAGING_RABBITMQ_ACK_RESULT,
12
+ N as SEMATTRS_MESSAGING_RABBITMQ_DESTINATION_EXCHANGE,
13
+ O as SEMATTRS_MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY,
14
+ P as SEMATTRS_MESSAGING_RABBITMQ_REQUEUE,
15
+ Q as SEMATTRS_MESSAGING_SYSTEM,
16
+ } from './constants-DKKe2D25.js';
3
17
 
4
18
  /**
5
19
  * RabbitMQ plugin types - Processing spans, ack tracking, and correlation
@@ -12,7 +26,9 @@ export { C as CORRELATION_ID_HEADER, t as SEMATTRS_LINKED_TRACE_ID_COUNT, u as S
12
26
  * Raw AMQP headers as provided by amqplib.
13
27
  * Values can be string, Buffer, number, boolean, or undefined.
14
28
  */
15
- type RawAmqpHeaders = Record<string, string | Buffer | number | boolean | object | undefined> | undefined;
29
+ type RawAmqpHeaders =
30
+ | Record<string, string | Buffer | number | boolean | object | undefined>
31
+ | undefined;
16
32
  /**
17
33
  * Context mode for processing spans.
18
34
  *
@@ -39,162 +55,158 @@ type AckOutcome = 'ack' | 'nack' | 'reject';
39
55
  * Controls for deferred ack tracking mode.
40
56
  */
41
57
  interface AckControls {
42
- /**
43
- * Acknowledge the message successfully. Ends the span with success.
44
- */
45
- ack(): void;
46
- /**
47
- * Negative acknowledge the message. Ends the span with the nack outcome.
48
- * @param options - Options for nack behavior
49
- */
50
- nack(options?: {
51
- requeue?: boolean;
52
- }): void;
53
- /**
54
- * Reject the message. Ends the span with the reject outcome.
55
- * @param options - Options for reject behavior
56
- */
57
- reject(options?: {
58
- requeue?: boolean;
59
- }): void;
58
+ /**
59
+ * Acknowledge the message successfully. Ends the span with success.
60
+ */
61
+ ack(): void;
62
+ /**
63
+ * Negative acknowledge the message. Ends the span with the nack outcome.
64
+ * @param options - Options for nack behavior
65
+ */
66
+ nack(options?: { requeue?: boolean }): void;
67
+ /**
68
+ * Reject the message. Ends the span with the reject outcome.
69
+ * @param options - Options for reject behavior
70
+ */
71
+ reject(options?: { requeue?: boolean }): void;
60
72
  }
61
73
  /**
62
74
  * Descriptor for creating a consume/processing span.
63
75
  */
64
76
  interface ConsumeDescriptor {
65
- /**
66
- * Name for the processing span (e.g., "order.process")
67
- */
68
- name: string;
69
- /**
70
- * AMQP message headers for context extraction.
71
- */
72
- headers: RawAmqpHeaders;
73
- /**
74
- * Context mode for relating to extracted remote context.
75
- * @default 'inherit'
76
- */
77
- contextMode?: ContextMode;
78
- /**
79
- * Additional span links to include.
80
- */
81
- links?: SpanLink[];
82
- /**
83
- * Queue name. Sets `messaging.destination.name` attribute.
84
- */
85
- queue?: string;
86
- /**
87
- * Source exchange name. Sets `messaging.rabbitmq.destination.exchange` attribute.
88
- */
89
- exchange?: string;
90
- /**
91
- * Routing key. Sets `messaging.rabbitmq.destination.routing_key` attribute.
92
- */
93
- routingKey?: string;
94
- /**
95
- * AMQP message ID. Sets `messaging.message.id` attribute.
96
- */
97
- messageId?: string;
98
- /**
99
- * AMQP correlation ID. Sets `messaging.message.conversation_id` attribute.
100
- */
101
- correlationId?: string;
102
- /**
103
- * Consumer tag. Sets `messaging.consumer.id` attribute.
104
- */
105
- consumerTag?: string;
106
- /**
107
- * Defer span end until ack/nack/reject is called.
108
- * When true, the callback receives AckControls and span ends when one is called.
109
- * @default false
110
- */
111
- deferSpanEnd?: boolean;
112
- /**
113
- * Timeout in milliseconds for deferred span end.
114
- * Required when `deferSpanEnd` is true.
115
- */
116
- ackTimeoutMs?: number;
77
+ /**
78
+ * Name for the processing span (e.g., "order.process")
79
+ */
80
+ name: string;
81
+ /**
82
+ * AMQP message headers for context extraction.
83
+ */
84
+ headers: RawAmqpHeaders;
85
+ /**
86
+ * Context mode for relating to extracted remote context.
87
+ * @default 'inherit'
88
+ */
89
+ contextMode?: ContextMode;
90
+ /**
91
+ * Additional span links to include.
92
+ */
93
+ links?: SpanLink[];
94
+ /**
95
+ * Queue name. Sets `messaging.destination.name` attribute.
96
+ */
97
+ queue?: string;
98
+ /**
99
+ * Source exchange name. Sets `messaging.rabbitmq.destination.exchange` attribute.
100
+ */
101
+ exchange?: string;
102
+ /**
103
+ * Routing key. Sets `messaging.rabbitmq.destination.routing_key` attribute.
104
+ */
105
+ routingKey?: string;
106
+ /**
107
+ * AMQP message ID. Sets `messaging.message.id` attribute.
108
+ */
109
+ messageId?: string;
110
+ /**
111
+ * AMQP correlation ID. Sets `messaging.message.conversation_id` attribute.
112
+ */
113
+ correlationId?: string;
114
+ /**
115
+ * Consumer tag. Sets `messaging.consumer.id` attribute.
116
+ */
117
+ consumerTag?: string;
118
+ /**
119
+ * Defer span end until ack/nack/reject is called.
120
+ * When true, the callback receives AckControls and span ends when one is called.
121
+ * @default false
122
+ */
123
+ deferSpanEnd?: boolean;
124
+ /**
125
+ * Timeout in milliseconds for deferred span end.
126
+ * Required when `deferSpanEnd` is true.
127
+ */
128
+ ackTimeoutMs?: number;
117
129
  }
118
130
  /**
119
131
  * Descriptor for creating a publish span.
120
132
  */
121
133
  interface PublishDescriptor {
122
- /**
123
- * Name for the publish span (e.g., "order.publish")
124
- */
125
- name: string;
126
- /**
127
- * Exchange name. Sets `messaging.destination.name` attribute.
128
- * Defaults to 'amq.default' for default exchange.
129
- */
130
- exchange?: string;
131
- /**
132
- * Routing key. Sets `messaging.rabbitmq.destination.routing_key` attribute.
133
- */
134
- routingKey: string;
135
- /**
136
- * AMQP message ID. Sets `messaging.message.id` attribute.
137
- */
138
- messageId?: string;
139
- /**
140
- * AMQP correlation ID. Sets `messaging.message.conversation_id` attribute.
141
- */
142
- correlationId?: string;
143
- /**
144
- * Messaging system. Defaults to 'rabbitmq'.
145
- */
146
- system?: string;
134
+ /**
135
+ * Name for the publish span (e.g., "order.publish")
136
+ */
137
+ name: string;
138
+ /**
139
+ * Exchange name. Sets `messaging.destination.name` attribute.
140
+ * Defaults to 'amq.default' for default exchange.
141
+ */
142
+ exchange?: string;
143
+ /**
144
+ * Routing key. Sets `messaging.rabbitmq.destination.routing_key` attribute.
145
+ */
146
+ routingKey: string;
147
+ /**
148
+ * AMQP message ID. Sets `messaging.message.id` attribute.
149
+ */
150
+ messageId?: string;
151
+ /**
152
+ * AMQP correlation ID. Sets `messaging.message.conversation_id` attribute.
153
+ */
154
+ correlationId?: string;
155
+ /**
156
+ * Messaging system. Defaults to 'rabbitmq'.
157
+ */
158
+ system?: string;
147
159
  }
148
160
  /**
149
161
  * Options for injecting trace headers.
150
162
  */
151
163
  interface InjectOptions {
152
- /**
153
- * Explicit correlation ID to use. If not provided, derives from current context.
154
- */
155
- correlationId?: string;
156
- /**
157
- * Whether to include x-correlation-id header.
158
- * @default true
159
- */
160
- includeCorrelationIdHeader?: boolean;
164
+ /**
165
+ * Explicit correlation ID to use. If not provided, derives from current context.
166
+ */
167
+ correlationId?: string;
168
+ /**
169
+ * Whether to include x-correlation-id header.
170
+ * @default true
171
+ */
172
+ includeCorrelationIdHeader?: boolean;
161
173
  }
162
174
  /**
163
175
  * Options for batch lineage extraction.
164
176
  */
165
177
  interface BatchLineageOptions {
166
- /**
167
- * Include raw trace IDs in the result.
168
- * @default false (privacy consideration)
169
- */
170
- includeTraceIds?: boolean;
171
- /**
172
- * Maximum number of links to include.
173
- * @default 128
174
- */
175
- maxLinks?: number;
178
+ /**
179
+ * Include raw trace IDs in the result.
180
+ * @default false (privacy consideration)
181
+ */
182
+ includeTraceIds?: boolean;
183
+ /**
184
+ * Maximum number of links to include.
185
+ * @default 128
186
+ */
187
+ maxLinks?: number;
176
188
  }
177
189
  /**
178
190
  * Result of batch lineage extraction.
179
191
  */
180
192
  interface BatchLineageResult {
181
- /**
182
- * Count of unique, linked trace IDs.
183
- */
184
- linked_trace_id_count: number;
185
- /**
186
- * Hash of sorted trace IDs (16 hex chars, 64-bit).
187
- * Useful for comparing batches without exposing individual trace IDs.
188
- */
189
- linked_trace_id_hash: string;
190
- /**
191
- * Raw trace IDs, only if includeTraceIds was true.
192
- */
193
- trace_ids?: string[];
194
- /**
195
- * Valid SpanLinks from extracted contexts (capped at maxLinks).
196
- */
197
- links: SpanLink[];
193
+ /**
194
+ * Count of unique, linked trace IDs.
195
+ */
196
+ linked_trace_id_count: number;
197
+ /**
198
+ * Hash of sorted trace IDs (16 hex chars, 64-bit).
199
+ * Useful for comparing batches without exposing individual trace IDs.
200
+ */
201
+ linked_trace_id_hash: string;
202
+ /**
203
+ * Raw trace IDs, only if includeTraceIds was true.
204
+ */
205
+ trace_ids?: string[];
206
+ /**
207
+ * Valid SpanLinks from extracted contexts (capped at maxLinks).
208
+ */
209
+ links: SpanLink[];
198
210
  }
199
211
  /**
200
212
  * Type for the consume span callback function without deferred ack.
@@ -203,7 +215,10 @@ type ConsumeSpanCallback<T> = (span: Span) => Promise<T>;
203
215
  /**
204
216
  * Type for the consume span callback function with deferred ack controls.
205
217
  */
206
- type DeferredConsumeSpanCallback<T> = (span: Span, controls: AckControls) => Promise<T>;
218
+ type DeferredConsumeSpanCallback<T> = (
219
+ span: Span,
220
+ controls: AckControls,
221
+ ) => Promise<T>;
207
222
  /**
208
223
  * Type for the publish span callback function.
209
224
  */
@@ -212,7 +227,7 @@ type PublishSpanCallback<T> = (span: Span) => Promise<T>;
212
227
  * Item with optional headers for batch lineage extraction.
213
228
  */
214
229
  interface BatchItem {
215
- headers?: RawAmqpHeaders;
230
+ headers?: RawAmqpHeaders;
216
231
  }
217
232
 
218
233
  /**
@@ -248,7 +263,9 @@ interface BatchItem {
248
263
  * // { traceparent: '00-abc...', 'content-type': 'application/json', retryCount: '3' }
249
264
  * ```
250
265
  */
251
- declare function normalizeHeaders(headers?: RawAmqpHeaders): Record<string, string>;
266
+ declare function normalizeHeaders(
267
+ headers?: RawAmqpHeaders,
268
+ ): Record<string, string>;
252
269
  /**
253
270
  * Extract trace context from normalized headers using OTel propagators.
254
271
  *
@@ -332,7 +349,10 @@ declare function deriveCorrelationId(): string;
332
349
  * }
333
350
  * ```
334
351
  */
335
- declare function extractCorrelationId(headers: Record<string, string>, amqpCorrelationId?: string): string | undefined;
352
+ declare function extractCorrelationId(
353
+ headers: Record<string, string>,
354
+ amqpCorrelationId?: string,
355
+ ): string | undefined;
336
356
  /**
337
357
  * Inject trace headers into outgoing message headers.
338
358
  *
@@ -362,7 +382,10 @@ declare function extractCorrelationId(headers: Record<string, string>, amqpCorre
362
382
  * });
363
383
  * ```
364
384
  */
365
- declare function injectTraceHeaders(base?: Record<string, string>, options?: InjectOptions): Record<string, string>;
385
+ declare function injectTraceHeaders(
386
+ base?: Record<string, string>,
387
+ options?: InjectOptions,
388
+ ): Record<string, string>;
366
389
 
367
390
  /**
368
391
  * Processing span wrapper for RabbitMQ message handling.
@@ -427,14 +450,23 @@ declare function injectTraceHeaders(base?: Record<string, string>, options?: Inj
427
450
  * });
428
451
  * ```
429
452
  */
430
- declare function withConsumeSpan<T>(descriptor: ConsumeDescriptor & {
453
+ declare function withConsumeSpan<T>(
454
+ descriptor: ConsumeDescriptor & {
431
455
  deferSpanEnd: true;
432
456
  ackTimeoutMs: number;
433
- }, fn: DeferredConsumeSpanCallback<T>): Promise<T>;
434
- declare function withConsumeSpan<T>(descriptor: ConsumeDescriptor & {
457
+ },
458
+ fn: DeferredConsumeSpanCallback<T>,
459
+ ): Promise<T>;
460
+ declare function withConsumeSpan<T>(
461
+ descriptor: ConsumeDescriptor & {
435
462
  deferSpanEnd?: false;
436
- }, fn: ConsumeSpanCallback<T>): Promise<T>;
437
- declare function withConsumeSpan<T>(descriptor: ConsumeDescriptor, fn: ConsumeSpanCallback<T> | DeferredConsumeSpanCallback<T>): Promise<T>;
463
+ },
464
+ fn: ConsumeSpanCallback<T>,
465
+ ): Promise<T>;
466
+ declare function withConsumeSpan<T>(
467
+ descriptor: ConsumeDescriptor,
468
+ fn: ConsumeSpanCallback<T> | DeferredConsumeSpanCallback<T>,
469
+ ): Promise<T>;
438
470
 
439
471
  /**
440
472
  * Publish span wrapper for RabbitMQ message publishing.
@@ -495,7 +527,10 @@ declare function withConsumeSpan<T>(descriptor: ConsumeDescriptor, fn: ConsumeSp
495
527
  * });
496
528
  * ```
497
529
  */
498
- declare function withPublishSpan<T>(descriptor: PublishDescriptor, fn: PublishSpanCallback<T>): Promise<T>;
530
+ declare function withPublishSpan<T>(
531
+ descriptor: PublishDescriptor,
532
+ fn: PublishSpanCallback<T>,
533
+ ): Promise<T>;
499
534
 
500
535
  /**
501
536
  * Batch lineage utilities for fan-in trace correlation.
@@ -545,7 +580,10 @@ declare function withPublishSpan<T>(descriptor: PublishDescriptor, fn: PublishSp
545
580
  * });
546
581
  * ```
547
582
  */
548
- declare function extractBatchLineage(items: BatchItem[], options?: BatchLineageOptions): BatchLineageResult;
583
+ declare function extractBatchLineage(
584
+ items: BatchItem[],
585
+ options?: BatchLineageOptions,
586
+ ): BatchLineageResult;
549
587
 
550
588
  /**
551
589
  * Ack tracking utilities for RabbitMQ message processing.
@@ -562,10 +600,10 @@ type AckResult = 'ack' | 'nack' | 'reject';
562
600
  * Options for recording ack results.
563
601
  */
564
602
  interface RecordAckOptions {
565
- /**
566
- * Whether the message will be requeued (for nack/reject).
567
- */
568
- requeue?: boolean;
603
+ /**
604
+ * Whether the message will be requeued (for nack/reject).
605
+ */
606
+ requeue?: boolean;
569
607
  }
570
608
  /**
571
609
  * Record an ack result on a span.
@@ -598,6 +636,35 @@ interface RecordAckOptions {
598
636
  * });
599
637
  * ```
600
638
  */
601
- declare function recordAckResult(span: Span, result: AckResult, options?: RecordAckOptions): void;
639
+ declare function recordAckResult(
640
+ span: Span,
641
+ result: AckResult,
642
+ options?: RecordAckOptions,
643
+ ): void;
602
644
 
603
- export { type AckControls, type AckOutcome, type AckResult, type BatchItem, type BatchLineageOptions, type BatchLineageResult, type ConsumeDescriptor, type ConsumeSpanCallback, type ContextMode, type DeferredConsumeSpanCallback, type InjectOptions, type PublishDescriptor, type PublishSpanCallback, type RawAmqpHeaders, type RecordAckOptions, deriveCorrelationId, extractBatchLineage, extractCorrelationId, extractTraceContext, injectTraceHeaders, normalizeHeaders, recordAckResult, withConsumeSpan, withPublishSpan };
645
+ export {
646
+ type AckControls,
647
+ type AckOutcome,
648
+ type AckResult,
649
+ type BatchItem,
650
+ type BatchLineageOptions,
651
+ type BatchLineageResult,
652
+ type ConsumeDescriptor,
653
+ type ConsumeSpanCallback,
654
+ type ContextMode,
655
+ type DeferredConsumeSpanCallback,
656
+ type InjectOptions,
657
+ type PublishDescriptor,
658
+ type PublishSpanCallback,
659
+ type RawAmqpHeaders,
660
+ type RecordAckOptions,
661
+ deriveCorrelationId,
662
+ extractBatchLineage,
663
+ extractCorrelationId,
664
+ extractTraceContext,
665
+ injectTraceHeaders,
666
+ normalizeHeaders,
667
+ recordAckResult,
668
+ withConsumeSpan,
669
+ withPublishSpan,
670
+ };