Sha256: 5fb9cc6088bcb542b7cb4537ab19b3ca98b2a2fe7b9d3f73013356a3b028fd06
Contents?: true
Size: 1.79 KB
Versions: 6
Compression:
Stored size: 1.79 KB
Contents
require 'ddtrace/transport/statistics' require 'ddtrace/transport/io/response' module Datadog module Transport module IO # Encodes and writes tracer data to IO class Client include Transport::Statistics attr_reader \ :encoder, :out def initialize(out, encoder) @out = out @encoder = encoder end def send_request(request) # Write data to IO # If block is given, allow it to handle writing # Otherwise use default encoding. response = if block_given? yield(out, request) else send_default_request(out, request) end # Update statistics update_stats_from_response!(response) # Return response response rescue StandardError => e message = "Internal error during IO transport request. Cause: #{e.message} Location: #{e.backtrace.first}" # Log error if stats.consecutive_errors > 0 Datadog::Logger.log.debug(message) else Datadog::Logger.log.error(message) end # Update statistics update_stats_from_exception!(e) InternalErrorResponse.new(e) end protected def encode_data(encoder, request) request.parcel.encode_with(encoder) end def write_data(out, data) out.puts(data) end private def send_default_request(out, request) # Encode data data = encode_data(encoder, request) # Write to IO result = write_data(out, data) # Generate a response IO::Response.new(result) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems