class Invoca::Metrics::Batch

Public Class Methods

new(client, statsd_batch) click to toggle source

@param [Invoca::Metrics::Client] client requires a configured Client instance @param [Statsd::Batch] statsd_batch requires a configured Batch instance

Calls superclass method
# File lib/invoca/metrics/batch.rb, line 13
def initialize(client, statsd_batch)
  super(
    hostname: client.hostname,
    port: client.port,
    cluster_name: client.cluster_name,
    service_name: client.service_name,
    server_label: client.server_label,
    sub_server_name: client.sub_server_name,
    namespace: client.namespace
  )
  @statsd_client = statsd_batch
end

Public Instance Methods

ensure_send() { |self| ... } click to toggle source

@yields [Batch] yields itself

A convenience method to ensure that data is not lost in the event of an exception being thrown. Batches will be transmitted on the parent socket as soon as the batch is full, and when the block finishes.

# File lib/invoca/metrics/batch.rb, line 31
def ensure_send
  yield self
ensure
  statsd_client.flush
end