From 95f813ec213ae63b1f9befb2b358757b8e937bc8 Mon Sep 17 00:00:00 2001 From: Tim Johnson Date: Mon, 19 Mar 2018 17:41:14 -0400 Subject: [PATCH] Include Hostname and Port into net/http resource --- lib/ddtrace/contrib/http/patcher.rb | 2 +- test/contrib/http/miniapp_test.rb | 2 +- test/contrib/http/request_test.rb | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ddtrace/contrib/http/patcher.rb b/lib/ddtrace/contrib/http/patcher.rb index 3c8cfc59b12..2a5c2910e3e 100644 --- a/lib/ddtrace/contrib/http/patcher.rb +++ b/lib/ddtrace/contrib/http/patcher.rb @@ -119,7 +119,7 @@ def request(req, body = nil, &block) # :yield: +response+ span.service = pin.service span.span_type = Datadog::Ext::HTTP::TYPE - span.resource = host_address + span.resource = "#{host_address}:#{host_port}" span.set_tag(Datadog::Ext::HTTP::URL, req.path) span.set_tag(Datadog::Ext::HTTP::METHOD, req.method) diff --git a/test/contrib/http/miniapp_test.rb b/test/contrib/http/miniapp_test.rb index eb65b405e43..effa0815501 100644 --- a/test/contrib/http/miniapp_test.rb +++ b/test/contrib/http/miniapp_test.rb @@ -33,7 +33,7 @@ def check_span_page(span) def check_span_get(span, parent_id, trace_id) assert_equal('http.request', span.name) assert_equal('net/http', span.service) - assert_equal(ELASTICSEARCH_HOST, span.resource) + assert_equal("#{ELASTICSEARCH_HOST}:#{ELASTICSEARCH_PORT}", span.resource) assert_equal('_cluster/health', span.get_tag('http.url')) assert_equal('GET', span.get_tag('http.method')) assert_equal('200', span.get_tag('http.status_code')) diff --git a/test/contrib/http/request_test.rb b/test/contrib/http/request_test.rb index ae63c92ffc4..ab542f6b440 100644 --- a/test/contrib/http/request_test.rb +++ b/test/contrib/http/request_test.rb @@ -36,7 +36,7 @@ def test_get_request span = spans[0] assert_equal('http.request', span.name) assert_equal('net/http', span.service) - assert_equal(ELASTICSEARCH_HOST, span.resource) + assert_equal("#{ELASTICSEARCH_HOST}:#{ELASTICSEARCH_PORT}", span.resource) assert_equal('_cluster/health', span.get_tag('http.url')) assert_equal('GET', span.get_tag('http.method')) assert_equal('200', span.get_tag('http.status_code')) @@ -52,7 +52,7 @@ def test_post_request span = spans[0] assert_equal('http.request', span.name) assert_equal('net/http', span.service) - assert_equal(ELASTICSEARCH_HOST, span.resource) + assert_equal("#{ELASTICSEARCH_HOST}:#{ELASTICSEARCH_PORT}", span.resource) assert_equal('/my/thing/42', span.get_tag('http.url')) assert_equal('POST', span.get_tag('http.method')) assert_equal('127.0.0.1', span.get_tag('out.host')) @@ -68,7 +68,7 @@ def test_404 span = spans[0] assert_equal('http.request', span.name) assert_equal('net/http', span.service) - assert_equal(ELASTICSEARCH_HOST, span.resource) + assert_equal("#{ELASTICSEARCH_HOST}:#{ELASTICSEARCH_PORT}", span.resource) assert_equal('/admin.php?user=admin&passwd=123456', span.get_tag('http.url')) assert_equal('GET', span.get_tag('http.method')) assert_equal('404', span.get_tag('http.status_code')) @@ -93,7 +93,7 @@ def test_pin_block_call span = spans[0] assert_equal('http.request', span.name) assert_equal('net/http', span.service) - assert_equal(ELASTICSEARCH_HOST, span.resource) + assert_equal("#{ELASTICSEARCH_HOST}:#{ELASTICSEARCH_PORT}", span.resource) assert_equal('/_cluster/health', span.get_tag('http.url')) assert_equal('GET', span.get_tag('http.method')) assert_equal('200', span.get_tag('http.status_code'))