Sha256: eb59e36f5732d2cbde25041718ebd1f2874be06eebec5d30d6220b857204d551

Contents?: true

Size: 878 Bytes

Versions: 11

Compression:

Stored size: 878 Bytes

Contents

module Datadog
  # SyncWriter flushes both services and traces synchronously
  class SyncWriter
    attr_reader :transport

    def initialize(options = {})
      @transport = options.fetch(:transport) do
        transport_options = options.fetch(:transport_options, {})
        HTTPTransport.new(transport_options)
      end
    end

    def write(trace, services)
      perform_concurrently(
        proc { flush_services(services) },
        proc { flush_trace(trace) }
      )
    rescue => e
      Tracer.log.debug(e)
    end

    private

    def perform_concurrently(*tasks)
      tasks.map { |task| Thread.new(&task) }.each(&:join)
    end

    def flush_services(services)
      transport.send(:services, services)
    end

    def flush_trace(trace)
      processed_traces = Pipeline.process!([trace])
      transport.send(:traces, processed_traces)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ddtrace-0.22.0 lib/ddtrace/sync_writer.rb
ddtrace-0.21.2 lib/ddtrace/sync_writer.rb
ddtrace-0.21.1 lib/ddtrace/sync_writer.rb
ddtrace-0.21.0 lib/ddtrace/sync_writer.rb
ddtrace-0.20.0 lib/ddtrace/sync_writer.rb
ddtrace-0.19.1 lib/ddtrace/sync_writer.rb
ddtrace-0.19.0 lib/ddtrace/sync_writer.rb
ddtrace-0.18.3 lib/ddtrace/sync_writer.rb
ddtrace-0.18.2 lib/ddtrace/sync_writer.rb
ddtrace-0.18.1 lib/ddtrace/sync_writer.rb
ddtrace-0.18.0 lib/ddtrace/sync_writer.rb