Class: Datadog::Core::Telemetry::Emitter
- Inherits:
-
Object
- Object
- Datadog::Core::Telemetry::Emitter
- Extended by:
- Utils::Forking
- Defined in:
- lib/datadog/core/telemetry/emitter.rb
Overview
Class that emits telemetry events
Instance Attribute Summary collapse
-
#http_transport ⇒ Object
readonly
Returns the value of attribute http_transport.
Class Method Summary collapse
-
.sequence ⇒ Object
Initializes a Sequence object to track seq_id if not already initialized; else returns stored Sequence object.
Instance Method Summary collapse
-
#initialize(http_transport: Datadog::Core::Telemetry::Http::Transport.new) ⇒ Emitter
constructor
A new instance of Emitter.
-
#request(event) ⇒ Object
Retrieves and emits a TelemetryRequest object based on the request type specified.
Methods included from Utils::Forking
after_fork!, extended, fork_pid, forked?, included, update_fork_pid!
Constructor Details
Instance Attribute Details
#http_transport ⇒ Object (readonly)
Returns the value of attribute http_transport.
11 12 13 |
# File 'lib/datadog/core/telemetry/emitter.rb', line 11 def http_transport @http_transport end |
Class Method Details
.sequence ⇒ Object
Initializes a Sequence object to track seq_id if not already initialized; else returns stored Sequence object
37 38 39 40 |
# File 'lib/datadog/core/telemetry/emitter.rb', line 37 def self.sequence after_fork! { @sequence = Datadog::Core::Utils::Sequence.new(1) } @sequence ||= Datadog::Core::Utils::Sequence.new(1) end |
Instance Method Details
#request(event) ⇒ Object
Retrieves and emits a TelemetryRequest object based on the request type specified
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/datadog/core/telemetry/emitter.rb', line 22 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}` (code: #{res.code.inspect})" } 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 |