diff --git a/packages/tracing/src/integrations/node/apollo.ts b/packages/tracing/src/integrations/node/apollo.ts index e505899df9f2..09442216deb7 100644 --- a/packages/tracing/src/integrations/node/apollo.ts +++ b/packages/tracing/src/integrations/node/apollo.ts @@ -28,6 +28,11 @@ export class Apollo implements Integration { * @inheritDoc */ public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { + if (shouldDisableAutoInstrumentation(getCurrentHub)) { + __DEBUG_BUILD__ && logger.log('Apollo Integration is skipped because of instrumenter configuration.'); + return; + } + const pkg = loadModule<{ ApolloServerBase: { prototype: { @@ -41,11 +46,6 @@ export class Apollo implements Integration { return; } - if (shouldDisableAutoInstrumentation(getCurrentHub)) { - __DEBUG_BUILD__ && logger.log('Apollo Integration is skipped because of instrumenter configuration.'); - return; - } - /** * Iterate over resolvers of the ApolloServer instance before schemas are constructed. */ diff --git a/packages/tracing/src/integrations/node/graphql.ts b/packages/tracing/src/integrations/node/graphql.ts index 4e777459cd80..0bf267850cec 100644 --- a/packages/tracing/src/integrations/node/graphql.ts +++ b/packages/tracing/src/integrations/node/graphql.ts @@ -20,6 +20,11 @@ export class GraphQL implements Integration { * @inheritDoc */ public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { + if (shouldDisableAutoInstrumentation(getCurrentHub)) { + __DEBUG_BUILD__ && logger.log('GraphQL Integration is skipped because of instrumenter configuration.'); + return; + } + const pkg = loadModule<{ [method: string]: (...args: unknown[]) => unknown; }>('graphql/execution/execute.js'); @@ -29,11 +34,6 @@ export class GraphQL implements Integration { return; } - if (shouldDisableAutoInstrumentation(getCurrentHub)) { - __DEBUG_BUILD__ && logger.log('GraphQL Integration is skipped because of instrumenter configuration.'); - return; - } - fill(pkg, 'execute', function (orig: () => void | Promise) { return function (this: unknown, ...args: unknown[]) { const scope = getCurrentHub().getScope(); diff --git a/packages/tracing/src/integrations/node/mongo.ts b/packages/tracing/src/integrations/node/mongo.ts index c66b93ff1651..b2933ba37022 100644 --- a/packages/tracing/src/integrations/node/mongo.ts +++ b/packages/tracing/src/integrations/node/mongo.ts @@ -127,6 +127,11 @@ export class Mongo implements Integration { * @inheritDoc */ public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { + if (shouldDisableAutoInstrumentation(getCurrentHub)) { + __DEBUG_BUILD__ && logger.log('Mongo Integration is skipped because of instrumenter configuration.'); + return; + } + const moduleName = this._useMongoose ? 'mongoose' : 'mongodb'; const pkg = loadModule<{ Collection: MongoCollection }>(moduleName); @@ -135,11 +140,6 @@ export class Mongo implements Integration { return; } - if (shouldDisableAutoInstrumentation(getCurrentHub)) { - __DEBUG_BUILD__ && logger.log('Mongo Integration is skipped because of instrumenter configuration.'); - return; - } - this._instrumentOperations(pkg.Collection, this._operations, getCurrentHub); } diff --git a/packages/tracing/src/integrations/node/mysql.ts b/packages/tracing/src/integrations/node/mysql.ts index a9e38cd1c0e7..9303522ea260 100644 --- a/packages/tracing/src/integrations/node/mysql.ts +++ b/packages/tracing/src/integrations/node/mysql.ts @@ -24,6 +24,11 @@ export class Mysql implements Integration { * @inheritDoc */ public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { + if (shouldDisableAutoInstrumentation(getCurrentHub)) { + __DEBUG_BUILD__ && logger.log('Mysql Integration is skipped because of instrumenter configuration.'); + return; + } + const pkg = loadModule('mysql/lib/Connection.js'); if (!pkg) { @@ -31,11 +36,6 @@ export class Mysql implements Integration { return; } - if (shouldDisableAutoInstrumentation(getCurrentHub)) { - __DEBUG_BUILD__ && logger.log('Mysql Integration is skipped because of instrumenter configuration.'); - return; - } - // The original function will have one of these signatures: // function (callback) => void // function (options, callback) => void diff --git a/packages/tracing/src/integrations/node/postgres.ts b/packages/tracing/src/integrations/node/postgres.ts index 6ed0f46c5dd7..5883ef94527f 100644 --- a/packages/tracing/src/integrations/node/postgres.ts +++ b/packages/tracing/src/integrations/node/postgres.ts @@ -36,6 +36,11 @@ export class Postgres implements Integration { * @inheritDoc */ public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { + if (shouldDisableAutoInstrumentation(getCurrentHub)) { + __DEBUG_BUILD__ && logger.log('Postgres Integration is skipped because of instrumenter configuration.'); + return; + } + const pkg = loadModule<{ Client: PgClient; native: { Client: PgClient } }>('pg'); if (!pkg) { @@ -43,11 +48,6 @@ export class Postgres implements Integration { return; } - if (shouldDisableAutoInstrumentation(getCurrentHub)) { - __DEBUG_BUILD__ && logger.log('Postgres Integration is skipped because of instrumenter configuration.'); - return; - } - if (this._usePgNative && !pkg.native?.Client) { __DEBUG_BUILD__ && logger.error("Postgres Integration was unable to access 'pg-native' bindings."); return;