Skip to content

Commit

Permalink
Include Hostname and Port into net/http resource
Browse files Browse the repository at this point in the history
  • Loading branch information
buddhistpirate committed Mar 19, 2018
1 parent cfbeb7e commit 1c50dca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/ddtrace/contrib/http/patcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion test/contrib/http/miniapp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
8 changes: 4 additions & 4 deletions test/contrib/http/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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'))
Expand All @@ -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'))
Expand All @@ -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'))
Expand Down

0 comments on commit 1c50dca

Please sign in to comment.