From d06685471a3b2ce89ca8c59eb73894629418290f Mon Sep 17 00:00:00 2001 From: Marc Pichler Date: Tue, 30 Apr 2024 11:29:47 +0200 Subject: [PATCH 1/4] chore: remove skipLibCheck: true from tsconfigs where it is not necessary (#2165) --- metapackages/auto-instrumentations-web/tsconfig.esm.json | 1 - metapackages/auto-instrumentations-web/tsconfig.esnext.json | 1 - metapackages/auto-instrumentations-web/tsconfig.json | 1 - plugins/node/instrumentation-cucumber/tsconfig.json | 3 +-- plugins/node/instrumentation-mongoose/tsconfig.json | 3 +-- .../node/opentelemetry-instrumentation-mongodb/tsconfig.json | 3 +-- .../tsconfig.esm.json | 1 - .../tsconfig.esnext.json | 1 - .../tsconfig.json | 3 +-- 9 files changed, 4 insertions(+), 13 deletions(-) diff --git a/metapackages/auto-instrumentations-web/tsconfig.esm.json b/metapackages/auto-instrumentations-web/tsconfig.esm.json index 356b6d0307..a94adff6aa 100644 --- a/metapackages/auto-instrumentations-web/tsconfig.esm.json +++ b/metapackages/auto-instrumentations-web/tsconfig.esm.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "src", "outDir": "build/esm", - "skipLibCheck": true, "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" }, "include": [ diff --git a/metapackages/auto-instrumentations-web/tsconfig.esnext.json b/metapackages/auto-instrumentations-web/tsconfig.esnext.json index d6054d1fb0..ff1191ab29 100644 --- a/metapackages/auto-instrumentations-web/tsconfig.esnext.json +++ b/metapackages/auto-instrumentations-web/tsconfig.esnext.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "src", "outDir": "build/esnext", - "skipLibCheck": true, "tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo" }, "include": ["src/**/*.ts"] diff --git a/metapackages/auto-instrumentations-web/tsconfig.json b/metapackages/auto-instrumentations-web/tsconfig.json index e1baf4c16d..569e38e289 100644 --- a/metapackages/auto-instrumentations-web/tsconfig.json +++ b/metapackages/auto-instrumentations-web/tsconfig.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": ".", "outDir": "build", - "skipLibCheck": true }, "include": [ "src/**/*.ts", diff --git a/plugins/node/instrumentation-cucumber/tsconfig.json b/plugins/node/instrumentation-cucumber/tsconfig.json index 568e7bb7cb..c87523782b 100644 --- a/plugins/node/instrumentation-cucumber/tsconfig.json +++ b/plugins/node/instrumentation-cucumber/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.base", "compilerOptions": { "rootDir": ".", - "outDir": "build", - "skipLibCheck": true + "outDir": "build" }, "include": ["src/**/*.ts", "test/**/*.ts"] } diff --git a/plugins/node/instrumentation-mongoose/tsconfig.json b/plugins/node/instrumentation-mongoose/tsconfig.json index 5c3680dd33..28be80d266 100644 --- a/plugins/node/instrumentation-mongoose/tsconfig.json +++ b/plugins/node/instrumentation-mongoose/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.base", "compilerOptions": { "rootDir": ".", - "outDir": "build", - "skipLibCheck": true + "outDir": "build" }, "include": [ "src/**/*.ts", diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/tsconfig.json b/plugins/node/opentelemetry-instrumentation-mongodb/tsconfig.json index 5c3680dd33..28be80d266 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/tsconfig.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.base", "compilerOptions": { "rootDir": ".", - "outDir": "build", - "skipLibCheck": true + "outDir": "build" }, "include": [ "src/**/*.ts", diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esm.json b/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esm.json index 2eb13ff857..379f547a46 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esm.json +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esm.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "src", "outDir": "build/esm", - "skipLibCheck": true, "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" }, "include": [ diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esnext.json b/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esnext.json index b7a30a41f1..cb78dd6ff3 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esnext.json +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.esnext.json @@ -3,7 +3,6 @@ "compilerOptions": { "rootDir": "src", "outDir": "build/esnext", - "skipLibCheck": true, "tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo" }, "include": [ diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.json b/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.json index 5c3680dd33..28be80d266 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.json +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../../tsconfig.base", "compilerOptions": { "rootDir": ".", - "outDir": "build", - "skipLibCheck": true + "outDir": "build" }, "include": [ "src/**/*.ts", From 59583f240715f29a80776dd6de5a36f2c6341765 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Tue, 30 Apr 2024 12:57:49 +0200 Subject: [PATCH 2/4] chore(deps): update postgres docker tag to v16 (#1703) * chore(deps): update postgres docker tag to v16 * fix(test-utils): align postgres docker image --------- Co-authored-by: Amir Blum --- .github/workflows/test-all-versions.yml | 2 +- .github/workflows/unit-test.yml | 2 +- packages/opentelemetry-test-utils/src/test-utils.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-all-versions.yml b/.github/workflows/test-all-versions.yml index aa0b908342..cc231a5174 100644 --- a/.github/workflows/test-all-versions.yml +++ b/.github/workflows/test-all-versions.yml @@ -53,7 +53,7 @@ jobs: --health-timeout 5s --health-retries 5 postgres: - image: postgres:15-alpine + image: postgres:16-alpine env: POSTGRES_USER: postgres POSTGRES_DB: otel_pg_database diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 025b727e9b..a03af4c942 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -51,7 +51,7 @@ jobs: --health-timeout 5s --health-retries 5 postgres: - image: postgres:15-alpine + image: postgres:16-alpine env: POSTGRES_USER: postgres POSTGRES_DB: otel_pg_database diff --git a/packages/opentelemetry-test-utils/src/test-utils.ts b/packages/opentelemetry-test-utils/src/test-utils.ts index 0020e043fd..aae38f160a 100644 --- a/packages/opentelemetry-test-utils/src/test-utils.ts +++ b/packages/opentelemetry-test-utils/src/test-utils.ts @@ -40,7 +40,7 @@ const dockerRunCmds = { mysql: 'docker run --rm -d --name otel-mysql -p 33306:3306 -e MYSQL_ROOT_PASSWORD=rootpw -e MYSQL_DATABASE=test_db -e MYSQL_USER=otel -e MYSQL_PASSWORD=secret mysql:5.7 --log_output=TABLE --general_log=ON', postgres: - 'docker run --rm -d --name otel-postgres -p 54320:5432 -e POSTGRES_PASSWORD=postgres postgres:15-alpine', + 'docker run --rm -d --name otel-postgres -p 54320:5432 -e POSTGRES_PASSWORD=postgres postgres:16-alpine', redis: 'docker run --rm -d --name otel-redis -p 63790:6379 redis:alpine', }; From 585b833dc8e911c17b483e871f752ad4988cee5a Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Tue, 30 Apr 2024 16:49:22 +0300 Subject: [PATCH 3/4] feat(pino): support new pino version ^9.0.0 (#2163) Co-authored-by: Marc Pichler --- plugins/node/opentelemetry-instrumentation-pino/.tav.yml | 5 ++++- plugins/node/opentelemetry-instrumentation-pino/README.md | 2 +- .../src/instrumentation.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-pino/.tav.yml b/plugins/node/opentelemetry-instrumentation-pino/.tav.yml index ca1f8bbabc..94d5d5f97e 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/.tav.yml +++ b/plugins/node/opentelemetry-instrumentation-pino/.tav.yml @@ -1,5 +1,8 @@ pino: - - versions: "^8.16.2 || 8.12.1 || 8.8.0 || 8.4.0 || 8.0.0 || ^7.11.0 || 7.8.0 || 7.2.0 || ^6.13.3 || 5.17.0 || 5.14.0" + - versions: "^9.0.0" + node: ">=18" + commands: npm run test + - versions: "^8.21.0 || 8.20.0 || 8.16.2 || 8.12.1 || 8.8.0 || 8.4.0 || 8.0.0 || ^7.11.0 || 7.8.0 || 7.2.0 || ^6.13.3 || 5.17.0 || 5.14.0" node: ">=14" commands: npm run test - versions: "^7.11.0 || 7.8.0 || 7.2.0 || ^6.13.1 || 5.17.0 || 5.14.0" diff --git a/plugins/node/opentelemetry-instrumentation-pino/README.md b/plugins/node/opentelemetry-instrumentation-pino/README.md index 7d8c7393f1..377ce7aa6e 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/README.md +++ b/plugins/node/opentelemetry-instrumentation-pino/README.md @@ -63,7 +63,7 @@ When no span context is active or the span context is invalid, injection is skip ### Supported versions -`>=5.14.0 <9` +`>=5.14.0 <10` ## Useful links diff --git a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts index dce1ff3ecc..d5821a2f6f 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-pino/src/instrumentation.ts @@ -29,7 +29,7 @@ import { import { PinoInstrumentationConfig } from './types'; import { VERSION } from './version'; -const pinoVersions = ['>=5.14.0 <9']; +const pinoVersions = ['>=5.14.0 <10']; const DEFAULT_LOG_KEYS = { traceId: 'trace_id', From e74cee49a7f8dde2e34a5a6e37d87e3b7d1bd949 Mon Sep 17 00:00:00 2001 From: David Luna Date: Wed, 1 May 2024 05:30:19 +0200 Subject: [PATCH 4/4] refactor(instr-cassandra-driver): use exported strings for attributes (#2139) Also, correct component-label mapping for instrumentation-cassandra-driver package Co-authored-by: Trent Mick Refs: #2025 --- .github/component-label-map.yml | 2 +- package-lock.json | 4 +-- .../README.md | 15 +++++++++++ .../package.json | 2 +- .../src/instrumentation.ts | 25 ++++++++++------- .../test/cassandra-driver.test.ts | 27 +++++++++++-------- 6 files changed, 50 insertions(+), 25 deletions(-) diff --git a/.github/component-label-map.yml b/.github/component-label-map.yml index 5a9fc3af56..c766a864d0 100644 --- a/.github/component-label-map.yml +++ b/.github/component-label-map.yml @@ -71,7 +71,7 @@ pkg:instrumentation-bunyan: - changed-files: - any-glob-to-any-file: - plugins/node/opentelemetry-instrumentation-bunyan/** -pkg:instrumentation-cassandra: +pkg:instrumentation-cassandra-driver: - changed-files: - any-glob-to-any-file: - plugins/node/opentelemetry-instrumentation-cassandra/** diff --git a/package-lock.json b/package-lock.json index 4c8e6c2a3b..72cbe122ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38193,7 +38193,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/instrumentation": "^0.51.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "devDependencies": { "@opentelemetry/api": "^1.3.0", @@ -47132,7 +47132,7 @@ "@opentelemetry/instrumentation": "^0.51.0", "@opentelemetry/sdk-trace-base": "^1.8.0", "@opentelemetry/sdk-trace-node": "^1.8.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.22.0", "@types/mocha": "7.0.2", "@types/node": "18.6.5", "@types/semver": "7.5.3", diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/README.md b/plugins/node/opentelemetry-instrumentation-cassandra/README.md index 637bcf4fa2..8743ebffaf 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/README.md +++ b/plugins/node/opentelemetry-instrumentation-cassandra/README.md @@ -49,6 +49,21 @@ await client.execute('select * from foo'); `>=4.4 <5.0` +## Semantic Conventions + +This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md) + +Attributes collected: + +| Attribute | Short Description | +| ----------------------- | ------------------------------------------------------------------------------ | +| `db.name` | This attribute is used to report the name of the database being accessed. | +| `db.statement` | The database statement being executed. | +| `db.system` | An identifier for the database management system (DBMS) product being used. | +| `db.user` | Username for accessing the database. | +| `net.peer.name` | Remote hostname or similar. | +| `net.peer.port` | Remote port number. | + ## Useful links * For more information on OpenTelemetry, visit: diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/package.json b/plugins/node/opentelemetry-instrumentation-cassandra/package.json index 2529936322..73ffc747d6 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/package.json +++ b/plugins/node/opentelemetry-instrumentation-cassandra/package.json @@ -62,7 +62,7 @@ }, "dependencies": { "@opentelemetry/instrumentation": "^0.51.0", - "@opentelemetry/semantic-conventions": "^1.0.0" + "@opentelemetry/semantic-conventions": "^1.22.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-cassandra#readme" } diff --git a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts index 754277310f..f11ffab83e 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/src/instrumentation.ts @@ -18,7 +18,7 @@ import { context, trace, Span, - SpanAttributes, + Attributes, SpanKind, SpanStatusCode, } from '@opentelemetry/api'; @@ -31,8 +31,13 @@ import { } from '@opentelemetry/instrumentation'; import { CassandraDriverInstrumentationConfig, ResultSet } from './types'; import { - SemanticAttributes, - DbSystemValues, + DBSYSTEMVALUES_CASSANDRA, + SEMATTRS_DB_NAME, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_DB_USER, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; import { VERSION } from './version'; import { EventEmitter } from 'events'; @@ -172,10 +177,10 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { if (span !== undefined && conn !== undefined) { const port = parseInt(conn.port, 10); - span.setAttribute(SemanticAttributes.NET_PEER_NAME, conn.address); + span.setAttribute(SEMATTRS_NET_PEER_NAME, conn.address); if (!isNaN(port)) { - span.setAttribute(SemanticAttributes.NET_PEER_PORT, port); + span.setAttribute(SEMATTRS_NET_PEER_PORT, port); } } @@ -302,24 +307,24 @@ export class CassandraDriverInstrumentation extends InstrumentationBase { { op, query }: { op: string; query?: unknown }, client: CassandraDriver.Client ): Span { - const attributes: SpanAttributes = { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.CASSANDRA, + const attributes: Attributes = { + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_CASSANDRA, }; if (this._shouldIncludeDbStatement() && query !== undefined) { const statement = truncateQuery(query, this._getMaxQueryLength()); - attributes[SemanticAttributes.DB_STATEMENT] = statement; + attributes[SEMATTRS_DB_STATEMENT] = statement; } // eslint-disable-next-line @typescript-eslint/no-explicit-any const user = (client as any).options?.credentials?.username; if (user) { - attributes[SemanticAttributes.DB_USER] = user; + attributes[SEMATTRS_DB_USER] = user; } if (client.keyspace) { - attributes[SemanticAttributes.DB_NAME] = client.keyspace; + attributes[SEMATTRS_DB_NAME] = client.keyspace; } return this.tracer.startSpan(`cassandra-driver.${op}`, { 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 c7a802d4b8..c663ab0abe 100644 --- a/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts +++ b/plugins/node/opentelemetry-instrumentation-cassandra/test/cassandra-driver.test.ts @@ -30,8 +30,13 @@ import { import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { - SemanticAttributes, - DbSystemValues, + DBSYSTEMVALUES_CASSANDRA, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, + SEMATTRS_DB_USER, + SEMATTRS_EXCEPTION_MESSAGE, + SEMATTRS_EXCEPTION_STACKTRACE, + SEMATTRS_EXCEPTION_TYPE, } from '@opentelemetry/semantic-conventions'; import * as assert from 'assert'; import * as testUtils from '@opentelemetry/contrib-test-utils'; @@ -60,13 +65,13 @@ function assertSpan( customAttributes?: Attributes ) { const attributes: Attributes = { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.CASSANDRA, - [SemanticAttributes.DB_USER]: 'cassandra', + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_CASSANDRA, + [SEMATTRS_DB_USER]: 'cassandra', ...customAttributes, }; if (query !== undefined) { - attributes[SemanticAttributes.DB_STATEMENT] = query; + attributes[SEMATTRS_DB_STATEMENT] = query; } const spanStatus = @@ -98,12 +103,12 @@ function assertErrorSpan( const [span] = spans; const attributes: Attributes = { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.CASSANDRA, - [SemanticAttributes.DB_USER]: 'cassandra', + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_CASSANDRA, + [SEMATTRS_DB_USER]: 'cassandra', }; if (query !== undefined) { - attributes[SemanticAttributes.DB_STATEMENT] = query; + attributes[SEMATTRS_DB_STATEMENT] = query; } const events = [ @@ -111,9 +116,9 @@ function assertErrorSpan( name: 'exception', droppedAttributesCount: 0, attributes: { - [SemanticAttributes.EXCEPTION_STACKTRACE]: error.stack, - [SemanticAttributes.EXCEPTION_MESSAGE]: error.message, - [SemanticAttributes.EXCEPTION_TYPE]: String(error.code), + [SEMATTRS_EXCEPTION_STACKTRACE]: error.stack, + [SEMATTRS_EXCEPTION_MESSAGE]: error.message, + [SEMATTRS_EXCEPTION_TYPE]: String(error.code), }, time: span.events[0].time, },