Class: Datadog::Tracing::Transport::HTTP::Client
- Inherits:
-
Object
- Object
- Datadog::Tracing::Transport::HTTP::Client
- Includes:
- Statistics, Traces::Client
- Defined in:
- lib/datadog/tracing/transport/http/client.rb
Overview
Routes, encodes, and sends tracer data to the trace agent via HTTP.
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
- #build_env(request) ⇒ Object
-
#initialize(api) ⇒ Client
constructor
A new instance of Client.
- #send_request(request, &block) ⇒ Object
Methods included from Traces::Client
Methods included from Statistics
Constructor Details
#initialize(api) ⇒ Client
Returns a new instance of Client.
17 18 19 |
# File 'lib/datadog/tracing/transport/http/client.rb', line 17 def initialize(api) @api = api end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
15 16 17 |
# File 'lib/datadog/tracing/transport/http/client.rb', line 15 def api @api end |
Instance Method Details
#build_env(request) ⇒ Object
50 51 52 |
# File 'lib/datadog/tracing/transport/http/client.rb', line 50 def build_env(request) Datadog::Core::Transport::HTTP::Env.new(request) end |
#send_request(request, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/datadog/tracing/transport/http/client.rb', line 21 def send_request(request, &block) # Build request into env env = build_env(request) # Get responses from API response = yield(api, env) # Update statistics update_stats_from_response!(response) response rescue StandardError => e = "Internal error during #{self.class.name} request. Cause: #{e.class.name} #{e.} " \ "Location: #{Array(e.backtrace).first}" # Log error if stats.consecutive_errors > 0 Datadog.logger.debug() else Datadog.logger.error() end # Update statistics update_stats_from_exception!(e) Datadog::Core::Transport::InternalErrorResponse.new(e) end |