Class: Fluent::DatadogOutput::DatadogClient

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/out_datadog.rb

Overview

Top level class for datadog transport clients, managing retries and backoff

Direct Known Subclasses

DatadogHTTPClient, DatadogTCPClient

Instance Method Summary collapse

Instance Method Details

#close ⇒ Object

Raises:

  • (NotImplementedError)


343
344
345
# File 'lib/fluent/plugin/out_datadog.rb', line 343

def close
  raise NotImplementedError, "Datadog transport client should implement the close method"
end

#send(payload) ⇒ Object

Raises:

  • (NotImplementedError)


339
340
341
# File 'lib/fluent/plugin/out_datadog.rb', line 339

def send(payload)
  raise NotImplementedError, "Datadog transport client should implement the send method"
end

#send_retries(payload, max_retries, max_backoff) ⇒ Object



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/fluent/plugin/out_datadog.rb', line 319

def send_retries(payload, max_retries, max_backoff)
  backoff = 1
  retries = 0
  begin
    send(payload)
  rescue RetryableError => e
    if retries < max_retries || max_retries < 0
      @logger.warn("Retrying ", :exception => e, :backtrace => e.backtrace)
      sleep backoff
      backoff = 2 * backoff unless backoff > max_backoff
      retries += 1
      retry
    end
    # Bounded retries exhausted: re-raise so the caller (and, ultimately,
    # Fluentd core's buffer retry) is signalled instead of the failure being
    # swallowed and the chunk silently dropped.
    raise
  end
end