diff --git a/lib/ddtrace/contrib/http/patcher.rb b/lib/ddtrace/contrib/http/patcher.rb index fd1134da49b..5684852e200 100644 --- a/lib/ddtrace/contrib/http/patcher.rb +++ b/lib/ddtrace/contrib/http/patcher.rb @@ -121,7 +121,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 a9e33d5fd2f..5a68193905b 100644 --- a/test/contrib/http/miniapp_test.rb +++ b/test/contrib/http/miniapp_test.rb @@ -29,7 +29,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 8845397f924..573969a461f 100644 --- a/test/contrib/http/request_test.rb +++ b/test/contrib/http/request_test.rb @@ -32,7 +32,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')) @@ -48,7 +48,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')) @@ -64,7 +64,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')) @@ -89,7 +89,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'))