Module: OpenTelemetry::Instrumentation::HTTP::Patches::Stable::Client

Defined in:
lib/opentelemetry/instrumentation/http/patches/stable/client.rb

Overview

Module to prepend to HTTP::Client for instrumentation

Constant Summary collapse

HTTP_STATUS_SUCCESS_RANGE =

Constant for the HTTP status range

(100..399)

Instance Method Summary collapse

Instance Method Details

#perform(req, options) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/opentelemetry/instrumentation/http/patches/stable/client.rb', line 18

def perform(req, options)
  span_data = HttpHelper.span_attrs_for_stable(req.verb)

  uri = req.uri
  span_name = create_span_name(span_data, uri.path)

  attributes = { 'url.scheme' => uri.scheme,
                 'url.path' => uri.path,
                 'url.full' => "#{uri.scheme}://#{uri.host}",
                 'server.address' => uri.host,
                 'server.port' => uri.port }
  attributes['url.query'] = uri.query unless uri.query.nil?
  attributes.merge!(span_data.attributes)

  tracer.in_span(span_name, attributes: attributes, kind: :client) do |span|
    OpenTelemetry.propagation.inject(req.headers)
    super.tap do |response|
      annotate_span_with_response!(span, response)
    end
  end
end