From 2ade5ae8da68c3b2e6d0d971ea6bd994d97d872b Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Thu, 2 May 2024 08:18:52 +0300 Subject: [PATCH] chore: align config constructor pattern across instrumentations (#2162) * chore: align config constructor pattern across instrumentations * fix: unused import * revert: remove diag patch message * fix: align config pattern for mongoose and koa * fix: apply common config handling in setConfig --- plugins/node/instrumentation-amqplib/src/amqplib.ts | 2 +- .../node/instrumentation-dataloader/src/instrumentation.ts | 2 +- plugins/node/instrumentation-fs/src/instrumentation.ts | 2 +- .../instrumentation-lru-memoizer/src/instrumentation.ts | 2 +- plugins/node/instrumentation-mongoose/src/mongoose.ts | 6 +----- plugins/node/instrumentation-tedious/src/instrumentation.ts | 2 +- plugins/node/instrumentation-undici/src/undici.ts | 4 ++-- .../src/instrumentation.ts | 6 ++++-- .../opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts | 6 +----- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 6 +----- .../src/instrumentation.ts | 6 ++++-- .../src/instrumentation.ts | 6 +----- .../src/instrumentation.ts | 6 +----- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 5 +---- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 6 ++++-- .../src/instrumentation.ts | 6 +----- .../src/instrumentation.ts | 6 ++++-- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 4 ++-- .../opentelemetry-instrumentation-pg/src/instrumentation.ts | 6 +----- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 6 ++++-- .../src/instrumentation.ts | 6 ++++-- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 +- .../src/instrumentation.ts | 2 +- 32 files changed, 52 insertions(+), 71 deletions(-) diff --git a/plugins/node/instrumentation-amqplib/src/amqplib.ts b/plugins/node/instrumentation-amqplib/src/amqplib.ts index 16224096fc..c81e2b51a3 100644 --- a/plugins/node/instrumentation-amqplib/src/amqplib.ts +++ b/plugins/node/instrumentation-amqplib/src/amqplib.ts @@ -77,7 +77,7 @@ import { VERSION } from './version'; export class AmqplibInstrumentation extends InstrumentationBase { protected override _config!: AmqplibInstrumentationConfig; - constructor(config?: AmqplibInstrumentationConfig) { + constructor(config: AmqplibInstrumentationConfig = {}) { super( '@opentelemetry/instrumentation-amqplib', VERSION, diff --git a/plugins/node/instrumentation-dataloader/src/instrumentation.ts b/plugins/node/instrumentation-dataloader/src/instrumentation.ts index 55d53ece64..adabc3c36d 100644 --- a/plugins/node/instrumentation-dataloader/src/instrumentation.ts +++ b/plugins/node/instrumentation-dataloader/src/instrumentation.ts @@ -76,7 +76,7 @@ export class DataloaderInstrumentation extends InstrumentationBase { return this._config; } - override setConfig(config: DataloaderInstrumentationConfig) { + override setConfig(config: DataloaderInstrumentationConfig = {}) { this._config = config; } diff --git a/plugins/node/instrumentation-fs/src/instrumentation.ts b/plugins/node/instrumentation-fs/src/instrumentation.ts index d3fea1c952..08490f496b 100644 --- a/plugins/node/instrumentation-fs/src/instrumentation.ts +++ b/plugins/node/instrumentation-fs/src/instrumentation.ts @@ -52,7 +52,7 @@ function patchedFunctionWithOriginalProperties< } export default class FsInstrumentation extends InstrumentationBase { - constructor(config?: FsInstrumentationConfig) { + constructor(config: FsInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-fs', VERSION, config); } diff --git a/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts b/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts index d11e803973..09112043d2 100644 --- a/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts +++ b/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts @@ -23,7 +23,7 @@ import { import { VERSION } from './version'; export default class LruMemoizerInstrumentation extends InstrumentationBase { - constructor(config?: InstrumentationConfig) { + constructor(config: InstrumentationConfig = {}) { super('@opentelemetry/instrumentation-lru-memoizer', VERSION, config); } diff --git a/plugins/node/instrumentation-mongoose/src/mongoose.ts b/plugins/node/instrumentation-mongoose/src/mongoose.ts index 3de0ea33ee..33aa3bf380 100644 --- a/plugins/node/instrumentation-mongoose/src/mongoose.ts +++ b/plugins/node/instrumentation-mongoose/src/mongoose.ts @@ -61,11 +61,7 @@ export class MongooseInstrumentation extends InstrumentationBase { protected override _config!: MongooseInstrumentationConfig; constructor(config: MongooseInstrumentationConfig = {}) { - super( - '@opentelemetry/instrumentation-mongoose', - VERSION, - Object.assign({}, config) - ); + super('@opentelemetry/instrumentation-mongoose', VERSION, config); } override setConfig(config: MongooseInstrumentationConfig = {}) { diff --git a/plugins/node/instrumentation-tedious/src/instrumentation.ts b/plugins/node/instrumentation-tedious/src/instrumentation.ts index 24935a32c3..ba63ce1eae 100644 --- a/plugins/node/instrumentation-tedious/src/instrumentation.ts +++ b/plugins/node/instrumentation-tedious/src/instrumentation.ts @@ -70,7 +70,7 @@ function setDatabase(this: ApproxConnection, databaseName: string) { export class TediousInstrumentation extends InstrumentationBase { static readonly COMPONENT = 'tedious'; - constructor(config?: TediousInstrumentationConfig) { + constructor(config: TediousInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-tedious', VERSION, config); } diff --git a/plugins/node/instrumentation-undici/src/undici.ts b/plugins/node/instrumentation-undici/src/undici.ts index 0fa07f97a3..ececad63c7 100644 --- a/plugins/node/instrumentation-undici/src/undici.ts +++ b/plugins/node/instrumentation-undici/src/undici.ts @@ -66,7 +66,7 @@ export class UndiciInstrumentation extends InstrumentationBase { private _recordFromReq = new WeakMap(); private _httpClientDurationHistogram!: Histogram; - constructor(config?: UndiciInstrumentationConfig) { + constructor(config: UndiciInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-undici', VERSION, config); this.setConfig(config); } @@ -111,7 +111,7 @@ export class UndiciInstrumentation extends InstrumentationBase { this.subscribeToChannel('undici:request:error', this.onError.bind(this)); } - override setConfig(config?: UndiciInstrumentationConfig): void { + override setConfig(config: UndiciInstrumentationConfig = {}): void { super.setConfig(config); if (config?.enabled) { diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts index 0b88aeec75..6d475f91dc 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts @@ -77,8 +77,10 @@ export class AwsLambdaInstrumentation extends InstrumentationBase { private _traceForceFlusher?: () => Promise; private _metricForceFlusher?: () => Promise; - constructor(protected override _config: AwsLambdaInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-aws-lambda', VERSION, _config); + protected override _config!: AwsLambdaInstrumentationConfig; + + constructor(config: AwsLambdaInstrumentationConfig = {}) { + super('@opentelemetry/instrumentation-aws-lambda', VERSION, config); if (this._config.disableAwsContextPropagation == null) { if ( typeof env['OTEL_LAMBDA_DISABLE_AWS_CONTEXT_PROPAGATION'] === 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 7203010630..d20d480180 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts @@ -78,11 +78,7 @@ export class AwsInstrumentation extends InstrumentationBase { private servicesExtensions: ServicesExtensions = new ServicesExtensions(); constructor(config: AwsSdkInstrumentationConfig = {}) { - super( - '@opentelemetry/instrumentation-aws-sdk', - VERSION, - Object.assign({}, config) - ); + super('@opentelemetry/instrumentation-aws-sdk', VERSION, config); } override setConfig(config: AwsSdkInstrumentationConfig = {}) { diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts index 571cbc992e..0f218787ea 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts @@ -103,7 +103,7 @@ export class BunyanInstrumentation extends InstrumentationBase { return this._config; } - override setConfig(config: BunyanInstrumentationConfig) { + override setConfig(config: BunyanInstrumentationConfig = {}) { this._config = Object.assign({}, DEFAULT_CONFIG, config); } diff --git a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts index f1d13bb575..63264490bc 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts @@ -43,11 +43,7 @@ export const ANONYMOUS_NAME = 'anonymous'; /** Connect instrumentation for OpenTelemetry */ export class ConnectInstrumentation extends InstrumentationBase { constructor(config: InstrumentationConfig = {}) { - super( - '@opentelemetry/instrumentation-connect', - VERSION, - Object.assign({}, config) - ); + super('@opentelemetry/instrumentation-connect', VERSION, config); } init() { diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts index 37ad2822fb..f408f7f17b 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts @@ -37,8 +37,10 @@ import { * Dns instrumentation for Opentelemetry */ export class DnsInstrumentation extends InstrumentationBase { - constructor(protected override _config: DnsInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-dns', VERSION, _config); + protected override _config!: DnsInstrumentationConfig; + + constructor(config: DnsInstrumentationConfig = {}) { + super('@opentelemetry/instrumentation-dns', VERSION, config); } init(): ( diff --git a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts index b20121b304..45a07f7446 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts @@ -51,11 +51,7 @@ import { /** Express instrumentation for OpenTelemetry */ export class ExpressInstrumentation extends InstrumentationBase { constructor(config: ExpressInstrumentationConfig = {}) { - super( - '@opentelemetry/instrumentation-express', - VERSION, - Object.assign({}, config) - ); + super('@opentelemetry/instrumentation-express', VERSION, config); } override setConfig(config: ExpressInstrumentationConfig = {}) { diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index aebf1bf721..914b608fd8 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -48,11 +48,7 @@ export const ANONYMOUS_NAME = 'anonymous'; /** Fastify instrumentation for OpenTelemetry */ export class FastifyInstrumentation extends InstrumentationBase { constructor(config: FastifyInstrumentationConfig = {}) { - super( - '@opentelemetry/instrumentation-fastify', - VERSION, - Object.assign({}, config) - ); + super('@opentelemetry/instrumentation-fastify', VERSION, config); } override setConfig(config: FastifyInstrumentationConfig = {}) { diff --git a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts index 29f3671688..adefe5a7be 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts @@ -33,7 +33,7 @@ export default class Instrumentation extends InstrumentationBase { private _isDisabled = false; constructor(config: InstrumentationConfig = {}) { - super(`@opentelemetry/instrumentation-${MODULE_NAME}`, VERSION); + super(`@opentelemetry/instrumentation-${MODULE_NAME}`, VERSION, config); } init() { diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index ddae6e3ddb..32fc2f4507 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -18,7 +18,6 @@ import { context, trace } from '@opentelemetry/api'; import { isWrapped, InstrumentationBase, - InstrumentationConfig, InstrumentationNodeModuleDefinition, InstrumentationNodeModuleFile, safeExecuteInTheMiddle, @@ -65,9 +64,7 @@ const DEFAULT_CONFIG: GraphQLInstrumentationConfig = { const supportedVersions = ['>=14 <17']; export class GraphQLInstrumentation extends InstrumentationBase { - constructor( - config: GraphQLInstrumentationConfig & InstrumentationConfig = {} - ) { + constructor(config: GraphQLInstrumentationConfig = {}) { super( '@opentelemetry/instrumentation-graphql', VERSION, diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts index 2b1988aa69..af550b137c 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts @@ -49,7 +49,7 @@ import { /** Hapi instrumentation for OpenTelemetry */ export class HapiInstrumentation extends InstrumentationBase { - constructor(config?: InstrumentationConfig) { + constructor(config: InstrumentationConfig = {}) { super('@opentelemetry/instrumentation-hapi', VERSION, config); } diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts index 26b671ab1f..00e3257ed4 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts @@ -36,11 +36,13 @@ const DEFAULT_CONFIG: IORedisInstrumentationConfig = { }; export class IORedisInstrumentation extends InstrumentationBase { - constructor(_config: IORedisInstrumentationConfig = {}) { + protected override _config!: IORedisInstrumentationConfig; + + constructor(config: IORedisInstrumentationConfig = {}) { super( '@opentelemetry/instrumentation-ioredis', VERSION, - Object.assign({}, DEFAULT_CONFIG, _config) + Object.assign({}, DEFAULT_CONFIG, config) ); } diff --git a/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts index 742e500122..ab6c2927be 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts @@ -36,11 +36,7 @@ import { /** Koa instrumentation for OpenTelemetry */ export class KoaInstrumentation extends InstrumentationBase { constructor(config: KoaInstrumentationConfig = {}) { - super( - '@opentelemetry/instrumentation-koa', - VERSION, - Object.assign({}, config) - ); + super('@opentelemetry/instrumentation-koa', VERSION, config); } override setConfig(config: KoaInstrumentationConfig = {}) { diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index f7c9e99d3a..7f9fa8e9c3 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -58,8 +58,10 @@ export class MongoDBInstrumentation extends InstrumentationBase { private _connectionsUsage!: UpDownCounter; private _poolName!: string; - constructor(protected override _config: MongoDBInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-mongodb', VERSION, _config); + protected override _config!: MongoDBInstrumentationConfig; + + constructor(config: MongoDBInstrumentationConfig = {}) { + super('@opentelemetry/instrumentation-mongodb', VERSION, config); } override _updateMetricInstruments() { diff --git a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts index 2e4ba8675e..f4de0bc36a 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts @@ -57,7 +57,7 @@ export class MySQLInstrumentation extends InstrumentationBase { }; private _connectionsUsage!: UpDownCounter; - constructor(config?: MySQLInstrumentationConfig) { + constructor(config: MySQLInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-mysql', VERSION, config); this._setMetricInstruments(); } diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts index e693488de0..18cb1681e0 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts @@ -44,7 +44,7 @@ export class MySQL2Instrumentation extends InstrumentationBase { [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MYSQL, }; - constructor(config?: MySQL2InstrumentationConfig) { + constructor(config: MySQL2InstrumentationConfig = {}) { super('@opentelemetry/instrumentation-mysql2', VERSION, config); } diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts index c480f3a546..29b86aadba 100644 --- a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts @@ -36,7 +36,7 @@ export class Instrumentation extends InstrumentationBase { }; constructor(config: InstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-nestjs-core', VERSION); + super('@opentelemetry/instrumentation-nestjs-core', VERSION, config); } init() { diff --git a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts index 49611da87c..b832473ef4 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts @@ -35,8 +35,8 @@ import { TLSSocket } from 'tls'; import type * as net from 'net'; export class NetInstrumentation extends InstrumentationBase { - constructor(_config?: InstrumentationConfig) { - super('@opentelemetry/instrumentation-net', VERSION, _config); + constructor(config: InstrumentationConfig = {}) { + super('@opentelemetry/instrumentation-net', VERSION, config); } init(): InstrumentationNodeModuleDefinition[] { diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts index d8043af302..38ccad0fe4 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -44,11 +44,7 @@ import { SpanNames } from './enums/SpanNames'; export class PgInstrumentation extends InstrumentationBase { constructor(config: PgInstrumentationConfig = {}) { - super( - '@opentelemetry/instrumentation-pg', - VERSION, - Object.assign({}, config) - ); + super('@opentelemetry/instrumentation-pg', VERSION, config); } protected init() { diff --git a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts index d5821a2f6f..96a0796cc5 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts @@ -97,7 +97,7 @@ export class PinoInstrumentation extends InstrumentationBase { return this._config; } - override setConfig(config: PinoInstrumentationConfig) { + override setConfig(config: PinoInstrumentationConfig = {}) { this._config = config; } diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts index a431fd76ca..75ae380965 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts @@ -54,8 +54,10 @@ const DEFAULT_CONFIG: RedisInstrumentationConfig = { export class RedisInstrumentation extends InstrumentationBase { static readonly COMPONENT = 'redis'; - constructor(protected override _config: RedisInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-redis-4', VERSION, _config); + protected override _config!: RedisInstrumentationConfig; + + constructor(config: RedisInstrumentationConfig = {}) { + super('@opentelemetry/instrumentation-redis-4', VERSION, config); } override setConfig(config: RedisInstrumentationConfig = {}) { diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts index 09ee03e6ad..85bb908c07 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts @@ -35,8 +35,10 @@ const DEFAULT_CONFIG: RedisInstrumentationConfig = { export class RedisInstrumentation extends InstrumentationBase { static readonly COMPONENT = 'redis'; - constructor(protected override _config: RedisInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-redis', VERSION, _config); + protected override _config!: RedisInstrumentationConfig; + + constructor(config: RedisInstrumentationConfig = {}) { + super('@opentelemetry/instrumentation-redis', VERSION, config); } override setConfig(config: RedisInstrumentationConfig = {}) { diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts index 73b8b8f5e7..a00c24ba98 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts @@ -40,7 +40,7 @@ export class RestifyInstrumentation extends InstrumentationBase { super( `@opentelemetry/instrumentation-${constants.MODULE_NAME}`, VERSION, - Object.assign({}, config) + config ); } diff --git a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts index 02e01d287e..fb02262e30 100644 --- a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts @@ -35,7 +35,7 @@ import AttributeNames from './enums/AttributeNames'; import LayerType from './enums/LayerType'; export default class RouterInstrumentation extends InstrumentationBase { - constructor(config?: InstrumentationConfig) { + constructor(config: InstrumentationConfig = {}) { super( `@opentelemetry/instrumentation-${constants.MODULE_NAME}`, VERSION, diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts index 2e75400741..4d4b1cfcc5 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -116,7 +116,7 @@ export class WinstonInstrumentation extends InstrumentationBase { return this._config; } - override setConfig(config: WinstonInstrumentationConfig) { + override setConfig(config: WinstonInstrumentationConfig = {}) { this._config = config; } diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts index bba10b2ff9..ea05bddbf1 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts @@ -67,7 +67,7 @@ export class UserInteractionInstrumentation extends InstrumentationBase { private _eventNames: Set; private _shouldPreventSpanCreation: ShouldPreventSpanCreation; - constructor(config?: UserInteractionInstrumentationConfig) { + constructor(config: UserInteractionInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-user-interaction', VERSION, config); this._eventNames = new Set(config?.eventNames ?? DEFAULT_EVENT_NAMES); this._shouldPreventSpanCreation =