This repository was archived by the owner on Oct 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathtypes.ts
72 lines (61 loc) · 2.58 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { Span } from '@opentelemetry/api';
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
import type amqp from 'amqplib';
export interface PublishParams {
exchange: string;
routingKey: string;
content: Buffer;
options?: amqp.Options.Publish;
isConfirmChannel?: boolean;
}
export interface AmqplibPublishCustomAttributeFunction {
(span: Span, publishParams: PublishParams): void;
}
export interface AmqplibConfirmCustomAttributeFunction {
(span: Span, publishParams: PublishParams, confirmError: any): void;
}
export interface AmqplibConsumerCustomAttributeFunction {
(span: Span, msg: amqp.ConsumeMessage): void;
}
export enum EndOperation {
AutoAck = 'auto ack',
Ack = 'ack',
AckAll = 'ackAll',
Reject = 'reject',
Nack = 'nack',
NackAll = 'nackAll',
ChannelClosed = 'channel closed',
ChannelError = 'channel error',
InstrumentationTimeout = 'instrumentation timeout',
}
export interface AmqplibInstrumentationConfig extends InstrumentationConfig {
/** hook for adding custom attributes before publish message is sent */
publishHook?: AmqplibPublishCustomAttributeFunction;
/** hook for adding custom attributes after publish message is confirmed by the broker */
publishConfirmHook?: AmqplibConfirmCustomAttributeFunction;
/** hook for adding custom attributes before consumer message is processed */
consumeHook?: AmqplibConsumerCustomAttributeFunction;
/**
* If passed, a span attribute will be added to all spans with key of the provided "moduleVersionAttributeName"
* and value of the module version.
*/
moduleVersionAttributeName?: string;
/**
* When user is setting up consume callback, it is user's responsibility to call
* ack/nack etc on the msg to resolve it in the server.
* If user is not calling the ack, the message will stay in the queue until
* channel is closed, or until server timeout expires (if configured).
* While we wait for the ack, a copy of the message is stored in plugin, which
* will never be garbage collected.
* To prevent memory leak, plugin has it's own configuration of timeout, which
* will close the span if user did not call ack after this timeout.
* If timeout is not big enough, span might be closed with 'InstrumentationTimeout',
* and then received valid ack from the user later which will not be instrumented.
*
* Default is 1 minute
*/
consumeTimeoutMs?: number;
}
export const DEFAULT_CONFIG: AmqplibInstrumentationConfig = {
consumeTimeoutMs: 1000 * 60, // 1 minute
};