From 9aaaafbe1c200bac95cd4930a8c04c8ee923bc5e Mon Sep 17 00:00:00 2001 From: Justin George Date: Wed, 22 Jun 2022 22:24:25 -0700 Subject: [PATCH] Update spies to use new service.target.name/type --- lib/elastic_apm/spies/azure_storage_table.rb | 5 ++--- lib/elastic_apm/spies/dynamo_db.rb | 8 ++++++-- lib/elastic_apm/spies/elasticsearch.rb | 6 +++++- lib/elastic_apm/spies/mongo.rb | 10 +++++++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/elastic_apm/spies/azure_storage_table.rb b/lib/elastic_apm/spies/azure_storage_table.rb index c0a9f45fb..52d888341 100644 --- a/lib/elastic_apm/spies/azure_storage_table.rb +++ b/lib/elastic_apm/spies/azure_storage_table.rb @@ -32,10 +32,9 @@ def instrument(operation_name, table_name = nil, service:) action = formatted_op_name(operation_name) account_name = account_name_from_storage_table_host(service.storage_service_host[:primary]) - destination = ElasticAPM::Span::Context::Destination.from_uri(service.storage_service_host[:primary]) - destination.service.resource = "#{SUBTYPE}/#{account_name}" + resource = "#{SUBTYPE}/#{account_name}" - context = ElasticAPM::Span::Context.new(destination: destination) + context = ElasticAPM::Span::Context.new(destination: {service: {resource: resource}}, service: {target: {name: account_name, type: SUBTYPE}}) ElasticAPM.with_span(span_name, TYPE, subtype: SUBTYPE, action: action, context: context) do ElasticAPM::Spies.without_faraday do diff --git a/lib/elastic_apm/spies/dynamo_db.rb b/lib/elastic_apm/spies/dynamo_db.rb index b9dbbaa5e..89c41e006 100644 --- a/lib/elastic_apm/spies/dynamo_db.rb +++ b/lib/elastic_apm/spies/dynamo_db.rb @@ -66,10 +66,14 @@ def self.prepended(mod) address: config.endpoint.host, port: config.endpoint.port, service: { - name: SUBTYPE, - type: TYPE, resource: SUBTYPE }, cloud: { region: config.region } + }, + service: { + target: { + name: config.region, + type: SUBTYPE + } } ) diff --git a/lib/elastic_apm/spies/elasticsearch.rb b/lib/elastic_apm/spies/elasticsearch.rb index c48aa529d..c98a0b9e7 100644 --- a/lib/elastic_apm/spies/elasticsearch.rb +++ b/lib/elastic_apm/spies/elasticsearch.rb @@ -62,8 +62,12 @@ def perform_request(method, path, *args, &block) db: { statement: statement.reduce({}, :merge).to_json }, destination: { service: { - name: SUBTYPE, resource: SUBTYPE, + } + }, + service: { + target: { + name: SUBTYPE, type: TYPE } } diff --git a/lib/elastic_apm/spies/mongo.rb b/lib/elastic_apm/spies/mongo.rb index 9b53e7008..f938fa167 100644 --- a/lib/elastic_apm/spies/mongo.rb +++ b/lib/elastic_apm/spies/mongo.rb @@ -108,11 +108,15 @@ def build_context(event) type: 'mongodb', user: nil }, + service: { + target: { + name: event.database_name, + type: SUBTYPE + } + }, destination: { service: { - name: SUBTYPE, - resource: SUBTYPE, - type: TYPE + resource: SUBTYPE } } )