Skip to content

Commit

Permalink
Merge branch 'main' into host-metrics-type
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Jun 27, 2024
2 parents 15745f5 + 0ed4038 commit 6a07fdc
Show file tree
Hide file tree
Showing 30 changed files with 53 additions and 96 deletions.
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-dataloader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
*/

export * from './types';
export { DataloaderInstrumentation } from './instrumentation';
export * from './instrumentation';
6 changes: 0 additions & 6 deletions plugins/node/instrumentation-fs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,5 @@
* limitations under the License.
*/

import FsInstrumentation from './instrumentation';

export { FsInstrumentation };

export * from './instrumentation';
export * from './types';

export default FsInstrumentation;
2 changes: 1 addition & 1 deletion plugins/node/instrumentation-fs/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function patchedFunctionWithOriginalProperties<
return Object.assign(patchedFunction, original);
}

export default class FsInstrumentation extends InstrumentationBase {
export class FsInstrumentation extends InstrumentationBase {
constructor(config: FsInstrumentationConfig = {}) {
super(PACKAGE_NAME, PACKAGE_VERSION, config);
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/node/instrumentation-fs/test/fs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';
import { promisify } from 'util';
import Instrumentation from '../src';
import { FsInstrumentation } from '../src';
import * as sinon from 'sinon';
import type * as FSType from 'fs';
import tests, { TestCase, TestCreator } from './definitions';
Expand Down Expand Up @@ -66,12 +66,12 @@ provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter));
describe('fs instrumentation', () => {
let contextManager: AsyncHooksContextManager;
let fs: typeof FSType;
let plugin: Instrumentation;
let plugin: FsInstrumentation;

beforeEach(async () => {
contextManager = new AsyncHooksContextManager();
context.setGlobalContextManager(contextManager.enable());
plugin = new Instrumentation(pluginConfig);
plugin = new FsInstrumentation(pluginConfig);
plugin.setTracerProvider(provider);
plugin.enable();
fs = require('fs');
Expand Down
6 changes: 3 additions & 3 deletions plugins/node/instrumentation-fs/test/fsHooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';
import Instrumentation from '../src';
import { FsInstrumentation } from '../src';
import * as sinon from 'sinon';
import type * as FSType from 'fs';
import type { FsInstrumentationConfig } from '../src/types';
Expand Down Expand Up @@ -76,11 +76,11 @@ const assertFailingCallHooks = (expectedFunctionName: string) => {
};

describe('fs instrumentation: hooks', () => {
let plugin: Instrumentation;
let plugin: FsInstrumentation;
let fs: typeof FSType;

beforeEach(async () => {
plugin = new Instrumentation(pluginConfig);
plugin = new FsInstrumentation(pluginConfig);
plugin.setTracerProvider(provider);
plugin.setConfig(pluginConfig as FsInstrumentationConfig);
plugin.enable();
Expand Down
6 changes: 3 additions & 3 deletions plugins/node/instrumentation-fs/test/fsPromises.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';
import Instrumentation from '../src';
import { FsInstrumentation } from '../src';
import * as sinon from 'sinon';
import type * as FSPromisesType from 'fs/promises';
import tests, { FsFunction, TestCase, TestCreator } from './definitions';
Expand All @@ -45,12 +45,12 @@ provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter));
describe('fs/promises instrumentation', () => {
let contextManager: AsyncHooksContextManager;
let fsPromises: typeof FSPromisesType;
let plugin: Instrumentation;
let plugin: FsInstrumentation;

beforeEach(async () => {
contextManager = new AsyncHooksContextManager();
context.setGlobalContextManager(contextManager.enable());
plugin = new Instrumentation(pluginConfig);
plugin = new FsInstrumentation(pluginConfig);
plugin.setTracerProvider(provider);
plugin.enable();
fsPromises = require('fs/promises');
Expand Down
6 changes: 3 additions & 3 deletions plugins/node/instrumentation-fs/test/fsPromisesHooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';
import Instrumentation from '../src';
import { FsInstrumentation } from '../src';
import * as sinon from 'sinon';
import type * as FSPromisesType from 'fs/promises';
import type { FsInstrumentationConfig } from '../src/types';
Expand Down Expand Up @@ -80,11 +80,11 @@ const assertFailingCallHooks = (expectedFunctionName: string) => {
const fsConstantsR_OK = 4;

describe('fs/promises instrumentation: hooks', () => {
let plugin: Instrumentation;
let plugin: FsInstrumentation;
let fsPromises: typeof FSPromisesType;

beforeEach(async () => {
plugin = new Instrumentation(pluginConfig);
plugin = new FsInstrumentation(pluginConfig);
plugin.setTracerProvider(provider);
plugin.setConfig(pluginConfig as FsInstrumentationConfig);
plugin.enable();
Expand Down
6 changes: 3 additions & 3 deletions plugins/node/instrumentation-fs/test/parent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
InMemorySpanExporter,
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import Instrumentation from '../src';
import { FsInstrumentation } from '../src';
import * as assert from 'assert';
import type * as FSType from 'fs';
import type { FsInstrumentationConfig } from '../src/types';
Expand All @@ -32,14 +32,14 @@ provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter));
const tracer = provider.getTracer('default');

describe('fs instrumentation: requireParentSpan', () => {
let plugin: Instrumentation;
let plugin: FsInstrumentation;
let fs: typeof FSType;
let ambientContext: api.Context;
let endRootSpan: () => void;
let expectedAmbientSpanCount: number;

const initializePlugin = (pluginConfig: FsInstrumentationConfig) => {
plugin = new Instrumentation();
plugin = new FsInstrumentation();
plugin.setTracerProvider(provider);
plugin.setConfig(pluginConfig);
plugin.enable();
Expand Down
6 changes: 1 addition & 5 deletions plugins/node/instrumentation-lru-memoizer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@
* limitations under the License.
*/

import LruMemoizerInstrumentation from './instrumentation';

export { LruMemoizerInstrumentation };

export default LruMemoizerInstrumentation;
export * from './instrumentation';
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '@opentelemetry/instrumentation';
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';

export default class LruMemoizerInstrumentation extends InstrumentationBase {
export class LruMemoizerInstrumentation extends InstrumentationBase {
constructor(config: InstrumentationConfig = {}) {
super(PACKAGE_NAME, PACKAGE_VERSION, config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LruMemoizerInstrumentation from '../src';
import { LruMemoizerInstrumentation } from '../src';
import { trace, context } from '@opentelemetry/api';
import { expect } from 'expect';

Expand Down
5 changes: 3 additions & 2 deletions plugins/node/instrumentation-runtime-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { RuntimeNodeInstrumentation } from './instrumentation';
export { RuntimeNodeInstrumentationConfig } from './types';

export * from './instrumentation';
export * from './types';
4 changes: 0 additions & 4 deletions plugins/node/instrumentation-tedious/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@
* limitations under the License.
*/

import { TediousInstrumentation } from './instrumentation';

export * from './instrumentation';
export default TediousInstrumentation;

export * from './types';
11 changes: 2 additions & 9 deletions plugins/node/instrumentation-undici/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,5 @@
* limitations under the License.
*/

export { UndiciInstrumentation } from './undici';
export {
UndiciRequest,
UndiciResponse,
IgnoreRequestFunction,
RequestHookFunction,
StartSpanHookFunction,
UndiciInstrumentationConfig,
} from './types';
export * from './undici';
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@
* limitations under the License.
*/

import GenericPoolInstrumentation from './instrumentation';

export { GenericPoolInstrumentation };
export default GenericPoolInstrumentation;
export * from './instrumentation';
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { PACKAGE_NAME, PACKAGE_VERSION } from './version';

const MODULE_NAME = 'generic-pool';

export default class Instrumentation extends InstrumentationBase {
export class GenericPoolInstrumentation extends InstrumentationBase {
// only used for v2 - v2.3)
private _isDisabled = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';

import Instrumentation from '../src';
const plugin = new Instrumentation();
import { GenericPoolInstrumentation } from '../src';
const plugin = new GenericPoolInstrumentation();

import * as util from 'util';
import * as genericPool from 'generic-pool';
Expand Down
4 changes: 0 additions & 4 deletions plugins/node/opentelemetry-instrumentation-knex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@
* limitations under the License.
*/

import { KnexInstrumentation } from './instrumentation';

export * from './instrumentation';
export default KnexInstrumentation;

export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
} from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';

import Instrumentation from '../src';
const plugin = new Instrumentation({
import { KnexInstrumentation } from '../src';
const plugin = new KnexInstrumentation({
maxQueryLength: 50,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@
* limitations under the License.
*/

import { Instrumentation } from './instrumentation';
export * from './types';

export * from './instrumentation';
export default Instrumentation;
export { Instrumentation as MemcachedInstrumentation };
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import * as utils from './utils';
import { InstrumentationConfig } from './types';
import { PACKAGE_NAME, PACKAGE_VERSION } from './version';

export class Instrumentation extends InstrumentationBase {
export class MemcachedInstrumentation extends InstrumentationBase {
static readonly COMPONENT = 'memcached';
static readonly COMMON_ATTRIBUTES = {
[SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MEMCACHED,
Expand All @@ -44,12 +44,16 @@ export class Instrumentation extends InstrumentationBase {
super(
PACKAGE_NAME,
PACKAGE_VERSION,
Object.assign({}, Instrumentation.DEFAULT_CONFIG, config)
Object.assign({}, MemcachedInstrumentation.DEFAULT_CONFIG, config)
);
}

override setConfig(config: InstrumentationConfig = {}) {
this._config = Object.assign({}, Instrumentation.DEFAULT_CONFIG, config);
this._config = Object.assign(
{},
MemcachedInstrumentation.DEFAULT_CONFIG,
config
);
}

init() {
Expand Down Expand Up @@ -97,7 +101,7 @@ export class Instrumentation extends InstrumentationBase {
kind: api.SpanKind.CLIENT,
attributes: {
'memcached.version': moduleVersion,
...Instrumentation.COMMON_ATTRIBUTES,
...MemcachedInstrumentation.COMMON_ATTRIBUTES,
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from '@opentelemetry/sdk-trace-base';
import type * as Memcached from 'memcached';
import * as assert from 'assert';
import Instrumentation from '../src';
import { MemcachedInstrumentation } from '../src';
import {
DBSYSTEMVALUES_MEMCACHED,
SEMATTRS_DB_SYSTEM,
Expand All @@ -40,7 +40,7 @@ import {
} from '@opentelemetry/semantic-conventions';
import * as util from 'util';

const instrumentation = new Instrumentation();
const instrumentation = new MemcachedInstrumentation();
const memoryExporter = new InMemorySpanExporter();

const CONFIG = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@
* limitations under the License.
*/

import { MySQL2Instrumentation } from './instrumentation';

export * from './instrumentation';
export default MySQL2Instrumentation;

export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@
* limitations under the License.
*/

import { Instrumentation } from './instrumentation';

export * from './instrumentation';
export { Instrumentation as NestInstrumentation };

export * from './enums/AttributeNames';
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import { AttributeNames, NestType } from './enums';

const supportedVersions = ['>=4.0.0 <11'];

export class Instrumentation extends InstrumentationBase {
export class NestInstrumentation extends InstrumentationBase {
static readonly COMPONENT = '@nestjs/core';
static readonly COMMON_ATTRIBUTES = {
component: Instrumentation.COMPONENT,
component: NestInstrumentation.COMPONENT,
};

constructor(config: InstrumentationConfig = {}) {
Expand All @@ -47,7 +47,7 @@ export class Instrumentation extends InstrumentationBase {

init() {
const module = new InstrumentationNodeModuleDefinition(
Instrumentation.COMPONENT,
NestInstrumentation.COMPONENT,
supportedVersions
);

Expand Down Expand Up @@ -122,7 +122,7 @@ function createWrapNestFactoryCreate(
) {
const span = tracer.startSpan('Create Nest App', {
attributes: {
...Instrumentation.COMMON_ATTRIBUTES,
...NestInstrumentation.COMMON_ATTRIBUTES,
[AttributeNames.TYPE]: NestType.APP_CREATION,
[AttributeNames.VERSION]: moduleVersion,
[AttributeNames.MODULE]: nestModule.name,
Expand Down Expand Up @@ -171,7 +171,7 @@ function createWrapCreateHandler(tracer: api.Tracer, moduleVersion?: string) {
) {
const span = tracer.startSpan(spanName, {
attributes: {
...Instrumentation.COMMON_ATTRIBUTES,
...NestInstrumentation.COMMON_ATTRIBUTES,
[AttributeNames.VERSION]: moduleVersion,
[AttributeNames.TYPE]: NestType.REQUEST_CONTEXT,
[SEMATTRS_HTTP_METHOD]: req.method,
Expand Down Expand Up @@ -206,7 +206,7 @@ function createWrapHandler(
const spanName = handler.name || 'anonymous nest handler';
const options = {
attributes: {
...Instrumentation.COMMON_ATTRIBUTES,
...NestInstrumentation.COMMON_ATTRIBUTES,
[AttributeNames.VERSION]: moduleVersion,
[AttributeNames.TYPE]: NestType.REQUEST_HANDLER,
[AttributeNames.CALLBACK]: handler.name,
Expand Down
Loading

0 comments on commit 6a07fdc

Please sign in to comment.