lib/ddtrace/contrib/http/patcher.rb in ddtrace-0.5.0 vs lib/ddtrace/contrib/http/patcher.rb in ddtrace-0.6.0
- old
+ new
@@ -16,11 +16,11 @@
def should_skip_tracing?(req, address, port, transport, pin)
# we don't want to trace our own call to the API (they use net/http)
# when we know the host & port (from the URI) we use it, else (most-likely
# called with a block) rely on the URL at the end.
- if req.uri
+ if req.respond_to?(:uri) && req.uri
if req.uri.host.to_s == transport.hostname.to_s &&
req.uri.port.to_i == transport.port.to_i
return true
end
elsif address && port &&
@@ -94,17 +94,17 @@
pin.tracer.trace(NAME) do |span|
span.service = pin.service
span.span_type = Datadog::Ext::HTTP::TYPE
- span.resource = req.path
- # *NOT* filling Datadog::Ext::HTTP::URL as it's already in resource.
- # The agent can then decide to quantize the URL and store the original,
- # untouched data in http.url but the client should not send redundant fields.
+ span.resource = req.method
+ # Using the method as a resource, as URL/path can trigger
+ # a possibly infinite number of resources.
+ span.set_tag(Datadog::Ext::HTTP::URL, req.path)
span.set_tag(Datadog::Ext::HTTP::METHOD, req.method)
response = request_without_datadog(req, body, &block)
span.set_tag(Datadog::Ext::HTTP::STATUS_CODE, response.code)
- if req.uri
+ if req.respond_to?(:uri) && req.uri
span.set_tag(Datadog::Ext::NET::TARGET_HOST, req.uri.host)
span.set_tag(Datadog::Ext::NET::TARGET_PORT, req.uri.port.to_s)
else
span.set_tag(Datadog::Ext::NET::TARGET_HOST, @address)
span.set_tag(Datadog::Ext::NET::TARGET_PORT, @port.to_s)