From 15ce086628ce823cf7ed791c45c58130cf0f0354 Mon Sep 17 00:00:00 2001 From: Robert Laurin Date: Thu, 6 May 2021 09:08:55 -0500 Subject: [PATCH] Fix: Nil value for db.name attribute --- instrumentation/mysql2/CHANGELOG.md | 26 +++++++++++-------- .../instrumentation/mysql2/patches/client.rb | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/instrumentation/mysql2/CHANGELOG.md b/instrumentation/mysql2/CHANGELOG.md index e1945063b..5c614cd84 100644 --- a/instrumentation/mysql2/CHANGELOG.md +++ b/instrumentation/mysql2/CHANGELOG.md @@ -1,18 +1,22 @@ # Release History: opentelemetry-instrumentation-mysql2 +### Unreleased + +* Fix: Nil value for db.name attribute #744 + ### v0.17.0 / 2021-04-22 * (No significant changes) ### v0.16.0 / 2021-03-17 -* FIXED: Update DB semantic conventions -* FIXED: Example scripts now reference local common lib +* FIXED: Update DB semantic conventions +* FIXED: Example scripts now reference local common lib * ADDED: Configurable obfuscation of sql in mysql2 instrumentation to avoid logging sensitive data ### v0.15.0 / 2021-02-18 -* ADDED: Add instrumentation config validation +* ADDED: Add instrumentation config validation ### v0.14.0 / 2021-02-03 @@ -28,12 +32,12 @@ ### v0.11.0 / 2020-12-11 -* ADDED: Add peer service config to mysql -* FIXED: Copyright comments to not reference year +* ADDED: Add peer service config to mysql +* FIXED: Copyright comments to not reference year ### v0.10.1 / 2020-12-09 -* FIXED: Semantic conventions db.type -> db.system +* FIXED: Semantic conventions db.type -> db.system ### v0.10.0 / 2020-12-03 @@ -41,19 +45,19 @@ ### v0.9.0 / 2020-11-27 -* BREAKING CHANGE: Add timeout for force_flush and shutdown +* BREAKING CHANGE: Add timeout for force_flush and shutdown -* ADDED: Add timeout for force_flush and shutdown +* ADDED: Add timeout for force_flush and shutdown ### v0.8.0 / 2020-10-27 -* BREAKING CHANGE: Remove 'canonical' from status codes +* BREAKING CHANGE: Remove 'canonical' from status codes -* FIXED: Remove 'canonical' from status codes +* FIXED: Remove 'canonical' from status codes ### v0.7.0 / 2020-10-07 -* DOCS: Standardize toplevel docs structure and readme +* DOCS: Standardize toplevel docs structure and readme ### v0.6.0 / 2020-09-10 diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb index 4bb0fc817..7c71aa029 100644 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb +++ b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/client.rb @@ -119,10 +119,10 @@ def client_attributes attributes = { 'db.system' => 'mysql', - 'db.name' => database_name, 'net.peer.name' => host, 'net.peer.port' => port } + attributes['db.name'] = database_name if database_name attributes['peer.service'] = config[:peer_service] if config[:peer_service] attributes end