From d0a10ebefbe3954e3a9b34e26e391eb73b53fb20 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 28 Oct 2022 10:07:04 +0200 Subject: [PATCH 1/5] fix(deps): update dependency gcp-metadata to v5 (#1009) Co-authored-by: Amir Blum --- detectors/node/opentelemetry-resource-detector-gcp/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detectors/node/opentelemetry-resource-detector-gcp/package.json b/detectors/node/opentelemetry-resource-detector-gcp/package.json index 59ed47f407..0b533231af 100644 --- a/detectors/node/opentelemetry-resource-detector-gcp/package.json +++ b/detectors/node/opentelemetry-resource-detector-gcp/package.json @@ -61,7 +61,7 @@ "@opentelemetry/core": "^1.0.0", "@opentelemetry/resources": "^1.0.0", "@opentelemetry/semantic-conventions": "^1.0.0", - "gcp-metadata": "^4.1.4", + "gcp-metadata": "^5.0.0", "semver": "7.3.5" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-gcp#readme" From 20767c4fffee34bc51392894001bbb667576e91d Mon Sep 17 00:00:00 2001 From: Sami Musallam Date: Fri, 28 Oct 2022 12:58:53 +0300 Subject: [PATCH 2/5] feat(cassandra-responsehook): added response hook to execute func (#1180) --- .../README.md | 10 +-- .../src/instrumentation.ts | 37 +++++++++- .../src/types.ts | 32 +++++++++ .../test/cassandra-driver.test.ts | 71 ++++++++++++++++++- 4 files changed, 140 insertions(+), 10 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/README.md b/plugins/node/opentelemetry-instrumentation-cassandra/README.md index 90411b6cee..637bcf4fa2 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/README.md +++ b/plugins/node/opentelemetry-instrumentation-cassandra/README.md @@ -39,11 +39,11 @@ await client.execute('select * from foo'); ### Instrumentation options -| Option | Type | Default | Description | -| ------ | ---- | ------- | ----------- | -| `enhancedDatabaseReporting` | `boolean` | `false` | Whether to include database queries with spans. These can contain sensitive information when using unescaped parameters - i.e. `insert into persons (name) values ('Bob')` instead of `insert into persons (name) values (?)`. | -| `maxQueryLength` | `number` | `65536` | If `enhancedDatabaseReporting` is enabled, limits the attached query strings -to this length. | +| Option | Type | Default | Description | +|-----------------------------|--------------------------------------------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `enhancedDatabaseReporting` | `boolean` | `false` | Whether to include database queries with spans. These can contain sensitive information when using unescaped parameters - i.e. `insert into persons (name) values ('Bob')` instead of `insert into persons (name) values (?)`. | +| `responseHook` | `CassandraDriverResponseCustomAttributeFunction` | `undefined` | Hook for adding custom attributes before response is handled | +| `maxQueryLength` | `number` | `65536` | If `enhancedDatabaseReporting` is enabled, limits the attached query strings to this length. | ### Supported versions diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts index 6982586ba6..68f8975ece 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -29,7 +29,7 @@ import { isWrapped, safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; -import { CassandraDriverInstrumentationConfig } from './types'; +import { CassandraDriverInstrumentationConfig, ResultSet } from './types'; import { SemanticAttributes, DbSystemValues, @@ -41,6 +41,8 @@ import type * as CassandraDriver from 'cassandra-driver'; const supportedVersions = ['>=4.4 <5.0']; export class CassandraDriverInstrumentation extends InstrumentationBase { + protected override _config!: CassandraDriverInstrumentationConfig; + constructor(config: CassandraDriverInstrumentationConfig = {}) { super('@opentelemetry/instrumentation-cassandra-driver', VERSION, config); } @@ -147,7 +149,13 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { } ); - const wrappedPromise = wrapPromise(span, execPromise); + const wrappedPromise = wrapPromise( + span, + execPromise, + (span, result) => { + plugin._callResponseHook(span, result); + } + ); return context.bind(execContext, wrappedPromise); }; @@ -319,6 +327,22 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { attributes, }); } + + private _callResponseHook(span: Span, response: ResultSet) { + if (!this._config.responseHook) { + return; + } + + safeExecuteInTheMiddle( + () => this._config.responseHook!(span, { response: response }), + e => { + if (e) { + this._diag.error('responseHook error', e); + } + }, + true + ); + } } function failSpan(span: Span, error: Error) { @@ -336,10 +360,17 @@ function combineQueries(queries: Array) { .join('\n'); } -function wrapPromise(span: Span, promise: Promise): Promise { +function wrapPromise( + span: Span, + promise: Promise, + successCallback?: (span: Span, result: T) => void +): Promise { return promise .then(result => { return new Promise(resolve => { + if (successCallback) { + successCallback(span, result); + } span.end(); resolve(result); }); diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/types.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/types.ts index eff54d1786..0ddabb3585 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/types.ts @@ -15,6 +15,32 @@ */ import { InstrumentationConfig } from '@opentelemetry/instrumentation'; +import { Span } from '@opentelemetry/api'; + +export interface Row { + get(columnName: string | number): any; + + keys(): string[]; + + forEach(callback: (row: Row) => void): void; + + values(): any[]; + + [key: string]: any; +} + +// https://github.com/datastax/nodejs-driver/blob/d42176e4baa1cfc3df79699cc3b5d575c86e3cec/lib/types/index.d.ts#L323 +export interface ResultSet { + rows: Row[]; +} + +export interface ResponseHookInfo { + response: ResultSet; +} + +export interface CassandraDriverResponseCustomAttributeFunction { + (span: Span, responseInfo: ResponseHookInfo): void; +} export interface CassandraDriverInstrumentationConfig extends InstrumentationConfig { @@ -29,4 +55,10 @@ export interface CassandraDriverInstrumentationConfig * @default 65536 */ maxQueryLength?: number; + /** + * Function for adding custom attributes before response is handled. + * @param span the current span + * @param responseInfo array of the resulting rows. This will only return the first page of results + */ + responseHook?: CassandraDriverResponseCustomAttributeFunction; } diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts b/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts index 42b8f9082c..bd696df85f 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts @@ -20,7 +20,9 @@ import { ReadableSpan, } from '@opentelemetry/sdk-trace-base'; import { + Attributes, context, + Span, SpanKind, SpanStatus, SpanStatusCode, @@ -38,6 +40,7 @@ import { CassandraDriverInstrumentation, CassandraDriverInstrumentationConfig, } from '../src'; +import { ResponseHookInfo } from '../src/types'; const memoryExporter = new InMemorySpanExporter(); const provider = new NodeTracerProvider(); @@ -53,11 +56,13 @@ function assertSpan( span: ReadableSpan, name: string, query?: string, - status?: SpanStatus + status?: SpanStatus, + customAttributes?: Attributes ) { - const attributes = { + const attributes: Attributes = { [SemanticAttributes.DB_SYSTEM]: DbSystemValues.CASSANDRA, [SemanticAttributes.DB_USER]: 'cassandra', + ...customAttributes, }; if (query !== undefined) { @@ -76,6 +81,13 @@ function assertSingleSpan(name: string, query?: string, status?: SpanStatus) { assertSpan(span, name, query, status); } +function assertAttributeInSingleSpan(name: string, attributes?: Attributes) { + const spans = memoryExporter.getFinishedSpans(); + assert.strictEqual(spans.length, 1); + const [span] = spans; + assertSpan(span, name, undefined, undefined, attributes); +} + function assertErrorSpan( name: string, error: Error & { code?: number }, @@ -131,6 +143,7 @@ describe('CassandraDriverInstrumentation', () => { } instrumentation = new CassandraDriverInstrumentation(); + instrumentation.setTracerProvider(provider); const cassandra = require('cassandra-driver'); @@ -228,6 +241,60 @@ describe('CassandraDriverInstrumentation', () => { assertSingleSpan('cassandra-driver.execute', query.substr(0, 25)); }); }); + + describe('responseHook', () => { + after(() => { + instrumentation.setConfig({}); + }); + + it('adds custom attributes to span', async () => { + const responseAttributeName = 'response.attribute'; + const customAttributeName = 'custom.attribute'; + const customAttributeValue = 'custom attribute value'; + + const config: CassandraDriverInstrumentationConfig = { + responseHook: (span: Span, responseInfo: ResponseHookInfo) => { + const row = responseInfo.response.rows[0]; + const responseValue = row.count.toNumber(); + + span.setAttribute(responseAttributeName, responseValue); + span.setAttribute(customAttributeName, customAttributeValue); + }, + }; + + instrumentation.setConfig(config); + + await client.execute( + "SELECT count(*) FROM system_schema.columns WHERE keyspace_name = 'ot' AND table_name = 'test';" + ); + + assertAttributeInSingleSpan('cassandra-driver.execute', { + [customAttributeName]: customAttributeValue, + [responseAttributeName]: 2, + }); + }); + + it('throws and should not affect user flow or span creation', async () => { + const hookAttributeName = 'hook.attribute'; + const hookAttributeValue = 'hook attribute value'; + + const config: CassandraDriverInstrumentationConfig = { + responseHook: (span: Span, responseInfo: ResponseHookInfo): void => { + span.setAttribute(hookAttributeName, hookAttributeValue); + throw new Error('error inside hook'); + }, + }; + + instrumentation.setConfig(config); + + const query = 'select * from ot.test'; + await client.execute(query); + + assertAttributeInSingleSpan('cassandra-driver.execute', { + [hookAttributeName]: hookAttributeValue, + }); + }); + }); }); describe('batch', () => { From 55c1a984ffd1578a15d989d665d1d7f052d38989 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 29 Oct 2022 11:16:01 +0200 Subject: [PATCH 3/5] chore(deps): update dependency @types/node to v18 (#1259) Co-authored-by: Amir Blum --- .../opentelemetry-resource-detector-alibaba-cloud/package.json | 2 +- detectors/node/opentelemetry-resource-detector-aws/package.json | 2 +- .../node/opentelemetry-resource-detector-container/package.json | 2 +- detectors/node/opentelemetry-resource-detector-gcp/package.json | 2 +- .../node/opentelemetry-resource-detector-github/package.json | 2 +- .../node/opentelemetry-resource-detector-instana/package.json | 2 +- metapackages/auto-instrumentations-node/package.json | 2 +- metapackages/auto-instrumentations-web/package.json | 2 +- packages/opentelemetry-host-metrics/package.json | 2 +- packages/opentelemetry-id-generator-aws-xray/package.json | 2 +- packages/opentelemetry-propagation-utils/package.json | 2 +- packages/opentelemetry-test-utils/package.json | 2 +- plugins/node/instrumentation-amqplib/package.json | 2 +- plugins/node/instrumentation-dataloader/package.json | 2 +- plugins/node/instrumentation-fs/package.json | 2 +- plugins/node/instrumentation-lru-memoizer/package.json | 2 +- plugins/node/instrumentation-mongoose/package.json | 2 +- plugins/node/instrumentation-tedious/package.json | 2 +- .../node/opentelemetry-instrumentation-aws-lambda/package.json | 2 +- plugins/node/opentelemetry-instrumentation-aws-sdk/package.json | 2 +- plugins/node/opentelemetry-instrumentation-bunyan/package.json | 2 +- .../node/opentelemetry-instrumentation-cassandra/package.json | 2 +- plugins/node/opentelemetry-instrumentation-connect/package.json | 2 +- plugins/node/opentelemetry-instrumentation-dns/package.json | 2 +- plugins/node/opentelemetry-instrumentation-express/package.json | 2 +- plugins/node/opentelemetry-instrumentation-fastify/package.json | 2 +- .../opentelemetry-instrumentation-generic-pool/package.json | 2 +- plugins/node/opentelemetry-instrumentation-graphql/package.json | 2 +- plugins/node/opentelemetry-instrumentation-hapi/package.json | 2 +- plugins/node/opentelemetry-instrumentation-ioredis/package.json | 2 +- plugins/node/opentelemetry-instrumentation-knex/package.json | 2 +- plugins/node/opentelemetry-instrumentation-koa/package.json | 2 +- .../node/opentelemetry-instrumentation-memcached/package.json | 2 +- plugins/node/opentelemetry-instrumentation-mongodb/package.json | 2 +- plugins/node/opentelemetry-instrumentation-mysql/package.json | 2 +- plugins/node/opentelemetry-instrumentation-mysql2/package.json | 2 +- .../node/opentelemetry-instrumentation-nestjs-core/package.json | 2 +- plugins/node/opentelemetry-instrumentation-net/package.json | 2 +- plugins/node/opentelemetry-instrumentation-pg/package.json | 2 +- plugins/node/opentelemetry-instrumentation-pino/package.json | 2 +- plugins/node/opentelemetry-instrumentation-redis-4/package.json | 2 +- plugins/node/opentelemetry-instrumentation-redis/package.json | 2 +- plugins/node/opentelemetry-instrumentation-restify/package.json | 2 +- plugins/node/opentelemetry-instrumentation-router/package.json | 2 +- plugins/node/opentelemetry-instrumentation-winston/package.json | 2 +- .../opentelemetry-instrumentation-document-load/package.json | 2 +- .../web/opentelemetry-instrumentation-long-task/package.json | 2 +- .../opentelemetry-instrumentation-user-interaction/package.json | 2 +- plugins/web/opentelemetry-plugin-react-load/package.json | 2 +- propagators/opentelemetry-propagator-aws-xray/package.json | 2 +- .../opentelemetry-propagator-grpc-census-binary/package.json | 2 +- propagators/opentelemetry-propagator-instana/package.json | 2 +- propagators/opentelemetry-propagator-ot-trace/package.json | 2 +- 53 files changed, 53 insertions(+), 53 deletions(-) diff --git a/detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json b/detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json index 2767784f8c..88cb6fd8f5 100644 --- a/detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json +++ b/detectors/node/opentelemetry-resource-detector-alibaba-cloud/package.json @@ -45,7 +45,7 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/contrib-test-utils": "^0.32.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/detectors/node/opentelemetry-resource-detector-aws/package.json b/detectors/node/opentelemetry-resource-detector-aws/package.json index efd0889b52..a1a76f71f8 100644 --- a/detectors/node/opentelemetry-resource-detector-aws/package.json +++ b/detectors/node/opentelemetry-resource-detector-aws/package.json @@ -44,7 +44,7 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/contrib-test-utils": "^0.32.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/detectors/node/opentelemetry-resource-detector-container/package.json b/detectors/node/opentelemetry-resource-detector-container/package.json index 6cbfb50119..c6cfc30dbb 100644 --- a/detectors/node/opentelemetry-resource-detector-container/package.json +++ b/detectors/node/opentelemetry-resource-detector-container/package.json @@ -38,7 +38,7 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/contrib-test-utils": "^0.32.0", "@types/mocha": "8.2.3", - "@types/node": "^17.0.14", + "@types/node": "^18.0.0", "@types/sinon": "10.0.2", "eslint-plugin-header": "^3.1.1", "gts": "^3.1.0", diff --git a/detectors/node/opentelemetry-resource-detector-gcp/package.json b/detectors/node/opentelemetry-resource-detector-gcp/package.json index 0b533231af..401982c14f 100644 --- a/detectors/node/opentelemetry-resource-detector-gcp/package.json +++ b/detectors/node/opentelemetry-resource-detector-gcp/package.json @@ -44,7 +44,7 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/contrib-test-utils": "^0.32.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/semver": "7.3.8", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/detectors/node/opentelemetry-resource-detector-github/package.json b/detectors/node/opentelemetry-resource-detector-github/package.json index b04c0b1f5f..e0227a18d5 100644 --- a/detectors/node/opentelemetry-resource-detector-github/package.json +++ b/detectors/node/opentelemetry-resource-detector-github/package.json @@ -47,7 +47,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/detectors/node/opentelemetry-resource-detector-instana/package.json b/detectors/node/opentelemetry-resource-detector-instana/package.json index f50bf21f04..f9d0a4973e 100644 --- a/detectors/node/opentelemetry-resource-detector-instana/package.json +++ b/detectors/node/opentelemetry-resource-detector-instana/package.json @@ -43,7 +43,7 @@ "@opentelemetry/contrib-test-utils": "^0.32.0", "@opentelemetry/sdk-node": "^0.32.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/semver": "7.3.8", "mocha": "7.2.0", "nock": "12.0.3", diff --git a/metapackages/auto-instrumentations-node/package.json b/metapackages/auto-instrumentations-node/package.json index 443e3badc9..1b2b5dc852 100644 --- a/metapackages/auto-instrumentations-node/package.json +++ b/metapackages/auto-instrumentations-node/package.json @@ -35,7 +35,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/metapackages/auto-instrumentations-web/package.json b/metapackages/auto-instrumentations-web/package.json index cd55e17299..e2296aabf0 100644 --- a/metapackages/auto-instrumentations-web/package.json +++ b/metapackages/auto-instrumentations-web/package.json @@ -36,7 +36,7 @@ "@babel/core": "7.15.0", "@opentelemetry/api": "^1.0.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", diff --git a/packages/opentelemetry-host-metrics/package.json b/packages/opentelemetry-host-metrics/package.json index 235b7c38c9..374c7a6beb 100644 --- a/packages/opentelemetry-host-metrics/package.json +++ b/packages/opentelemetry-host-metrics/package.json @@ -48,7 +48,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/packages/opentelemetry-id-generator-aws-xray/package.json b/packages/opentelemetry-id-generator-aws-xray/package.json index 6a2b5398d9..5eac111cf0 100644 --- a/packages/opentelemetry-id-generator-aws-xray/package.json +++ b/packages/opentelemetry-id-generator-aws-xray/package.json @@ -56,7 +56,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "gts": "3.1.0", diff --git a/packages/opentelemetry-propagation-utils/package.json b/packages/opentelemetry-propagation-utils/package.json index 720d19b802..e35153d111 100644 --- a/packages/opentelemetry-propagation-utils/package.json +++ b/packages/opentelemetry-propagation-utils/package.json @@ -47,7 +47,7 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/contrib-test-utils": "^0.31.0", "@types/mocha": "^9.1.1", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "^10.0.11", "expect": "27.4.2", "gts": "3.1.0", diff --git a/packages/opentelemetry-test-utils/package.json b/packages/opentelemetry-test-utils/package.json index b818511eb5..1b41eea269 100644 --- a/packages/opentelemetry-test-utils/package.json +++ b/packages/opentelemetry-test-utils/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@opentelemetry/api": "^1.0.0", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "gts": "3.1.0", "typescript": "4.3.5" }, diff --git a/plugins/node/instrumentation-amqplib/package.json b/plugins/node/instrumentation-amqplib/package.json index 958a25ee1e..8e7d661da9 100644 --- a/plugins/node/instrumentation-amqplib/package.json +++ b/plugins/node/instrumentation-amqplib/package.json @@ -57,7 +57,7 @@ "@types/lodash": "4.14.178", "@types/mocha": "8.2.3", "@types/sinon": "10.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "amqplib": "0.8.0", "expect": "27.4.2", "lodash": "4.17.21", diff --git a/plugins/node/instrumentation-dataloader/package.json b/plugins/node/instrumentation-dataloader/package.json index 17a24ac1ac..2772dc5f6e 100644 --- a/plugins/node/instrumentation-dataloader/package.json +++ b/plugins/node/instrumentation-dataloader/package.json @@ -51,7 +51,7 @@ "@opentelemetry/sdk-trace-base": "^1.6.0", "@opentelemetry/sdk-trace-node": "^1.6.0", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "dataloader": "2.0.0", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/instrumentation-fs/package.json b/plugins/node/instrumentation-fs/package.json index 0dfa1cdb02..c70e624aad 100644 --- a/plugins/node/instrumentation-fs/package.json +++ b/plugins/node/instrumentation-fs/package.json @@ -48,7 +48,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "14.17.9", + "@types/node": "18.11.7", "@types/sinon": "^10.0.11", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/instrumentation-lru-memoizer/package.json b/plugins/node/instrumentation-lru-memoizer/package.json index c32e02bb1f..4264d5a57a 100644 --- a/plugins/node/instrumentation-lru-memoizer/package.json +++ b/plugins/node/instrumentation-lru-memoizer/package.json @@ -46,7 +46,7 @@ "@opentelemetry/contrib-test-utils": "^0.32.0", "@types/lru-cache": "7.10.9", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "expect": "25.5.0", "gts": "3.1.0", "lru-memoizer": "2.1.4", diff --git a/plugins/node/instrumentation-mongoose/package.json b/plugins/node/instrumentation-mongoose/package.json index 2968026639..04cf61d62e 100644 --- a/plugins/node/instrumentation-mongoose/package.json +++ b/plugins/node/instrumentation-mongoose/package.json @@ -49,7 +49,7 @@ "@opentelemetry/contrib-test-utils": "^0.32.0", "@opentelemetry/sdk-trace-base": "^1.3.1", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "expect": "27.4.2", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/instrumentation-tedious/package.json b/plugins/node/instrumentation-tedious/package.json index 5796b71cb8..a6c29f955d 100644 --- a/plugins/node/instrumentation-tedious/package.json +++ b/plugins/node/instrumentation-tedious/package.json @@ -52,7 +52,7 @@ "@opentelemetry/contrib-test-utils": "^0.32.0", "@opentelemetry/sdk-trace-base": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json b/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json index 76791f9f1d..e343b6395a 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/package.json @@ -50,7 +50,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json b/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json index 4a4524030a..18668bee7e 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/package.json @@ -62,7 +62,7 @@ "@opentelemetry/contrib-test-utils": "^0.32.0", "@opentelemetry/sdk-trace-base": "^1.3.1", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.6", "aws-sdk": "2.1008.0", "eslint": "8.7.0", diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/package.json b/plugins/node/opentelemetry-instrumentation-bunyan/package.json index 1084870ef0..2703a84807 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/package.json +++ b/plugins/node/opentelemetry-instrumentation-bunyan/package.json @@ -52,7 +52,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "bunyan": "1.8.15", "gts": "3.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/package.json b/plugins/node/opentelemetry-instrumentation-cassandra/package.json index 48329ebc9f..80ae3b037b 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/package.json +++ b/plugins/node/opentelemetry-instrumentation-cassandra/package.json @@ -52,7 +52,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/semver": "7.3.8", "@types/sinon": "10.0.2", "cassandra-driver": "4.6.3", diff --git a/plugins/node/opentelemetry-instrumentation-connect/package.json b/plugins/node/opentelemetry-instrumentation-connect/package.json index 7f47e08600..540defb34a 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/package.json +++ b/plugins/node/opentelemetry-instrumentation-connect/package.json @@ -49,7 +49,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "connect": "3.7.0", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-dns/package.json b/plugins/node/opentelemetry-instrumentation-dns/package.json index 07ecd28586..d9aae48dea 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/package.json +++ b/plugins/node/opentelemetry-instrumentation-dns/package.json @@ -50,7 +50,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/semver": "7.3.8", "@types/shimmer": "1.0.2", "@types/sinon": "10.0.2", diff --git a/plugins/node/opentelemetry-instrumentation-express/package.json b/plugins/node/opentelemetry-instrumentation-express/package.json index 30de0ef155..db9c1a1637 100644 --- a/plugins/node/opentelemetry-instrumentation-express/package.json +++ b/plugins/node/opentelemetry-instrumentation-express/package.json @@ -53,7 +53,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.9", "express": "4.17.1", "gts": "3.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-fastify/package.json b/plugins/node/opentelemetry-instrumentation-fastify/package.json index 5f73d37d80..c7bf493baf 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/package.json +++ b/plugins/node/opentelemetry-instrumentation-fastify/package.json @@ -53,7 +53,7 @@ "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/express": "4.17.13", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "gts": "3.1.0", "fastify": "^4.5.3", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-generic-pool/package.json b/plugins/node/opentelemetry-instrumentation-generic-pool/package.json index 487e433fb8..20c5add2c7 100644 --- a/plugins/node/opentelemetry-instrumentation-generic-pool/package.json +++ b/plugins/node/opentelemetry-instrumentation-generic-pool/package.json @@ -50,7 +50,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/semver": "7.3.8", "generic-pool": "3.8.2", "gts": "3.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-graphql/package.json b/plugins/node/opentelemetry-instrumentation-graphql/package.json index 31ec14494e..3f50d1465d 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/package.json +++ b/plugins/node/opentelemetry-instrumentation-graphql/package.json @@ -52,7 +52,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/semantic-conventions": "^1.3.1", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "graphql": "^16.5.0", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-hapi/package.json b/plugins/node/opentelemetry-instrumentation-hapi/package.json index 7ca6cc05fb..70d62dfd75 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/package.json +++ b/plugins/node/opentelemetry-instrumentation-hapi/package.json @@ -51,7 +51,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/package.json b/plugins/node/opentelemetry-instrumentation-ioredis/package.json index e8dfb06e1f..86cfd2ce52 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/package.json +++ b/plugins/node/opentelemetry-instrumentation-ioredis/package.json @@ -57,7 +57,7 @@ "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", "@types/sinon": "10.0.9", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "cross-env": "7.0.3", "gts": "3.1.0", "ioredis": "4.27.7", diff --git a/plugins/node/opentelemetry-instrumentation-knex/package.json b/plugins/node/opentelemetry-instrumentation-knex/package.json index 4ad242bd12..70d8eaf99a 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/package.json +++ b/plugins/node/opentelemetry-instrumentation-knex/package.json @@ -50,7 +50,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "gts": "3.1.0", "knex": "0.95.9", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-koa/package.json b/plugins/node/opentelemetry-instrumentation-koa/package.json index dc55af90a4..15e1298a3b 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/package.json +++ b/plugins/node/opentelemetry-instrumentation-koa/package.json @@ -55,7 +55,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.9", "gts": "3.1.0", "koa": "2.13.1", diff --git a/plugins/node/opentelemetry-instrumentation-memcached/package.json b/plugins/node/opentelemetry-instrumentation-memcached/package.json index 219837e037..d663bae15c 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/package.json +++ b/plugins/node/opentelemetry-instrumentation-memcached/package.json @@ -53,7 +53,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "cross-env": "7.0.3", "gts": "3.1.0", "memcached": "2.2.2", diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/package.json b/plugins/node/opentelemetry-instrumentation-mongodb/package.json index f3cc1f3f47..140a5656b3 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/package.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/package.json @@ -56,7 +56,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "gts": "3.1.0", "mocha": "7.2.0", "mongodb": "3.6.11", diff --git a/plugins/node/opentelemetry-instrumentation-mysql/package.json b/plugins/node/opentelemetry-instrumentation-mysql/package.json index 7f20c7c3ce..5b64b88541 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/package.json +++ b/plugins/node/opentelemetry-instrumentation-mysql/package.json @@ -51,7 +51,7 @@ "@opentelemetry/contrib-test-utils": "^0.32.0", "@opentelemetry/sdk-trace-base": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.13", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/package.json b/plugins/node/opentelemetry-instrumentation-mysql2/package.json index d3046e5fcd..cca6363ef7 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/package.json +++ b/plugins/node/opentelemetry-instrumentation-mysql2/package.json @@ -53,7 +53,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@types/mocha": "7.0.2", "@types/mysql2": "github:types/mysql2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/semver": "7.3.8", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/package.json b/plugins/node/opentelemetry-instrumentation-nestjs-core/package.json index e3083c202b..a6fd2ddc73 100644 --- a/plugins/node/opentelemetry-instrumentation-nestjs-core/package.json +++ b/plugins/node/opentelemetry-instrumentation-nestjs-core/package.json @@ -58,7 +58,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/semver": "7.3.8", "@types/vinyl-fs": "2.4.12", "cross-env": "7.0.3", diff --git a/plugins/node/opentelemetry-instrumentation-net/package.json b/plugins/node/opentelemetry-instrumentation-net/package.json index be30162492..66b72e8e7e 100644 --- a/plugins/node/opentelemetry-instrumentation-net/package.json +++ b/plugins/node/opentelemetry-instrumentation-net/package.json @@ -50,7 +50,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-pg/package.json b/plugins/node/opentelemetry-instrumentation-pg/package.json index 25d01df335..8a52b46fa0 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/package.json +++ b/plugins/node/opentelemetry-instrumentation-pg/package.json @@ -59,7 +59,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "cross-env": "7.0.3", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-pino/package.json b/plugins/node/opentelemetry-instrumentation-pino/package.json index 1dab60e0b3..bbf1c6f169 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/package.json +++ b/plugins/node/opentelemetry-instrumentation-pino/package.json @@ -52,7 +52,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/semver": "7.3.8", "@types/sinon": "10.0.2", "gts": "3.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/package.json b/plugins/node/opentelemetry-instrumentation-redis-4/package.json index 465220b119..d1f3a22052 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/package.json +++ b/plugins/node/opentelemetry-instrumentation-redis-4/package.json @@ -58,7 +58,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "cross-env": "7.0.3", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-redis/package.json b/plugins/node/opentelemetry-instrumentation-redis/package.json index 995b88f5e0..8ec1142ae8 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/package.json +++ b/plugins/node/opentelemetry-instrumentation-redis/package.json @@ -58,7 +58,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "cross-env": "7.0.3", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/node/opentelemetry-instrumentation-restify/package.json b/plugins/node/opentelemetry-instrumentation-restify/package.json index 0a3c8b99bf..8ea86c487b 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/package.json +++ b/plugins/node/opentelemetry-instrumentation-restify/package.json @@ -51,7 +51,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/restify": "4.3.8", "@types/semver": "^7.3.12", "gts": "3.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-router/package.json b/plugins/node/opentelemetry-instrumentation-router/package.json index 671bc28c94..ec56fe2d39 100644 --- a/plugins/node/opentelemetry-instrumentation-router/package.json +++ b/plugins/node/opentelemetry-instrumentation-router/package.json @@ -50,7 +50,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "gts": "3.1.0", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/plugins/node/opentelemetry-instrumentation-winston/package.json b/plugins/node/opentelemetry-instrumentation-winston/package.json index c14e8c2193..9309d847de 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/package.json +++ b/plugins/node/opentelemetry-instrumentation-winston/package.json @@ -52,7 +52,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@opentelemetry/sdk-trace-node": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/plugins/web/opentelemetry-instrumentation-document-load/package.json b/plugins/web/opentelemetry-instrumentation-document-load/package.json index a801a8232d..40354f52ba 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/package.json +++ b/plugins/web/opentelemetry-instrumentation-document-load/package.json @@ -53,7 +53,7 @@ "@babel/core": "7.15.0", "@opentelemetry/api": "^1.0.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", diff --git a/plugins/web/opentelemetry-instrumentation-long-task/package.json b/plugins/web/opentelemetry-instrumentation-long-task/package.json index c10f9620af..d930c5b2df 100644 --- a/plugins/web/opentelemetry-instrumentation-long-task/package.json +++ b/plugins/web/opentelemetry-instrumentation-long-task/package.json @@ -52,7 +52,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@types/jquery": "3.5.6", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json index 97ac28c08f..0c98369713 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/package.json +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/package.json @@ -54,7 +54,7 @@ "@opentelemetry/sdk-trace-base": "^1.3.1", "@types/jquery": "3.5.6", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/sinon": "10.0.2", "@types/webpack-env": "1.16.2", "babel-loader": "8.2.2", diff --git a/plugins/web/opentelemetry-plugin-react-load/package.json b/plugins/web/opentelemetry-plugin-react-load/package.json index 93f8d305d6..4b1c817e1f 100644 --- a/plugins/web/opentelemetry-plugin-react-load/package.json +++ b/plugins/web/opentelemetry-plugin-react-load/package.json @@ -51,7 +51,7 @@ "@opentelemetry/api": "^1.0.0", "@opentelemetry/propagator-b3": "^1.3.1", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/react": "17.0.16", "@types/react-addons-test-utils": "0.14.26", "@types/react-dom": "18.0.2", diff --git a/propagators/opentelemetry-propagator-aws-xray/package.json b/propagators/opentelemetry-propagator-aws-xray/package.json index c3c6e3d9f0..36609b71b6 100644 --- a/propagators/opentelemetry-propagator-aws-xray/package.json +++ b/propagators/opentelemetry-propagator-aws-xray/package.json @@ -50,7 +50,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/webpack-env": "1.16.2", "gts": "3.1.0", "@jsdevtools/coverage-istanbul-loader": "3.0.5", diff --git a/propagators/opentelemetry-propagator-grpc-census-binary/package.json b/propagators/opentelemetry-propagator-grpc-census-binary/package.json index 9f70884dc6..289d486335 100644 --- a/propagators/opentelemetry-propagator-grpc-census-binary/package.json +++ b/propagators/opentelemetry-propagator-grpc-census-binary/package.json @@ -47,7 +47,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0", "@types/mocha": "7.0.2", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "grpc": "1.24.11", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/propagators/opentelemetry-propagator-instana/package.json b/propagators/opentelemetry-propagator-instana/package.json index c3d8c6718f..9e48535f19 100644 --- a/propagators/opentelemetry-propagator-instana/package.json +++ b/propagators/opentelemetry-propagator-instana/package.json @@ -52,7 +52,7 @@ "@jsdevtools/coverage-istanbul-loader": "3.0.5", "@opentelemetry/api": "^1.0.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/webpack-env": "1.16.2", "assert": "2.0.0", "gts": "3.1.0", diff --git a/propagators/opentelemetry-propagator-ot-trace/package.json b/propagators/opentelemetry-propagator-ot-trace/package.json index 2c8c604b68..56290292f9 100644 --- a/propagators/opentelemetry-propagator-ot-trace/package.json +++ b/propagators/opentelemetry-propagator-ot-trace/package.json @@ -51,7 +51,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0", "@types/mocha": "8.2.3", - "@types/node": "16.11.21", + "@types/node": "18.11.7", "@types/webpack-env": "1.16.2", "gts": "3.1.0", "@jsdevtools/coverage-istanbul-loader": "3.0.5", From 1db3b7e7aa15fc0759264535752b771abff81feb Mon Sep 17 00:00:00 2001 From: Damien Mathieu <42@dmathieu.com> Date: Sun, 30 Oct 2022 09:41:28 +0100 Subject: [PATCH 4/5] fix: allow hapi plugin from array to be registered as argument (#1253) --- .../src/instrumentation.ts | 2 +- .../test/hapi-plugin.test.ts | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts index b3a53cc9d4..17071a2cfc 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts @@ -149,7 +149,7 @@ export class HapiInstrumentation extends InstrumentationBase { if (Array.isArray(pluginInput)) { for (const pluginObj of pluginInput) { instrumentation._wrapRegisterHandler( - pluginObj.plugin?.plugin ?? pluginObj.plugin + pluginObj.plugin?.plugin ?? pluginObj.plugin ?? pluginObj ); } } else { diff --git a/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-plugin.test.ts b/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-plugin.test.ts index 6118445777..459090abd8 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-plugin.test.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-plugin.test.ts @@ -228,6 +228,64 @@ describe('Hapi Instrumentation - Hapi.Plugin Tests', () => { ); }); + it('should create spans for routes across multiple plugins declared in attribute level', async () => { + const rootSpan = tracer.startSpan('rootSpan'); + + await server.register([packagePlugin, simplePlugin]); + await server.start(); + assert.strictEqual(memoryExporter.getFinishedSpans().length, 0); + + await context.with( + trace.setSpan(context.active(), rootSpan), + async () => { + const res1 = await server.inject({ + method: 'GET', + url: '/package', + }); + assert.strictEqual(res1.statusCode, 200); + const res2 = await server.inject({ + method: 'GET', + url: '/hello', + }); + assert.strictEqual(res2.statusCode, 200); + + rootSpan.end(); + + assert.deepStrictEqual(memoryExporter.getFinishedSpans().length, 3); + + const firstHandlerSpan = memoryExporter + .getFinishedSpans() + .find(span => span.name === 'plugin-by-package: route - /package'); + assert.notStrictEqual(firstHandlerSpan, undefined); + assert.strictEqual( + firstHandlerSpan?.attributes[AttributeNames.HAPI_TYPE], + HapiLayerType.PLUGIN + ); + assert.strictEqual( + firstHandlerSpan?.attributes[AttributeNames.PLUGIN_NAME], + 'plugin-by-package' + ); + const secondHandlerSpan = memoryExporter + .getFinishedSpans() + .find(span => span.name === 'simplePlugin: route - /hello'); + assert.notStrictEqual(secondHandlerSpan, undefined); + assert.strictEqual( + secondHandlerSpan?.attributes[AttributeNames.HAPI_TYPE], + HapiLayerType.PLUGIN + ); + assert.strictEqual( + secondHandlerSpan?.attributes[AttributeNames.PLUGIN_NAME], + 'simplePlugin' + ); + + const exportedRootSpan = memoryExporter + .getFinishedSpans() + .find(span => span.name === 'rootSpan'); + assert.notStrictEqual(exportedRootSpan, undefined); + } + ); + }); + it('should instrument multiple versions of the same plugin just once', async () => { const rootSpan = tracer.startSpan('rootSpan'); From e72ea58cfb888a90590970f63d3a042a8ea3aaf2 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Sun, 30 Oct 2022 12:13:08 +0200 Subject: [PATCH 5/5] fix: separate public and internal types for all instrumentations (#1251) --- GUIDELINES.md | 41 ++++++ .../instrumentation-dataloader/src/index.ts | 2 +- plugins/node/instrumentation-fs/src/index.ts | 8 +- .../node/instrumentation-tedious/src/index.ts | 2 +- .../src/index.ts | 6 +- .../src/instrumentation.ts | 7 +- .../src/internal-types.ts} | 3 + .../src/types.ts | 4 +- .../src/index.ts | 1 + .../src/index.ts | 2 +- .../src/index.ts | 1 - .../src/instrumentation.ts | 2 +- .../src/{types.ts => internal-types.ts} | 0 .../src/index.ts | 2 +- .../src/instrumentation.ts | 8 +- .../src/internal-types.ts | 93 +++++++++++++ .../src/types.ts | 79 ----------- .../src/index.ts | 5 +- .../src/instrumentation.ts | 22 ++-- .../src/internal-types.ts | 72 ++++++++++ .../src/types.ts | 51 +------- .../src/utils.ts | 9 +- .../test/utils.test.ts | 3 +- .../src/instrumentation.ts | 2 +- .../src/{types.ts => internal-types.ts} | 0 .../src/utils.ts | 2 +- .../src/index.ts | 5 +- .../src/instrumentation.ts | 4 +- .../src/internal-types.ts | 123 ++++++++++++++++++ .../src/types.ts | 103 --------------- .../src/utils.ts | 4 +- .../src/index.ts | 1 + .../src/instrumentation.ts | 5 +- .../src/{types.ts => internal-types.ts} | 7 +- .../src/utils.ts | 2 +- .../test/hapi-plugin.test.ts | 2 +- .../test/hapi-server-ext.test.ts | 2 +- .../test/hapi.test.ts | 2 +- .../src/index.ts | 2 +- .../src/index.ts | 2 +- .../src/index.ts | 2 + .../src/instrumentation.ts | 9 +- .../src/internal-types.ts | 28 ++++ .../src/types.ts | 23 +--- .../src/index.ts | 2 +- .../src/index.ts | 6 +- .../src/index.ts | 2 +- .../src/index.ts | 2 +- .../src/index.ts | 2 + .../src/index.ts | 1 + .../src/instrumentation.ts | 3 +- .../src/internal-types.ts | 32 +++++ .../src/types.ts | 17 --- .../src/utils.ts | 2 +- .../test/connect.test.ts | 2 +- .../test/tls.test.ts | 2 +- .../src/index.ts | 7 +- .../src/instrumentation.ts | 8 +- .../src/internal-types.ts | 64 +++++++++ .../src/types.ts | 49 +------ .../src/utils.ts | 6 +- .../test/utils.test.ts | 2 +- .../src/index.ts | 1 + .../src/index.ts | 2 +- .../src/index.ts | 2 +- .../src/internal-types.ts | 23 ++++ .../src/types.ts | 9 -- .../src/utils.ts | 2 +- .../src/index.ts | 2 + .../src/instrumentation.ts | 6 +- .../src/{types.ts => internal-types.ts} | 0 .../test/restify.test.ts | 2 +- .../src/index.ts | 2 + .../src/instrumentation.ts | 2 +- .../src/{types.ts => internal-types.ts} | 0 .../src/utils.ts | 2 +- .../test/index.test.ts | 2 +- .../src/index.ts | 1 + .../src/index.ts | 1 + .../src/index.ts | 1 + .../src/index.ts | 2 + .../src/instrumentation.ts | 10 +- .../src/internal-types.ts | 64 +++++++++ .../src/types.ts | 48 +------ .../test/userInteraction.test.ts | 6 +- .../src/BaseOpenTelemetryComponent.ts | 2 +- .../src/index.ts | 1 + .../src/{types.ts => internal-types.ts} | 0 88 files changed, 666 insertions(+), 489 deletions(-) create mode 100644 GUIDELINES.md rename plugins/node/{opentelemetry-instrumentation-pg/src/enums.ts => opentelemetry-instrumentation-aws-lambda/src/internal-types.ts} (86%) rename plugins/node/opentelemetry-instrumentation-connect/src/{types.ts => internal-types.ts} (100%) create mode 100644 plugins/node/opentelemetry-instrumentation-dns/src/internal-types.ts create mode 100644 plugins/node/opentelemetry-instrumentation-express/src/internal-types.ts rename plugins/node/opentelemetry-instrumentation-fastify/src/{types.ts => internal-types.ts} (100%) create mode 100644 plugins/node/opentelemetry-instrumentation-graphql/src/internal-types.ts rename plugins/node/opentelemetry-instrumentation-hapi/src/{types.ts => internal-types.ts} (93%) create mode 100644 plugins/node/opentelemetry-instrumentation-koa/src/internal-types.ts create mode 100644 plugins/node/opentelemetry-instrumentation-net/src/internal-types.ts create mode 100644 plugins/node/opentelemetry-instrumentation-pg/src/internal-types.ts create mode 100644 plugins/node/opentelemetry-instrumentation-redis/src/internal-types.ts rename plugins/node/opentelemetry-instrumentation-restify/src/{types.ts => internal-types.ts} (100%) rename plugins/node/opentelemetry-instrumentation-router/src/{types.ts => internal-types.ts} (100%) create mode 100644 plugins/web/opentelemetry-instrumentation-user-interaction/src/internal-types.ts rename plugins/web/opentelemetry-plugin-react-load/src/{types.ts => internal-types.ts} (100%) diff --git a/GUIDELINES.md b/GUIDELINES.md new file mode 100644 index 0000000000..42e4478421 --- /dev/null +++ b/GUIDELINES.md @@ -0,0 +1,41 @@ +# Instrumentations Implementation Guide + +This document captures general guidelines for implementing instrumentations in NodeJS and browser. + +## Types + +### Public Types + +Public types are meant to be consumed by instrumentation users (OpenTelemetry distribution packages or end users implementing OpenTelemetry in their services). These are mostly instrumentation specific config interface (extending `InstrumentationConfig`) and the transitive types used in the config. + +#### File Name + +These typescript `interface`s, `type`s, `enum`s and js `const`ants statements SHOULD be placed in a file named `types.ts`. This file SHOULD contain only public types that are needed for instrumentation users. + +#### Exporting + +All types from `types.ts` file MUST be exported from instrumentation `index.ts` using export statement `export * from './types'`, which guarentee that they publicly available. + +#### Breaking Changes + +Since these types are publicly exported, a breaking change in this file can cause transpilation issues or require code changes for existing users. Special care and attention should be put when modifiying this file to guarantee backword compatibility or proper documentation of breaking changes. + +### Internal Types + +All types and constants that instrumentation needs internally to implement the instrumentation logic. This can include extensions to instrumented package interfaces (for example - when adding data to existing objects), symbols for patches, enums etc. + +#### File Name + +It is sometimes convenient to place these declarations in a dedicated file which can then be imported from various instrumentation files such as `instrumentation.ts`, `utils.ts` or test files. + +The file SHOULD be named `internal-types.ts`. + +Using this file is optional - when a type is used only in a single file, it is ok to declare it and use it in this file **without exporting it**. When a type is expected to be shared between multiple files, it is encourged to be declared in `internal-types.ts` to prevent circular dependencies. + +#### Exporting + +This file MUST NOT be exported publicly from instrumentation package, not directly (via `index.ts`) and not transitivly via export of other files. + +#### Changes + +Since the declarations in this file are not exported in the public instrumentation api, it is allowed to apply any refactors to this file, and they will not be breaking changes to users. diff --git a/plugins/node/instrumentation-dataloader/src/index.ts b/plugins/node/instrumentation-dataloader/src/index.ts index 6725a11566..400b81745a 100644 --- a/plugins/node/instrumentation-dataloader/src/index.ts +++ b/plugins/node/instrumentation-dataloader/src/index.ts @@ -14,5 +14,5 @@ * limitations under the License. */ -export { DataloaderInstrumentationConfig } from './types'; +export * from './types'; export { DataloaderInstrumentation } from './instrumentation'; diff --git a/plugins/node/instrumentation-fs/src/index.ts b/plugins/node/instrumentation-fs/src/index.ts index a5d5e04e00..27e4d2717e 100644 --- a/plugins/node/instrumentation-fs/src/index.ts +++ b/plugins/node/instrumentation-fs/src/index.ts @@ -19,12 +19,6 @@ import FsInstrumentation from './instrumentation'; export { FsInstrumentation }; export * from './instrumentation'; -export { - FMember, - FPMember, - CreateHook, - EndHook, - FsInstrumentationConfig, -} from './types'; +export * from './types'; export default FsInstrumentation; diff --git a/plugins/node/instrumentation-tedious/src/index.ts b/plugins/node/instrumentation-tedious/src/index.ts index 6f2dd724b7..add054c2a8 100644 --- a/plugins/node/instrumentation-tedious/src/index.ts +++ b/plugins/node/instrumentation-tedious/src/index.ts @@ -19,4 +19,4 @@ import { TediousInstrumentation } from './instrumentation'; export * from './instrumentation'; export default TediousInstrumentation; -export { TediousInstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/index.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/index.ts index cbb9f4f5b9..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/index.ts @@ -15,8 +15,4 @@ */ export * from './instrumentation'; -export { - AwsLambdaInstrumentationConfig, - RequestHook, - ResponseHook, -} from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts index f8d0c52289..76d4410240 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts @@ -53,12 +53,9 @@ import { Handler, } from 'aws-lambda'; -import { - LambdaModule, - AwsLambdaInstrumentationConfig, - EventContextExtractor, -} from './types'; +import { AwsLambdaInstrumentationConfig, EventContextExtractor } from './types'; import { VERSION } from './version'; +import { LambdaModule } from './internal-types'; const awsPropagator = new AWSXRayPropagator(); const headerGetter: TextMapGetter = { diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/enums.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/internal-types.ts similarity index 86% rename from plugins/node/opentelemetry-instrumentation-pg/src/enums.ts rename to plugins/node/opentelemetry-instrumentation-aws-lambda/src/internal-types.ts index bcd7cadc04..55a387e39a 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/enums.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/internal-types.ts @@ -13,3 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Handler } from 'aws-lambda'; + +export type LambdaModule = Record; diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/types.ts b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/types.ts index 5ff557aead..da507efc09 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/src/types.ts @@ -16,9 +16,7 @@ import { Span, Context as OtelContext } from '@opentelemetry/api'; import { InstrumentationConfig } from '@opentelemetry/instrumentation'; -import { Handler, Context } from 'aws-lambda'; - -export type LambdaModule = Record; +import type { Context } from 'aws-lambda'; export type RequestHook = ( span: Span, diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/index.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/index.ts index 24c76056a1..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/index.ts @@ -15,3 +15,4 @@ */ export * from './instrumentation'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/index.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/index.ts index 175fc1f262..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/index.ts @@ -15,4 +15,4 @@ */ export * from './instrumentation'; -export { CassandraDriverInstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-connect/src/index.ts b/plugins/node/opentelemetry-instrumentation-connect/src/index.ts index 16b659dde3..34b600dd0c 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-connect/src/index.ts @@ -16,4 +16,3 @@ export * from './enums/AttributeNames'; export * from './instrumentation'; -export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts index 99425cd7ea..5e2d28584e 100644 --- a/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-connect/src/instrumentation.ts @@ -23,7 +23,7 @@ import { ConnectNames, ConnectTypes, } from './enums/AttributeNames'; -import { Use, UseArgs, UseArgs2 } from './types'; +import { Use, UseArgs, UseArgs2 } from './internal-types'; import { VERSION } from './version'; import { InstrumentationBase, diff --git a/plugins/node/opentelemetry-instrumentation-connect/src/types.ts b/plugins/node/opentelemetry-instrumentation-connect/src/internal-types.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-connect/src/types.ts rename to plugins/node/opentelemetry-instrumentation-connect/src/internal-types.ts diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/index.ts b/plugins/node/opentelemetry-instrumentation-dns/src/index.ts index f5ac075040..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/index.ts @@ -15,4 +15,4 @@ */ export * from './instrumentation'; -export { DnsInstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts index d47cf7565b..9a057ca0bd 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/instrumentation.ts @@ -24,14 +24,14 @@ import { } from '@opentelemetry/instrumentation'; import * as semver from 'semver'; import { AddressFamily } from './enums/AddressFamily'; +import { DnsInstrumentationConfig } from './types'; +import * as utils from './utils'; +import { VERSION } from './version'; import { Dns, - DnsInstrumentationConfig, LookupCallbackSignature, LookupPromiseSignature, -} from './types'; -import * as utils from './utils'; -import { VERSION } from './version'; +} from './internal-types'; /** * Dns instrumentation for Opentelemetry diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-dns/src/internal-types.ts new file mode 100644 index 0000000000..e3ae4e0f55 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-dns/src/internal-types.ts @@ -0,0 +1,93 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type * as dns from 'dns'; + +export type Dns = typeof dns; + +export type LookupFunction = (( + hostname: string, + family: number, + callback: LookupSimpleCallback +) => void) & + (( + hostname: string, + options: dns.LookupOneOptions, + callback: LookupSimpleCallback + ) => void) & + (( + hostname: string, + options: dns.LookupAllOptions, + callback: ( + err: NodeJS.ErrnoException | null, + addresses: dns.LookupAddress[] + ) => void + ) => void) & + (( + hostname: string, + options: dns.LookupOptions, + callback: ( + err: NodeJS.ErrnoException | null, + address: string | dns.LookupAddress[], + family: number + ) => void + ) => void) & + ((hostname: string, callback: LookupSimpleCallback) => void); + +export type LookupSimpleArgs = [number, LookupSimpleCallback]; +export type LookupOneArgs = [dns.LookupOneOptions, LookupSimpleCallback]; +export type LookupAllArgs = [ + dns.LookupAllOptions, + (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void +]; +export type LookupArgs = [ + dns.LookupOptions, + ( + err: NodeJS.ErrnoException | null, + address: string | dns.LookupAddress[], + family: number + ) => void +]; +export type LookupArgSignature = LookupSimpleArgs & + LookupSimpleCallback & + LookupOneArgs & + LookupAllArgs & + LookupArgs; + +export type LookupFunctionSignature = ( + hostname: string, + args: Array +) => void; +export type LookupPromiseSignature = ( + hostname: string, + ...args: unknown[] +) => Promise; +export type LookupSimpleCallback = ( + err: NodeJS.ErrnoException | null, + address: string, + family: number +) => void; + +export type LookupCallbackSignature = LookupSimpleCallback & + (( + err: NodeJS.ErrnoException | null, + addresses: dns.LookupAddress[] + ) => void) & + (( + err: NodeJS.ErrnoException | null, + address: string | dns.LookupAddress[], + family: number + ) => void); diff --git a/plugins/node/opentelemetry-instrumentation-dns/src/types.ts b/plugins/node/opentelemetry-instrumentation-dns/src/types.ts index 70f4f6d54e..10383813d1 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-dns/src/types.ts @@ -13,88 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -import type * as dns from 'dns'; import { InstrumentationConfig } from '@opentelemetry/instrumentation'; -export type Dns = typeof dns; - export type IgnoreMatcher = string | RegExp | ((url: string) => boolean); - -export type LookupFunction = (( - hostname: string, - family: number, - callback: LookupSimpleCallback -) => void) & - (( - hostname: string, - options: dns.LookupOneOptions, - callback: LookupSimpleCallback - ) => void) & - (( - hostname: string, - options: dns.LookupAllOptions, - callback: ( - err: NodeJS.ErrnoException | null, - addresses: dns.LookupAddress[] - ) => void - ) => void) & - (( - hostname: string, - options: dns.LookupOptions, - callback: ( - err: NodeJS.ErrnoException | null, - address: string | dns.LookupAddress[], - family: number - ) => void - ) => void) & - ((hostname: string, callback: LookupSimpleCallback) => void); - -export type LookupSimpleArgs = [number, LookupSimpleCallback]; -export type LookupOneArgs = [dns.LookupOneOptions, LookupSimpleCallback]; -export type LookupAllArgs = [ - dns.LookupAllOptions, - (err: NodeJS.ErrnoException | null, addresses: dns.LookupAddress[]) => void -]; -export type LookupArgs = [ - dns.LookupOptions, - ( - err: NodeJS.ErrnoException | null, - address: string | dns.LookupAddress[], - family: number - ) => void -]; -export type LookupArgSignature = LookupSimpleArgs & - LookupSimpleCallback & - LookupOneArgs & - LookupAllArgs & - LookupArgs; - -export type LookupFunctionSignature = ( - hostname: string, - args: Array -) => void; -export type LookupPromiseSignature = ( - hostname: string, - ...args: unknown[] -) => Promise; -export type LookupSimpleCallback = ( - err: NodeJS.ErrnoException | null, - address: string, - family: number -) => void; - -export type LookupCallbackSignature = LookupSimpleCallback & - (( - err: NodeJS.ErrnoException | null, - addresses: dns.LookupAddress[] - ) => void) & - (( - err: NodeJS.ErrnoException | null, - address: string | dns.LookupAddress[], - family: number - ) => void); - export interface DnsInstrumentationConfig extends InstrumentationConfig { ignoreHostnames?: IgnoreMatcher[]; } diff --git a/plugins/node/opentelemetry-instrumentation-express/src/index.ts b/plugins/node/opentelemetry-instrumentation-express/src/index.ts index d5f1ff3bc5..79da17f7d5 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/index.ts @@ -15,5 +15,6 @@ */ export * from './instrumentation'; -export { ExpressLayerType } from './enums/ExpressLayerType'; -export { ExpressInstrumentationConfig } from './types'; +export * from './enums/ExpressLayerType'; +export * from './enums/AttributeNames'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts index f728bd5f80..2fda3891fd 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts @@ -17,14 +17,7 @@ import { setRPCMetadata, getRPCMetadata, RPCType } from '@opentelemetry/core'; import { trace, context, diag, SpanAttributes } from '@opentelemetry/api'; import type * as express from 'express'; -import { - ExpressLayer, - ExpressRouter, - PatchedRequest, - _LAYERS_STORE_PROPERTY, - ExpressInstrumentationConfig, - ExpressRequestInfo, -} from './types'; +import { ExpressInstrumentationConfig, ExpressRequestInfo } from './types'; import { ExpressLayerType } from './enums/ExpressLayerType'; import { AttributeNames } from './enums/AttributeNames'; import { getLayerMetadata, storeLayerPath, isLayerIgnored } from './utils'; @@ -36,12 +29,13 @@ import { safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; - -/** - * This symbol is used to mark express layer as being already instrumented - * since its possible to use a given layer multiple times (ex: middlewares) - */ -export const kLayerPatched: unique symbol = Symbol('express-layer-patched'); +import { + ExpressLayer, + ExpressRouter, + kLayerPatched, + PatchedRequest, + _LAYERS_STORE_PROPERTY, +} from './internal-types'; /** Express instrumentation for OpenTelemetry */ export class ExpressInstrumentation extends InstrumentationBase< diff --git a/plugins/node/opentelemetry-instrumentation-express/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-express/src/internal-types.ts new file mode 100644 index 0000000000..ab53fc37e7 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-express/src/internal-types.ts @@ -0,0 +1,72 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type { Request } from 'express'; +import { SpanAttributes } from '@opentelemetry/api'; + +/** + * This symbol is used to mark express layer as being already instrumented + * since its possible to use a given layer multiple times (ex: middlewares) + */ +export const kLayerPatched: unique symbol = Symbol('express-layer-patched'); + +/** + * This const define where on the `request` object the Instrumentation will mount the + * current stack of express layer. + * + * It is necessary because express doesnt store the different layers + * (ie: middleware, router etc) that it called to get to the current layer. + * Given that, the only way to know the route of a given layer is to + * store the path of where each previous layer has been mounted. + * + * ex: bodyParser > auth middleware > /users router > get /:id + * in this case the stack would be: ["/users", "/:id"] + * + * ex2: bodyParser > /api router > /v1 router > /users router > get /:id + * stack: ["/api", "/v1", "/users", ":id"] + * + */ +export const _LAYERS_STORE_PROPERTY = '__ot_middlewares'; + +export type PatchedRequest = { + [_LAYERS_STORE_PROPERTY]?: string[]; +} & Request; +export type PathParams = string | RegExp | Array; + +// https://github.com/expressjs/express/blob/main/lib/router/index.js#L53 +export type ExpressRouter = { + params: { [key: string]: string }; + _params: string[]; + caseSensitive: boolean; + mergeParams: boolean; + strict: boolean; + stack: ExpressLayer[]; +}; + +// https://github.com/expressjs/express/blob/main/lib/router/layer.js#L33 +export type ExpressLayer = { + handle: Function; + [kLayerPatched]?: boolean; + name: string; + params: { [key: string]: string }; + path: string; + regexp: RegExp; +}; + +export type LayerMetadata = { + attributes: SpanAttributes; + name: string; +}; diff --git a/plugins/node/opentelemetry-instrumentation-express/src/types.ts b/plugins/node/opentelemetry-instrumentation-express/src/types.ts index 0c1f922f13..d8498e3b93 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/types.ts @@ -14,60 +14,11 @@ * limitations under the License. */ -import { kLayerPatched } from './'; import type { Request } from 'express'; -import { Span, SpanAttributes } from '@opentelemetry/api'; +import { Span } from '@opentelemetry/api'; import { InstrumentationConfig } from '@opentelemetry/instrumentation'; import { ExpressLayerType } from './enums/ExpressLayerType'; -/** - * This const define where on the `request` object the Instrumentation will mount the - * current stack of express layer. - * - * It is necessary because express doesnt store the different layers - * (ie: middleware, router etc) that it called to get to the current layer. - * Given that, the only way to know the route of a given layer is to - * store the path of where each previous layer has been mounted. - * - * ex: bodyParser > auth middleware > /users router > get /:id - * in this case the stack would be: ["/users", "/:id"] - * - * ex2: bodyParser > /api router > /v1 router > /users router > get /:id - * stack: ["/api", "/v1", "/users", ":id"] - * - */ -export const _LAYERS_STORE_PROPERTY = '__ot_middlewares'; - -export type PatchedRequest = { - [_LAYERS_STORE_PROPERTY]?: string[]; -} & Request; -export type PathParams = string | RegExp | Array; - -// https://github.com/expressjs/express/blob/main/lib/router/index.js#L53 -export type ExpressRouter = { - params: { [key: string]: string }; - _params: string[]; - caseSensitive: boolean; - mergeParams: boolean; - strict: boolean; - stack: ExpressLayer[]; -}; - -// https://github.com/expressjs/express/blob/main/lib/router/layer.js#L33 -export type ExpressLayer = { - handle: Function; - [kLayerPatched]?: boolean; - name: string; - params: { [key: string]: string }; - path: string; - regexp: RegExp; -}; - -export type LayerMetadata = { - attributes: SpanAttributes; - name: string; -}; - export type IgnoreMatcher = string | RegExp | ((name: string) => boolean); export type ExpressRequestInfo = { diff --git a/plugins/node/opentelemetry-instrumentation-express/src/utils.ts b/plugins/node/opentelemetry-instrumentation-express/src/utils.ts index 542e36bc2a..d272434422 100644 --- a/plugins/node/opentelemetry-instrumentation-express/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-express/src/utils.ts @@ -15,15 +15,14 @@ */ import { SpanAttributes } from '@opentelemetry/api'; +import { IgnoreMatcher, ExpressInstrumentationConfig } from './types'; +import { ExpressLayerType } from './enums/ExpressLayerType'; +import { AttributeNames } from './enums/AttributeNames'; import { ExpressLayer, PatchedRequest, _LAYERS_STORE_PROPERTY, - IgnoreMatcher, - ExpressInstrumentationConfig, -} from './types'; -import { ExpressLayerType } from './enums/ExpressLayerType'; -import { AttributeNames } from './enums/AttributeNames'; +} from './internal-types'; /** * Store layers path in the request to be able to construct route later diff --git a/plugins/node/opentelemetry-instrumentation-express/test/utils.test.ts b/plugins/node/opentelemetry-instrumentation-express/test/utils.test.ts index 396eea75e3..e85a677af1 100644 --- a/plugins/node/opentelemetry-instrumentation-express/test/utils.test.ts +++ b/plugins/node/opentelemetry-instrumentation-express/test/utils.test.ts @@ -16,7 +16,8 @@ import * as utils from '../src/utils'; import * as assert from 'assert'; -import { ExpressInstrumentationConfig, ExpressLayer } from '../src/types'; +import { ExpressInstrumentationConfig } from '../src/types'; +import { ExpressLayer } from '../src/internal-types'; import { ExpressLayerType } from '../src/enums/ExpressLayerType'; import { AttributeNames } from '../src/enums/AttributeNames'; diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index b267f03336..6ed80ca648 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -38,7 +38,7 @@ import { FastifyNames, FastifyTypes, } from './enums/AttributeNames'; -import type { HandlerOriginal, PluginFastifyReply } from './types'; +import type { HandlerOriginal, PluginFastifyReply } from './internal-types'; import { endSpan, safeExecuteInTheMiddleMaybePromise, diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/types.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/internal-types.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-fastify/src/types.ts rename to plugins/node/opentelemetry-instrumentation-fastify/src/internal-types.ts diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/utils.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/utils.ts index 45efc3ab75..0ff05492a3 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/utils.ts @@ -22,7 +22,7 @@ import { } from '@opentelemetry/api'; import { spanRequestSymbol } from './constants'; -import type { PluginFastifyReply } from './types'; +import type { PluginFastifyReply } from './internal-types'; /** * Starts Span diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/index.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/index.ts index c03a08a21c..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/index.ts @@ -15,7 +15,4 @@ */ export * from './instrumentation'; -export { - GraphQLInstrumentationExecutionResponseHook, - GraphQLInstrumentationConfig, -} from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts index cec77eefe0..00538a594d 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/instrumentation.ts @@ -34,13 +34,12 @@ import { executeType, parseType, validateType, - GraphQLInstrumentationConfig, GraphQLInstrumentationParsedConfig, OtelExecutionArgs, ObjectWithGraphQLData, OPERATION_NOT_SUPPORTED, Maybe, -} from './types'; +} from './internal-types'; import { addInputVariableAttributes, addSpanSource, @@ -54,6 +53,7 @@ import { import { VERSION } from './version'; import * as api from '@opentelemetry/api'; import type { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue'; +import { GraphQLInstrumentationConfig } from './types'; const DEFAULT_CONFIG: GraphQLInstrumentationConfig = { mergeItems: false, diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/internal-types.ts new file mode 100644 index 0000000000..4fb6b5858d --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/internal-types.ts @@ -0,0 +1,123 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { InstrumentationConfig } from '@opentelemetry/instrumentation'; +import type * as graphqlTypes from 'graphql'; +import type * as api from '@opentelemetry/api'; +import type { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue'; +import { DocumentNode } from 'graphql/language/ast'; +import { + GraphQLFieldResolver, + GraphQLTypeResolver, +} from 'graphql/type/definition'; +import { OTEL_GRAPHQL_DATA_SYMBOL, OTEL_PATCHED_SYMBOL } from './symbols'; +import { GraphQLInstrumentationConfig } from './types'; + +export const OPERATION_NOT_SUPPORTED = + 'Operation$operationName$not' + ' supported'; + +/** + * Merged and parsed config of default instrumentation config and GraphQL + */ +export type GraphQLInstrumentationParsedConfig = + Required & InstrumentationConfig; + +export type executeFunctionWithObj = ( + args: graphqlTypes.ExecutionArgs +) => PromiseOrValue; + +export type executeArgumentsArray = [ + graphqlTypes.GraphQLSchema, + graphqlTypes.DocumentNode, + any, + any, + Maybe<{ [key: string]: any }>, + Maybe, + Maybe>, + Maybe> +]; + +export type executeFunctionWithArgs = ( + schema: graphqlTypes.GraphQLSchema, + document: graphqlTypes.DocumentNode, + rootValue?: any, + contextValue?: any, + variableValues?: Maybe<{ [key: string]: any }>, + operationName?: Maybe, + fieldResolver?: Maybe>, + typeResolver?: Maybe> +) => PromiseOrValue; + +export interface OtelExecutionArgs { + schema: graphqlTypes.GraphQLSchema; + document: DocumentNode & ObjectWithGraphQLData; + rootValue?: any; + contextValue?: any & ObjectWithGraphQLData; + variableValues?: Maybe<{ [key: string]: any }>; + operationName?: Maybe; + fieldResolver?: Maybe & OtelPatched>; + typeResolver?: Maybe>; +} + +export type executeType = executeFunctionWithObj | executeFunctionWithArgs; + +export type parseType = ( + source: string | graphqlTypes.Source, + options?: graphqlTypes.ParseOptions +) => graphqlTypes.DocumentNode; + +export type validateType = ( + schema: graphqlTypes.GraphQLSchema, + documentAST: graphqlTypes.DocumentNode, + rules?: ReadonlyArray, + options?: { maxErrors?: number }, + typeInfo?: graphqlTypes.TypeInfo +) => ReadonlyArray; + +export interface GraphQLField { + parent: api.Span; + span: api.Span; + error: Error | null; +} + +interface OtelGraphQLData { + source?: any; + span: api.Span; + fields: { [key: string]: GraphQLField }; +} + +export interface ObjectWithGraphQLData { + [OTEL_GRAPHQL_DATA_SYMBOL]?: OtelGraphQLData; +} + +export interface OtelPatched { + [OTEL_PATCHED_SYMBOL]?: boolean; +} + +export interface GraphQLPath { + prev: GraphQLPath | undefined; + key: string | number; + /** + * optional as it didn't exist yet in ver 14 + */ + typename?: string | undefined; +} + +/** + * Moving this type from ver 15 of graphql as it is nto available in ver. 14s + * this way it can compile against ver 14. + */ +export type Maybe = null | undefined | T; diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts index f783140bed..56c72a1ad4 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/types.ts @@ -17,16 +17,6 @@ import { InstrumentationConfig } from '@opentelemetry/instrumentation'; import type * as graphqlTypes from 'graphql'; import type * as api from '@opentelemetry/api'; -import type { PromiseOrValue } from 'graphql/jsutils/PromiseOrValue'; -import { DocumentNode } from 'graphql/language/ast'; -import { - GraphQLFieldResolver, - GraphQLTypeResolver, -} from 'graphql/type/definition'; -import { OTEL_GRAPHQL_DATA_SYMBOL, OTEL_PATCHED_SYMBOL } from './symbols'; - -export const OPERATION_NOT_SUPPORTED = - 'Operation$operationName$not' + ' supported'; export interface GraphQLInstrumentationExecutionResponseHook { (span: api.Span, data: graphqlTypes.ExecutionResult): void; @@ -65,96 +55,3 @@ export interface GraphQLInstrumentationConfig extends InstrumentationConfig { */ responseHook?: GraphQLInstrumentationExecutionResponseHook; } - -/** - * Merged and parsed config of default instrumentation config and GraphQL - */ -export type GraphQLInstrumentationParsedConfig = - Required & InstrumentationConfig; - -export type executeFunctionWithObj = ( - args: graphqlTypes.ExecutionArgs -) => PromiseOrValue; - -export type executeArgumentsArray = [ - graphqlTypes.GraphQLSchema, - graphqlTypes.DocumentNode, - any, - any, - Maybe<{ [key: string]: any }>, - Maybe, - Maybe>, - Maybe> -]; - -export type executeFunctionWithArgs = ( - schema: graphqlTypes.GraphQLSchema, - document: graphqlTypes.DocumentNode, - rootValue?: any, - contextValue?: any, - variableValues?: Maybe<{ [key: string]: any }>, - operationName?: Maybe, - fieldResolver?: Maybe>, - typeResolver?: Maybe> -) => PromiseOrValue; - -export interface OtelExecutionArgs { - schema: graphqlTypes.GraphQLSchema; - document: DocumentNode & ObjectWithGraphQLData; - rootValue?: any; - contextValue?: any & ObjectWithGraphQLData; - variableValues?: Maybe<{ [key: string]: any }>; - operationName?: Maybe; - fieldResolver?: Maybe & OtelPatched>; - typeResolver?: Maybe>; -} - -export type executeType = executeFunctionWithObj | executeFunctionWithArgs; - -export type parseType = ( - source: string | graphqlTypes.Source, - options?: graphqlTypes.ParseOptions -) => graphqlTypes.DocumentNode; - -export type validateType = ( - schema: graphqlTypes.GraphQLSchema, - documentAST: graphqlTypes.DocumentNode, - rules?: ReadonlyArray, - options?: { maxErrors?: number }, - typeInfo?: graphqlTypes.TypeInfo -) => ReadonlyArray; - -export interface GraphQLField { - parent: api.Span; - span: api.Span; - error: Error | null; -} - -interface OtelGraphQLData { - source?: any; - span: api.Span; - fields: { [key: string]: GraphQLField }; -} - -export interface ObjectWithGraphQLData { - [OTEL_GRAPHQL_DATA_SYMBOL]?: OtelGraphQLData; -} - -export interface OtelPatched { - [OTEL_PATCHED_SYMBOL]?: boolean; -} - -export interface GraphQLPath { - prev: GraphQLPath | undefined; - key: string | number; - /** - * optional as it didn't exist yet in ver 14 - */ - typename?: string | undefined; -} - -/** - * Moving this type from ver 15 of graphql as it is nto available in ver. 14s - * this way it can compile against ver 14. - */ -export type Maybe = null | undefined | T; diff --git a/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts b/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts index f0af42d9ef..eb05983be9 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/src/utils.ts @@ -22,12 +22,12 @@ import { OTEL_GRAPHQL_DATA_SYMBOL, OTEL_PATCHED_SYMBOL } from './symbols'; import { GraphQLField, GraphQLPath, - GraphQLInstrumentationConfig, GraphQLInstrumentationParsedConfig, ObjectWithGraphQLData, OtelPatched, Maybe, -} from './types'; +} from './internal-types'; +import { GraphQLInstrumentationConfig } from './types'; const OPERATION_VALUES = Object.values(AllowedOperationTypes); diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/index.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/index.ts index 24c76056a1..c464af622c 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/index.ts @@ -15,3 +15,4 @@ */ export * from './instrumentation'; +export * from './enums/AttributeNames'; diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts index 17071a2cfc..1e15b28276 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/instrumentation.ts @@ -23,7 +23,8 @@ import { isWrapped, } from '@opentelemetry/instrumentation'; -import type * as Hapi from '@hapi/hapi'; +// types for @hapi/hapi are published under @types/hapi__hapi +import type * as Hapi from 'hapi__hapi'; import { VERSION } from './version'; import { HapiComponentName, @@ -35,7 +36,7 @@ import { RegisterFunction, PatchableExtMethod, ServerExtDirectInput, -} from './types'; +} from './internal-types'; import { getRouteMetadata, getPluginName, diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/types.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/internal-types.ts similarity index 93% rename from plugins/node/opentelemetry-instrumentation-hapi/src/types.ts rename to plugins/node/opentelemetry-instrumentation-hapi/src/internal-types.ts index 782776b5a3..4e4b864836 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/internal-types.ts @@ -13,8 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import type * as Hapi from '@hapi/hapi'; -import { Lifecycle } from '@hapi/hapi'; + +// types for @hapi/hapi are published under @types/hapi__hapi +import type * as Hapi from 'hapi__hapi'; export const HapiComponentName = '@hapi/hapi'; @@ -35,7 +36,7 @@ export type HapiServerRouteInput = export type PatchableServerRoute = Hapi.ServerRoute & { [handlerPatched]?: boolean; options?: { - handler?: Lifecycle.Method; + handler?: Hapi.Lifecycle.Method; }; }; diff --git a/plugins/node/opentelemetry-instrumentation-hapi/src/utils.ts b/plugins/node/opentelemetry-instrumentation-hapi/src/utils.ts index 556f73070e..1ddebf0a5e 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/src/utils.ts @@ -22,7 +22,7 @@ import { HapiLifecycleMethodNames, PatchableExtMethod, ServerExtDirectInput, -} from './types'; +} from './internal-types'; import { AttributeNames } from './enums/AttributeNames'; export function getPluginName(plugin: Hapi.Plugin): string { diff --git a/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-plugin.test.ts b/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-plugin.test.ts index 459090abd8..b2737b8b1d 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-plugin.test.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-plugin.test.ts @@ -25,7 +25,7 @@ import * as assert from 'assert'; import { getPlugin } from './plugin'; const plugin = getPlugin(); import * as hapi from '@hapi/hapi'; -import { HapiLayerType } from '../src/types'; +import { HapiLayerType } from '../src/internal-types'; import { AttributeNames } from '../src/enums/AttributeNames'; describe('Hapi Instrumentation - Hapi.Plugin Tests', () => { diff --git a/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-server-ext.test.ts b/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-server-ext.test.ts index 6deef8b021..529df11299 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-server-ext.test.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/test/hapi-server-ext.test.ts @@ -26,7 +26,7 @@ import { getPlugin } from './plugin'; const plugin = getPlugin(); import * as hapi from '@hapi/hapi'; -import { HapiLayerType } from '../src/types'; +import { HapiLayerType } from '../src/internal-types'; import { AttributeNames } from '../src/enums/AttributeNames'; describe('Hapi Instrumentation - Server.Ext Tests', () => { diff --git a/plugins/node/opentelemetry-instrumentation-hapi/test/hapi.test.ts b/plugins/node/opentelemetry-instrumentation-hapi/test/hapi.test.ts index ba3d87614c..f255f762b7 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/test/hapi.test.ts +++ b/plugins/node/opentelemetry-instrumentation-hapi/test/hapi.test.ts @@ -28,7 +28,7 @@ const plugin = getPlugin(); import * as assert from 'assert'; import * as hapi from '@hapi/hapi'; -import { HapiLayerType } from '../src/types'; +import { HapiLayerType } from '../src/internal-types'; import { AttributeNames } from '../src/enums/AttributeNames'; describe('Hapi Instrumentation - Core Tests', () => { diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/src/index.ts b/plugins/node/opentelemetry-instrumentation-ioredis/src/index.ts index 5c024b60d6..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-ioredis/src/index.ts @@ -15,4 +15,4 @@ */ export * from './instrumentation'; -export { IORedisInstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-knex/src/index.ts b/plugins/node/opentelemetry-instrumentation-knex/src/index.ts index 500f2675e4..4d2b9abbeb 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/src/index.ts @@ -19,4 +19,4 @@ import { KnexInstrumentation } from './instrumentation'; export * from './instrumentation'; export default KnexInstrumentation; -export { KnexInstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-koa/src/index.ts b/plugins/node/opentelemetry-instrumentation-koa/src/index.ts index 24c76056a1..13de301c07 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-koa/src/index.ts @@ -15,3 +15,5 @@ */ export * from './instrumentation'; +export * from './types'; +export * from './enums/AttributeNames'; diff --git a/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts index 620d8883c1..2a454e0ef8 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-koa/src/instrumentation.ts @@ -26,8 +26,6 @@ import type * as koa from 'koa'; import { KoaMiddleware, KoaContext, - KoaComponentName, - kLayerPatched, KoaLayerType, KoaInstrumentationConfig, } from './types'; @@ -35,6 +33,11 @@ import { AttributeNames } from './enums/AttributeNames'; import { VERSION } from './version'; import { getMiddlewareMetadata, isLayerIgnored } from './utils'; import { getRPCMetadata, RPCType, setRPCMetadata } from '@opentelemetry/core'; +import { + kLayerPatched, + KoaComponentName, + KoaPatchedMiddleware, +} from './internal-types'; /** Koa instrumentation for OpenTelemetry */ export class KoaInstrumentation extends InstrumentationBase { @@ -136,7 +139,7 @@ export class KoaInstrumentation extends InstrumentationBase { * router about the routed path which the middleware is attached to */ private _patchLayer( - middlewareLayer: KoaMiddleware, + middlewareLayer: KoaPatchedMiddleware, isRouter: boolean, layerPath?: string ): KoaMiddleware { diff --git a/plugins/node/opentelemetry-instrumentation-koa/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-koa/src/internal-types.ts new file mode 100644 index 0000000000..d228b0f4fc --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-koa/src/internal-types.ts @@ -0,0 +1,28 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { KoaMiddleware } from './types'; + +/** + * This symbol is used to mark a Koa layer as being already instrumented + * since its possible to use a given layer multiple times (ex: middlewares) + */ +export const kLayerPatched: unique symbol = Symbol('koa-layer-patched'); + +export type KoaPatchedMiddleware = KoaMiddleware & { + [kLayerPatched]?: boolean; +}; + +export const KoaComponentName = 'koa'; diff --git a/plugins/node/opentelemetry-instrumentation-koa/src/types.ts b/plugins/node/opentelemetry-instrumentation-koa/src/types.ts index 696e265b67..83e59389ca 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-koa/src/types.ts @@ -19,22 +19,20 @@ import type * as Router from '@koa/router'; import { Span } from '@opentelemetry/api'; import { InstrumentationConfig } from '@opentelemetry/instrumentation'; -/** - * This symbol is used to mark a Koa layer as being already instrumented - * since its possible to use a given layer multiple times (ex: middlewares) - */ -export const kLayerPatched: unique symbol = Symbol('koa-layer-patched'); +export enum KoaLayerType { + ROUTER = 'router', + MIDDLEWARE = 'middleware', +} + +export type KoaContext = ParameterizedContext; export type KoaMiddleware = Middleware & { - [kLayerPatched]?: boolean; router?: Router; }; -export type KoaContext = ParameterizedContext; - export type KoaRequestInfo = { context: KoaContext; - middlewareLayer: KoaMiddleware; + middlewareLayer: Middleware; layerType: KoaLayerType; }; @@ -56,10 +54,3 @@ export interface KoaInstrumentationConfig extends InstrumentationConfig { /** Function for adding custom attributes to each middleware layer span */ requestHook?: KoaRequestCustomAttributeFunction; } - -export enum KoaLayerType { - ROUTER = 'router', - MIDDLEWARE = 'middleware', -} - -export const KoaComponentName = 'koa'; diff --git a/plugins/node/opentelemetry-instrumentation-memcached/src/index.ts b/plugins/node/opentelemetry-instrumentation-memcached/src/index.ts index 4c831c2980..22efa9b0a5 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/src/index.ts @@ -15,7 +15,7 @@ */ import { Instrumentation } from './instrumentation'; -export { InstrumentationConfig } from './types'; +export * from './types'; export * from './instrumentation'; export default Instrumentation; diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/index.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/index.ts index 172fda8882..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/index.ts @@ -15,8 +15,4 @@ */ export * from './instrumentation'; -export { - MongoDBInstrumentationConfig, - MongoDBInstrumentationExecutionResponseHook, - MongoResponseHookInformation, -} from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-mysql/src/index.ts b/plugins/node/opentelemetry-instrumentation-mysql/src/index.ts index 53d2b7dd35..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/index.ts @@ -15,4 +15,4 @@ */ export * from './instrumentation'; -export { MySQLInstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/index.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/index.ts index a6a38a3c70..1973717afb 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/index.ts @@ -19,4 +19,4 @@ import { MySQL2Instrumentation } from './instrumentation'; export * from './instrumentation'; export default MySQL2Instrumentation; -export { MySQL2InstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/index.ts b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/index.ts index d7649869f9..8744bbf0ae 100644 --- a/plugins/node/opentelemetry-instrumentation-nestjs-core/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-nestjs-core/src/index.ts @@ -18,3 +18,5 @@ import { Instrumentation } from './instrumentation'; export * from './instrumentation'; export { Instrumentation as NestInstrumentation }; + +export * from './enums/AttributeNames'; diff --git a/plugins/node/opentelemetry-instrumentation-net/src/index.ts b/plugins/node/opentelemetry-instrumentation-net/src/index.ts index 24c76056a1..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/index.ts @@ -15,3 +15,4 @@ */ export * from './instrumentation'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts index 8c4fa9abc3..1247ffd990 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts @@ -26,7 +26,8 @@ import { SemanticAttributes, NetTransportValues, } from '@opentelemetry/semantic-conventions'; -import { Net, NormalizedOptions, SocketEvent, TLSAttributes } from './types'; +import { TLSAttributes } from './types'; +import { Net, NormalizedOptions, SocketEvent } from './internal-types'; import { getNormalizedArgs, IPC_TRANSPORT } from './utils'; import { VERSION } from './version'; import { Socket } from 'net'; diff --git a/plugins/node/opentelemetry-instrumentation-net/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-net/src/internal-types.ts new file mode 100644 index 0000000000..a9cb63f735 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-net/src/internal-types.ts @@ -0,0 +1,32 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type * as net from 'net'; + +export type Net = typeof net; + +export interface NormalizedOptions { + host?: string; + port?: number; + path?: string; +} + +export enum SocketEvent { + CLOSE = 'close', + CONNECT = 'connect', + ERROR = 'error', + SECURE_CONNECT = 'secureConnect', +} diff --git a/plugins/node/opentelemetry-instrumentation-net/src/types.ts b/plugins/node/opentelemetry-instrumentation-net/src/types.ts index 5db05c71cc..367fecff04 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/types.ts @@ -14,23 +14,6 @@ * limitations under the License. */ -import type * as net from 'net'; - -export type Net = typeof net; - -export interface NormalizedOptions { - host?: string; - port?: number; - path?: string; -} - -export enum SocketEvent { - CLOSE = 'close', - CONNECT = 'connect', - ERROR = 'error', - SECURE_CONNECT = 'secureConnect', -} - /* The following attributes are not offical, see open-telemetry/opentelemetry-specification#1652 */ export enum TLSAttributes { PROTOCOL = 'tls.protocol', diff --git a/plugins/node/opentelemetry-instrumentation-net/src/utils.ts b/plugins/node/opentelemetry-instrumentation-net/src/utils.ts index 40320b2439..8b013deead 100644 --- a/plugins/node/opentelemetry-instrumentation-net/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-net/src/utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NormalizedOptions } from './types'; +import { NormalizedOptions } from './internal-types'; import { NetTransportValues } from '@opentelemetry/semantic-conventions'; import { platform } from 'os'; diff --git a/plugins/node/opentelemetry-instrumentation-net/test/connect.test.ts b/plugins/node/opentelemetry-instrumentation-net/test/connect.test.ts index 8352d98ea3..9826c8dc27 100644 --- a/plugins/node/opentelemetry-instrumentation-net/test/connect.test.ts +++ b/plugins/node/opentelemetry-instrumentation-net/test/connect.test.ts @@ -24,7 +24,7 @@ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; import * as net from 'net'; import * as assert from 'assert'; import { NetInstrumentation } from '../src'; -import { SocketEvent } from '../src/types'; +import { SocketEvent } from '../src/internal-types'; import { assertIpcSpan, assertTcpSpan, IPC_PATH, HOST, PORT } from './utils'; const memoryExporter = new InMemorySpanExporter(); diff --git a/plugins/node/opentelemetry-instrumentation-net/test/tls.test.ts b/plugins/node/opentelemetry-instrumentation-net/test/tls.test.ts index 032e65ce0b..5e27a99195 100644 --- a/plugins/node/opentelemetry-instrumentation-net/test/tls.test.ts +++ b/plugins/node/opentelemetry-instrumentation-net/test/tls.test.ts @@ -23,7 +23,7 @@ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; import * as assert from 'assert'; import * as tls from 'tls'; import { NetInstrumentation } from '../src'; -import { SocketEvent } from '../src/types'; +import { SocketEvent } from '../src/internal-types'; import { assertTLSSpan, HOST, diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/index.ts b/plugins/node/opentelemetry-instrumentation-pg/src/index.ts index ae4b1c23b3..13de301c07 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/index.ts @@ -15,8 +15,5 @@ */ export * from './instrumentation'; -export { - PgInstrumentationConfig, - PgInstrumentationExecutionResponseHook, - PgResponseHookInformation, -} from './types'; +export * from './types'; +export * from './enums/AttributeNames'; diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts index ebdcf2f602..7c1b6d77f2 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/instrumentation.ts @@ -20,8 +20,8 @@ import { } from '@opentelemetry/instrumentation'; import { context, diag, trace, Span, SpanStatusCode } from '@opentelemetry/api'; -import * as pgTypes from 'pg'; -import * as pgPoolTypes from 'pg-pool'; +import type * as pgTypes from 'pg'; +import type * as pgPoolTypes from 'pg-pool'; import { PgClientConnect, PgClientExtended, @@ -30,8 +30,8 @@ import { PostgresCallback, PgPoolExtended, PgPoolCallback, - PgInstrumentationConfig, -} from './types'; +} from './internal-types'; +import { PgInstrumentationConfig } from './types'; import * as utils from './utils'; import { AttributeNames } from './enums/AttributeNames'; import { diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-pg/src/internal-types.ts new file mode 100644 index 0000000000..dc4e54fe7a --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-pg/src/internal-types.ts @@ -0,0 +1,64 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type * as pgTypes from 'pg'; +import type * as pgPoolTypes from 'pg-pool'; + +export type PostgresCallback = (err: Error, res: object) => unknown; + +// These are not included in @types/pg, so manually define them. +// https://github.com/brianc/node-postgres/blob/fde5ec586e49258dfc4a2fcd861fcdecb4794fc3/lib/client.js#L25 +export interface PgClientConnectionParams { + database?: string; + host?: string; + port?: number; + user?: string; +} + +export interface PgClientExtended extends pgTypes.Client { + connectionParameters: PgClientConnectionParams; +} + +// Interface name based on original driver implementation +// https://github.com/brianc/node-postgres/blob/2ef55503738eb2cbb6326744381a92c0bc0439ab/packages/pg/lib/utils.js#L157 +export interface NormalizedQueryConfig extends pgTypes.QueryConfig { + callback?: PostgresCallback; +} + +export type PgPoolCallback = ( + err: Error, + client: any, + done: (release?: any) => void +) => void; + +export type PgErrorCallback = (err: Error) => void; + +export interface PgPoolOptionsParams { + database: string; + host: string; + port: number; + user: string; + idleTimeoutMillis: number; // the minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due to idle time + maxClient: number; // maximum size of the pool +} + +export interface PgPoolExtended extends pgPoolTypes { + options: PgPoolOptionsParams; +} + +export type PgClientConnect = ( + callback?: (err: Error) => void +) => Promise | void; diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/types.ts b/plugins/node/opentelemetry-instrumentation-pg/src/types.ts index 73ad89b061..d37ab0323f 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/types.ts @@ -14,8 +14,7 @@ * limitations under the License. */ -import * as pgTypes from 'pg'; -import * as pgPoolTypes from 'pg-pool'; +import type * as pgTypes from 'pg'; import type * as api from '@opentelemetry/api'; import { InstrumentationConfig } from '@opentelemetry/instrumentation'; @@ -48,49 +47,3 @@ export interface PgInstrumentationConfig extends InstrumentationConfig { */ requireParentSpan?: boolean; } - -export type PostgresCallback = (err: Error, res: object) => unknown; - -// These are not included in @types/pg, so manually define them. -// https://github.com/brianc/node-postgres/blob/fde5ec586e49258dfc4a2fcd861fcdecb4794fc3/lib/client.js#L25 -export interface PgClientConnectionParams { - database?: string; - host?: string; - port?: number; - user?: string; -} - -export interface PgClientExtended extends pgTypes.Client { - connectionParameters: PgClientConnectionParams; -} - -// Interface name based on original driver implementation -// https://github.com/brianc/node-postgres/blob/2ef55503738eb2cbb6326744381a92c0bc0439ab/packages/pg/lib/utils.js#L157 -export interface NormalizedQueryConfig extends pgTypes.QueryConfig { - callback?: PostgresCallback; -} - -export type PgPoolCallback = ( - err: Error, - client: any, - done: (release?: any) => void -) => void; - -export type PgErrorCallback = (err: Error) => void; - -export interface PgPoolOptionsParams { - database: string; - host: string; - port: number; - user: string; - idleTimeoutMillis: number; // the minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due to idle time - maxClient: number; // maximum size of the pool -} - -export interface PgPoolExtended extends pgPoolTypes { - options: PgPoolOptionsParams; -} - -export type PgClientConnect = ( - callback?: (err: Error) => void -) => Promise | void; diff --git a/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts b/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts index 5b0711e302..7e5359c4ec 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts @@ -38,9 +38,9 @@ import { PgErrorCallback, PgPoolCallback, PgPoolExtended, - PgInstrumentationConfig, -} from './types'; -import * as pgTypes from 'pg'; +} from './internal-types'; +import { PgInstrumentationConfig } from './types'; +import type * as pgTypes from 'pg'; import { PgInstrumentation } from './'; import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation'; diff --git a/plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts b/plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts index e1b628f4fe..6bb03076bf 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts +++ b/plugins/node/opentelemetry-instrumentation-pg/test/utils.test.ts @@ -26,7 +26,7 @@ import * as assert from 'assert'; import * as pg from 'pg'; import { PgInstrumentationConfig } from '../src'; import { AttributeNames } from '../src/enums/AttributeNames'; -import { PgClientExtended, NormalizedQueryConfig } from '../src/types'; +import { PgClientExtended, NormalizedQueryConfig } from '../src/internal-types'; import * as utils from '../src/utils'; const memoryExporter = new InMemorySpanExporter(); diff --git a/plugins/node/opentelemetry-instrumentation-pino/src/index.ts b/plugins/node/opentelemetry-instrumentation-pino/src/index.ts index 24c76056a1..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-pino/src/index.ts @@ -15,3 +15,4 @@ */ export * from './instrumentation'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/src/index.ts b/plugins/node/opentelemetry-instrumentation-redis-4/src/index.ts index cad137182f..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/src/index.ts @@ -15,4 +15,4 @@ */ export * from './instrumentation'; -export { RedisInstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/index.ts b/plugins/node/opentelemetry-instrumentation-redis/src/index.ts index cad137182f..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/index.ts @@ -15,4 +15,4 @@ */ export * from './instrumentation'; -export { RedisInstrumentationConfig } from './types'; +export * from './types'; diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/internal-types.ts b/plugins/node/opentelemetry-instrumentation-redis/src/internal-types.ts new file mode 100644 index 0000000000..99e2efe829 --- /dev/null +++ b/plugins/node/opentelemetry-instrumentation-redis/src/internal-types.ts @@ -0,0 +1,23 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export interface RedisPluginClientTypes { + options?: { + host: string; + port: string; + }; + + address?: string; +} diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/types.ts b/plugins/node/opentelemetry-instrumentation-redis/src/types.ts index 245e7611e8..5644a60187 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/types.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/types.ts @@ -28,15 +28,6 @@ export interface RedisCommand { call_on_write: boolean; } -export interface RedisPluginClientTypes { - options?: { - host: string; - port: string; - }; - - address?: string; -} - /** * Function that can be used to serialize db.statement tag * @param cmdName - The name of the command (eg. set, get, mset) diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts b/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts index 4f74b17a19..29b2e34f95 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts @@ -28,7 +28,6 @@ import { DbStatementSerializer, RedisCommand, RedisInstrumentationConfig, - RedisPluginClientTypes, } from './types'; import { EventEmitter } from 'events'; import { RedisInstrumentation } from './'; @@ -37,6 +36,7 @@ import { SemanticAttributes, } from '@opentelemetry/semantic-conventions'; import { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation'; +import { RedisPluginClientTypes } from './internal-types'; const endSpan = (span: Span, err?: Error | null) => { if (err) { diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/index.ts b/plugins/node/opentelemetry-instrumentation-restify/src/index.ts index 1a843eb1f0..dae24360d1 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/src/index.ts @@ -18,3 +18,5 @@ import { RestifyInstrumentation } from './instrumentation'; export * from './instrumentation'; export default RestifyInstrumentation; + +export * from './enums/AttributeNames'; diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts index baa98469a1..76fb7b95f9 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/src/instrumentation.ts @@ -14,12 +14,12 @@ * limitations under the License. */ -import type * as types from './types'; +import type * as types from './internal-types'; import type * as restify from 'restify'; import * as api from '@opentelemetry/api'; -import { Server } from 'restify'; -import { LayerType } from './types'; +import type { Server } from 'restify'; +import { LayerType } from './internal-types'; import * as AttributeNames from './enums/AttributeNames'; import { VERSION } from './version'; import * as constants from './constants'; diff --git a/plugins/node/opentelemetry-instrumentation-restify/src/types.ts b/plugins/node/opentelemetry-instrumentation-restify/src/internal-types.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-restify/src/types.ts rename to plugins/node/opentelemetry-instrumentation-restify/src/internal-types.ts diff --git a/plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts b/plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts index 27c35b3fb6..33ce317188 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts +++ b/plugins/node/opentelemetry-instrumentation-restify/test/restify.test.ts @@ -24,7 +24,7 @@ import { } from '@opentelemetry/sdk-trace-base'; import RestifyInstrumentation from '../src'; -import * as types from '../src/types'; +import * as types from '../src/internal-types'; const plugin = new RestifyInstrumentation(); import * as semver from 'semver'; diff --git a/plugins/node/opentelemetry-instrumentation-router/src/index.ts b/plugins/node/opentelemetry-instrumentation-router/src/index.ts index df07144357..b1cddbd9a5 100644 --- a/plugins/node/opentelemetry-instrumentation-router/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-router/src/index.ts @@ -18,3 +18,5 @@ import RouterInstrumentation from './instrumentation'; export { RouterInstrumentation }; export default RouterInstrumentation; + +export * from './enums/AttributeNames'; diff --git a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts index 7de5eeea61..8733daf1ab 100644 --- a/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-router/src/instrumentation.ts @@ -27,7 +27,7 @@ import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; import * as http from 'http'; import type * as Router from 'router'; -import * as types from './types'; +import * as types from './internal-types'; import { VERSION } from './version'; import * as constants from './constants'; import * as utils from './utils'; diff --git a/plugins/node/opentelemetry-instrumentation-router/src/types.ts b/plugins/node/opentelemetry-instrumentation-router/src/internal-types.ts similarity index 100% rename from plugins/node/opentelemetry-instrumentation-router/src/types.ts rename to plugins/node/opentelemetry-instrumentation-router/src/internal-types.ts diff --git a/plugins/node/opentelemetry-instrumentation-router/src/utils.ts b/plugins/node/opentelemetry-instrumentation-router/src/utils.ts index a9811942f2..9eee5a43da 100644 --- a/plugins/node/opentelemetry-instrumentation-router/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-router/src/utils.ts @@ -15,7 +15,7 @@ */ import * as constants from './constants'; -import * as types from './types'; +import * as types from './internal-types'; // Detect whether a function is a router package internal plumming handler export const isInternal = (fn: Function) => { diff --git a/plugins/node/opentelemetry-instrumentation-router/test/index.test.ts b/plugins/node/opentelemetry-instrumentation-router/test/index.test.ts index 0e6730bf20..c5b9309cf6 100644 --- a/plugins/node/opentelemetry-instrumentation-router/test/index.test.ts +++ b/plugins/node/opentelemetry-instrumentation-router/test/index.test.ts @@ -23,7 +23,7 @@ import { } from '@opentelemetry/sdk-trace-base'; import Instrumentation from '../src'; -import { InstrumentationSpan } from '../src/types'; +import { InstrumentationSpan } from '../src/internal-types'; const plugin = new Instrumentation(); import * as http from 'http'; diff --git a/plugins/node/opentelemetry-instrumentation-winston/src/index.ts b/plugins/node/opentelemetry-instrumentation-winston/src/index.ts index 24c76056a1..c26f998cff 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/src/index.ts +++ b/plugins/node/opentelemetry-instrumentation-winston/src/index.ts @@ -15,3 +15,4 @@ */ export * from './instrumentation'; +export * from './types'; diff --git a/plugins/web/opentelemetry-instrumentation-document-load/src/index.ts b/plugins/web/opentelemetry-instrumentation-document-load/src/index.ts index 24c76056a1..c464af622c 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/src/index.ts +++ b/plugins/web/opentelemetry-instrumentation-document-load/src/index.ts @@ -15,3 +15,4 @@ */ export * from './instrumentation'; +export * from './enums/AttributeNames'; diff --git a/plugins/web/opentelemetry-instrumentation-long-task/src/index.ts b/plugins/web/opentelemetry-instrumentation-long-task/src/index.ts index 24c76056a1..c26f998cff 100644 --- a/plugins/web/opentelemetry-instrumentation-long-task/src/index.ts +++ b/plugins/web/opentelemetry-instrumentation-long-task/src/index.ts @@ -15,3 +15,4 @@ */ export * from './instrumentation'; +export * from './types'; diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/src/index.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/src/index.ts index 24c76056a1..13de301c07 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/src/index.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/src/index.ts @@ -15,3 +15,5 @@ */ export * from './instrumentation'; +export * from './types'; +export * from './enums/AttributeNames'; diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts index bf2ed64b9f..24476e9c80 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/src/instrumentation.ts @@ -21,15 +21,17 @@ import { hrTime } from '@opentelemetry/core'; import { getElementXPath } from '@opentelemetry/sdk-trace-web'; import { AttributeNames } from './enums/AttributeNames'; import { - AsyncTask, EventName, - RunTaskFunction, ShouldPreventSpanCreation, - SpanData, UserInteractionInstrumentationConfig, +} from './types'; +import { + AsyncTask, + RunTaskFunction, + SpanData, WindowWithZone, ZoneTypeWithPrototype, -} from './types'; +} from './internal-types'; import { VERSION } from './version'; const ZONE_CONTEXT_KEY = 'OT_ZONE_CONTEXT'; diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/src/internal-types.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/src/internal-types.ts new file mode 100644 index 0000000000..a845906632 --- /dev/null +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/src/internal-types.ts @@ -0,0 +1,64 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { HrTime } from '@opentelemetry/api'; +import { EventName } from './types'; + +/** + * Async Zone task + */ +export type AsyncTask = Task & { + eventName: EventName; + target: EventTarget; + // Allows access to the private `_zone` property of a Zone.js Task. + _zone: Zone; +}; + +/** + * Type for patching Zone RunTask function + */ +export type RunTaskFunction = ( + task: AsyncTask, + applyThis?: any, + applyArgs?: any +) => Zone; + +/** + * interface to store information in weak map per span + */ +export interface SpanData { + hrTimeLastTimeout?: HrTime; + taskCount: number; +} + +/** + * interface to be able to check Zone presence on window + */ +export interface WindowWithZone { + Zone: ZoneTypeWithPrototype; +} + +/** + * interface to be able to use prototype in Zone + */ +interface ZonePrototype { + prototype: any; +} + +/** + * type to be able to use prototype on Zone + */ +export type ZoneTypeWithPrototype = ZonePrototype & Zone; diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/src/types.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/src/types.ts index 665a68ba6a..8c04b3c98a 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/src/types.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { HrTime, Span } from '@opentelemetry/api'; +import { Span } from '@opentelemetry/api'; import { InstrumentationConfig } from '@opentelemetry/instrumentation'; export type EventName = keyof HTMLElementEventMap; @@ -40,49 +40,3 @@ export interface UserInteractionInstrumentationConfig */ shouldPreventSpanCreation?: ShouldPreventSpanCreation; } - -/** - * Async Zone task - */ -export type AsyncTask = Task & { - eventName: EventName; - target: EventTarget; - // Allows access to the private `_zone` property of a Zone.js Task. - _zone: Zone; -}; - -/** - * Type for patching Zone RunTask function - */ -export type RunTaskFunction = ( - task: AsyncTask, - applyThis?: any, - applyArgs?: any -) => Zone; - -/** - * interface to store information in weak map per span - */ -export interface SpanData { - hrTimeLastTimeout?: HrTime; - taskCount: number; -} - -/** - * interface to be able to check Zone presence on window - */ -export interface WindowWithZone { - Zone: ZoneTypeWithPrototype; -} - -/** - * interface to be able to use prototype in Zone - */ -interface ZonePrototype { - prototype: any; -} - -/** - * type to be able to use prototype on Zone - */ -export type ZoneTypeWithPrototype = ZonePrototype & Zone; diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts index 5cfa3b4f7d..330e7f5879 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts @@ -27,10 +27,8 @@ import * as assert from 'assert'; import * as sinon from 'sinon'; import 'zone.js'; import { UserInteractionInstrumentation } from '../src'; -import { - UserInteractionInstrumentationConfig, - WindowWithZone, -} from '../src/types'; +import { WindowWithZone } from '../src/internal-types'; +import { UserInteractionInstrumentationConfig } from '../src/types'; import { assertClickSpan, assertInteractionSpan, diff --git a/plugins/web/opentelemetry-plugin-react-load/src/BaseOpenTelemetryComponent.ts b/plugins/web/opentelemetry-plugin-react-load/src/BaseOpenTelemetryComponent.ts index 13399394b1..9cc976605f 100644 --- a/plugins/web/opentelemetry-plugin-react-load/src/BaseOpenTelemetryComponent.ts +++ b/plugins/web/opentelemetry-plugin-react-load/src/BaseOpenTelemetryComponent.ts @@ -29,7 +29,7 @@ import { ForceUpdateFunction, GetSnapshotBeforeUpdateFunction, ComponentWillUnmountFunction, -} from './types'; +} from './internal-types'; /** * This class is the base component for a React component with lifecycle instrumentation diff --git a/plugins/web/opentelemetry-plugin-react-load/src/index.ts b/plugins/web/opentelemetry-plugin-react-load/src/index.ts index e7784b30a9..5c898a23d4 100644 --- a/plugins/web/opentelemetry-plugin-react-load/src/index.ts +++ b/plugins/web/opentelemetry-plugin-react-load/src/index.ts @@ -15,3 +15,4 @@ */ export * from './BaseOpenTelemetryComponent'; +export * from './enums/AttributeNames'; diff --git a/plugins/web/opentelemetry-plugin-react-load/src/types.ts b/plugins/web/opentelemetry-plugin-react-load/src/internal-types.ts similarity index 100% rename from plugins/web/opentelemetry-plugin-react-load/src/types.ts rename to plugins/web/opentelemetry-plugin-react-load/src/internal-types.ts