From bf39b908fd64cec92c862b2deca5d760ddcf4509 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 24 Feb 2022 10:55:31 -0800 Subject: [PATCH] fix!(mysql*,redis): net.peer.ip -> db.connection_string (#913) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gerhard Stöbich --- .../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 +- 4 files changed, 12 insertions(+), 4 deletions(-) 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 = {