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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SyncWriter

Returns a new instance of SyncWriter.



13
14
15
16
17
18
19
20
# File 'lib/ddtrace/sync_writer.rb', line 13

def initialize(options = {})
  @transport = options.fetch(:transport) do
    transport_options = options.fetch(:transport_options, {})
    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.



9
10
11
# File 'lib/ddtrace/sync_writer.rb', line 9

def priority_sampler
  @priority_sampler
end

#transportObject (readonly)

Returns the value of attribute transport.



9
10
11
# File 'lib/ddtrace/sync_writer.rb', line 9

def transport
  @transport
end

Instance Method Details

#stopObject

Added for interface completeness



40
41
42
43
# File 'lib/ddtrace/sync_writer.rb', line 40

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

#write(trace, services = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ddtrace/sync_writer.rb', line 22

def write(trace, services = nil)
  unless services.nil?
    Datadog::Patcher.do_once('SyncWriter#write') do
      Datadog.logger.warn(%(
        write: Writing services has been deprecated and no longer need to be provided.
        write(traces, services) can be updted to write(traces)
      ))
    end
  end

  perform_concurrently(
    proc { flush_trace(trace) }
  )
rescue => e
  Datadog.logger.debug(e)
end