From 6ba387ab45d0f67fdfac85c43bb0f0f67f2a119b Mon Sep 17 00:00:00 2001 From: Haddas Bronfman <85441461+haddasbronfman@users.noreply.github.com> Date: Sun, 6 Feb 2022 10:33:00 +0200 Subject: [PATCH] fix(auto-instrumentations-node): add more instrumentations (#865) --- .../auto-instrumentations-node/README.md | 21 +++++++++++ .../auto-instrumentations-node/package.json | 18 +++++++++- .../auto-instrumentations-node/src/utils.ts | 35 ++++++++++++++++++- .../test/utils.test.ts | 18 +++++++++- .../src/instrumentation.ts | 3 +- .../src/instrumentation.ts | 3 +- .../src/instrumentation.ts | 3 +- 7 files changed, 95 insertions(+), 6 deletions(-) diff --git a/metapackages/auto-instrumentations-node/README.md b/metapackages/auto-instrumentations-node/README.md index 25d34d20d38..bb33a672593 100644 --- a/metapackages/auto-instrumentations-node/README.md +++ b/metapackages/auto-instrumentations-node/README.md @@ -56,17 +56,38 @@ registerInstrumentations({ ## Supported instrumentations +- [@opentelemetry/instrumentation-aws-lambda](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-aws-lambda) +- [@opentelemetry/instrumentation-aws-sdk](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-aws-sdk) +- [@opentelemetry/instrumentation-bunyan](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-bunyan) +- [@opentelemetry/instrumentation-cassandra-driver](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-cassandra) +- [@opentelemetry/instrumentation-connect](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-connect) - [@opentelemetry/instrumentation-dns](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-dns) - [@opentelemetry/instrumentation-http](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-http) - [@opentelemetry/instrumentation-grpc](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-grpc) - [@opentelemetry/instrumentation-express](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express) - [@opentelemetry/instrumentation-koa](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-koa) +- [@opentelemetry/instrumentation-fastify](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-fastify) +- [@opentelemetry/instrumentation-generic-pool](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-generic-pool) - [@opentelemetry/instrumentation-graphql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-graphql) +- [@opentelemetry/instrumentation-grpc](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-grpc) +- [@opentelemetry/instrumentation-hapi](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-hapi) +- [@opentelemetry/instrumentation-http](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-http) - [@opentelemetry/instrumentation-ioredis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-ioredis) - [@opentelemetry/instrumentation-redis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-redis) - [@opentelemetry/instrumentation-pg](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-pg) +- [@opentelemetry/instrumentation-knex](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-knex) +- [@opentelemetry/instrumentation-koa](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-koa) +- [@opentelemetry/instrumentation-memcached](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-memcached) - [@opentelemetry/instrumentation-mongodb](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mongodb) +- [@opentelemetry/instrumentation-mysql2](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mysql2) - [@opentelemetry/instrumentation-mysql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mysql) +- [@opentelemetry/instrumentation-nestjs-core](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-nestjs-core) +- [@opentelemetry/instrumentation-net](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-net) +- [@opentelemetry/instrumentation-pg](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-pg) +- [@opentelemetry/instrumentation-pino](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-pino) +- [@opentelemetry/instrumentation-redis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-redis) +- [@opentelemetry/instrumentation-restify](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-restify) +- [@opentelemetry/instrumentation-winston](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-winston) ## Useful links diff --git a/metapackages/auto-instrumentations-node/package.json b/metapackages/auto-instrumentations-node/package.json index 8a043acd103..a8d0621dc8a 100644 --- a/metapackages/auto-instrumentations-node/package.json +++ b/metapackages/auto-instrumentations-node/package.json @@ -46,16 +46,32 @@ }, "dependencies": { "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation-aws-lambda": "^0.28.0", + "@opentelemetry/instrumentation-aws-sdk": "^0.5.0", + "@opentelemetry/instrumentation-bunyan": "^0.27.0", + "@opentelemetry/instrumentation-cassandra-driver": "^0.27.0", + "@opentelemetry/instrumentation-connect": "^0.27.0", "@opentelemetry/instrumentation-dns": "^0.27.1", "@opentelemetry/instrumentation-express": "^0.27.1", + "@opentelemetry/instrumentation-fastify": "^0.25.0", + "@opentelemetry/instrumentation-generic-pool": "^0.27.0", "@opentelemetry/instrumentation-graphql": "^0.27.2", "@opentelemetry/instrumentation-grpc": "^0.27.0", + "@opentelemetry/instrumentation-hapi": "^0.27.0", "@opentelemetry/instrumentation-http": "^0.27.0", "@opentelemetry/instrumentation-ioredis": "^0.27.1", + "@opentelemetry/instrumentation-knex": "^0.27.0", "@opentelemetry/instrumentation-koa": "^0.28.1", + "@opentelemetry/instrumentation-memcached": "^0.27.0", "@opentelemetry/instrumentation-mongodb": "^0.28.0", "@opentelemetry/instrumentation-mysql": "^0.27.1", + "@opentelemetry/instrumentation-mysql2": "^0.28.0", + "@opentelemetry/instrumentation-nestjs-core": "^0.28.1", + "@opentelemetry/instrumentation-net": "^0.27.0", "@opentelemetry/instrumentation-pg": "^0.28.0", - "@opentelemetry/instrumentation-redis": "^0.28.0" + "@opentelemetry/instrumentation-pino": "^0.28.0", + "@opentelemetry/instrumentation-redis": "^0.28.0", + "@opentelemetry/instrumentation-restify": "^0.27.0", + "@opentelemetry/instrumentation-winston": "^0.27.0" } } diff --git a/metapackages/auto-instrumentations-node/src/utils.ts b/metapackages/auto-instrumentations-node/src/utils.ts index 65b272b4b1d..1f705172b6f 100644 --- a/metapackages/auto-instrumentations-node/src/utils.ts +++ b/metapackages/auto-instrumentations-node/src/utils.ts @@ -16,30 +16,63 @@ import { diag } from '@opentelemetry/api'; import { Instrumentation } from '@opentelemetry/instrumentation'; +import { AwsLambdaInstrumentation } from '@opentelemetry/instrumentation-aws-lambda'; +import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk'; +import { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan'; +import { CassandraDriverInstrumentation } from '@opentelemetry/instrumentation-cassandra-driver'; +import { ConnectInstrumentation } from '@opentelemetry/instrumentation-connect'; import { DnsInstrumentation } from '@opentelemetry/instrumentation-dns'; import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'; +import { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify'; +import { GenericPoolInstrumentation } from '@opentelemetry/instrumentation-generic-pool'; import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql'; import { GrpcInstrumentation } from '@opentelemetry/instrumentation-grpc'; +import { HapiInstrumentation } from '@opentelemetry/instrumentation-hapi'; import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'; import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis'; +import { KnexInstrumentation } from '@opentelemetry/instrumentation-knex'; import { KoaInstrumentation } from '@opentelemetry/instrumentation-koa'; +import { MemcachedInstrumentation } from '@opentelemetry/instrumentation-memcached'; import { MongoDBInstrumentation } from '@opentelemetry/instrumentation-mongodb'; -import { PgInstrumentation } from '@opentelemetry/instrumentation-pg'; +import { MySQL2Instrumentation } from '@opentelemetry/instrumentation-mysql2'; import { MySQLInstrumentation } from '@opentelemetry/instrumentation-mysql'; +import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core'; +import { NetInstrumentation } from '@opentelemetry/instrumentation-net'; +import { PgInstrumentation } from '@opentelemetry/instrumentation-pg'; +import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino'; import { RedisInstrumentation } from '@opentelemetry/instrumentation-redis'; +import { RestifyInstrumentation } from '@opentelemetry/instrumentation-restify'; +import { WinstonInstrumentation } from '@opentelemetry/instrumentation-winston'; const InstrumentationMap = { + '@opentelemetry/instrumentation-aws-lambda': AwsLambdaInstrumentation, + '@opentelemetry/instrumentation-aws-sdk': AwsInstrumentation, + '@opentelemetry/instrumentation-bunyan': BunyanInstrumentation, + '@opentelemetry/instrumentation-cassandra-driver': + CassandraDriverInstrumentation, + '@opentelemetry/instrumentation-connect': ConnectInstrumentation, '@opentelemetry/instrumentation-dns': DnsInstrumentation, '@opentelemetry/instrumentation-express': ExpressInstrumentation, + '@opentelemetry/instrumentation-fastify': FastifyInstrumentation, + '@opentelemetry/instrumentation-generic-pool': GenericPoolInstrumentation, '@opentelemetry/instrumentation-graphql': GraphQLInstrumentation, '@opentelemetry/instrumentation-grpc': GrpcInstrumentation, + '@opentelemetry/instrumentation-hapi': HapiInstrumentation, '@opentelemetry/instrumentation-http': HttpInstrumentation, '@opentelemetry/instrumentation-ioredis': IORedisInstrumentation, + '@opentelemetry/instrumentation-knex': KnexInstrumentation, '@opentelemetry/instrumentation-koa': KoaInstrumentation, + '@opentelemetry/instrumentation-memcached': MemcachedInstrumentation, '@opentelemetry/instrumentation-mongodb': MongoDBInstrumentation, + '@opentelemetry/instrumentation-mysql2': MySQL2Instrumentation, '@opentelemetry/instrumentation-mysql': MySQLInstrumentation, + '@opentelemetry/instrumentation-nestjs-core': NestInstrumentation, + '@opentelemetry/instrumentation-net': NetInstrumentation, '@opentelemetry/instrumentation-pg': PgInstrumentation, + '@opentelemetry/instrumentation-pino': PinoInstrumentation, '@opentelemetry/instrumentation-redis': RedisInstrumentation, + '@opentelemetry/instrumentation-restify': RestifyInstrumentation, + '@opentelemetry/instrumentation-winston': WinstonInstrumentation, }; // Config types inferred automatically from the first argument of the constructor diff --git a/metapackages/auto-instrumentations-node/test/utils.test.ts b/metapackages/auto-instrumentations-node/test/utils.test.ts index 832902d7416..9cbb59917f8 100644 --- a/metapackages/auto-instrumentations-node/test/utils.test.ts +++ b/metapackages/auto-instrumentations-node/test/utils.test.ts @@ -25,19 +25,35 @@ describe('utils', () => { it('should load default instrumentations', () => { const instrumentations = getNodeAutoInstrumentations(); const expectedInstrumentations = [ + '@opentelemetry/instrumentation-aws-lambda', + '@opentelemetry/instrumentation-aws-sdk', + '@opentelemetry/instrumentation-bunyan', + '@opentelemetry/instrumentation-cassandra-driver', + '@opentelemetry/instrumentation-connect', '@opentelemetry/instrumentation-dns', '@opentelemetry/instrumentation-express', + '@opentelemetry/instrumentation-fastify', + '@opentelemetry/instrumentation-generic-pool', '@opentelemetry/instrumentation-graphql', '@opentelemetry/instrumentation-grpc', + '@opentelemetry/instrumentation-hapi', '@opentelemetry/instrumentation-http', '@opentelemetry/instrumentation-ioredis', + '@opentelemetry/instrumentation-knex', '@opentelemetry/instrumentation-koa', + '@opentelemetry/instrumentation-memcached', '@opentelemetry/instrumentation-mongodb', + '@opentelemetry/instrumentation-mysql2', '@opentelemetry/instrumentation-mysql', + '@opentelemetry/instrumentation-nestjs-core', + '@opentelemetry/instrumentation-net', '@opentelemetry/instrumentation-pg', + '@opentelemetry/instrumentation-pino', '@opentelemetry/instrumentation-redis', + '@opentelemetry/instrumentation-restify', + '@opentelemetry/instrumentation-winston', ]; - assert.strictEqual(instrumentations.length, 11); + assert.strictEqual(instrumentations.length, 27); for (let i = 0, j = instrumentations.length; i < j; i++) { assert.strictEqual( instrumentations[i].instrumentationName, diff --git a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts index 7e078ef24b2..fa2f4c35f4f 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts @@ -17,6 +17,7 @@ import * as api from '@opentelemetry/api'; import { InstrumentationBase, + InstrumentationConfig, InstrumentationNodeModuleDefinition, isWrapped, } from '@opentelemetry/instrumentation'; @@ -33,7 +34,7 @@ export default class Instrumentation extends InstrumentationBase< // only used for v2 - v2.3) private _isDisabled = false; - constructor() { + constructor(config: InstrumentationConfig = {}) { super(`@opentelemetry/instrumentation-${MODULE_NAME}`, VERSION); } diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts index b753901f014..113b1ca05c6 100644 --- a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/instrumentation.ts @@ -17,6 +17,7 @@ import * as api from '@opentelemetry/api'; import { InstrumentationBase, + InstrumentationConfig, InstrumentationNodeModuleDefinition, InstrumentationNodeModuleFile, isWrapped, @@ -35,7 +36,7 @@ export class Instrumentation extends InstrumentationBase { component: Instrumentation.COMPONENT, }; - constructor() { + constructor(config: InstrumentationConfig = {}) { super('@opentelemetry/instrumentation-nestjs-core', VERSION); } diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts index 18045736842..89b39ad4237 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts @@ -23,6 +23,7 @@ import { VERSION } from './version'; import * as constants from './constants'; import { InstrumentationBase, + InstrumentationConfig, InstrumentationNodeModuleDefinition, InstrumentationNodeModuleFile, isWrapped, @@ -36,7 +37,7 @@ const { diag } = api; export class RestifyInstrumentation extends InstrumentationBase< typeof restify > { - constructor() { + constructor(config: InstrumentationConfig = {}) { super(`@opentelemetry/instrumentation-${constants.MODULE_NAME}`, VERSION); }