diff --git a/package-lock.json b/package-lock.json index ed93a0f2cf..a178c73cf0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38019,7 +38019,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/instrumentation": "^0.51.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.23.0", "@types/memcached": "^2.2.6" }, "devDependencies": { @@ -46866,7 +46866,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.23.0", "@types/memcached": "^2.2.6", "@types/mocha": "7.0.2", "@types/node": "18.6.5", diff --git a/plugins/node/opentelemetry-instrumentation-memcached/README.md b/plugins/node/opentelemetry-instrumentation-memcached/README.md index 6913253d98..24e6477889 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/README.md +++ b/plugins/node/opentelemetry-instrumentation-memcached/README.md @@ -48,6 +48,20 @@ registerInstrumentations({ | ------- | ---- | ------- | ----------- | | `enhancedDatabaseReporting` | `boolean` | `false` | Include full command statement in the span - **leaks potentially sensitive information to your spans**. Defaults to `false`. | +## 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.operation` | The name of the operation being executed. | +| `db.statement` | The database statement being executed. | +| `db.system` | An identifier for the database management system (DBMS) product being used. | +| `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-memcached/package.json b/plugins/node/opentelemetry-instrumentation-memcached/package.json index d34a39820c..bf47bf5d4a 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/package.json +++ b/plugins/node/opentelemetry-instrumentation-memcached/package.json @@ -61,7 +61,7 @@ }, "dependencies": { "@opentelemetry/instrumentation": "^0.51.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/semantic-conventions": "^1.23.0", "@types/memcached": "^2.2.6" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-memcached#readme" diff --git a/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts index fba48b5434..b72ab76896 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/src/instrumentation.ts @@ -22,8 +22,10 @@ import { } from '@opentelemetry/instrumentation'; import type * as Memcached from 'memcached'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_MEMCACHED, + SEMATTRS_DB_OPERATION, + SEMATTRS_DB_STATEMENT, + SEMATTRS_DB_SYSTEM, } from '@opentelemetry/semantic-conventions'; import * as utils from './utils'; import { InstrumentationConfig } from './types'; @@ -32,7 +34,7 @@ import { VERSION } from './version'; export class Instrumentation extends InstrumentationBase { static readonly COMPONENT = 'memcached'; static readonly COMMON_ATTRIBUTES = { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.MEMCACHED, + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MEMCACHED, }; static readonly DEFAULT_CONFIG: InstrumentationConfig = { enhancedDatabaseReporting: false, @@ -135,8 +137,8 @@ export class Instrumentation extends InstrumentationBase { span.setAttributes({ 'db.memcached.key': query.key, 'db.memcached.lifetime': query.lifetime, - [SemanticAttributes.DB_OPERATION]: query.type, - [SemanticAttributes.DB_STATEMENT]: ( + [SEMATTRS_DB_OPERATION]: query.type, + [SEMATTRS_DB_STATEMENT]: ( instrumentation._config as InstrumentationConfig ).enhancedDatabaseReporting ? query.command diff --git a/plugins/node/opentelemetry-instrumentation-memcached/src/utils.ts b/plugins/node/opentelemetry-instrumentation-memcached/src/utils.ts index 4cebd4112e..f8f517071d 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/src/utils.ts @@ -15,7 +15,10 @@ */ import type * as Memcached from 'memcached'; -import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; +import { + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, +} from '@opentelemetry/semantic-conventions'; export const getPeerAttributes = ( client: any /* Memcached, but the type definitions are lacking */, @@ -49,12 +52,12 @@ export const getPeerAttributes = ( const portNumber = parseInt(port, 10); if (!isNaN(portNumber)) { return { - [SemanticAttributes.NET_PEER_NAME]: host, - [SemanticAttributes.NET_PEER_PORT]: portNumber, + [SEMATTRS_NET_PEER_NAME]: host, + [SEMATTRS_NET_PEER_PORT]: portNumber, }; } return { - [SemanticAttributes.NET_PEER_NAME]: host, + [SEMATTRS_NET_PEER_NAME]: host, }; } } diff --git a/plugins/node/opentelemetry-instrumentation-memcached/test/index.test.ts b/plugins/node/opentelemetry-instrumentation-memcached/test/index.test.ts index 87b96b537e..4e32af5fa6 100644 --- a/plugins/node/opentelemetry-instrumentation-memcached/test/index.test.ts +++ b/plugins/node/opentelemetry-instrumentation-memcached/test/index.test.ts @@ -32,8 +32,11 @@ import type * as Memcached from 'memcached'; import * as assert from 'assert'; import Instrumentation from '../src'; import { - DbSystemValues, - SemanticAttributes, + DBSYSTEMVALUES_MEMCACHED, + SEMATTRS_DB_SYSTEM, + SEMATTRS_EXCEPTION_MESSAGE, + SEMATTRS_NET_PEER_NAME, + SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; import * as util from 'util'; @@ -48,9 +51,9 @@ const CONFIG = { }; const DEFAULT_ATTRIBUTES: Attributes = { - [SemanticAttributes.DB_SYSTEM]: DbSystemValues.MEMCACHED, - [SemanticAttributes.NET_PEER_NAME]: CONFIG.host, - [SemanticAttributes.NET_PEER_PORT]: CONFIG.port, + [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MEMCACHED, + [SEMATTRS_NET_PEER_NAME]: CONFIG.host, + [SEMATTRS_NET_PEER_PORT]: CONFIG.port, }; interface ExtendedMemcached extends Memcached { @@ -178,7 +181,7 @@ describe('memcached@2.x', () => { assertMatch( instrumentationSpans?.[0]?.events[0]?.attributes?.[ - SemanticAttributes.EXCEPTION_MESSAGE + SEMATTRS_EXCEPTION_MESSAGE ] as 'string', /not stored/ );