diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts index a673a364bd..0a3a8102a7 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts @@ -14,13 +14,7 @@ * limitations under the License. */ -import { - context, - diag, - trace, - isSpanContextValid, - Span, -} from '@opentelemetry/api'; +import { context, trace, isSpanContextValid, Span } from '@opentelemetry/api'; import { InstrumentationBase, InstrumentationNodeModuleDefinition, @@ -43,7 +37,8 @@ export class BunyanInstrumentation extends InstrumentationBase< new InstrumentationNodeModuleDefinition( 'bunyan', ['<2.0'], - logger => { + (logger, moduleVersion) => { + this._diag.debug(`Applying patch for bunyan@${moduleVersion}`); // eslint-disable-next-line @typescript-eslint/no-explicit-any const proto = logger.prototype as any; if (isWrapped(proto['_emit'])) { @@ -58,8 +53,9 @@ export class BunyanInstrumentation extends InstrumentationBase< ); return logger; }, - logger => { + (logger, moduleVersion) => { if (logger === undefined) return; + this._diag.debug(`Removing patch for bunyan@${moduleVersion}`); // eslint-disable-next-line @typescript-eslint/no-explicit-any this._unwrap(logger.prototype as any, '_emit'); } @@ -114,7 +110,7 @@ export class BunyanInstrumentation extends InstrumentationBase< () => hook(span, record), err => { if (err) { - diag.error('bunyan instrumentation: error calling logHook', err); + this._diag.error('error calling logHook', err); } }, true diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts index 68f8975ece..fe2f9718e5 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -51,7 +51,10 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleDefinition( 'cassandra-driver', supportedVersions, - driverModule => { + (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; @@ -73,7 +76,10 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { return driverModule; }, - 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-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index 5872fb8df6..217744e3da 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -102,7 +102,8 @@ 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) => { + (moduleExports: any, moduleVersion) => { + this._diag.debug(`Applying patch for graphql@${moduleVersion} execute`); if (isWrapped(moduleExports.execute)) { this._unwrap(moduleExports, 'execute'); } @@ -113,8 +114,11 @@ export class GraphQLInstrumentation extends InstrumentationBase { ); return moduleExports; }, - moduleExports => { + (moduleExports, moduleVersion) => { if (moduleExports) { + this._diag.debug( + `Removing patch for graphql@${moduleVersion} execute` + ); this._unwrap(moduleExports, 'execute'); } } @@ -127,15 +131,17 @@ export class GraphQLInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleFile( 'graphql/language/parser.js', supportedVersions, - moduleExports => { - if (isWrapped(moduleExports.execute)) { + (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 => { + (moduleExports, moduleVersion) => { if (moduleExports) { + this._diag.debug(`Removing patch for graphql@${moduleVersion} parse`); this._unwrap(moduleExports, 'parse'); } } @@ -148,15 +154,21 @@ export class GraphQLInstrumentation extends InstrumentationBase { return new InstrumentationNodeModuleFile( 'graphql/validation/validate.js', supportedVersions, - moduleExports => { - if (isWrapped(moduleExports.execute)) { + (moduleExports, moduleVersion) => { + this._diag.debug( + `Applying patch for graphql@${moduleVersion} validate` + ); + if (isWrapped(moduleExports.validate)) { this._unwrap(moduleExports, 'validate'); } this._wrap(moduleExports, 'validate', this._patchValidate()); return moduleExports; }, - moduleExports => { + (moduleExports, moduleVersion) => { if (moduleExports) { + this._diag.debug( + `Removing patch for graphql@${moduleVersion} validate` + ); this._unwrap(moduleExports, 'validate'); } } @@ -285,7 +297,7 @@ export class GraphQLInstrumentation extends InstrumentationBase { }, err => { if (err) { - api.diag.error('Error running response hook', err); + this._diag.error('Error running response hook', err); } endSpan(span, undefined); diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts index 8d7914c51b..1fa8f58d3d 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -22,7 +22,6 @@ import { import { context, - diag, trace, Span, SpanStatusCode, @@ -66,7 +65,8 @@ export class PgInstrumentation extends InstrumentationBase { const modulePG = new InstrumentationNodeModuleDefinition( 'pg', ['8.*'], - (module: any) => { + (module: any, moduleVersion) => { + this._diag.debug(`Applying patch for pg@${moduleVersion}`); const moduleExports: typeof pgTypes = module[Symbol.toStringTag] === 'Module' ? module.default // ESM @@ -93,11 +93,12 @@ export class PgInstrumentation extends InstrumentationBase { return module; }, - (module: any) => { + (module: any, moduleVersion) => { 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'); } @@ -109,7 +110,8 @@ export class PgInstrumentation extends InstrumentationBase { >( 'pg-pool', ['2.*', '3.*'], - moduleExports => { + (moduleExports, moduleVersion) => { + this._diag.debug(`Applying patch for pg-pool@${moduleVersion}`); if (isWrapped(moduleExports.prototype.connect)) { this._unwrap(moduleExports.prototype, 'connect'); } @@ -120,7 +122,8 @@ export class PgInstrumentation extends InstrumentationBase { ); return moduleExports; }, - moduleExports => { + (moduleExports, moduleVersion) => { + this._diag.debug(`Removing patch for pg-pool@${moduleVersion}`); if (isWrapped(moduleExports.prototype.connect)) { this._unwrap(moduleExports.prototype, 'connect'); } @@ -180,7 +183,7 @@ export class PgInstrumentation extends InstrumentationBase { private _getClientQueryPatch() { const plugin = this; return (original: typeof pgTypes.Client.prototype.query) => { - diag.debug( + this._diag.debug( `Patching ${PgInstrumentation.COMPONENT}.Client.prototype.query` ); return function query(this: PgClientExtended, ...args: unknown[]) { diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts index 3db88c7921..6b4c8dbaa8 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -16,7 +16,6 @@ import { context, - diag, trace, isSpanContextValid, Span, @@ -57,7 +56,8 @@ export class WinstonInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'winston/lib/winston/logger.js', winston3Versions, - logger => { + (logger, moduleVersion) => { + this._diag.debug(`Applying patch for winston@${moduleVersion}`); if (isWrapped(logger.prototype['write'])) { this._unwrap(logger.prototype, 'write'); } @@ -65,8 +65,9 @@ export class WinstonInstrumentation extends InstrumentationBase { this._wrap(logger.prototype, 'write', this._getPatchedWrite()); return logger; }, - logger => { + (logger, moduleVersion) => { if (logger === undefined) return; + this._diag.debug(`Removing patch for winston@${moduleVersion}`); this._unwrap(logger.prototype, 'write'); } ), @@ -81,7 +82,8 @@ export class WinstonInstrumentation extends InstrumentationBase { new InstrumentationNodeModuleFile( 'winston/lib/winston/logger.js', winstonPre3Versions, - fileExports => { + (fileExports, moduleVersion) => { + this._diag.debug(`Applying patch for winston@${moduleVersion}`); const proto = fileExports.Logger.prototype; if (isWrapped(proto.log)) { @@ -92,8 +94,9 @@ export class WinstonInstrumentation extends InstrumentationBase { return fileExports; }, - fileExports => { + (fileExports, moduleVersion) => { if (fileExports === undefined) return; + this._diag.debug(`Removing patch for winston@${moduleVersion}`); this._unwrap(fileExports.Logger.prototype, 'log'); } ), @@ -121,7 +124,7 @@ export class WinstonInstrumentation extends InstrumentationBase { () => hook(span, record), err => { if (err) { - diag.error('winston instrumentation: error calling logHook', err); + this._diag.error('error calling logHook', err); } }, true