From 5497328743f7685a08667a5cbea3659eaa1031ce Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 20 Feb 2022 16:59:59 -0800 Subject: [PATCH] fix(mysql*,*redis): net.peer.ip -> db.connection_string --- .../src/instrumentation.ts | 2 +- .../test/ioredis.test.ts | 2 +- .../node/opentelemetry-instrumentation-mysql/src/utils.ts | 6 +++++- .../node/opentelemetry-instrumentation-mysql2/src/utils.ts | 6 +++++- .../node/opentelemetry-instrumentation-redis/src/utils.ts | 2 +- .../opentelemetry-instrumentation-redis/test/redis.test.ts | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts index d3a26a9ec3..fcc2e09b96 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-ioredis/src/instrumentation.ts @@ -143,7 +143,7 @@ export class IORedisInstrumentation extends InstrumentationBase< span.setAttributes({ [SemanticAttributes.NET_PEER_NAME]: host, [SemanticAttributes.NET_PEER_PORT]: port, - [SemanticAttributes.NET_PEER_IP]: `redis://${host}:${port}`, + [SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`, }); try { diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/test/ioredis.test.ts b/plugins/node/opentelemetry-instrumentation-ioredis/test/ioredis.test.ts index 2a346a81b1..879d729653 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/test/ioredis.test.ts +++ b/plugins/node/opentelemetry-instrumentation-ioredis/test/ioredis.test.ts @@ -54,7 +54,7 @@ const DEFAULT_ATTRIBUTES = { [SemanticAttributes.DB_SYSTEM]: IORedisInstrumentation.DB_SYSTEM, [SemanticAttributes.NET_PEER_NAME]: CONFIG.host, [SemanticAttributes.NET_PEER_PORT]: CONFIG.port, - [SemanticAttributes.NET_PEER_IP]: URL, + [SemanticAttributes.DB_CONNECTION_STRING]: URL, }; const unsetStatus: SpanStatus = { diff --git a/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts b/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts index b89d19e9a6..90b07bea4f 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql/src/utils.ts @@ -36,7 +36,11 @@ export function getConnectionAttributes( return { [SemanticAttributes.NET_PEER_NAME]: host, [SemanticAttributes.NET_PEER_PORT]: port, - [SemanticAttributes.NET_PEER_IP]: getJDBCString(host, port, database), + [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( + host, + port, + database + ), [SemanticAttributes.DB_NAME]: database, [SemanticAttributes.DB_USER]: user, }; diff --git a/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts b/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts index b6ab662be2..a71560014e 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-mysql2/src/utils.ts @@ -36,7 +36,11 @@ export function getConnectionAttributes(config: Config): SpanAttributes { return { [SemanticAttributes.NET_PEER_NAME]: host, [SemanticAttributes.NET_PEER_PORT]: port, - [SemanticAttributes.NET_PEER_IP]: getJDBCString(host, port, database), + [SemanticAttributes.DB_CONNECTION_STRING]: getJDBCString( + host, + port, + database + ), [SemanticAttributes.DB_NAME]: database, [SemanticAttributes.DB_USER]: user, }; diff --git a/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts b/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts index 471e288dbc..2e8aaa944a 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/src/utils.ts @@ -120,7 +120,7 @@ export const getTracedInternalSendCommand = ( } if (this.address) { span.setAttribute( - SemanticAttributes.NET_PEER_IP, + SemanticAttributes.DB_CONNECTION_STRING, `redis://${this.address}` ); } diff --git a/plugins/node/opentelemetry-instrumentation-redis/test/redis.test.ts b/plugins/node/opentelemetry-instrumentation-redis/test/redis.test.ts index 9728e05b12..a5f491520d 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/test/redis.test.ts +++ b/plugins/node/opentelemetry-instrumentation-redis/test/redis.test.ts @@ -53,7 +53,7 @@ const DEFAULT_ATTRIBUTES = { [SemanticAttributes.DB_SYSTEM]: RedisInstrumentation.COMPONENT, [SemanticAttributes.NET_PEER_NAME]: CONFIG.host, [SemanticAttributes.NET_PEER_PORT]: CONFIG.port, - [SemanticAttributes.NET_PEER_IP]: URL, + [SemanticAttributes.DB_CONNECTION_STRING]: URL, }; const unsetStatus: SpanStatus = {