From f27f500ffda45ac178769af85324be62a5ec8c62 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Wed, 17 Apr 2024 13:04:14 +0300 Subject: [PATCH 1/7] chore: remove patch and unpatch diag from instrumentations --- .../src/instrumentation.ts | 16 ++---------- .../src/instrumentation.ts | 8 ++---- .../instrumentation-fs/src/instrumentation.ts | 4 --- .../src/instrumentation.ts | 2 -- .../src/socket.io.ts | 17 ------------- .../src/instrumentation.ts | 4 +-- .../src/instrumentation.ts | 2 -- .../src/aws-sdk.ts | 15 ----------- .../src/instrumentation.ts | 1 - .../src/instrumentation.ts | 6 ----- .../src/instrumentation.ts | 6 +---- .../src/instrumentation.ts | 4 --- .../src/instrumentation.ts | 2 -- .../src/instrumentation.ts | 1 - .../src/instrumentation.ts | 12 +++------ .../src/instrumentation.ts | 22 ++++------------ .../src/instrumentation.ts | 2 -- .../src/instrumentation.ts | 25 ++----------------- .../src/instrumentation.ts | 13 +--------- .../src/instrumentation.ts | 6 ----- .../src/instrumentation.ts | 20 +-------------- .../src/instrumentation.ts | 2 -- .../src/instrumentation.ts | 8 ++---- .../src/instrumentation.ts | 3 +-- .../src/instrumentation.ts | 6 ----- .../src/instrumentation.ts | 10 ++------ .../src/instrumentation.ts | 15 ----------- .../src/instrumentation.ts | 6 +---- 28 files changed, 24 insertions(+), 214 deletions(-) diff --git a/plugins/node/instrumentation-cucumber/src/instrumentation.ts b/plugins/node/instrumentation-cucumber/src/instrumentation.ts index 5ea3305db2..2fa4b670de 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, moduleVersion) => { - this._diag.debug( - `Applying patch for @cucumber/cucumber@${moduleVersion}` - ); + moduleExports => { this.module = moduleExports; steps.forEach(step => { if (isWrapped(moduleExports[step])) { @@ -72,11 +69,8 @@ export class CucumberInstrumentation extends InstrumentationBase { }); return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (moduleExports === undefined) return; - this._diag.debug( - `Removing patch for @cucumber/cucumber@${moduleVersion}` - ); [...hooks, ...steps].forEach(method => { this._unwrap(moduleExports, method); }); @@ -88,9 +82,6 @@ export class CucumberInstrumentation extends InstrumentationBase { '@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}` - ); if (isWrapped(moduleExports.default.prototype.run)) { this._unwrap(moduleExports.default.prototype, 'run'); this._unwrap(moduleExports.default.prototype, 'runStep'); @@ -119,9 +110,6 @@ export class CucumberInstrumentation extends InstrumentationBase { }, (moduleExports, moduleVersion) => { 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 7264d031ae..1a49c62bcb 100644 --- a/plugins/node/instrumentation-dataloader/src/instrumentation.ts +++ b/plugins/node/instrumentation-dataloader/src/instrumentation.ts @@ -54,17 +54,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 048b8d7b34..5ee5e58492 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 b26d9468a3..4d46dfa7fe 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-socket.io/src/socket.io.ts b/plugins/node/instrumentation-socket.io/src/socket.io.ts index db37e5c375..dab552689b 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'); } @@ -113,9 +112,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'); } @@ -143,9 +139,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'); } @@ -172,7 +165,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'); } @@ -208,9 +200,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'); } @@ -239,9 +228,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'); } @@ -274,9 +260,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 7484dd49fb..bcdbe18968 100644 --- a/plugins/node/instrumentation-tedious/src/instrumentation.ts +++ b/plugins/node/instrumentation-tedious/src/instrumentation.ts @@ -75,9 +75,7 @@ export class TediousInstrumentation extends InstrumentationBase< new InstrumentationNodeModuleDefinition( TediousInstrumentation.COMPONENT, ['>=1.11.0 <=15'], - (moduleExports: any, moduleVersion) => { - this._diag.debug(`Patching tedious@${moduleVersion}`); - + (moduleExports: any) => { 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 0b85377d1d..c6820fafca 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts @@ -150,7 +150,6 @@ export class AwsLambdaInstrumentation extends InstrumentationBase { module, ['*'], (moduleExports: LambdaModule) => { - diag.debug('Applying patch for lambda handler'); if (isWrapped(moduleExports[functionName])) { this._unwrap(moduleExports, functionName); } @@ -159,7 +158,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 349d2ff388..ef25833fdb 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts @@ -173,9 +173,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', @@ -185,17 +182,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', @@ -205,17 +196,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 d3e76a74ce..beda4e0f45 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts @@ -49,7 +49,6 @@ export class BunyanInstrumentation extends InstrumentationBase< 'bunyan', ['<2.0'], (module: any, moduleVersion) => { - this._diag.debug(`Applying patch for bunyan@${moduleVersion}`); 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 fe2f9718e5..bd4eb132ae 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -52,9 +52,6 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { 'cassandra-driver', supportedVersions, (driverModule, moduleVersion) => { - this._diag.debug( - `Applying patch for cassandra-driver@${moduleVersion}` - ); // eslint-disable-next-line @typescript-eslint/no-explicit-any const Client = driverModule.Client.prototype as any; @@ -77,9 +74,6 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return driverModule; }, (driverModule, moduleVersion) => { - this._diag.debug( - `Removing patch for cassandra-driver@${moduleVersion}` - ); // 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 97a06d8a37..3d4412c89e 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts @@ -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 319a27e1c1..94792dca1f 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 => { - 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 => { - 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 3df15aa699..71b6da162b 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts @@ -74,7 +74,6 @@ export class ExpressInstrumentation extends InstrumentationBase< 'express', ['^4.0.0'], (moduleExports, moduleVersion) => { - diag.debug(`Applying patch for express@${moduleVersion}`); const routerProto = moduleExports.Router as unknown as express.Router; // patch express.Router.route if (isWrapped(routerProto.route)) { @@ -101,7 +100,6 @@ export class ExpressInstrumentation extends InstrumentationBase< }, (moduleExports, moduleVersion) => { 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 223ed28854..15e7d79e6c 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -69,7 +69,6 @@ export class FastifyInstrumentation extends InstrumentationBase { 'fastify', ['^3.0.0', '^4.0.0'], (moduleExports, moduleVersion) => { - this._diag.debug(`Applying patch for fastify@${moduleVersion}`); 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 35a9266e36..3308783b39 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts @@ -42,7 +42,6 @@ export default class Instrumentation extends InstrumentationBase { MODULE_NAME, ['>=3'], (moduleExports, moduleVersion) => { - api.diag.debug(`Applying patch for ${MODULE_NAME}@${moduleVersion}`); 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; @@ -65,7 +63,6 @@ export default class Instrumentation extends InstrumentationBase { MODULE_NAME, ['^2.4'], (moduleExports, moduleVersion) => { - api.diag.debug(`Applying patch for ${MODULE_NAME}@${moduleVersion}`); 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; @@ -88,7 +84,6 @@ export default class Instrumentation extends InstrumentationBase { MODULE_NAME, ['2 - 2.3'], (moduleExports, moduleVersion) => { - api.diag.debug(`Applying patch for ${MODULE_NAME}@${moduleVersion}`); 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 0bb1bc2c3a..0d36c8eb83 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -103,8 +103,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'); } @@ -115,11 +114,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'); } } @@ -133,16 +129,14 @@ export class GraphQLInstrumentation extends InstrumentationBase { 'graphql/language/parser.js', supportedVersions, (moduleExports, moduleVersion) => { - this._diag.debug(`Applying patch for graphql@${moduleVersion} parse`); if (isWrapped(moduleExports.parse)) { this._unwrap(moduleExports, 'parse'); } this._wrap(moduleExports, 'parse', this._patchParse()); return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (moduleExports) { - this._diag.debug(`Removing patch for graphql@${moduleVersion} parse`); this._unwrap(moduleExports, 'parse'); } } @@ -155,21 +149,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-ioredis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts index 0753518de3..16c6211e38 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 257232f278..741ad2c5db 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts @@ -65,11 +65,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) @@ -77,9 +73,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; } @@ -90,24 +83,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) @@ -206,15 +193,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-memcached/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts index afa205dad9..7c1a537b56 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, moduleVersion) => { - this._diag.debug( - `Patching ${Instrumentation.COMPONENT}@${moduleVersion}` - ); this.ensureWrapped( - moduleVersion, moduleExports.prototype, 'command', this.wrapCommand.bind(this, moduleVersion) ); return moduleExports; }, - (moduleExports, moduleVersion) => { - this._diag.debug( - `Unpatching ${Instrumentation.COMPONENT}@${moduleVersion}` - ); + moduleExports => { 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 d5239d9706..306d113222 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -149,7 +149,6 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV3ConnectionPatches() { return { v3PatchConnection: (moduleExports: T, moduleVersion?: string) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); // patch insert operation if (isWrapped(moduleExports.insert)) { this._unwrap(moduleExports, 'insert'); @@ -210,7 +209,6 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4SessionsPatches() { return { v4PatchSessions: (moduleExports: any, moduleVersion?: string) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); if (isWrapped(moduleExports.acquire)) { this._unwrap(moduleExports, 'acquire'); } @@ -295,7 +293,6 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4ConnectionPoolPatches() { return { v4PatchConnectionPool: (moduleExports: any, moduleVersion?: string) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); const poolPrototype = moduleExports.ConnectionPool.prototype; if (isWrapped(poolPrototype.checkOut)) { @@ -324,7 +321,6 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4ConnectPatches() { return { v4PatchConnect: (moduleExports: any, moduleVersion?: string) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); if (isWrapped(moduleExports.connect)) { this._unwrap(moduleExports, 'connect'); } @@ -406,7 +402,6 @@ export class MongoDBInstrumentation extends InstrumentationBase { moduleExports: any, moduleVersion?: string ) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); // patch insert operation if (isWrapped(moduleExports.Connection.prototype.command)) { this._unwrap(moduleExports.Connection.prototype, 'command'); @@ -423,7 +418,6 @@ export class MongoDBInstrumentation extends InstrumentationBase { moduleExports: any, moduleVersion?: string ) => { - diag.debug(`Applying patch for mongodb@${moduleVersion}`); // patch insert operation if (isWrapped(moduleExports.Connection.prototype.command)) { this._unwrap(moduleExports.Connection.prototype, 'command'); diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts index 98922126fa..f8d70f2c4e 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 e3aa6f1e33..678d5b0a4a 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts @@ -44,7 +44,6 @@ export class NetInstrumentation extends InstrumentationBase { 'net', ['*'], moduleExports => { - diag.debug('Applying patch for net module'); if (isWrapped(moduleExports.Socket.prototype.connect)) { this._unwrap(moduleExports.Socket.prototype, 'connect'); } @@ -58,7 +57,6 @@ export class NetInstrumentation extends InstrumentationBase { }, moduleExports => { 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 abe4e65c5e..f136b9a1cf 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 @@ -88,7 +87,6 @@ export class PgInstrumentation extends InstrumentationBase { 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'); } @@ -100,8 +98,7 @@ export class PgInstrumentation extends InstrumentationBase { >( 'pg-pool', ['2.*', '3.*'], - (moduleExports, moduleVersion) => { - this._diag.debug(`Applying patch for pg-pool@${moduleVersion}`); + moduleExports => { if (isWrapped(moduleExports.prototype.connect)) { this._unwrap(moduleExports.prototype, 'connect'); } @@ -113,7 +110,6 @@ export class PgInstrumentation extends InstrumentationBase { return moduleExports; }, (moduleExports, moduleVersion) => { - this._diag.debug(`Removing patch for pg-pool@${moduleVersion}`); 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 3c5824b359..1d2228ba58 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts @@ -47,8 +47,7 @@ export class PinoInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'pino', pinoVersions, - (module, moduleVersion?: string) => { - diag.debug(`Applying patch for pino@${moduleVersion}`); + module => { const isESM = module[Symbol.toStringTag] === 'Module'; const moduleExports = isESM ? module.default : module; const instrumentation = this; diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts index e018845e2d..f65d808686 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts @@ -96,7 +96,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 +108,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 +121,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 +145,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 +160,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 +206,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'); diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts index 9efe444502..c81eea59c7 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts @@ -71,10 +71,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 +96,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 8733daf1ab..2cd37fa80f 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; } ); @@ -69,9 +60,6 @@ export default class RouterInstrumentation extends InstrumentationBase { 'router/lib/layer.js', constants.SUPPORTED_VERSIONS, (moduleExports, moduleVersion) => { - api.diag.debug( - `Applying patch for "lib/layer.js" of ${constants.MODULE_NAME}@${moduleVersion}` - ); const Layer: any = moduleExports; if (isWrapped(Layer.prototype.handle_request)) { this._unwrap(Layer.prototype, 'handle_request'); @@ -92,9 +80,6 @@ export default class RouterInstrumentation extends InstrumentationBase { return moduleExports; }, (moduleExports, moduleVersion) => { - api.diag.debug( - `Removing patch for "lib/layer.js" of ${constants.MODULE_NAME}@${moduleVersion}` - ); 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 d89107144c..1fdffb42a9 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -52,7 +52,6 @@ export class WinstonInstrumentation extends InstrumentationBase { 'winston/lib/winston/logger.js', winston3Versions, (logger, moduleVersion) => { - this._diag.debug(`Applying patch for winston@${moduleVersion}`); if (isWrapped(logger.prototype['write'])) { this._unwrap(logger.prototype, 'write'); } @@ -72,7 +71,6 @@ export class WinstonInstrumentation extends InstrumentationBase { }, (logger, moduleVersion) => { if (logger === undefined) return; - this._diag.debug(`Removing patch for winston@${moduleVersion}`); this._unwrap(logger.prototype, 'write'); this._unwrap(logger.prototype, 'configure'); } @@ -91,7 +89,6 @@ export class WinstonInstrumentation extends InstrumentationBase { 'winston/lib/winston/logger.js', winstonPre3Versions, (fileExports, moduleVersion) => { - this._diag.debug(`Applying patch for winston@${moduleVersion}`); const proto = fileExports.Logger.prototype; if (isWrapped(proto.log)) { @@ -101,9 +98,8 @@ export class WinstonInstrumentation extends InstrumentationBase { return fileExports; }, - (fileExports, moduleVersion) => { + fileExports => { if (fileExports === undefined) return; - this._diag.debug(`Removing patch for winston@${moduleVersion}`); this._unwrap(fileExports.Logger.prototype, 'log'); } ), From 6c0fb571a8d11b72b72a3a6759f6d6861f9ad938 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Wed, 17 Apr 2024 13:25:47 +0300 Subject: [PATCH 2/7] fix: compile --- plugins/node/instrumentation-dataloader/src/instrumentation.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/node/instrumentation-dataloader/src/instrumentation.ts b/plugins/node/instrumentation-dataloader/src/instrumentation.ts index 1a49c62bcb..ba0ee9059e 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, From d7e9df3f917de0be31dea81ac6c5913861a29e1c Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Wed, 17 Apr 2024 13:30:24 +0300 Subject: [PATCH 3/7] fix: compile error connect instrumentation --- .../src/instrumentation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts index 3d4412c89e..2fbf1566eb 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'; From 5a221b9db97d1f97e1f03a39402d25564b755388 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Wed, 17 Apr 2024 13:58:01 +0300 Subject: [PATCH 4/7] fix: compile --- .../opentelemetry-instrumentation-net/src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts index 678d5b0a4a..457e11feff 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, diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts index c81eea59c7..a2720a9c4a 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( From 6df5320f8ccca205a9e84b87e51dbfc210410df0 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Sun, 21 Apr 2024 17:07:20 +0300 Subject: [PATCH 5/7] fix: remove more patch and unpatch diag prints --- .../instrumentation-mongoose/src/mongoose.ts | 1 - .../src/instrumentation.ts | 3 --- .../src/instrumentation.ts | 2 -- .../src/instrumentation.ts | 20 ++++++------------- .../src/instrumentation.ts | 2 -- .../src/instrumentation.ts | 4 +--- .../src/instrumentation.ts | 11 ++-------- .../src/instrumentation.ts | 3 +-- 8 files changed, 10 insertions(+), 36 deletions(-) diff --git a/plugins/node/instrumentation-mongoose/src/mongoose.ts b/plugins/node/instrumentation-mongoose/src/mongoose.ts index 77c8dbee0d..cf041368c2 100644 --- a/plugins/node/instrumentation-mongoose/src/mongoose.ts +++ b/plugins/node/instrumentation-mongoose/src/mongoose.ts @@ -128,7 +128,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/opentelemetry-instrumentation-hapi/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts index 9644497626..a05322bd6d 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 => { 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 => { - api.diag.debug('Unpatching Hapi'); this._massUnwrap([moduleExports], ['server', 'Server']); } ); diff --git a/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts index 69a14157cc..03af2a9372 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-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index 306d113222..4a97129984 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -193,9 +193,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'); @@ -208,7 +207,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4SessionsPatches() { return { - v4PatchSessions: (moduleExports: any, moduleVersion?: string) => { + v4PatchSessions: (moduleExports: any) => { if (isWrapped(moduleExports.acquire)) { this._unwrap(moduleExports, 'acquire'); } @@ -228,8 +227,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'); @@ -292,7 +290,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4ConnectionPoolPatches() { return { - v4PatchConnectionPool: (moduleExports: any, moduleVersion?: string) => { + v4PatchConnectionPool: (moduleExports: any) => { const poolPrototype = moduleExports.ConnectionPool.prototype; if (isWrapped(poolPrototype.checkOut)) { @@ -306,11 +304,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'); @@ -329,7 +323,6 @@ export class MongoDBInstrumentation extends InstrumentationBase { return moduleExports; }, v4UnpatchConnect: (moduleExports?: T, moduleVersion?: string) => { - diag.debug(`Removing internal patch for mongodb@${moduleVersion}`); if (moduleExports === undefined) return; this._unwrap(moduleExports, 'connect'); @@ -430,9 +423,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 8ef20b9e2b..b9063b7ec2 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts @@ -85,8 +85,6 @@ export class MySQLInstrumentation extends InstrumentationBase< 'mysql', ['2.*'], (moduleExports, moduleVersion) => { - diag.debug(`Patching mysql@${moduleVersion}`); - 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 ea792f8025..77d097d3c6 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts @@ -52,9 +52,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-redis-4/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts index f65d808686..2028f57af0 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts @@ -222,17 +222,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 819daa3398..8618abb9f8 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( From fce0e1686fcfccfcdb6d4cc72ff10441d741257e Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Sun, 21 Apr 2024 17:18:54 +0300 Subject: [PATCH 6/7] fix: remove unused moduleVersion argument --- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 6 +++--- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 16 +++++----------- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 6 +++--- 13 files changed, 26 insertions(+), 32 deletions(-) diff --git a/plugins/node/instrumentation-cucumber/src/instrumentation.ts b/plugins/node/instrumentation-cucumber/src/instrumentation.ts index 2fa4b670de..4840814a99 100644 --- a/plugins/node/instrumentation-cucumber/src/instrumentation.ts +++ b/plugins/node/instrumentation-cucumber/src/instrumentation.ts @@ -81,7 +81,7 @@ export class CucumberInstrumentation extends InstrumentationBase { }>( '@cucumber/cucumber/lib/runtime/test_case_runner.js', ['^8.0.0', '^9.0.0', '^10.0.0'], - (moduleExports, moduleVersion) => { + moduleExports => { if (isWrapped(moduleExports.default.prototype.run)) { this._unwrap(moduleExports.default.prototype, 'run'); this._unwrap(moduleExports.default.prototype, 'runStep'); @@ -108,7 +108,7 @@ export class CucumberInstrumentation extends InstrumentationBase { } return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (moduleExports === undefined) return; this._unwrap(moduleExports.default.prototype, 'run'); this._unwrap(moduleExports.default.prototype, 'runStep'); diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts index beda4e0f45..52cb65d5ad 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts @@ -48,7 +48,7 @@ export class BunyanInstrumentation extends InstrumentationBase< new InstrumentationNodeModuleDefinition( 'bunyan', ['<2.0'], - (module: any, 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 bd4eb132ae..68f8975ece 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -51,7 +51,7 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleDefinition( 'cassandra-driver', supportedVersions, - (driverModule, moduleVersion) => { + driverModule => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const Client = driverModule.Client.prototype as any; @@ -73,7 +73,7 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return driverModule; }, - (driverModule, 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-express/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts index 71b6da162b..438ae40ed2 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts @@ -73,7 +73,7 @@ export class ExpressInstrumentation extends InstrumentationBase< new InstrumentationNodeModuleDefinition( 'express', ['^4.0.0'], - (moduleExports, moduleVersion) => { + moduleExports => { const routerProto = moduleExports.Router as unknown as express.Router; // patch express.Router.route if (isWrapped(routerProto.route)) { @@ -98,7 +98,7 @@ export class ExpressInstrumentation extends InstrumentationBase< ); return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (moduleExports === undefined) return; const routerProto = moduleExports.Router as unknown as express.Router; this._unwrap(routerProto, 'route'); diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index 15e7d79e6c..78f5a6e3d1 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -68,7 +68,7 @@ export class FastifyInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'fastify', ['^3.0.0', '^4.0.0'], - (moduleExports, 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 3308783b39..578aa8b195 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts @@ -41,7 +41,7 @@ export default class Instrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( MODULE_NAME, ['>=3'], - (moduleExports, moduleVersion) => { + moduleExports => { const Pool: any = moduleExports.Pool; if (isWrapped(Pool.prototype.acquire)) { this._unwrap(Pool.prototype, 'acquire'); @@ -62,7 +62,7 @@ export default class Instrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( MODULE_NAME, ['^2.4'], - (moduleExports, moduleVersion) => { + moduleExports => { const Pool: any = moduleExports.Pool; if (isWrapped(Pool.prototype.acquire)) { this._unwrap(Pool.prototype, 'acquire'); @@ -83,7 +83,7 @@ export default class Instrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( MODULE_NAME, ['2 - 2.3'], - (moduleExports, moduleVersion) => { + moduleExports => { this._isDisabled = false; if (isWrapped(moduleExports.Pool)) { this._unwrap(moduleExports, 'Pool'); diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index 0d36c8eb83..d549d67ee9 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -128,7 +128,7 @@ export class GraphQLInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleFile( 'graphql/language/parser.js', supportedVersions, - (moduleExports, moduleVersion) => { + moduleExports => { if (isWrapped(moduleExports.parse)) { this._unwrap(moduleExports, 'parse'); } diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index 4a97129984..98fa9d2c5f 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -148,7 +148,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV3ConnectionPatches() { return { - v3PatchConnection: (moduleExports: T, moduleVersion?: string) => { + v3PatchConnection: (moduleExports: T) => { // patch insert operation if (isWrapped(moduleExports.insert)) { this._unwrap(moduleExports, 'insert'); @@ -314,7 +314,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _getV4ConnectPatches() { return { - v4PatchConnect: (moduleExports: any, moduleVersion?: string) => { + v4PatchConnect: (moduleExports: any) => { if (isWrapped(moduleExports.connect)) { this._unwrap(moduleExports, 'connect'); } @@ -322,7 +322,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { this._wrap(moduleExports, 'connect', this._getV4ConnectCommand()); return moduleExports; }, - v4UnpatchConnect: (moduleExports?: T, moduleVersion?: string) => { + v4UnpatchConnect: (moduleExports?: T) => { if (moduleExports === undefined) return; this._unwrap(moduleExports, 'connect'); @@ -391,10 +391,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { // eslint-disable-next-line @typescript-eslint/no-unused-vars private _getV4ConnectionPatches() { return { - v4PatchConnectionCallback: ( - moduleExports: any, - moduleVersion?: string - ) => { + v4PatchConnectionCallback: (moduleExports: any) => { // patch insert operation if (isWrapped(moduleExports.Connection.prototype.command)) { this._unwrap(moduleExports.Connection.prototype, 'command'); @@ -407,10 +404,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { ); return moduleExports; }, - v4PatchConnectionPromise: ( - moduleExports: any, - moduleVersion?: string - ) => { + v4PatchConnectionPromise: (moduleExports: any) => { // patch insert operation if (isWrapped(moduleExports.Connection.prototype.command)) { 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 b9063b7ec2..87f38fc337 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts @@ -84,7 +84,7 @@ export class MySQLInstrumentation extends InstrumentationBase< new InstrumentationNodeModuleDefinition( 'mysql', ['2.*'], - (moduleExports, moduleVersion) => { + moduleExports => { diag.debug('Patching mysql.createConnection'); if (isWrapped(moduleExports.createConnection)) { this._unwrap(moduleExports, 'createConnection'); diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts index f136b9a1cf..e02a753f1e 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -82,7 +82,7 @@ export class PgInstrumentation extends InstrumentationBase { return module; }, - (module: any, moduleVersion) => { + (module: any) => { const moduleExports: typeof pgTypes = module[Symbol.toStringTag] === 'Module' ? module.default // ESM @@ -109,7 +109,7 @@ export class PgInstrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports, moduleVersion) => { + moduleExports => { if (isWrapped(moduleExports.prototype.connect)) { this._unwrap(moduleExports.prototype, 'connect'); } diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts index 8618abb9f8..4817488bee 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts @@ -48,7 +48,7 @@ export class RedisInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleDefinition( 'redis', ['^2.6.0', '^3.0.0'], - (moduleExports) => { + moduleExports => { diag.debug('Patching redis.RedisClient.internal_send_command'); if ( isWrapped( diff --git a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts index 2cd37fa80f..c14953bbb6 100644 --- a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts @@ -59,7 +59,7 @@ export default class RouterInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'router/lib/layer.js', constants.SUPPORTED_VERSIONS, - (moduleExports, moduleVersion) => { + moduleExports => { const Layer: any = moduleExports; if (isWrapped(Layer.prototype.handle_request)) { this._unwrap(Layer.prototype, 'handle_request'); @@ -79,7 +79,7 @@ export default class RouterInstrumentation extends InstrumentationBase { ); return moduleExports; }, - (moduleExports, 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 1fdffb42a9..3ef6527a88 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -51,7 +51,7 @@ export class WinstonInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'winston/lib/winston/logger.js', winston3Versions, - (logger, moduleVersion) => { + logger => { if (isWrapped(logger.prototype['write'])) { this._unwrap(logger.prototype, 'write'); } @@ -69,7 +69,7 @@ export class WinstonInstrumentation extends InstrumentationBase { return logger; }, - (logger, moduleVersion) => { + logger => { if (logger === undefined) return; this._unwrap(logger.prototype, 'write'); this._unwrap(logger.prototype, 'configure'); @@ -88,7 +88,7 @@ export class WinstonInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'winston/lib/winston/logger.js', winstonPre3Versions, - (fileExports, moduleVersion) => { + fileExports => { const proto = fileExports.Logger.prototype; if (isWrapped(proto.log)) { From 9d8f67b8b16272ee1523de113a9f8f41cfb7f73d Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Thu, 25 Apr 2024 12:18:26 +0300 Subject: [PATCH 7/7] fix: unused import from merge --- .../opentelemetry-instrumentation-mongodb/src/instrumentation.ts | 1 - .../opentelemetry-instrumentation-redis-4/src/instrumentation.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index ee7796ea6f..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, diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts index a4de15a44a..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,