Skip to content

Commit

Permalink
Merge branch 'main' into fix_mongoose_model_method_session_instrument…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
ferrelucas committed May 23, 2024
2 parents cbce832 + 0cef9fa commit b6b04f7
Show file tree
Hide file tree
Showing 47 changed files with 108 additions and 120 deletions.
6 changes: 3 additions & 3 deletions packages/opentelemetry-host-metrics/src/BaseMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +33,7 @@ export interface MetricsCollectorConfig {
url?: string;
}

const DEFAULT_NAME = '@opentelemetry/host-metrics';
const DEFAULT_NAME = PACKAGE_NAME;

/**
* Base Class for metrics
Expand All @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/winston-transport/src/OpenTelemetryTransportV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

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 {
private _logger: Logger;

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) {
Expand Down
6 changes: 3 additions & 3 deletions plugins/node/instrumentation-amqplib/src/amqplib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/instrumentation-cucumber/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/instrumentation-fs/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(): (
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/instrumentation-kafkajs/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/instrumentation-mongoose/src/mongoose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
);
}
Expand Down
8 changes: 2 additions & 6 deletions plugins/node/instrumentation-socket.io/src/socket.io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/instrumentation-tedious/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/instrumentation-undici/src/undici.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
ValueType,
} from '@opentelemetry/api';

import { VERSION } from './version';
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';

import {
ListenerRecord,
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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'] ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
NormalizedRequest,
NormalizedResponse,
} from './types';
import { VERSION } from './version';
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';
import {
InstrumentationBase,
InstrumentationModuleDefinition,
Expand Down Expand Up @@ -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 = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(): (
Expand Down

0 comments on commit b6b04f7

Please sign in to comment.