class Datadog::SyncWriter
SyncWriter
flushes both services and traces synchronously DEV: To be replaced by Datadog::Workers::TraceWriter
.
Note: If you're wondering if this class is used at all, since there are no other references to it on the codebase, the separate `datadog-lambda` uses it as of February 2021: <github.com/DataDog/datadog-lambda-rb/blob/c15f0f0916c90123416dc44e7d6800ef4a7cfdbf/lib/datadog/lambda.rb#L38>
Constants
- DEPRECATION_WARN_ONLY_ONCE
Attributes
priority_sampler[R]
transport[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/ddtrace/sync_writer.rb, line 21 def initialize(options = {}) @transport = options.fetch(:transport) do transport_options = options.fetch(:transport_options, {}) transport_options[:agent_settings] = options[:agent_settings] if options.key?(:agent_settings) Transport::HTTP.default(**transport_options) end @priority_sampler = options.fetch(:priority_sampler, nil) end
Public Instance Methods
stop()
click to toggle source
Added for interface completeness
# File lib/ddtrace/sync_writer.rb, line 47 def stop # No cleanup to do for the SyncWriter true end
write(trace, services = nil)
click to toggle source
# File lib/ddtrace/sync_writer.rb, line 31 def write(trace, services = nil) unless services.nil? DEPRECATION_WARN_ONLY_ONCE.run do Datadog.logger.warn(%( write: Writing services has been deprecated and no longer need to be provided. write(traces, services) can be updated to write(traces) )) end end flush_trace(trace) rescue => e Datadog.logger.debug(e) end
Private Instance Methods
flush_trace(trace)
click to toggle source
# File lib/ddtrace/sync_writer.rb, line 54 def flush_trace(trace) processed_traces = Pipeline.process!([trace]) return if processed_traces.empty? inject_hostname!(processed_traces.first) if Datadog.configuration.report_hostname transport.send_traces(processed_traces) end
inject_hostname!(trace)
click to toggle source
# File lib/ddtrace/sync_writer.rb, line 62 def inject_hostname!(trace) unless trace.first.nil? hostname = Datadog::Core::Environment::Socket.hostname trace.first.set_tag(Ext::NET::TAG_HOSTNAME, hostname) unless hostname.nil? || hostname.empty? end end