|
1 | 1 | import type { Integration } from '@sentry/types'; |
2 | 2 |
|
3 | | -import type { NodePerformanceIntegration } from './NodePerformanceIntegration'; |
4 | | -import { Express } from './express'; |
5 | | -import { Fastify } from './fastify'; |
6 | | -import { GraphQL } from './graphql'; |
7 | | -import { Hapi } from './hapi'; |
8 | | -import { Mongo } from './mongo'; |
9 | | -import { Mongoose } from './mongoose'; |
10 | | -import { Mysql } from './mysql'; |
11 | | -import { Mysql2 } from './mysql2'; |
12 | | -import { Nest } from './nest'; |
13 | | -import { Postgres } from './postgres'; |
14 | | -import { Prisma } from './prisma'; |
15 | | - |
16 | | -const INTEGRATIONS: (() => NodePerformanceIntegration<unknown>)[] = [ |
17 | | - () => { |
18 | | - return new Express(); |
19 | | - }, |
20 | | - () => { |
21 | | - return new Fastify(); |
22 | | - }, |
23 | | - () => { |
24 | | - return new GraphQL(); |
25 | | - }, |
26 | | - () => { |
27 | | - return new Mongo(); |
28 | | - }, |
29 | | - () => { |
30 | | - return new Mongoose(); |
31 | | - }, |
32 | | - () => { |
33 | | - return new Mysql(); |
34 | | - }, |
35 | | - () => { |
36 | | - return new Mysql2(); |
37 | | - }, |
38 | | - () => { |
39 | | - return new Postgres(); |
40 | | - }, |
41 | | - () => { |
42 | | - return new Prisma(); |
43 | | - }, |
44 | | - () => { |
45 | | - return new Nest(); |
46 | | - }, |
47 | | - () => { |
48 | | - return new Hapi(); |
49 | | - }, |
50 | | -]; |
| 3 | +import { expressIntegration } from './express'; |
| 4 | +import { fastifyIntegration } from './fastify'; |
| 5 | +import { graphqlIntegration } from './graphql'; |
| 6 | +import { hapiIntegration } from './hapi'; |
| 7 | +import { mongoIntegration } from './mongo'; |
| 8 | +import { mongooseIntegration } from './mongoose'; |
| 9 | +import { mysqlIntegration } from './mysql'; |
| 10 | +import { mysql2Integration } from './mysql2'; |
| 11 | +import { nestIntegration } from './nest'; |
| 12 | +import { postgresIntegration } from './postgres'; |
| 13 | +import { prismaIntegration } from './prisma'; |
51 | 14 |
|
52 | 15 | /** |
53 | | - * Get auto-dsicovered performance integrations. |
54 | | - * Note that due to the way OpenTelemetry instrumentation works, this will generally still return Integrations |
55 | | - * for stuff that may not be installed. This is because Otel only instruments when the module is imported/required, |
56 | | - * so if the package is not required at all it will not be patched, and thus not instrumented. |
57 | | - * But the _Sentry_ Integration will still be added. |
58 | | - * This _may_ be a bit confusing because it shows all integrations as being installed in the debug logs, but this is |
59 | | - * technically not wrong because we install it (it just doesn't do anything). |
| 16 | + * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required. |
60 | 17 | */ |
61 | 18 | export function getAutoPerformanceIntegrations(): Integration[] { |
62 | | - const loadedIntegrations = INTEGRATIONS.map(tryLoad => { |
63 | | - try { |
64 | | - const integration = tryLoad(); |
65 | | - const isLoaded = integration.loadInstrumentations(); |
66 | | - return isLoaded ? integration : false; |
67 | | - } catch (_) { |
68 | | - return false; |
69 | | - } |
70 | | - }).filter(integration => !!integration) as Integration[]; |
71 | | - |
72 | | - return loadedIntegrations; |
| 19 | + return [ |
| 20 | + expressIntegration(), |
| 21 | + fastifyIntegration(), |
| 22 | + graphqlIntegration(), |
| 23 | + mongoIntegration(), |
| 24 | + mongooseIntegration(), |
| 25 | + mysqlIntegration(), |
| 26 | + mysql2Integration(), |
| 27 | + postgresIntegration(), |
| 28 | + prismaIntegration(), |
| 29 | + nestIntegration(), |
| 30 | + hapiIntegration(), |
| 31 | + ]; |
73 | 32 | } |
0 commit comments