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

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: https://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, logger: Datadog.logger) ⇒ SyncWriter

Returns a new instance of SyncWriter.

Parameters:

  • transport (Datadog::Tracing::Transport::Traces::Transport) (defaults to: nil)

    a custom transport instance. If provided, overrides transport_options and agent_settings.

  • transport_options (Hash<Symbol,Object>) (defaults to: {})

    options for the default transport instance.

  • agent_settings (Datadog::Tracing::Configuration::AgentSettingsResolver::AgentSettings) (defaults to: nil)

    agent options for the default transport instance.



30
31
32
33
34
35
36
37
38
39
# File 'lib/datadog/tracing/sync_writer.rb', line 30

def initialize(transport: nil, transport_options: {}, agent_settings: nil, logger: Datadog.logger)
  @logger = logger
  @agent_settings = agent_settings

  @transport = transport || begin
    Transport::HTTP.default(agent_settings: agent_settings, logger: logger, **transport_options)
  end

  @events = Writer::Events.new
end

Instance Attribute Details

#agent_settingsObject (readonly)

Returns the value of attribute agent_settings.



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

def agent_settings
  @agent_settings
end

#eventsObject (readonly)

Returns the value of attribute events.



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

def events
  @events
end

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
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.



52
53
54
55
# File 'lib/datadog/tracing/sync_writer.rb', line 52

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

#write(trace) ⇒ Object

Sends traces to the configured transport.

Traces are flushed immediately.



44
45
46
47
48
# File 'lib/datadog/tracing/sync_writer.rb', line 44

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