Class: Datadog::Tracing::SyncWriter

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

Overview

SyncWriter flushes both services and traces synchronously DEV: To be replaced by Datadog::Tracing::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>

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport: nil, transport_options: {}, agent_settings: nil) ⇒ SyncWriter

Returns a new instance of SyncWriter.

Parameters:



28
29
30
31
32
33
34
35
# File 'lib/datadog/tracing/sync_writer.rb', line 28

def initialize(transport: nil, transport_options: {}, agent_settings: nil)
  @transport = transport || begin
    transport_options[:agent_settings] = agent_settings if agent_settings
    Transport::HTTP.default(**transport_options)
  end

  @events = Writer::Events.new
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



19
20
21
# File 'lib/datadog/tracing/sync_writer.rb', line 19

def events
  @events
end

#transportObject (readonly)

Returns the value of attribute transport.



19
20
21
# File 'lib/datadog/tracing/sync_writer.rb', line 19

def transport
  @transport
end

Instance Method Details

#stopObject

Does nothing. The Datadog::Tracing::SyncWriter does not need to be stopped as it holds no state.



48
49
50
51
# File 'lib/datadog/tracing/sync_writer.rb', line 48

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

#write(trace) ⇒ Object

Sends traces to the configured transport.

Traces are flushed immediately.



40
41
42
43
44
# File 'lib/datadog/tracing/sync_writer.rb', line 40

def write(trace)
  flush_trace(trace)
rescue => e
  Datadog.logger.debug(e)
end