From 0cef9fa95d065489b7349bfa0150ff858ed59157 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Thu, 23 May 2024 10:23:25 +0300 Subject: [PATCH] refactor: use package json auto generated export also for npm package name (#2203) * refactor: rename VERSION to NPM_PACKAGE_VERSION * refactor: use auto-generated NPM_PACKAGE_NAME * fix: remove the NPM_ prefix from the auto generated names * fix: use PACKAGE_NAME in host-metrics * chore: apply also for new instrumentation kafkajs --- packages/opentelemetry-host-metrics/src/BaseMetrics.ts | 6 +++--- .../winston-transport/src/OpenTelemetryTransportV3.ts | 4 ++-- plugins/node/instrumentation-amqplib/src/amqplib.ts | 6 +++--- .../node/instrumentation-cucumber/src/instrumentation.ts | 4 ++-- .../instrumentation-dataloader/src/instrumentation.ts | 4 ++-- plugins/node/instrumentation-fs/src/instrumentation.ts | 4 ++-- .../node/instrumentation-kafkajs/src/instrumentation.ts | 4 ++-- .../instrumentation-lru-memoizer/src/instrumentation.ts | 4 ++-- plugins/node/instrumentation-mongoose/src/mongoose.ts | 4 ++-- .../instrumentation-runtime-node/src/instrumentation.ts | 6 +++--- plugins/node/instrumentation-socket.io/src/socket.io.ts | 8 ++------ .../node/instrumentation-tedious/src/instrumentation.ts | 4 ++-- plugins/node/instrumentation-undici/src/undici.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts | 4 ++-- .../src/OpenTelemetryBunyanStream.ts | 7 +++---- .../src/instrumentation.ts | 6 +++--- .../test/bunyan.test.ts | 6 +++--- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 6 +++--- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 6 +++--- .../src/instrumentation.ts | 6 +++--- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 6 +++--- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 8 ++------ .../src/instrumentation.ts | 8 ++------ .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 4 ++-- .../src/instrumentation.ts | 6 +++--- .../src/instrumentation.ts | 6 +++--- .../src/BaseOpenTelemetryComponent.ts | 8 ++++---- scripts/version-update.js | 3 ++- 47 files changed, 108 insertions(+), 120 deletions(-) diff --git a/packages/opentelemetry-host-metrics/src/BaseMetrics.ts b/packages/opentelemetry-host-metrics/src/BaseMetrics.ts index fa9453ff22..f314f79282 100644 --- a/packages/opentelemetry-host-metrics/src/BaseMetrics.ts +++ b/packages/opentelemetry-host-metrics/src/BaseMetrics.ts @@ -17,7 +17,7 @@ import * as api from '@opentelemetry/api'; import * as metrics from '@opentelemetry/sdk-metrics'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; /** * Metrics Collector Configuration @@ -33,7 +33,7 @@ export interface MetricsCollectorConfig { url?: string; } -const DEFAULT_NAME = '@opentelemetry/host-metrics'; +const DEFAULT_NAME = PACKAGE_NAME; /** * Base Class for metrics @@ -50,7 +50,7 @@ export abstract class BaseMetrics { if (!config.meterProvider) { this._logger.warn('No meter provider, using default'); } - this._meter = meterProvider.getMeter(this._name, VERSION); + this._meter = meterProvider.getMeter(this._name, PACKAGE_VERSION); } /** diff --git a/packages/winston-transport/src/OpenTelemetryTransportV3.ts b/packages/winston-transport/src/OpenTelemetryTransportV3.ts index a7e164adce..e3a93b1b57 100644 --- a/packages/winston-transport/src/OpenTelemetryTransportV3.ts +++ b/packages/winston-transport/src/OpenTelemetryTransportV3.ts @@ -16,7 +16,7 @@ import { Logger, logs } from '@opentelemetry/api-logs'; import TransportStream = require('winston-transport'); -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { emitLogRecord } from './utils'; export class OpenTelemetryTransportV3 extends TransportStream { @@ -24,7 +24,7 @@ export class OpenTelemetryTransportV3 extends TransportStream { constructor(options?: TransportStream.TransportStreamOptions) { super(options); - this._logger = logs.getLogger('@opentelemetry/winston-transport', VERSION); + this._logger = logs.getLogger(PACKAGE_NAME, PACKAGE_VERSION); } public override log(info: any, callback: () => void) { diff --git a/plugins/node/instrumentation-amqplib/src/amqplib.ts b/plugins/node/instrumentation-amqplib/src/amqplib.ts index c81e2b51a3..6cca9bfd80 100644 --- a/plugins/node/instrumentation-amqplib/src/amqplib.ts +++ b/plugins/node/instrumentation-amqplib/src/amqplib.ts @@ -72,15 +72,15 @@ import { normalizeExchange, unmarkConfirmChannelTracing, } from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; export class AmqplibInstrumentation extends InstrumentationBase { protected override _config!: AmqplibInstrumentationConfig; constructor(config: AmqplibInstrumentationConfig = {}) { super( - '@opentelemetry/instrumentation-amqplib', - VERSION, + PACKAGE_NAME, + PACKAGE_VERSION, Object.assign({}, DEFAULT_CONFIG, config) ); } diff --git a/plugins/node/instrumentation-cucumber/src/instrumentation.ts b/plugins/node/instrumentation-cucumber/src/instrumentation.ts index 255b2a297c..42962feb78 100644 --- a/plugins/node/instrumentation-cucumber/src/instrumentation.ts +++ b/plugins/node/instrumentation-cucumber/src/instrumentation.ts @@ -38,7 +38,7 @@ import type { } from '@cucumber/cucumber/lib/support_code_library_builder/types'; import { AttributeNames, CucumberInstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; const hooks = ['Before', 'BeforeStep', 'AfterStep', 'After'] as const; const steps = ['Given', 'When', 'Then'] as const; @@ -50,7 +50,7 @@ export class CucumberInstrumentation extends InstrumentationBase { private module: Cucumber | undefined; constructor(config: CucumberInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-cucumber', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init(): InstrumentationNodeModuleDefinition[] { diff --git a/plugins/node/instrumentation-dataloader/src/instrumentation.ts b/plugins/node/instrumentation-dataloader/src/instrumentation.ts index adabc3c36d..ecfa6ac9aa 100644 --- a/plugins/node/instrumentation-dataloader/src/instrumentation.ts +++ b/plugins/node/instrumentation-dataloader/src/instrumentation.ts @@ -27,7 +27,7 @@ import { SpanKind, } from '@opentelemetry/api'; import { DataloaderInstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import type * as Dataloader from 'dataloader'; const MODULE_NAME = 'dataloader'; @@ -45,7 +45,7 @@ type LoadManyFn = (typeof Dataloader.prototype)['loadMany']; export class DataloaderInstrumentation extends InstrumentationBase { constructor(config: DataloaderInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-dataloader', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } protected init() { diff --git a/plugins/node/instrumentation-fs/src/instrumentation.ts b/plugins/node/instrumentation-fs/src/instrumentation.ts index 08490f496b..57db632a0e 100644 --- a/plugins/node/instrumentation-fs/src/instrumentation.ts +++ b/plugins/node/instrumentation-fs/src/instrumentation.ts @@ -21,7 +21,7 @@ import { InstrumentationNodeModuleDefinition, isWrapped, } from '@opentelemetry/instrumentation'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { CALLBACK_FUNCTIONS, PROMISE_FUNCTIONS, @@ -53,7 +53,7 @@ function patchedFunctionWithOriginalProperties< export default class FsInstrumentation extends InstrumentationBase { constructor(config: FsInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-fs', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init(): ( diff --git a/plugins/node/instrumentation-kafkajs/src/instrumentation.ts b/plugins/node/instrumentation-kafkajs/src/instrumentation.ts index 09762e8e6f..ed3eeeea27 100644 --- a/plugins/node/instrumentation-kafkajs/src/instrumentation.ts +++ b/plugins/node/instrumentation-kafkajs/src/instrumentation.ts @@ -44,7 +44,7 @@ import type { Consumer, } from 'kafkajs'; import { KafkaJsInstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { bufferTextMapGetter } from './propagator'; import { InstrumentationBase, @@ -57,7 +57,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase { protected override _config!: KafkaJsInstrumentationConfig; constructor(config: KafkaJsInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-kafkajs', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } protected init() { diff --git a/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts b/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts index 09112043d2..6224fe7edf 100644 --- a/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts +++ b/plugins/node/instrumentation-lru-memoizer/src/instrumentation.ts @@ -20,11 +20,11 @@ import { InstrumentationConfig, InstrumentationNodeModuleDefinition, } from '@opentelemetry/instrumentation'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; export default class LruMemoizerInstrumentation extends InstrumentationBase { constructor(config: InstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-lru-memoizer', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init(): InstrumentationNodeModuleDefinition[] { diff --git a/plugins/node/instrumentation-mongoose/src/mongoose.ts b/plugins/node/instrumentation-mongoose/src/mongoose.ts index ff76b33735..0cd136f4fa 100644 --- a/plugins/node/instrumentation-mongoose/src/mongoose.ts +++ b/plugins/node/instrumentation-mongoose/src/mongoose.ts @@ -27,7 +27,7 @@ import { InstrumentationModuleDefinition, InstrumentationNodeModuleDefinition, } from '@opentelemetry/instrumentation'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { SEMATTRS_DB_OPERATION, SEMATTRS_DB_STATEMENT, @@ -61,7 +61,7 @@ export class MongooseInstrumentation extends InstrumentationBase { protected override _config!: MongooseInstrumentationConfig; constructor(config: MongooseInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-mongoose', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } override setConfig(config: MongooseInstrumentationConfig = {}) { diff --git a/plugins/node/instrumentation-runtime-node/src/instrumentation.ts b/plugins/node/instrumentation-runtime-node/src/instrumentation.ts index c7733e2de4..ba26129590 100644 --- a/plugins/node/instrumentation-runtime-node/src/instrumentation.ts +++ b/plugins/node/instrumentation-runtime-node/src/instrumentation.ts @@ -18,7 +18,7 @@ const { eventLoopUtilization } = performance; import { InstrumentationBase } from '@opentelemetry/instrumentation'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { RuntimeNodeInstrumentationConfig } from './types'; const ELUS_LENGTH = 2; @@ -32,8 +32,8 @@ export class RuntimeNodeInstrumentation extends InstrumentationBase { constructor(config: RuntimeNodeInstrumentationConfig = {}) { super( - '@opentelemetry/instrumentation-runtime-node', - VERSION, + PACKAGE_NAME, + PACKAGE_VERSION, Object.assign({}, DEFAULT_CONFIG, config) ); } diff --git a/plugins/node/instrumentation-socket.io/src/socket.io.ts b/plugins/node/instrumentation-socket.io/src/socket.io.ts index 5ed289c65b..9f8de7b534 100644 --- a/plugins/node/instrumentation-socket.io/src/socket.io.ts +++ b/plugins/node/instrumentation-socket.io/src/socket.io.ts @@ -37,7 +37,7 @@ import { } from '@opentelemetry/semantic-conventions'; import { SocketIoInstrumentationConfig } from './types'; import { SocketIoInstrumentationAttributes } from './AttributeNames'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { extractRoomsAttributeValue, isPromise, @@ -57,11 +57,7 @@ export class SocketIoInstrumentation extends InstrumentationBase { protected override _config!: SocketIoInstrumentationConfig; constructor(config: SocketIoInstrumentationConfig = {}) { - super( - '@opentelemetry/instrumentation-socket.io', - VERSION, - normalizeConfig(config) - ); + super(PACKAGE_NAME, PACKAGE_VERSION, normalizeConfig(config)); } protected init() { diff --git a/plugins/node/instrumentation-tedious/src/instrumentation.ts b/plugins/node/instrumentation-tedious/src/instrumentation.ts index b544ac9fe9..f701451421 100644 --- a/plugins/node/instrumentation-tedious/src/instrumentation.ts +++ b/plugins/node/instrumentation-tedious/src/instrumentation.ts @@ -34,7 +34,7 @@ import { import type * as tedious from 'tedious'; import { TediousInstrumentationConfig } from './types'; import { getSpanName, once } from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; const CURRENT_DATABASE = Symbol( 'opentelemetry.instrumentation-tedious.current-database' @@ -71,7 +71,7 @@ export class TediousInstrumentation extends InstrumentationBase { static readonly COMPONENT = 'tedious'; constructor(config: TediousInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-tedious', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } protected init() { diff --git a/plugins/node/instrumentation-undici/src/undici.ts b/plugins/node/instrumentation-undici/src/undici.ts index ececad63c7..aa89c4f4ea 100644 --- a/plugins/node/instrumentation-undici/src/undici.ts +++ b/plugins/node/instrumentation-undici/src/undici.ts @@ -34,7 +34,7 @@ import { ValueType, } from '@opentelemetry/api'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { ListenerRecord, @@ -67,7 +67,7 @@ export class UndiciInstrumentation extends InstrumentationBase { private _httpClientDurationHistogram!: Histogram; constructor(config: UndiciInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-undici', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); this.setConfig(config); } diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts index 6d475f91dc..0d8eb8a5e2 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts @@ -57,7 +57,7 @@ import { } from 'aws-lambda'; import { AwsLambdaInstrumentationConfig, EventContextExtractor } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { env } from 'process'; import { LambdaModule } from './internal-types'; @@ -80,7 +80,7 @@ export class AwsLambdaInstrumentation extends InstrumentationBase { protected override _config!: AwsLambdaInstrumentationConfig; constructor(config: AwsLambdaInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-aws-lambda', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 d20d480180..cca362e293 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts @@ -33,7 +33,7 @@ import { NormalizedRequest, NormalizedResponse, } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { InstrumentationBase, InstrumentationModuleDefinition, @@ -78,7 +78,7 @@ export class AwsInstrumentation extends InstrumentationBase { private servicesExtensions: ServicesExtensions = new ServicesExtensions(); constructor(config: AwsSdkInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-aws-sdk', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } override setConfig(config: AwsSdkInstrumentationConfig = {}) { diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts index 8b3d1c8977..c82f967372 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts @@ -16,11 +16,10 @@ import { logs, SeverityNumber, Logger } from '@opentelemetry/api-logs'; import type { LogLevelString } from 'bunyan'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; -const DEFAULT_INSTRUMENTATION_SCOPE_NAME = - '@opentelemetry/instrumentation-bunyan'; -const DEFAULT_INSTRUMENTATION_SCOPE_VERSION = VERSION; +const DEFAULT_INSTRUMENTATION_SCOPE_NAME = PACKAGE_NAME; +const DEFAULT_INSTRUMENTATION_SCOPE_VERSION = PACKAGE_VERSION; // This block is a copy (modulo code style and TypeScript types) of the Bunyan // code that defines log level value and names. These values won't ever change diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts index 0f218787ea..c2eb53bb58 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/instrumentation.ts @@ -22,7 +22,7 @@ import { safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; import { BunyanInstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { OpenTelemetryBunyanStream } from './OpenTelemetryBunyanStream'; import type * as BunyanLogger from 'bunyan'; import { SeverityNumber } from '@opentelemetry/api-logs'; @@ -35,8 +35,8 @@ const DEFAULT_CONFIG: BunyanInstrumentationConfig = { export class BunyanInstrumentation extends InstrumentationBase { constructor(config: BunyanInstrumentationConfig = {}) { super( - '@opentelemetry/instrumentation-bunyan', - VERSION, + PACKAGE_NAME, + PACKAGE_VERSION, Object.assign({}, DEFAULT_CONFIG, config) ); } diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/test/bunyan.test.ts b/plugins/node/opentelemetry-instrumentation-bunyan/test/bunyan.test.ts index deaf2fb1e7..b26c290b97 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/test/bunyan.test.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/test/bunyan.test.ts @@ -33,7 +33,7 @@ import * as assert from 'assert'; import * as sinon from 'sinon'; import { Writable } from 'stream'; import { BunyanInstrumentation, OpenTelemetryBunyanStream } from '../src'; -import { VERSION } from '../src/version'; +import { PACKAGE_VERSION } from '../src/version'; import type * as BunyanLogger from 'bunyan'; @@ -219,7 +219,7 @@ describe('BunyanInstrumentation', () => { rec.instrumentationScope.name, '@opentelemetry/instrumentation-bunyan' ); - assert.strictEqual(rec.instrumentationScope.version, VERSION); + assert.strictEqual(rec.instrumentationScope.version, PACKAGE_VERSION); assert.strictEqual(rec.spanContext, undefined); // spanContext @@ -519,7 +519,7 @@ describe('OpenTelemetryBunyanStream', () => { rec.instrumentationScope.name, '@opentelemetry/instrumentation-bunyan' ); - assert.strictEqual(rec.instrumentationScope.version, VERSION); + assert.strictEqual(rec.instrumentationScope.version, PACKAGE_VERSION); assert.strictEqual(rec.spanContext, undefined); // spanContext diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts index f11ffab83e..3d90300b9c 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -39,7 +39,7 @@ import { SEMATTRS_NET_PEER_NAME, SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { EventEmitter } from 'events'; import type * as CassandraDriver from 'cassandra-driver'; @@ -49,7 +49,7 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { protected override _config!: CassandraDriverInstrumentationConfig; constructor(config: CassandraDriverInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-cassandra-driver', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } protected init() { diff --git a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts index 5b57f5f7bb..0c1fde4956 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts @@ -24,7 +24,7 @@ import { ConnectTypes, } from './enums/AttributeNames'; import { PatchedRequest, Use, UseArgs, UseArgs2 } from './internal-types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { InstrumentationBase, InstrumentationConfig, @@ -43,7 +43,7 @@ export const ANONYMOUS_NAME = 'anonymous'; /** Connect instrumentation for OpenTelemetry */ export class ConnectInstrumentation extends InstrumentationBase { constructor(config: InstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-connect', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init() { diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts index 0be1211a60..ae97438ddb 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts @@ -27,7 +27,7 @@ import { import { AddressFamily } from './enums/AddressFamily'; import { DnsInstrumentationConfig } from './types'; import * as utils from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { LookupCallbackSignature, LookupPromiseSignature, @@ -40,7 +40,7 @@ export class DnsInstrumentation extends InstrumentationBase { protected override _config!: DnsInstrumentationConfig; constructor(config: DnsInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-dns', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init(): ( diff --git a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts index 76da7ffe5f..8337a17427 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts @@ -33,7 +33,7 @@ import { isLayerIgnored, storeLayerPath, } from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { InstrumentationBase, InstrumentationNodeModuleDefinition, @@ -52,7 +52,7 @@ import { /** Express instrumentation for OpenTelemetry */ export class ExpressInstrumentation extends InstrumentationBase { constructor(config: ExpressInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-express', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 208a2e09a5..34871ee978 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -41,14 +41,14 @@ import { safeExecuteInTheMiddleMaybePromise, startSpan, } from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; export const ANONYMOUS_NAME = 'anonymous'; /** Fastify instrumentation for OpenTelemetry */ export class FastifyInstrumentation extends InstrumentationBase { constructor(config: FastifyInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-fastify', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 adefe5a7be..08b31e5eb1 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts @@ -24,7 +24,7 @@ import { import type * as genericPool from 'generic-pool'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; const MODULE_NAME = 'generic-pool'; @@ -33,7 +33,7 @@ export default class Instrumentation extends InstrumentationBase { private _isDisabled = false; constructor(config: InstrumentationConfig = {}) { - super(`@opentelemetry/instrumentation-${MODULE_NAME}`, VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init() { diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index 32fc2f4507..e6e55cf118 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -49,7 +49,7 @@ import { wrapFields, } from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import * as api from '@opentelemetry/api'; import type { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue'; import { GraphQLInstrumentationConfig } from './types'; @@ -66,8 +66,8 @@ const supportedVersions = ['>=14 <17']; export class GraphQLInstrumentation extends InstrumentationBase { constructor(config: GraphQLInstrumentationConfig = {}) { super( - '@opentelemetry/instrumentation-graphql', - VERSION, + PACKAGE_NAME, + PACKAGE_VERSION, Object.assign({}, DEFAULT_CONFIG, config) ); } diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts index 0b18fc5dfd..8fd9442974 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts @@ -24,7 +24,7 @@ import { } from '@opentelemetry/instrumentation'; import type * as Hapi from '@hapi/hapi'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { HapiComponentName, HapiServerRouteInput, @@ -50,7 +50,7 @@ import { /** Hapi instrumentation for OpenTelemetry */ export class HapiInstrumentation extends InstrumentationBase { constructor(config: InstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-hapi', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } protected init() { diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts index 34930c354b..abf9e2c5e8 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts @@ -33,7 +33,7 @@ import { import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation'; import { endSpan } from './utils'; import { defaultDbStatementSerializer } from '@opentelemetry/redis-common'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; const DEFAULT_CONFIG: IORedisInstrumentationConfig = { requireParentSpan: true, @@ -44,8 +44,8 @@ export class IORedisInstrumentation extends InstrumentationBase { constructor(config: IORedisInstrumentationConfig = {}) { super( - '@opentelemetry/instrumentation-ioredis', - VERSION, + PACKAGE_NAME, + PACKAGE_VERSION, Object.assign({}, DEFAULT_CONFIG, config) ); } diff --git a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts index 762b9d1455..c80ebbe55c 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts @@ -15,7 +15,7 @@ */ import * as api from '@opentelemetry/api'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import * as constants from './constants'; import { InstrumentationBase, @@ -45,8 +45,8 @@ const DEFAULT_CONFIG: types.KnexInstrumentationConfig = { export class KnexInstrumentation extends InstrumentationBase { constructor(config: types.KnexInstrumentationConfig = {}) { super( - `@opentelemetry/instrumentation-${constants.MODULE_NAME}`, - VERSION, + PACKAGE_NAME, + PACKAGE_VERSION, 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 ab6c2927be..0598850569 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts @@ -24,7 +24,7 @@ import { import type * as koa from 'koa'; import { KoaContext, KoaLayerType, KoaInstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { getMiddlewareMetadata, isLayerIgnored } from './utils'; import { getRPCMetadata, RPCType } from '@opentelemetry/core'; import { @@ -36,7 +36,7 @@ import { /** Koa instrumentation for OpenTelemetry */ export class KoaInstrumentation extends InstrumentationBase { constructor(config: KoaInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-koa', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } override setConfig(config: KoaInstrumentationConfig = {}) { diff --git a/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts index b72ab76896..600179254b 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts @@ -29,7 +29,7 @@ import { } from '@opentelemetry/semantic-conventions'; import * as utils from './utils'; import { InstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; export class Instrumentation extends InstrumentationBase { static readonly COMPONENT = 'memcached'; @@ -42,8 +42,8 @@ export class Instrumentation extends InstrumentationBase { constructor(config: InstrumentationConfig = {}) { super( - '@opentelemetry/instrumentation-memcached', - VERSION, + PACKAGE_NAME, + PACKAGE_VERSION, Object.assign({}, Instrumentation.DEFAULT_CONFIG, config) ); } diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index 7f9fa8e9c3..a1417a9487 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -50,7 +50,7 @@ import { V4ConnectionPool, } from './internal-types'; import { V4Connect, V4Session } from './internal-types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { UpDownCounter } from '@opentelemetry/api'; /** mongodb instrumentation plugin for OpenTelemetry */ @@ -61,7 +61,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { protected override _config!: MongoDBInstrumentationConfig; constructor(config: MongoDBInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-mongodb', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 cf43c406e6..11eab4bf93 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts @@ -42,7 +42,7 @@ import { getSpanName, getPoolName, } from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { UpDownCounter, MeterProvider } from '@opentelemetry/api'; type getConnectionCallbackType = ( @@ -57,7 +57,7 @@ export class MySQLInstrumentation extends InstrumentationBase { private _connectionsUsage!: UpDownCounter; constructor(config: MySQLInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-mysql', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 ade7fd117f..38f2ce8bd3 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/instrumentation.ts @@ -35,7 +35,7 @@ import { getSpanName, once, } from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; type formatType = typeof mysqlTypes.format; @@ -45,7 +45,7 @@ export class MySQL2Instrumentation extends InstrumentationBase { }; constructor(config: MySQL2InstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-mysql2', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } protected init() { diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts index 9f90a7c1b8..a7b2380250 100644 --- a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts @@ -25,12 +25,12 @@ import { import type { NestFactory } from '@nestjs/core/nest-factory.js'; import type { RouterExecutionContext } from '@nestjs/core/router/router-execution-context.js'; import type { Controller } from '@nestjs/common/interfaces'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_URL, } from '@opentelemetry/semantic-conventions'; -import { VERSION } from './version'; import { AttributeNames, NestType } from './enums'; export class Instrumentation extends InstrumentationBase { @@ -40,7 +40,7 @@ export class Instrumentation extends InstrumentationBase { }; constructor(config: InstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-nestjs-core', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init() { diff --git a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts index 1cac375019..567df7dee3 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts @@ -34,14 +34,14 @@ import { import { TLSAttributes } from './types'; import { NormalizedOptions, SocketEvent } from './internal-types'; import { getNormalizedArgs, IPC_TRANSPORT } from './utils'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { Socket } from 'net'; import { TLSSocket } from 'tls'; import type * as net from 'net'; export class NetInstrumentation extends InstrumentationBase { constructor(config: InstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-net', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 38ccad0fe4..c6bee00999 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -39,12 +39,12 @@ import { import { PgInstrumentationConfig } from './types'; import * as utils from './utils'; import { addSqlCommenterComment } from '@opentelemetry/sql-common'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { SpanNames } from './enums/SpanNames'; export class PgInstrumentation extends InstrumentationBase { constructor(config: PgInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-pg', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 96a0796cc5..f7dc81f034 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts @@ -27,7 +27,7 @@ import { safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; import { PinoInstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; const pinoVersions = ['>=5.14.0 <10']; @@ -39,7 +39,7 @@ const DEFAULT_LOG_KEYS = { export class PinoInstrumentation extends InstrumentationBase { constructor(config: PinoInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-pino', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } protected init() { diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts index 75ae380965..d62eceaa2c 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts @@ -30,7 +30,7 @@ import { import { getClientAttributes } from './utils'; import { defaultDbStatementSerializer } from '@opentelemetry/redis-common'; import { RedisInstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { SEMATTRS_DB_STATEMENT } from '@opentelemetry/semantic-conventions'; import type { MultiErrorReply } from './internal-types'; @@ -57,7 +57,7 @@ export class RedisInstrumentation extends InstrumentationBase { protected override _config!: RedisInstrumentationConfig; constructor(config: RedisInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-redis-4', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 8d6f2ba88d..1d627b5820 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/instrumentation.ts @@ -25,7 +25,7 @@ import { getTracedInternalSendCommand, } from './utils'; import { RedisInstrumentationConfig } from './types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; const DEFAULT_CONFIG: RedisInstrumentationConfig = { requireParentSpan: false, @@ -37,7 +37,7 @@ export class RedisInstrumentation extends InstrumentationBase { protected override _config!: RedisInstrumentationConfig; constructor(config: RedisInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-redis', VERSION, config); + super(PACKAGE_NAME, PACKAGE_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 a00c24ba98..5d4c7f39cb 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts @@ -21,7 +21,7 @@ import * as api from '@opentelemetry/api'; import type { Server } from 'restify'; import { LayerType } from './types'; import { AttributeNames } from './enums/AttributeNames'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import * as constants from './constants'; import { InstrumentationBase, @@ -37,11 +37,7 @@ import type { RestifyInstrumentationConfig } from './types'; export class RestifyInstrumentation extends InstrumentationBase { constructor(config: RestifyInstrumentationConfig = {}) { - super( - `@opentelemetry/instrumentation-${constants.MODULE_NAME}`, - VERSION, - config - ); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } private _moduleVersion?: string; diff --git a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts index fb02262e30..50803ab148 100644 --- a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts @@ -28,7 +28,7 @@ import * as http from 'http'; import type * as Router from 'router'; import * as types from './internal-types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import * as constants from './constants'; import * as utils from './utils'; import AttributeNames from './enums/AttributeNames'; @@ -36,11 +36,7 @@ import LayerType from './enums/LayerType'; export default class RouterInstrumentation extends InstrumentationBase { constructor(config: InstrumentationConfig = {}) { - super( - `@opentelemetry/instrumentation-${constants.MODULE_NAME}`, - VERSION, - config - ); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } private _moduleVersion?: string; diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts index 4d4b1cfcc5..dddb1c0835 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts @@ -31,14 +31,14 @@ import type { Winston3LogMethod, Winston3Logger, } from './internal-types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; const winston3Versions = ['>=3 <4']; const winstonPre3Versions = ['>=1 <3']; export class WinstonInstrumentation extends InstrumentationBase { constructor(config: WinstonInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-winston', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } protected init() { diff --git a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts index f3837177a0..cdde8cfefd 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts @@ -39,7 +39,7 @@ import { ResourceFetchCustomAttributeFunction, } from './types'; import { AttributeNames } from './enums/AttributeNames'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import { SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, @@ -62,7 +62,7 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { * @param config */ constructor(config: DocumentLoadInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-document-load', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init() {} diff --git a/plugins/web/opentelemetry-instrumentation-long-task/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-long-task/src/instrumentation.ts index 7b17907a89..b77bae7a65 100644 --- a/plugins/web/opentelemetry-instrumentation-long-task/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-long-task/src/instrumentation.ts @@ -16,7 +16,7 @@ import { hrTime } from '@opentelemetry/core'; import { diag } from '@opentelemetry/api'; import { InstrumentationBase } from '@opentelemetry/instrumentation'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; import type { PerformanceLongTaskTiming, LongtaskInstrumentationConfig, @@ -25,7 +25,7 @@ import type { const LONGTASK_PERFORMANCE_TYPE = 'longtask'; export class LongTaskInstrumentation extends InstrumentationBase { - readonly version: string = VERSION; + readonly version: string = PACKAGE_VERSION; private _observer?: PerformanceObserver; override _config!: LongtaskInstrumentationConfig; @@ -35,7 +35,7 @@ export class LongTaskInstrumentation extends InstrumentationBase { * @param config */ constructor(config: LongtaskInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-long-task', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); } init() {} diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts index ea05bddbf1..4a502b7051 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts @@ -34,7 +34,7 @@ import { WindowWithZone, ZoneTypeWithPrototype, } from './internal-types'; -import { VERSION } from './version'; +import { PACKAGE_NAME, PACKAGE_VERSION } from './version'; const ZONE_CONTEXT_KEY = 'OT_ZONE_CONTEXT'; const EVENT_NAVIGATION_NAME = 'Navigation:'; @@ -50,7 +50,7 @@ function defaultShouldPreventSpanCreation() { * addEventListener of HTMLElement */ export class UserInteractionInstrumentation extends InstrumentationBase { - readonly version = VERSION; + readonly version = PACKAGE_VERSION; readonly moduleName: string = 'user-interaction'; private _spansData = new WeakMap(); private _zonePatched?: boolean; @@ -68,7 +68,7 @@ export class UserInteractionInstrumentation extends InstrumentationBase { private _shouldPreventSpanCreation: ShouldPreventSpanCreation; constructor(config: UserInteractionInstrumentationConfig = {}) { - super('@opentelemetry/instrumentation-user-interaction', VERSION, config); + super(PACKAGE_NAME, PACKAGE_VERSION, config); this._eventNames = new Set(config?.eventNames ?? DEFAULT_EVENT_NAMES); this._shouldPreventSpanCreation = typeof config?.shouldPreventSpanCreation === 'function' diff --git a/plugins/web/opentelemetry-plugin-react-load/src/BaseOpenTelemetryComponent.ts b/plugins/web/opentelemetry-plugin-react-load/src/BaseOpenTelemetryComponent.ts index 9b46621027..fa7b007d0a 100644 --- a/plugins/web/opentelemetry-plugin-react-load/src/BaseOpenTelemetryComponent.ts +++ b/plugins/web/opentelemetry-plugin-react-load/src/BaseOpenTelemetryComponent.ts @@ -19,7 +19,7 @@ import { isWrapped } from '@opentelemetry/core'; import * as shimmer from 'shimmer'; import { AttributeNames } from './enums/AttributeNames'; import * as React from 'react'; -import { VERSION } from './version'; +import { PACKAGE_VERSION } from './version'; import { RenderFunction, ComponentDidMountFunction, @@ -58,7 +58,7 @@ export class BaseOpenTelemetryComponent extends React.Component { static setTracer(name: string, version?: string): void { BaseOpenTelemetryComponent._tracer = api.trace.getTracer( name, - version ? version : VERSION + version ? version : PACKAGE_VERSION ); } @@ -423,7 +423,7 @@ export class BaseOpenTelemetryComponent extends React.Component { BaseOpenTelemetryComponent._logger.debug( 'applying patch to', this.moduleName, - VERSION + PACKAGE_VERSION ); if (isWrapped(this.render)) { @@ -536,7 +536,7 @@ export class BaseOpenTelemetryComponent extends React.Component { BaseOpenTelemetryComponent._logger.debug( 'removing patch from', this.moduleName, - VERSION + PACKAGE_VERSION ); shimmer.unwrap(this, 'render'); diff --git a/scripts/version-update.js b/scripts/version-update.js index 77a4969bca..8b56a54b18 100644 --- a/scripts/version-update.js +++ b/scripts/version-update.js @@ -40,7 +40,8 @@ const content = `/* */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '${pjson.version}'; +export const PACKAGE_VERSION = '${pjson.version}'; +export const PACKAGE_NAME = '${pjson.name}'; `; const fileUrl = path.join(appRoot, 'src', 'version.ts')