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.



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

def initialize
  super
  @queue_size = Prometheus.registry.gauge(:fetcher_queue_size, docstring: 'Queue size', labels: [:client, :group_id])
end

Instance Method Details

#loop(event) ⇒ Object



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

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(queue_size, labels: { client: client, group_id: group_id })
end