Sha256: 7ea7b8036b9795eb2c3827d7db59f6558c5fd1267a58211ca4ebca0b0fe9e37d
Contents?: true
Size: 1.53 KB
Versions: 7
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true require_relative 'statistics' require_relative '../../../core/transport/http/env' require_relative '../../../core/transport/http/response' module Datadog module Tracing module Transport module HTTP # Routes, encodes, and sends tracer data to the trace agent via HTTP. class Client include Datadog::Tracing::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 #{self.class.name} request. Cause: #{e.class.name} #{e.message} " \ "Location: #{Array(e.backtrace).first}" # Log error if stats.consecutive_errors > 0 Datadog.logger.debug(message) else # Not to report telemetry logs Datadog.logger.error(message) end # Update statistics update_stats_from_exception!(e) Datadog::Core::Transport::InternalErrorResponse.new(e) end def build_env(request) Datadog::Core::Transport::HTTP::Env.new(request) end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems