Class: Kafka::Datadog::AsyncProducerSubscriber

Inherits:
StatsdSubscriber
  • Object
show all
Defined in:
lib/kafka/datadog.rb

Instance Method Summary collapse

Instance Method Details

#buffer_overflow(event) ⇒ Object



355
356
357
358
359
360
361
362
# File 'lib/kafka/datadog.rb', line 355

def buffer_overflow(event)
  tags = {
    client: event.payload.fetch(:client_id),
    topic: event.payload.fetch(:topic),
  }

  increment("async_producer.produce.errors", tags: tags)
end

#drop_messages(event) ⇒ Object



364
365
366
367
368
369
370
371
372
# File 'lib/kafka/datadog.rb', line 364

def drop_messages(event)
  tags = {
    client: event.payload.fetch(:client_id),
  }

  message_count = event.payload.fetch(:message_count)

  count("async_producer.dropped_messages", message_count, tags: tags)
end

#enqueue_message(event) ⇒ Object



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/kafka/datadog.rb', line 336

def enqueue_message(event)
  client = event.payload.fetch(:client_id)
  topic = event.payload.fetch(:topic)
  queue_size = event.payload.fetch(:queue_size)
  max_queue_size = event.payload.fetch(:max_queue_size)
  queue_fill_ratio = queue_size.to_f / max_queue_size.to_f

  tags = {
    client: client,
    topic: topic,
  }

  # This gets us the avg/max queue size per producer.
  histogram("async_producer.queue.size", queue_size, tags: tags)

  # This gets us the avg/max queue fill ratio per producer.
  histogram("async_producer.queue.fill_ratio", queue_fill_ratio, tags: tags)
end