Class: Datadog::SyncWriter

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

Overview

SyncWriter flushes both services and traces synchronously

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SyncWriter

Returns a new instance of SyncWriter.



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

def initialize(options = {})
  @transport = options.fetch(:transport) do
    transport_options = options.fetch(:transport_options, {})
    Transport::HTTP.default(transport_options)
  end

  # Runtime metrics
  @runtime_metrics = options.fetch(:runtime_metrics) do
    Runtime::Metrics.new
  end
end

Instance Attribute Details

#runtime_metricsObject (readonly)

Returns the value of attribute runtime_metrics.



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

def runtime_metrics
  @runtime_metrics
end

#transportObject (readonly)

Returns the value of attribute transport.



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

def transport
  @transport
end

Instance Method Details

#write(trace, services = nil) ⇒ Object



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

def write(trace, services = nil)
  unless services.nil?
    Datadog::Patcher.do_once('SyncWriter#write') do
      Datadog::Tracer.log.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
  Tracer.log.debug(e)
end