-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathgenericPool.ts
49 lines (41 loc) · 1.68 KB
/
genericPool.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
import { GenericPoolInstrumentation } from '@opentelemetry/instrumentation-generic-pool';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, spanToJSON } from '@sentry/core';
import type { IntegrationFn } from '@sentry/types';
import { generateInstrumentOnce } from '../../otel/instrument';
const INTEGRATION_NAME = 'GenericPool';
export const instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME, () => new GenericPoolInstrumentation({}));
const _genericPoolIntegration = (() => {
return {
name: INTEGRATION_NAME,
setupOnce() {
instrumentGenericPool();
},
setup(client) {
client.on('spanStart', span => {
const spanJSON = spanToJSON(span);
const spanDescription = spanJSON.description;
// typo in emitted span for version <= 0.38.0 of @opentelemetry/instrumentation-generic-pool
const isGenericPoolSpan =
spanDescription === 'generic-pool.aquire' || spanDescription === 'generic-pool.acquire';
if (isGenericPoolSpan) {
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.generic_pool');
}
});
},
};
}) satisfies IntegrationFn;
/**
* Adds Sentry tracing instrumentation for the [generic-pool](https://www.npmjs.com/package/generic-pool) library.
*
* For more information, see the [`genericPoolIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/genericpool/).
*
* @example
* ```javascript
* const Sentry = require('@sentry/node');
*
* Sentry.init({
* integrations: [Sentry.genericPoolIntegration()],
* });
* ```
*/
export const genericPoolIntegration = defineIntegration(_genericPoolIntegration);