-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node-experimental): Update tracing integrations to functional style
- Loading branch information
Showing
19 changed files
with
530 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 25 additions & 66 deletions
91
packages/node-experimental/src/integrations/getAutoPerformanceIntegrations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,32 @@ | ||
import type { Integration } from '@sentry/types'; | ||
|
||
import type { NodePerformanceIntegration } from './NodePerformanceIntegration'; | ||
import { Express } from './express'; | ||
import { Fastify } from './fastify'; | ||
import { GraphQL } from './graphql'; | ||
import { Hapi } from './hapi'; | ||
import { Mongo } from './mongo'; | ||
import { Mongoose } from './mongoose'; | ||
import { Mysql } from './mysql'; | ||
import { Mysql2 } from './mysql2'; | ||
import { Nest } from './nest'; | ||
import { Postgres } from './postgres'; | ||
import { Prisma } from './prisma'; | ||
|
||
const INTEGRATIONS: (() => NodePerformanceIntegration<unknown>)[] = [ | ||
() => { | ||
return new Express(); | ||
}, | ||
() => { | ||
return new Fastify(); | ||
}, | ||
() => { | ||
return new GraphQL(); | ||
}, | ||
() => { | ||
return new Mongo(); | ||
}, | ||
() => { | ||
return new Mongoose(); | ||
}, | ||
() => { | ||
return new Mysql(); | ||
}, | ||
() => { | ||
return new Mysql2(); | ||
}, | ||
() => { | ||
return new Postgres(); | ||
}, | ||
() => { | ||
return new Prisma(); | ||
}, | ||
() => { | ||
return new Nest(); | ||
}, | ||
() => { | ||
return new Hapi(); | ||
}, | ||
]; | ||
import { expressIntegration } from './express'; | ||
import { fastifyIntegration } from './fastify'; | ||
import { graphqlIntegration } from './graphql'; | ||
import { hapiIntegration } from './hapi'; | ||
import { mongoIntegration } from './mongo'; | ||
import { mongooseIntegration } from './mongoose'; | ||
import { mysqlIntegration } from './mysql'; | ||
import { mysql2Integration } from './mysql2'; | ||
import { nestIntegration } from './nest'; | ||
import { postgresIntegration } from './postgres'; | ||
import { prismaIntegration } from './prisma'; | ||
|
||
/** | ||
* Get auto-dsicovered performance integrations. | ||
* Note that due to the way OpenTelemetry instrumentation works, this will generally still return Integrations | ||
* for stuff that may not be installed. This is because Otel only instruments when the module is imported/required, | ||
* so if the package is not required at all it will not be patched, and thus not instrumented. | ||
* But the _Sentry_ Integration will still be added. | ||
* This _may_ be a bit confusing because it shows all integrations as being installed in the debug logs, but this is | ||
* technically not wrong because we install it (it just doesn't do anything). | ||
* With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required. | ||
*/ | ||
export function getAutoPerformanceIntegrations(): Integration[] { | ||
const loadedIntegrations = INTEGRATIONS.map(tryLoad => { | ||
try { | ||
const integration = tryLoad(); | ||
const isLoaded = integration.loadInstrumentations(); | ||
return isLoaded ? integration : false; | ||
} catch (_) { | ||
return false; | ||
} | ||
}).filter(integration => !!integration) as Integration[]; | ||
|
||
return loadedIntegrations; | ||
return [ | ||
expressIntegration(), | ||
fastifyIntegration(), | ||
graphqlIntegration(), | ||
mongoIntegration(), | ||
mongooseIntegration(), | ||
mysqlIntegration(), | ||
mysql2Integration(), | ||
postgresIntegration(), | ||
prismaIntegration(), | ||
nestIntegration(), | ||
hapiIntegration(), | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.