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



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/kafka/datadog.rb', line 63

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