diff --git a/plugins/node/instrumentation-cucumber/src/instrumentation.ts b/plugins/node/instrumentation-cucumber/src/instrumentation.ts index 4633707e33..29e466cb69 100644 --- a/plugins/node/instrumentation-cucumber/src/instrumentation.ts +++ b/plugins/node/instrumentation-cucumber/src/instrumentation.ts @@ -53,10 +53,7 @@ export class CucumberInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( '@cucumber/cucumber', ['^8.0.0', '^9.0.0', '^10.0.0'], - (moduleExports: Cucumber, moduleVersion) => { - this._diag.debug( - `Applying patch for @cucumber/cucumber@${moduleVersion}` - ); + (moduleExports: Cucumber) => { this.module = moduleExports; steps.forEach(step => { if (isWrapped(moduleExports[step])) { @@ -72,11 +69,8 @@ export class CucumberInstrumentation extends InstrumentationBase { }); return moduleExports; }, - (moduleExports: Cucumber, moduleVersion) => { + (moduleExports: Cucumber) => { if (moduleExports === undefined) return; - this._diag.debug( - `Removing patch for @cucumber/cucumber@${moduleVersion}` - ); [...hooks, ...steps].forEach(method => { this._unwrap(moduleExports, method); }); @@ -85,10 +79,7 @@ export class CucumberInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( '@cucumber/cucumber/lib/runtime/test_case_runner.js', ['^8.0.0', '^9.0.0', '^10.0.0'], - (moduleExports, moduleVersion) => { - this._diag.debug( - `Applying patch for @cucumber/cucumber/lib/runtime/test_case_runner.js@${moduleVersion}` - ); + moduleExports => { if (isWrapped(moduleExports.default.prototype.run)) { this._unwrap(moduleExports.default.prototype, 'run'); this._unwrap(moduleExports.default.prototype, 'runStep'); @@ -115,11 +106,8 @@ export class CucumberInstrumentation extends InstrumentationBase { } return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (moduleExports === undefined) return; - this._diag.debug( - `Removing patch for @cucumber/cucumber/lib/runtime/test_case_runner.js@${moduleVersion}` - ); this._unwrap(moduleExports.default.prototype, 'run'); this._unwrap(moduleExports.default.prototype, 'runStep'); if ('runAttempt' in moduleExports.default.prototype) { diff --git a/plugins/node/instrumentation-dataloader/src/instrumentation.ts b/plugins/node/instrumentation-dataloader/src/instrumentation.ts index 75cfb03861..55d53ece64 100644 --- a/plugins/node/instrumentation-dataloader/src/instrumentation.ts +++ b/plugins/node/instrumentation-dataloader/src/instrumentation.ts @@ -20,7 +20,6 @@ import { isWrapped, } from '@opentelemetry/instrumentation'; import { - diag, trace, context, Link, @@ -54,17 +53,13 @@ export class DataloaderInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( MODULE_NAME, ['^2.0.0'], - (dataloader, moduleVersion) => { - diag.debug(`Applying patch for ${MODULE_NAME}@${moduleVersion}`); - + dataloader => { this._patchLoad(dataloader.prototype); this._patchLoadMany(dataloader.prototype); return this._getPatchedConstructor(dataloader); }, - (dataloader, moduleVersion) => { - diag.debug(`Removing patch for ${MODULE_NAME}@${moduleVersion}`); - + dataloader => { if (isWrapped(dataloader.prototype.load)) { this._unwrap(dataloader.prototype, 'load'); } diff --git a/plugins/node/instrumentation-fs/src/instrumentation.ts b/plugins/node/instrumentation-fs/src/instrumentation.ts index 15da51a5ea..d3fea1c952 100644 --- a/plugins/node/instrumentation-fs/src/instrumentation.ts +++ b/plugins/node/instrumentation-fs/src/instrumentation.ts @@ -65,7 +65,6 @@ export default class FsInstrumentation extends InstrumentationBase { 'fs', ['*'], (fs: FS) => { - this._diag.debug('Applying patch for fs'); for (const fName of SYNC_FUNCTIONS) { const { objectToPatch, functionNameToPatch } = indexFs(fs, fName); @@ -113,7 +112,6 @@ export default class FsInstrumentation extends InstrumentationBase { }, (fs: FS) => { if (fs === undefined) return; - this._diag.debug('Removing patch for fs'); for (const fName of SYNC_FUNCTIONS) { const { objectToPatch, functionNameToPatch } = indexFs(fs, fName); if (isWrapped(objectToPatch[functionNameToPatch])) { @@ -137,7 +135,6 @@ export default class FsInstrumentation extends InstrumentationBase { 'fs/promises', ['*'], (fsPromises: FSPromises) => { - this._diag.debug('Applying patch for fs/promises'); for (const fName of PROMISE_FUNCTIONS) { if (isWrapped(fsPromises[fName])) { this._unwrap(fsPromises, fName); @@ -152,7 +149,6 @@ export default class FsInstrumentation extends InstrumentationBase { }, (fsPromises: FSPromises) => { if (fsPromises === undefined) return; - this._diag.debug('Removing patch for fs/promises'); for (const fName of PROMISE_FUNCTIONS) { if (isWrapped(fsPromises[fName])) { this._unwrap(fsPromises, fName); diff --git a/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts b/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts index c901a500a5..d11e803973 100644 --- a/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts +++ b/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts @@ -33,8 +33,6 @@ export default class LruMemoizerInstrumentation extends InstrumentationBase { 'lru-memoizer', ['>=1.3 <3'], moduleExports => { - this._diag.debug('applying patch for lru-memoizer'); - // moduleExports is a function which receives an options object, // and returns a "memoizer" function upon invocation. // We want to patch this "memoizer's" internal function diff --git a/plugins/node/instrumentation-mongoose/src/mongoose.ts b/plugins/node/instrumentation-mongoose/src/mongoose.ts index 967a30ded1..3de0ea33ee 100644 --- a/plugins/node/instrumentation-mongoose/src/mongoose.ts +++ b/plugins/node/instrumentation-mongoose/src/mongoose.ts @@ -126,7 +126,6 @@ export class MongooseInstrumentation extends InstrumentationBase { } private unpatch(moduleExports: typeof mongoose): void { - this._diag.debug('mongoose instrumentation: unpatch mongoose'); this._unwrap(moduleExports.Model.prototype, 'save'); // revert the patch for $save which we applied by aliasing it to patched `save` moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save; diff --git a/plugins/node/instrumentation-socket.io/src/socket.io.ts b/plugins/node/instrumentation-socket.io/src/socket.io.ts index f5ef96df8f..51c3d1d962 100644 --- a/plugins/node/instrumentation-socket.io/src/socket.io.ts +++ b/plugins/node/instrumentation-socket.io/src/socket.io.ts @@ -72,7 +72,6 @@ export class SocketIoInstrumentation extends InstrumentationBase { if (moduleVersion === undefined) { return moduleExports; } - this._diag.debug(`applying patch to socket.io@${moduleVersion} Socket`); if (isWrapped(moduleExports?.Socket?.prototype?.on)) { this._unwrap(moduleExports.Socket.prototype, 'on'); } @@ -112,9 +111,6 @@ export class SocketIoInstrumentation extends InstrumentationBase { if (moduleVersion === undefined) { return moduleExports; } - this._diag.debug( - `applying patch to socket.io@${moduleVersion} StrictEventEmitter` - ); if (isWrapped(moduleExports?.BroadcastOperator?.prototype?.emit)) { this._unwrap(moduleExports.BroadcastOperator.prototype, 'emit'); } @@ -142,9 +138,6 @@ export class SocketIoInstrumentation extends InstrumentationBase { if (moduleVersion === undefined) { return moduleExports; } - this._diag.debug( - `applying patch to socket.io@${moduleVersion} Namespace` - ); if (isWrapped(moduleExports?.Namespace?.prototype?.emit)) { this._unwrap(moduleExports.Namespace.prototype, 'emit'); } @@ -171,7 +164,6 @@ export class SocketIoInstrumentation extends InstrumentationBase { if (moduleVersion === undefined) { return moduleExports; } - this._diag.debug(`applying patch to socket.io@${moduleVersion} Socket`); if (isWrapped(moduleExports.prototype?.on)) { this._unwrap(moduleExports.prototype, 'on'); } @@ -206,9 +198,6 @@ export class SocketIoInstrumentation extends InstrumentationBase { if (moduleVersion === undefined) { return moduleExports; } - this._diag.debug( - `applying patch to socket.io@${moduleVersion} Namespace` - ); if (isWrapped(moduleExports?.prototype?.emit)) { this._unwrap(moduleExports.prototype, 'emit'); } @@ -237,9 +226,6 @@ export class SocketIoInstrumentation extends InstrumentationBase { if (moduleVersion === undefined) { return moduleExports; } - this._diag.debug( - `applying patch to socket.io@${moduleVersion} Server` - ); if (isWrapped(moduleExports?.Server?.prototype?.on)) { this._unwrap(moduleExports.Server.prototype, 'on'); } @@ -250,7 +236,7 @@ export class SocketIoInstrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (isWrapped(moduleExports?.Server?.prototype?.on)) { this._unwrap(moduleExports.Server.prototype, 'on'); } @@ -272,9 +258,6 @@ export class SocketIoInstrumentation extends InstrumentationBase { if (moduleVersion === undefined) { return moduleExports; } - this._diag.debug( - `applying patch to socket.io@${moduleVersion} Server` - ); if (isWrapped(moduleExports?.prototype?.on)) { this._unwrap(moduleExports.prototype, 'on'); } diff --git a/plugins/node/instrumentation-tedious/src/instrumentation.ts b/plugins/node/instrumentation-tedious/src/instrumentation.ts index 5415bae955..d9c23eeb86 100644 --- a/plugins/node/instrumentation-tedious/src/instrumentation.ts +++ b/plugins/node/instrumentation-tedious/src/instrumentation.ts @@ -73,9 +73,7 @@ export class TediousInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( TediousInstrumentation.COMPONENT, ['>=1.11.0 <=15'], - (moduleExports: typeof tedious, moduleVersion) => { - this._diag.debug(`Patching tedious@${moduleVersion}`); - + (moduleExports: typeof tedious) => { const ConnectionPrototype: any = moduleExports.Connection.prototype; for (const method of PATCHED_METHODS) { if (isWrapped(ConnectionPrototype[method])) { diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts index 35345739c3..0b88aeec75 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts @@ -151,7 +151,6 @@ export class AwsLambdaInstrumentation extends InstrumentationBase { module, ['*'], (moduleExports: LambdaModule) => { - diag.debug('Applying patch for lambda handler'); if (isWrapped(moduleExports[functionName])) { this._unwrap(moduleExports, functionName); } @@ -160,7 +159,6 @@ export class AwsLambdaInstrumentation extends InstrumentationBase { }, (moduleExports?: LambdaModule) => { if (moduleExports == null) return; - diag.debug('Removing patch for lambda handler'); this._unwrap(moduleExports, functionName); } ), diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts index 186976a190..7203010630 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts @@ -174,9 +174,6 @@ export class AwsInstrumentation extends InstrumentationBase { } protected patchV3ConstructStack(moduleExports: any, moduleVersion?: string) { - diag.debug( - 'aws-sdk instrumentation: applying patch to aws-sdk v3 constructStack' - ); this._wrap( moduleExports, 'constructStack', @@ -186,17 +183,11 @@ export class AwsInstrumentation extends InstrumentationBase { } protected unpatchV3ConstructStack(moduleExports: any) { - diag.debug( - 'aws-sdk instrumentation: applying unpatch to aws-sdk v3 constructStack' - ); this._unwrap(moduleExports, 'constructStack'); return moduleExports; } protected patchV3SmithyClient(moduleExports: any) { - diag.debug( - 'aws-sdk instrumentation: applying patch to aws-sdk v3 client send' - ); this._wrap( moduleExports.Client.prototype, 'send', @@ -206,17 +197,11 @@ export class AwsInstrumentation extends InstrumentationBase { } protected unpatchV3SmithyClient(moduleExports: any) { - diag.debug( - 'aws-sdk instrumentation: applying patch to aws-sdk v3 constructStack' - ); this._unwrap(moduleExports.Client.prototype, 'send'); return moduleExports; } protected patchV2(moduleExports: any, moduleVersion?: string) { - diag.debug( - `aws-sdk instrumentation: applying patch to ${AwsInstrumentation.component}` - ); this.unpatchV2(moduleExports); this._wrap( moduleExports?.Request.prototype, diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts index 08928a23d6..571cbc992e 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts @@ -46,8 +46,7 @@ export class BunyanInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'bunyan', ['<2.0'], - (module: any, moduleVersion) => { - this._diag.debug(`Applying patch for bunyan@${moduleVersion}`); + (module: any) => { const instrumentation = this; const Logger = module[Symbol.toStringTag] === 'Module' diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts index a9bd3d2b85..754277310f 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -51,10 +51,7 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleDefinition( 'cassandra-driver', supportedVersions, - (driverModule, moduleVersion) => { - this._diag.debug( - `Applying patch for cassandra-driver@${moduleVersion}` - ); + driverModule => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const Client = driverModule.Client.prototype as any; @@ -76,10 +73,7 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return driverModule; }, - (driverModule, moduleVersion) => { - this._diag.debug( - `Removing patch for cassandra-driver@${moduleVersion}` - ); + driverModule => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const Client = driverModule.Client.prototype as any; diff --git a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts index e28dd67d74..f1d13bb575 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { context, diag, Span, SpanOptions } from '@opentelemetry/api'; +import { context, Span, SpanOptions } from '@opentelemetry/api'; import { getRPCMetadata, RPCType } from '@opentelemetry/core'; import type { HandleFunction, NextFunction, Server } from 'connect'; import type { ServerResponse } from 'http'; @@ -55,12 +55,8 @@ export class ConnectInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'connect', ['^3.0.0'], - (moduleExports, moduleVersion) => { - diag.debug(`Applying patch for connect@${moduleVersion}`); + moduleExports => { return this._patchConstructor(moduleExports); - }, - (moduleExports, moduleVersion) => { - diag.debug(`Removing patch for connect@${moduleVersion}`); } ), ]; diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts index ca96db7167..37ad2822fb 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts @@ -50,7 +50,6 @@ export class DnsInstrumentation extends InstrumentationBase { 'dns', ['*'], (moduleExports: typeof dns) => { - diag.debug('Applying patch for dns'); if (isWrapped(moduleExports.lookup)) { this._unwrap(moduleExports, 'lookup'); } @@ -66,7 +65,6 @@ export class DnsInstrumentation extends InstrumentationBase { }, moduleExports => { if (moduleExports === undefined) return; - diag.debug('Removing patch for dns'); this._unwrap(moduleExports, 'lookup'); this._unwrap(moduleExports.promises, 'lookup'); } @@ -75,7 +73,6 @@ export class DnsInstrumentation extends InstrumentationBase { 'dns/promises', ['*'], (moduleExports: typeof dnsPromises) => { - diag.debug('Applying patch for dns/promises'); if (isWrapped(moduleExports.lookup)) { this._unwrap(moduleExports, 'lookup'); } @@ -85,7 +82,6 @@ export class DnsInstrumentation extends InstrumentationBase { }, moduleExports => { if (moduleExports === undefined) return; - diag.debug('Removing patch for dns/promises'); this._unwrap(moduleExports, 'lookup'); } ), diff --git a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts index 1d53559cf3..b20121b304 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts @@ -71,8 +71,7 @@ export class ExpressInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'express', ['^4.0.0'], - (moduleExports, moduleVersion) => { - diag.debug(`Applying patch for express@${moduleVersion}`); + moduleExports => { const routerProto = moduleExports.Router as unknown as express.Router; // patch express.Router.route if (isWrapped(routerProto.route)) { @@ -97,9 +96,8 @@ export class ExpressInstrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (moduleExports === undefined) return; - diag.debug(`Removing patch for express@${moduleVersion}`); const routerProto = moduleExports.Router as unknown as express.Router; this._unwrap(routerProto, 'route'); this._unwrap(routerProto, 'use'); diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index f1fb316081..aebf1bf721 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -68,8 +68,7 @@ export class FastifyInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'fastify', ['^3.0.0', '^4.0.0'], - (moduleExports, moduleVersion) => { - this._diag.debug(`Applying patch for fastify@${moduleVersion}`); + moduleExports => { return this._patchConstructor(moduleExports); } ), diff --git a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts index cea3ff9b81..29f3671688 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts @@ -41,8 +41,7 @@ export default class Instrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( MODULE_NAME, ['>=3'], - (moduleExports, moduleVersion) => { - api.diag.debug(`Applying patch for ${MODULE_NAME}@${moduleVersion}`); + moduleExports => { const Pool: any = moduleExports.Pool; if (isWrapped(Pool.prototype.acquire)) { this._unwrap(Pool.prototype, 'acquire'); @@ -54,8 +53,7 @@ export default class Instrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports, moduleVersion) => { - api.diag.debug(`Removing patch for ${MODULE_NAME}@${moduleVersion}`); + moduleExports => { const Pool: any = moduleExports.Pool; this._unwrap(Pool.prototype, 'acquire'); return moduleExports; @@ -64,8 +62,7 @@ export default class Instrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( MODULE_NAME, ['^2.4'], - (moduleExports, moduleVersion) => { - api.diag.debug(`Applying patch for ${MODULE_NAME}@${moduleVersion}`); + moduleExports => { const Pool: any = moduleExports.Pool; if (isWrapped(Pool.prototype.acquire)) { this._unwrap(Pool.prototype, 'acquire'); @@ -77,8 +74,7 @@ export default class Instrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports, moduleVersion) => { - api.diag.debug(`Removing patch for ${MODULE_NAME}@${moduleVersion}`); + moduleExports => { const Pool: any = moduleExports.Pool; this._unwrap(Pool.prototype, 'acquire'); return moduleExports; @@ -87,8 +83,7 @@ export default class Instrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( MODULE_NAME, ['2 - 2.3'], - (moduleExports, moduleVersion) => { - api.diag.debug(`Applying patch for ${MODULE_NAME}@${moduleVersion}`); + moduleExports => { this._isDisabled = false; if (isWrapped(moduleExports.Pool)) { this._unwrap(moduleExports, 'Pool'); @@ -96,8 +91,7 @@ export default class Instrumentation extends InstrumentationBase { this._wrap(moduleExports, 'Pool', this._poolWrapper.bind(this)); return moduleExports; }, - (moduleExports, moduleVersion) => { - api.diag.debug(`Removing patch for ${MODULE_NAME}@${moduleVersion}`); + moduleExports => { // since the object is created on the fly every time, we need to use // a boolean switch here to disable the instrumentation this._isDisabled = true; diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index 8d30b67391..ddae6e3ddb 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -101,8 +101,7 @@ export class GraphQLInstrumentation extends InstrumentationBase { supportedVersions, // cannot make it work with appropriate type as execute function has 2 //types and/cannot import function but only types - (moduleExports: any, moduleVersion) => { - this._diag.debug(`Applying patch for graphql@${moduleVersion} execute`); + (moduleExports: any) => { if (isWrapped(moduleExports.execute)) { this._unwrap(moduleExports, 'execute'); } @@ -113,11 +112,8 @@ export class GraphQLInstrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (moduleExports) { - this._diag.debug( - `Removing patch for graphql@${moduleVersion} execute` - ); this._unwrap(moduleExports, 'execute'); } } @@ -128,17 +124,15 @@ export class GraphQLInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleFile( 'graphql/language/parser.js', supportedVersions, - (moduleExports: typeof graphqlTypes, moduleVersion) => { - this._diag.debug(`Applying patch for graphql@${moduleVersion} parse`); + (moduleExports: typeof graphqlTypes) => { if (isWrapped(moduleExports.parse)) { this._unwrap(moduleExports, 'parse'); } this._wrap(moduleExports, 'parse', this._patchParse()); return moduleExports; }, - (moduleExports: typeof graphqlTypes, moduleVersion) => { + (moduleExports: typeof graphqlTypes) => { if (moduleExports) { - this._diag.debug(`Removing patch for graphql@${moduleVersion} parse`); this._unwrap(moduleExports, 'parse'); } } @@ -149,21 +143,15 @@ export class GraphQLInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleFile( 'graphql/validation/validate.js', supportedVersions, - (moduleExports, moduleVersion) => { - this._diag.debug( - `Applying patch for graphql@${moduleVersion} validate` - ); + moduleExports => { if (isWrapped(moduleExports.validate)) { this._unwrap(moduleExports, 'validate'); } this._wrap(moduleExports, 'validate', this._patchValidate()); return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (moduleExports) { - this._diag.debug( - `Removing patch for graphql@${moduleVersion} validate` - ); this._unwrap(moduleExports, 'validate'); } } diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts index 4e938f438b..4e3d1d4ce9 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts @@ -59,7 +59,6 @@ export class HapiInstrumentation extends InstrumentationBase { ['>=17 <21'], (moduleExports: typeof Hapi) => { if (!isWrapped(moduleExports.server)) { - api.diag.debug('Patching Hapi.server'); this._wrap(moduleExports, 'server', this._getServerPatch.bind(this)); } @@ -69,7 +68,6 @@ export class HapiInstrumentation extends InstrumentationBase { // also be supported and instrumented. This is an issue with the DefinitelyTyped repo. // Function is defined at: https://github.com/hapijs/hapi/blob/main/lib/index.js#L9 if (!isWrapped(moduleExports.Server)) { - api.diag.debug('Patching Hapi.Server'); this._wrap( // eslint-disable-next-line @typescript-eslint/no-explicit-any moduleExports as any, @@ -80,7 +78,6 @@ export class HapiInstrumentation extends InstrumentationBase { return moduleExports; }, (moduleExports: typeof Hapi) => { - api.diag.debug('Unpatching Hapi'); this._massUnwrap([moduleExports], ['server', 'Server']); } ); diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts index d0d662cccd..26b671ab1f 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts @@ -54,7 +54,6 @@ export class IORedisInstrumentation extends InstrumentationBase { module[Symbol.toStringTag] === 'Module' ? module.default // ESM : module; // CommonJS - diag.debug('Applying patch for ioredis'); if (isWrapped(moduleExports.prototype.sendCommand)) { this._unwrap(moduleExports.prototype, 'sendCommand'); } @@ -79,7 +78,6 @@ export class IORedisInstrumentation extends InstrumentationBase { module[Symbol.toStringTag] === 'Module' ? module.default // ESM : module; // CommonJS - diag.debug('Removing patch for ioredis'); this._unwrap(moduleExports.prototype, 'sendCommand'); this._unwrap(moduleExports.prototype, 'connect'); } diff --git a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts index 7aab25716a..ce45403efc 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts @@ -73,11 +73,7 @@ export class KnexInstrumentation extends InstrumentationBase { `knex/${basePath}/runner.js`, constants.SUPPORTED_VERSIONS, (Runner: any, moduleVersion) => { - api.diag.debug( - `Applying ${basePath}/runner.js patch for ${constants.MODULE_NAME}@${moduleVersion}` - ); this.ensureWrapped( - moduleVersion, Runner.prototype, 'query', this.createQueryWrapper(moduleVersion) @@ -85,9 +81,6 @@ export class KnexInstrumentation extends InstrumentationBase { return Runner; }, (Runner: any, moduleVersion) => { - api.diag.debug( - `Removing ${basePath}/runner.js patch for ${constants.MODULE_NAME}@${moduleVersion}` - ); this._unwrap(Runner.prototype, 'query'); return Runner; } @@ -98,24 +91,18 @@ export class KnexInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleFile( `knex/${basePath}/client.js`, constants.SUPPORTED_VERSIONS, - (Client: any, moduleVersion) => { - api.diag.debug( - `Applying ${basePath}/client.js patch for ${constants.MODULE_NAME}@${moduleVersion}` - ); + (Client: any) => { this.ensureWrapped( - moduleVersion, Client.prototype, 'queryBuilder', this.storeContext.bind(this) ); this.ensureWrapped( - moduleVersion, Client.prototype, 'schemaBuilder', this.storeContext.bind(this) ); this.ensureWrapped( - moduleVersion, Client.prototype, 'raw', this.storeContext.bind(this) @@ -214,15 +201,7 @@ export class KnexInstrumentation extends InstrumentationBase { }; } - ensureWrapped( - moduleVersion: string | undefined, - obj: any, - methodName: string, - wrapper: (original: any) => any - ) { - api.diag.debug( - `Applying ${methodName} patch for ${constants.MODULE_NAME}@${moduleVersion}` - ); + ensureWrapped(obj: any, methodName: string, wrapper: (original: any) => any) { if (isWrapped(obj[methodName])) { this._unwrap(obj, methodName); } diff --git a/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts index 7ce213fe82..742e500122 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts @@ -63,7 +63,6 @@ export class KoaInstrumentation extends InstrumentationBase { if (moduleExports == null) { return moduleExports; } - api.diag.debug('Patching Koa'); if (isWrapped(moduleExports.prototype.use)) { this._unwrap(moduleExports.prototype, 'use'); } @@ -79,7 +78,6 @@ export class KoaInstrumentation extends InstrumentationBase { module[Symbol.toStringTag] === 'Module' ? module.default // ESM : module; // CommonJS - api.diag.debug('Unpatching Koa'); if (isWrapped(moduleExports.prototype.use)) { this._unwrap(moduleExports.prototype, 'use'); } diff --git a/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts index 3ba0770355..fba48b5434 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts @@ -56,21 +56,14 @@ export class Instrumentation extends InstrumentationBase { 'memcached', ['>=2.2'], (moduleExports: typeof Memcached, moduleVersion) => { - this._diag.debug( - `Patching ${Instrumentation.COMPONENT}@${moduleVersion}` - ); this.ensureWrapped( - moduleVersion, moduleExports.prototype, 'command', this.wrapCommand.bind(this, moduleVersion) ); return moduleExports; }, - (moduleExports: typeof Memcached, moduleVersion) => { - this._diag.debug( - `Unpatching ${Instrumentation.COMPONENT}@${moduleVersion}` - ); + (moduleExports: typeof Memcached) => { if (moduleExports === undefined) return; // `command` is documented API missing from the types this._unwrap(moduleExports.prototype, 'command' as keyof Memcached); @@ -175,14 +168,10 @@ export class Instrumentation extends InstrumentationBase { } private ensureWrapped( - moduleVersion: string | undefined, obj: any, methodName: string, wrapper: (original: any) => any ) { - this._diag.debug( - `Applying ${methodName} patch for ${Instrumentation.COMPONENT}@${moduleVersion}` - ); if (isWrapped(obj[methodName])) { this._unwrap(obj, methodName); } diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index 7b99c55c9a..f7c9e99d3a 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -15,7 +15,6 @@ */ import { context, - diag, trace, Span, SpanKind, @@ -148,8 +147,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV3ConnectionPatches() { return { - v3PatchConnection: (moduleExports: T, moduleVersion?: string) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); + v3PatchConnection: (moduleExports: T) => { // patch insert operation if (isWrapped(moduleExports.insert)) { this._unwrap(moduleExports, 'insert'); @@ -194,9 +192,8 @@ export class MongoDBInstrumentation extends InstrumentationBase { this._wrap(moduleExports, 'getMore', this._getV3PatchCursor()); return moduleExports; }, - v3UnpatchConnection: (moduleExports?: T, moduleVersion?: string) => { + v3UnpatchConnection: (moduleExports?: T) => { if (moduleExports === undefined) return; - diag.debug(`Removing internal patch for mongodb@${moduleVersion}`); this._unwrap(moduleExports, 'insert'); this._unwrap(moduleExports, 'remove'); this._unwrap(moduleExports, 'update'); @@ -209,8 +206,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4SessionsPatches() { return { - v4PatchSessions: (moduleExports: any, moduleVersion?: string) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); + v4PatchSessions: (moduleExports: any) => { if (isWrapped(moduleExports.acquire)) { this._unwrap(moduleExports, 'acquire'); } @@ -230,8 +226,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { ); return moduleExports; }, - v4UnpatchSessions: (moduleExports?: T, moduleVersion?: string) => { - diag.debug(`Removing internal patch for mongodb@${moduleVersion}`); + v4UnpatchSessions: (moduleExports?: T) => { if (moduleExports === undefined) return; if (isWrapped(moduleExports.acquire)) { this._unwrap(moduleExports, 'acquire'); @@ -294,8 +289,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4ConnectionPoolPatches() { return { - v4PatchConnectionPool: (moduleExports: any, moduleVersion?: string) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); + v4PatchConnectionPool: (moduleExports: any) => { const poolPrototype = moduleExports.ConnectionPool.prototype; if (isWrapped(poolPrototype.checkOut)) { @@ -309,11 +303,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { ); return moduleExports; }, - v4UnpatchConnectionPool: ( - moduleExports?: any, - moduleVersion?: string - ) => { - diag.debug(`Removing internal patch for mongodb@${moduleVersion}`); + v4UnpatchConnectionPool: (moduleExports?: any) => { if (moduleExports === undefined) return; this._unwrap(moduleExports.ConnectionPool.prototype, 'checkOut'); @@ -323,8 +313,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4ConnectPatches() { return { - v4PatchConnect: (moduleExports: any, moduleVersion?: string) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); + v4PatchConnect: (moduleExports: any) => { if (isWrapped(moduleExports.connect)) { this._unwrap(moduleExports, 'connect'); } @@ -332,8 +321,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { this._wrap(moduleExports, 'connect', this._getV4ConnectCommand()); return moduleExports; }, - v4UnpatchConnect: (moduleExports?: T, moduleVersion?: string) => { - diag.debug(`Removing internal patch for mongodb@${moduleVersion}`); + v4UnpatchConnect: (moduleExports?: T) => { if (moduleExports === undefined) return; this._unwrap(moduleExports, 'connect'); @@ -402,11 +390,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { // eslint-disable-next-line @typescript-eslint/no-unused-vars private _getV4ConnectionPatches() { return { - v4PatchConnectionCallback: ( - moduleExports: any, - moduleVersion?: string - ) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); + v4PatchConnectionCallback: (moduleExports: any) => { // patch insert operation if (isWrapped(moduleExports.Connection.prototype.command)) { this._unwrap(moduleExports.Connection.prototype, 'command'); @@ -419,11 +403,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { ); return moduleExports; }, - v4PatchConnectionPromise: ( - moduleExports: any, - moduleVersion?: string - ) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); + v4PatchConnectionPromise: (moduleExports: any) => { // patch insert operation if (isWrapped(moduleExports.Connection.prototype.command)) { this._unwrap(moduleExports.Connection.prototype, 'command'); @@ -436,9 +416,8 @@ export class MongoDBInstrumentation extends InstrumentationBase { ); return moduleExports; }, - v4UnpatchConnection: (moduleExports?: any, moduleVersion?: string) => { + v4UnpatchConnection: (moduleExports?: any) => { if (moduleExports === undefined) return; - diag.debug(`Removing internal patch for mongodb@${moduleVersion}`); this._unwrap(moduleExports.Connection.prototype, 'command'); }, }; diff --git a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts index 78e9b78a03..2e4ba8675e 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts @@ -83,9 +83,7 @@ export class MySQLInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'mysql', ['2.*'], - (moduleExports: typeof mysqlTypes, moduleVersion) => { - diag.debug(`Patching mysql@${moduleVersion}`); - + (moduleExports: typeof mysqlTypes) => { diag.debug('Patching mysql.createConnection'); if (isWrapped(moduleExports.createConnection)) { this._unwrap(moduleExports, 'createConnection'); diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts index d2f130b2ac..e693488de0 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts @@ -53,9 +53,7 @@ export class MySQL2Instrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'mysql2', ['>= 1.4.2 < 4.0'], - (moduleExports: any, moduleVersion) => { - api.diag.debug(`Patching mysql2@${moduleVersion}`); - + (moduleExports: any) => { const ConnectionPrototype: mysqlTypes.Connection = moduleExports.Connection.prototype; api.diag.debug('Patching Connection.prototype.query'); diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts index d947169ec4..619c68760f 100644 --- a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts @@ -42,19 +42,7 @@ export class Instrumentation extends InstrumentationBase { init() { const module = new InstrumentationNodeModuleDefinition( Instrumentation.COMPONENT, - ['>=4.0.0'], - (moduleExports, moduleVersion) => { - this._diag.debug( - `Patching ${Instrumentation.COMPONENT}@${moduleVersion}` - ); - return moduleExports; - }, - (moduleExports, moduleVersion) => { - this._diag.debug( - `Unpatching ${Instrumentation.COMPONENT}@${moduleVersion}` - ); - if (moduleExports === undefined) return; - } + ['>=4.0.0'] ); module.files.push( @@ -71,7 +59,6 @@ export class Instrumentation extends InstrumentationBase { versions, (NestFactoryStatic: any, moduleVersion?: string) => { this.ensureWrapped( - moduleVersion, NestFactoryStatic.NestFactoryStatic.prototype, 'create', createWrapNestFactoryCreate(this.tracer, moduleVersion) @@ -90,7 +77,6 @@ export class Instrumentation extends InstrumentationBase { versions, (RouterExecutionContext: any, moduleVersion?: string) => { this.ensureWrapped( - moduleVersion, RouterExecutionContext.RouterExecutionContext.prototype, 'create', createWrapCreateHandler(this.tracer, moduleVersion) @@ -107,14 +93,10 @@ export class Instrumentation extends InstrumentationBase { } private ensureWrapped( - moduleVersion: string | undefined, obj: any, methodName: string, wrapper: (original: any) => any ) { - this._diag.debug( - `Applying ${methodName} patch for ${Instrumentation.COMPONENT}@${moduleVersion}` - ); if (isWrapped(obj[methodName])) { this._unwrap(obj, methodName); } diff --git a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts index 59befd2daa..49611da87c 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { diag, Span, SpanStatusCode, context, trace } from '@opentelemetry/api'; +import { Span, SpanStatusCode, context, trace } from '@opentelemetry/api'; import { InstrumentationBase, InstrumentationConfig, @@ -45,7 +45,6 @@ export class NetInstrumentation extends InstrumentationBase { 'net', ['*'], (moduleExports: typeof net) => { - diag.debug('Applying patch for net module'); if (isWrapped(moduleExports.Socket.prototype.connect)) { this._unwrap(moduleExports.Socket.prototype, 'connect'); } @@ -59,7 +58,6 @@ export class NetInstrumentation extends InstrumentationBase { }, (moduleExports: typeof net) => { if (moduleExports === undefined) return; - diag.debug('Removing patch from net module'); this._unwrap(moduleExports.Socket.prototype, 'connect'); } ), diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts index 3a05d00ce4..d8043af302 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -55,8 +55,7 @@ export class PgInstrumentation extends InstrumentationBase { const modulePG = new InstrumentationNodeModuleDefinition( 'pg', ['8.*'], - (module: any, moduleVersion) => { - this._diag.debug(`Applying patch for pg@${moduleVersion}`); + (module: any) => { const moduleExports: typeof pgTypes = module[Symbol.toStringTag] === 'Module' ? module.default // ESM @@ -83,12 +82,11 @@ export class PgInstrumentation extends InstrumentationBase { return module; }, - (module: any, moduleVersion) => { + (module: any) => { const moduleExports: typeof pgTypes = module[Symbol.toStringTag] === 'Module' ? module.default // ESM : module; // CommonJS - this._diag.debug(`Removing patch for pg@${moduleVersion}`); if (isWrapped(moduleExports.Client.prototype.query)) { this._unwrap(moduleExports.Client.prototype, 'query'); } @@ -98,8 +96,7 @@ export class PgInstrumentation extends InstrumentationBase { const modulePGPool = new InstrumentationNodeModuleDefinition( 'pg-pool', ['2.*', '3.*'], - (moduleExports: typeof pgPoolTypes, moduleVersion) => { - this._diag.debug(`Applying patch for pg-pool@${moduleVersion}`); + (moduleExports: typeof pgPoolTypes) => { if (isWrapped(moduleExports.prototype.connect)) { this._unwrap(moduleExports.prototype, 'connect'); } @@ -110,8 +107,7 @@ export class PgInstrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports: typeof pgPoolTypes, moduleVersion) => { - this._diag.debug(`Removing patch for pg-pool@${moduleVersion}`); + (moduleExports: typeof pgPoolTypes) => { if (isWrapped(moduleExports.prototype.connect)) { this._unwrap(moduleExports.prototype, 'connect'); } diff --git a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts index b84dfd4209..dce1ff3ecc 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts @@ -44,57 +44,52 @@ export class PinoInstrumentation extends InstrumentationBase { protected init() { return [ - new InstrumentationNodeModuleDefinition( - 'pino', - pinoVersions, - (module, moduleVersion?: string) => { - diag.debug(`Applying patch for pino@${moduleVersion}`); - const isESM = module[Symbol.toStringTag] === 'Module'; - const moduleExports = isESM ? module.default : module; - const instrumentation = this; - const patchedPino = Object.assign((...args: unknown[]) => { - if (args.length === 0) { - return moduleExports({ + new InstrumentationNodeModuleDefinition('pino', pinoVersions, module => { + const isESM = module[Symbol.toStringTag] === 'Module'; + const moduleExports = isESM ? module.default : module; + const instrumentation = this; + const patchedPino = Object.assign((...args: unknown[]) => { + if (args.length === 0) { + return moduleExports({ + mixin: instrumentation._getMixinFunction(), + }); + } + + if (args.length === 1) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const optsOrStream = args[0] as any; + if ( + typeof optsOrStream === 'string' || + typeof optsOrStream?.write === 'function' + ) { + args.splice(0, 0, { mixin: instrumentation._getMixinFunction(), }); + return moduleExports(...args); } + } - if (args.length === 1) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const optsOrStream = args[0] as any; - if ( - typeof optsOrStream === 'string' || - typeof optsOrStream?.write === 'function' - ) { - args.splice(0, 0, { - mixin: instrumentation._getMixinFunction(), - }); - return moduleExports(...args); - } - } - - args[0] = instrumentation._combineOptions(args[0]); + args[0] = instrumentation._combineOptions(args[0]); - return moduleExports(...args); - }, moduleExports); + return moduleExports(...args); + }, moduleExports); - if (typeof patchedPino.pino === 'function') { - patchedPino.pino = patchedPino; - } - if (typeof patchedPino.default === 'function') { - patchedPino.default = patchedPino; - } - if (isESM) { - if (module.pino) { - // This was added in pino@6.8.0 (https://github.com/pinojs/pino/pull/936). - module.pino = patchedPino; - } - module.default = patchedPino; + if (typeof patchedPino.pino === 'function') { + patchedPino.pino = patchedPino; + } + if (typeof patchedPino.default === 'function') { + patchedPino.default = patchedPino; + } + if (isESM) { + if (module.pino) { + // This was added in pino@6.8.0 (https://github.com/pinojs/pino/pull/936). + module.pino = patchedPino; } - - return patchedPino; + module.default = patchedPino; } - ), + + return patchedPino; + }), ]; } diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts index 42f44e8775..a431fd76ca 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts @@ -15,7 +15,6 @@ */ import { - diag, trace, context, SpanKind, @@ -96,7 +95,6 @@ export class RedisInstrumentation extends InstrumentationBase { : 'attachCommands'; // this is the function that extend a redis client with a list of commands. // the function patches the commandExecutor to record a span - this._diag.debug('Patching redis commands executor'); if (isWrapped(moduleExports?.[functionToPatch])) { this._unwrap(moduleExports, functionToPatch); } @@ -109,7 +107,6 @@ export class RedisInstrumentation extends InstrumentationBase { return moduleExports; }, (moduleExports: any) => { - this._diag.debug('Unpatching redis commands executor'); if (isWrapped(moduleExports?.extendWithCommands)) { this._unwrap(moduleExports, 'extendWithCommands'); } @@ -123,7 +120,6 @@ export class RedisInstrumentation extends InstrumentationBase { `${basePackageName}/dist/lib/client/multi-command.js`, ['^1.0.0'], (moduleExports: any) => { - this._diag.debug('Patching redis multi commands executor'); const redisClientMultiCommandPrototype = moduleExports?.default?.prototype; @@ -148,7 +144,6 @@ export class RedisInstrumentation extends InstrumentationBase { return moduleExports; }, (moduleExports: any) => { - this._diag.debug('Unpatching redis multi commands executor'); const redisClientMultiCommandPrototype = moduleExports?.default?.prototype; if (isWrapped(redisClientMultiCommandPrototype?.exec)) { @@ -164,7 +159,6 @@ export class RedisInstrumentation extends InstrumentationBase { `${basePackageName}/dist/lib/client/index.js`, ['^1.0.0'], (moduleExports: any) => { - this._diag.debug('Patching redis client'); const redisClientPrototype = moduleExports?.default?.prototype; // In some @redis/client versions 'multi' is a method. In later @@ -211,7 +205,6 @@ export class RedisInstrumentation extends InstrumentationBase { return moduleExports; }, (moduleExports: any) => { - this._diag.debug('Unpatching redis client'); const redisClientPrototype = moduleExports?.default?.prototype; if (isWrapped(redisClientPrototype?.multi)) { this._unwrap(redisClientPrototype, 'multi'); @@ -228,17 +221,10 @@ export class RedisInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleDefinition( basePackageName, ['^1.0.0'], - (moduleExports: any, moduleVersion?: string) => { - diag.debug( - `Patching ${basePackageName}/client@${moduleVersion} (redis@^4.0.0)` - ); + (moduleExports: any) => { return moduleExports; }, - (_moduleExports: any, moduleVersion?: string) => { - diag.debug( - `Unpatching ${basePackageName}/client@${moduleVersion} (redis@^4.0.0)` - ); - }, + () => {}, [commanderModuleFile, multiCommanderModule, clientIndexModule] ); } diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts index a25ef5b8ed..09ee03e6ad 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts @@ -48,8 +48,7 @@ export class RedisInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'redis', ['^2.6.0', '^3.0.0'], - (moduleExports, moduleVersion) => { - diag.debug(`Patching redis@${moduleVersion}`); + moduleExports => { diag.debug('Patching redis.RedisClient.internal_send_command'); if ( isWrapped( diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts index f5a1ee96dd..73b8b8f5e7 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts @@ -35,8 +35,6 @@ import { isPromise, isAsyncFunction } from './utils'; import { getRPCMetadata, RPCType } from '@opentelemetry/core'; import type { RestifyInstrumentationConfig } from './types'; -const { diag } = api; - export class RestifyInstrumentation extends InstrumentationBase { constructor(config: RestifyInstrumentationConfig = {}) { super( @@ -71,10 +69,7 @@ export class RestifyInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'restify/lib/server.js', constants.SUPPORTED_VERSIONS, - (moduleExports, moduleVersion) => { - diag.debug( - `Applying patch for ${constants.MODULE_NAME}@${moduleVersion}` - ); + moduleExports => { this._isDisabled = false; const Server: any = moduleExports; for (const name of constants.RESTIFY_METHODS) { @@ -99,10 +94,7 @@ export class RestifyInstrumentation extends InstrumentationBase { } return moduleExports; }, - (moduleExports, moduleVersion) => { - diag.debug( - `Removing patch for ${constants.MODULE_NAME}@${moduleVersion}` - ); + moduleExports => { this._isDisabled = true; if (moduleExports) { const Server: any = moduleExports; diff --git a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts index ca5c73790c..02e01d287e 100644 --- a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts @@ -50,17 +50,8 @@ export default class RouterInstrumentation extends InstrumentationBase { constants.MODULE_NAME, constants.SUPPORTED_VERSIONS, (moduleExports, moduleVersion) => { - api.diag.debug( - `Applying patch for ${constants.MODULE_NAME}@${moduleVersion}` - ); this._moduleVersion = moduleVersion; return moduleExports; - }, - (moduleExports, moduleVersion) => { - api.diag.debug( - `Removing patch for ${constants.MODULE_NAME}@${moduleVersion}` - ); - return moduleExports; } ); @@ -68,10 +59,7 @@ export default class RouterInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'router/lib/layer.js', constants.SUPPORTED_VERSIONS, - (moduleExports, moduleVersion) => { - api.diag.debug( - `Applying patch for "lib/layer.js" of ${constants.MODULE_NAME}@${moduleVersion}` - ); + moduleExports => { const Layer: any = moduleExports; if (isWrapped(Layer.prototype.handle_request)) { this._unwrap(Layer.prototype, 'handle_request'); @@ -91,10 +79,7 @@ export default class RouterInstrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports, moduleVersion) => { - api.diag.debug( - `Removing patch for "lib/layer.js" of ${constants.MODULE_NAME}@${moduleVersion}` - ); + moduleExports => { const Layer: any = moduleExports; this._unwrap(Layer.prototype, 'handle_request'); this._unwrap(Layer.prototype, 'handle_error'); diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts index 4312f2bc31..2e75400741 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -52,8 +52,7 @@ export class WinstonInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'winston/lib/winston/logger.js', winston3Versions, - (logger: Winston3Logger, moduleVersion) => { - this._diag.debug(`Applying patch for winston@${moduleVersion}`); + (logger: Winston3Logger) => { if (isWrapped(logger.prototype['write'])) { this._unwrap(logger.prototype, 'write'); } @@ -71,9 +70,8 @@ export class WinstonInstrumentation extends InstrumentationBase { return logger; }, - (logger: Winston3Logger, moduleVersion) => { + (logger: Winston3Logger) => { if (logger === undefined) return; - this._diag.debug(`Removing patch for winston@${moduleVersion}`); this._unwrap(logger.prototype, 'write'); this._unwrap(logger.prototype, 'configure'); } @@ -91,8 +89,7 @@ export class WinstonInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'winston/lib/winston/logger.js', winstonPre3Versions, - (fileExports: Winston2LoggerModule, moduleVersion) => { - this._diag.debug(`Applying patch for winston@${moduleVersion}`); + (fileExports: Winston2LoggerModule) => { const proto = fileExports.Logger.prototype; if (isWrapped(proto.log)) { @@ -102,9 +99,8 @@ export class WinstonInstrumentation extends InstrumentationBase { return fileExports; }, - (fileExports: Winston2LoggerModule, moduleVersion) => { + (fileExports: Winston2LoggerModule) => { if (fileExports === undefined) return; - this._diag.debug(`Removing patch for winston@${moduleVersion}`); this._unwrap(fileExports.Logger.prototype, 'log'); } ),