Class: Kafka::Statsd::ConnectionSubscriber

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

Instance Method Summary collapse

Instance Method Details

#request(event) ⇒ Object


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/kafka/statsd.rb', line 62

def request(event)
  client = event.payload.fetch(:client_id)
  api = event.payload.fetch(:api, "unknown")
  request_size = event.payload.fetch(:request_size, 0)
  response_size = event.payload.fetch(:response_size, 0)
  broker = event.payload.fetch(:broker_host)

  timing("api.#{client}.#{api}.#{broker}.latency", event.duration)
  increment("api.#{client}.#{api}.#{broker}.calls")

  timing("api.#{client}.#{api}.#{broker}.request_size", request_size)
  timing("api.#{client}.#{api}.#{broker}.response_size", response_size)

  if event.payload.key?(:exception)
    increment("api.#{client}.#{api}.#{broker}.errors")
  end
end