Sha256: 84251a028cb17493de01cbfe925fd13ba9d661fa879a618505ece0adcdcb5702
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require_relative 'request' require_relative 'http/transport' require_relative '../utils/sequence' require_relative '../utils/forking' module Datadog module Core module Telemetry # Class that emits telemetry events class Emitter attr_reader :http_transport extend Core::Utils::Forking # @param http_transport [Datadog::Core::Telemetry::Http::Transport] Transport object that can be used to send # telemetry requests via the agent def initialize(http_transport: Datadog::Core::Telemetry::Http::Transport.new) @http_transport = http_transport end # Retrieves and emits a TelemetryRequest object based on the request type specified def request(event) begin seq_id = self.class.sequence.next payload = Request.build_payload(event, seq_id) res = @http_transport.request(request_type: event.type, payload: payload.to_json) Datadog.logger.debug { "Telemetry sent for event `#{event.type}` (status code: #{res.code})" } res rescue => e Datadog.logger.debug("Unable to send telemetry request for event `#{event.type rescue 'unknown'}`: #{e}") Telemetry::Http::InternalErrorResponse.new(e) end end # Initializes a Sequence object to track seq_id if not already initialized; else returns stored # Sequence object def self.sequence after_fork! { @sequence = Datadog::Core::Utils::Sequence.new(1) } @sequence ||= Datadog::Core::Utils::Sequence.new(1) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ddtrace-1.22.0 | lib/datadog/core/telemetry/emitter.rb |