Sha256: c54077a457f62e29b19f098d918cec524e38836fc65bfcc0c138ae97792112bd

Contents?: true

Size: 1.17 KB

Versions: 21

Compression:

Stored size: 1.17 KB

Contents

require 'ddtrace/transport/http/statistics'
require 'ddtrace/transport/http/env'

module Datadog
  module Transport
    module HTTP
      # Routes, encodes, and sends tracer data to the trace agent via HTTP.
      class Client
        include Transport::HTTP::Statistics

        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
          response = yield(api, env)

          # Update statistics
          update_stats_from_response!(response)

          response
        rescue StandardError => e
          message = "Internal error during HTTP transport request. Cause: #{e.message} Location: #{e.backtrace.first}"

          # Log error
          if stats.consecutive_errors > 0
            Datadog.logger.debug(message)
          else
            Datadog.logger.error(message)
          end

          # Update statistics
          update_stats_from_exception!(e)

          InternalErrorResponse.new(e)
        end

        def build_env(request)
          Env.new(request)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/transport/http/client.rb
ddtrace-0.51.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.50.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.49.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.48.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.47.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.46.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.45.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.44.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.43.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.42.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.41.0 lib/ddtrace/transport/http/client.rb
ls-trace-0.2.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.40.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.39.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.38.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.37.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.36.0 lib/ddtrace/transport/http/client.rb
ddtrace-0.35.2 lib/ddtrace/transport/http/client.rb
ddtrace-0.35.1 lib/ddtrace/transport/http/client.rb