Sha256: 9806a991427f04e0ca7b8804aa686756531ade25391d2e31c2a24d461fec5362

Contents?: true

Size: 1.31 KB

Versions: 24

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_relative '../../../../core/transport/http/env'
require_relative '../../../../core/transport/http/response'

# TODO: Decouple transport/http/client
#
# The standard one does `include Transport::HTTP::Statistics` and performs
# stats updates, which may or may not be desirable in general.

module Datadog
  module Core
    module Remote
      module Transport
        module HTTP
          # Routes, encodes, and sends tracer data to the trace agent via HTTP.
          class Client
            attr_reader :api

            def initialize(api)
              @api = api
            end

            def send_request(request, &block)
              # Build request into env
              env = build_env(request)

              # Get responses from API
              yield(api, env)
            rescue StandardError => e
              message =
                "Internal error during #{self.class.name} request. Cause: #{e.class.name} #{e.message} " \
                  "Location: #{Array(e.backtrace).first}"

              Datadog.logger.debug(message)

              Datadog::Core::Transport::InternalErrorResponse.new(e)
            end

            def build_env(request)
              Datadog::Core::Transport::HTTP::Env.new(request)
            end
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
datadog-2.7.0 lib/datadog/core/remote/transport/http/client.rb
datadog-2.6.0 lib/datadog/core/remote/transport/http/client.rb
datadog-2.5.0 lib/datadog/core/remote/transport/http/client.rb
datadog-2.4.0 lib/datadog/core/remote/transport/http/client.rb
datadog-2.3.0 lib/datadog/core/remote/transport/http/client.rb
datadog-2.2.0 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.23.3 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.23.2 lib/datadog/core/remote/transport/http/client.rb
datadog-2.1.0 lib/datadog/core/remote/transport/http/client.rb
datadog-2.0.0 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.23.1 lib/datadog/core/remote/transport/http/client.rb
datadog-2.0.0.beta2 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.22.0 lib/datadog/core/remote/transport/http/client.rb
datadog-2.0.0.beta1 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.21.1 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.21.0 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.20.0 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.19.0 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.18.0 lib/datadog/core/remote/transport/http/client.rb
ddtrace-1.17.0 lib/datadog/core/remote/transport/http/client.rb