Class: Kafka::Prometheus::FetcherSubscriber

Inherits:
ActiveSupport::Subscriber
  • Object
show all
Defined in:
lib/kafka/prometheus.rb

Instance Method Summary collapse

Constructor Details

#initializeFetcherSubscriber

Returns a new instance of FetcherSubscriber


300
301
302
303
# File 'lib/kafka/prometheus.rb', line 300

def initialize
  super
  @queue_size = Prometheus.registry.gauge(:fetcher_queue_size, 'Queue size')
end

Instance Method Details

#loop(event) ⇒ Object


305
306
307
308
309
310
311
# File 'lib/kafka/prometheus.rb', line 305

def loop(event)
  queue_size = event.payload.fetch(:queue_size)
  client = event.payload.fetch(:client_id)
  group_id = event.payload.fetch(:group_id)

  @queue_size.set({ client: client, group_id: group_id }, queue_size)
end