-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathamqplib.ts
44 lines (39 loc) · 1.43 KB
/
amqplib.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
import type { Span } from '@opentelemetry/api';
import { AmqplibInstrumentation, type AmqplibInstrumentationConfig } from '@opentelemetry/instrumentation-amqplib';
import { defineIntegration } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';
import { generateInstrumentOnce } from '../../otel/instrument';
import { addOriginToSpan } from '../../utils/addOriginToSpan';
const INTEGRATION_NAME = 'Amqplib';
const config: AmqplibInstrumentationConfig = {
consumeEndHook: (span: Span) => {
addOriginToSpan(span, 'auto.amqplib.otel.consumer');
},
publishHook: (span: Span) => {
addOriginToSpan(span, 'auto.amqplib.otel.publisher');
},
};
export const instrumentAmqplib = generateInstrumentOnce(INTEGRATION_NAME, () => new AmqplibInstrumentation(config));
const _amqplibIntegration = (() => {
return {
name: INTEGRATION_NAME,
setupOnce() {
instrumentAmqplib();
},
};
}) satisfies IntegrationFn;
/**
* Adds Sentry tracing instrumentation for the [amqplib](https://www.npmjs.com/package/amqplib) library.
*
* For more information, see the [`amqplibIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/amqplib/).
*
* @example
* ```javascript
* const Sentry = require('@sentry/node');
*
* Sentry.init({
* integrations: [Sentry.amqplibIntegration()],
* });
* ```
*/
export const amqplibIntegration = defineIntegration(_amqplibIntegration);