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



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/kafka/datadog.rb', line 112

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