Class: Datadog::SyncWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/ddtrace/sync_writer.rb

Overview

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>

Constant Summary collapse

DEPRECATION_WARN_ONLY_ONCE =
Datadog::Utils::OnlyOnce.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SyncWriter

Returns a new instance of SyncWriter.



21
22
23
24
25
26
27
28
29
# 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

Instance Attribute Details

#priority_samplerObject (readonly)

Returns the value of attribute priority_sampler.



17
18
19
# File 'lib/ddtrace/sync_writer.rb', line 17

def priority_sampler
  @priority_sampler
end

#transportObject (readonly)

Returns the value of attribute transport.



17
18
19
# File 'lib/ddtrace/sync_writer.rb', line 17

def transport
  @transport
end

Instance Method Details

#stopObject

Added for interface completeness



47
48
49
50
# File 'lib/ddtrace/sync_writer.rb', line 47

def stop
  # No cleanup to do for the SyncWriter
  true
end

#write(trace, services = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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