From 73fa809867dd08c1e3fde7413d88538e0df748bf Mon Sep 17 00:00:00 2001 From: Dave Lahn Date: Fri, 8 Dec 2023 18:33:33 +0000 Subject: [PATCH] feat!: change db.mysql.instance.address to db.instance.id (#758) * refactor(trilogy): change db.mysql.instance.address to db.instance.id fixes #745 * feat!(trilogy): change db.mysql.instance.address to db.instance.id fixes #745 --------- Co-authored-by: Ariel Valentin Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com> --- .../instrumentation/trilogy/patches/client.rb | 2 +- .../instrumentation/trilogy/instrumentation_test.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb index 9858d5981..c155a7a40 100644 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb +++ b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb @@ -91,7 +91,7 @@ def client_attributes(sql = nil) attributes[::OpenTelemetry::SemanticConventions::Trace::DB_NAME] = database_name if database_name attributes[::OpenTelemetry::SemanticConventions::Trace::DB_USER] = database_user if database_user attributes[::OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] unless config[:peer_service].nil? - attributes['db.mysql.instance.address'] = @connected_host if defined?(@connected_host) + attributes['db.instance.id'] = @connected_host if defined?(@connected_host) if sql case config[:db_statement] diff --git a/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb b/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb index b4cf1e6d7..ffc1a58ec 100644 --- a/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb +++ b/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb @@ -139,7 +139,7 @@ _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'SELECT ?' _(span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal(host) - _(span.attributes['db.mysql.instance.address']).must_be_nil + _(span.attributes['db.instance.id']).must_be_nil end it 'extracts statement type' do @@ -177,7 +177,7 @@ _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_USER]).must_equal(username) _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' _(span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal(host) - _(span.attributes['db.mysql.instance.address']).must_be_nil + _(span.attributes['db.instance.id']).must_be_nil end end @@ -207,7 +207,7 @@ _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'select @@hostname' _(span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal(host) - _(span.attributes['db.mysql.instance.address']).must_be_nil + _(span.attributes['db.instance.id']).must_be_nil client.query('SELECT 1') @@ -219,7 +219,7 @@ _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT]).must_equal 'SELECT ?' _(last_span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal(host) - _(last_span.attributes['db.mysql.instance.address']).must_equal client.connected_host + _(last_span.attributes['db.instance.id']).must_equal client.connected_host end end