Class: Datadog::Tracing::Workers::TraceWriter
- Inherits:
-
Core::Worker
- Object
- Core::Worker
- Datadog::Tracing::Workers::TraceWriter
- Defined in:
- lib/datadog/tracing/workers/trace_writer.rb
Overview
Writes traces to transport synchronously
Direct Known Subclasses
Defined Under Namespace
Classes: FlushCompleted
Instance Attribute Summary collapse
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Attributes inherited from Core::Worker
Instance Method Summary collapse
-
#flush_completed ⇒ Object
TODO: Register ‘Datadog::Core::Diagnostics::EnvironmentLogger.log!` TODO: as a flush_completed subscriber when the `TraceWriter` TODO: instantiation code is implemented.
- #flush_traces(traces) ⇒ Object
-
#initialize(options = {}) ⇒ TraceWriter
constructor
rubocop:disable Lint/MissingSuper.
-
#perform(traces) ⇒ Object
rubocop:enable Lint/MissingSuper.
- #process_traces(traces) ⇒ Object
- #write(trace) ⇒ Object
- #write_traces(traces) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TraceWriter
rubocop:disable Lint/MissingSuper
22 23 24 25 26 27 28 29 30 |
# File 'lib/datadog/tracing/workers/trace_writer.rb', line 22 def initialize( = {}) = .fetch(:transport_options, {}) [:agent_settings] = [:agent_settings] if .key?(:agent_settings) @transport = .fetch(:transport) do Transport::HTTP.default(**) end end |
Instance Attribute Details
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
18 19 20 |
# File 'lib/datadog/tracing/workers/trace_writer.rb', line 18 def transport @transport end |
Instance Method Details
#flush_completed ⇒ Object
TODO: Register ‘Datadog::Core::Diagnostics::EnvironmentLogger.log!` TODO: as a flush_completed subscriber when the `TraceWriter` TODO: instantiation code is implemented.
64 65 66 |
# File 'lib/datadog/tracing/workers/trace_writer.rb', line 64 def flush_completed @flush_completed ||= FlushCompleted.new end |
#flush_traces(traces) ⇒ Object
55 56 57 58 59 |
# File 'lib/datadog/tracing/workers/trace_writer.rb', line 55 def flush_traces(traces) transport.send_traces(traces).tap do |response| flush_completed.publish(response) end end |
#perform(traces) ⇒ Object
rubocop:enable Lint/MissingSuper
33 34 35 |
# File 'lib/datadog/tracing/workers/trace_writer.rb', line 33 def perform(traces) write_traces(traces) end |
#process_traces(traces) ⇒ Object
50 51 52 53 |
# File 'lib/datadog/tracing/workers/trace_writer.rb', line 50 def process_traces(traces) # Run traces through the processing pipeline Pipeline.process!(traces) end |
#write(trace) ⇒ Object
37 38 39 |
# File 'lib/datadog/tracing/workers/trace_writer.rb', line 37 def write(trace) write_traces([trace]) end |
#write_traces(traces) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/datadog/tracing/workers/trace_writer.rb', line 41 def write_traces(traces) traces = process_traces(traces) flush_traces(traces) rescue StandardError => e Datadog.logger.error( "Error while writing traces: dropped #{traces.length} items. Cause: #{e} Location: #{Array(e.backtrace).first}" ) end |