Class: Kafka::Datadog::ConnectionSubscriber

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

Instance Method Summary collapse

Instance Method Details

#request(event) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/kafka/datadog.rb', line 96

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)

  tags = {
    client: client,
    api: api,
    broker: broker
  }

  timing("api.latency", event.duration, tags: tags)
  increment("api.calls", tags: tags)

  histogram("api.request_size", request_size, tags: tags)
  histogram("api.response_size", response_size, tags: tags)

  if event.payload.key?(:exception)
    increment("api.errors", tags: tags)
  end
end