Class: Yabeda::Karafka::Consumer

Inherits:
Object
  • Object
show all
Defined in:
lib/yabeda/karafka/consumer.rb

Constant Summary collapse

BATCH_PROCESSING_TIME_BUCKETS =
[
  1, 3, 5, 10, 15, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275,
  300, 350, 400, 450, 500, 550, 600, 650, 700, 800, 900, 1_000, 1_500, 2_000,
  3_000, 4_000, 5_000, 6_000, 7_000, 8_000, 9_000, 10_000
].freeze
MESSAGE_PROCESSING_TIME_BUCKETS =
[
  1, 2, 3, 4, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 30, 35, 40, 45,
  50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 225, 250, 275, 300, 400,
  500, 600, 700, 800, 900, 1_000
].freeze
MESSAGE_PER_BATCH_BUCKETS =
[
  1, 5, 10, 15, 20, 25, 30, 40, 50, 60, 75, 100, 125, 150, 200, 250, 300, 400, 500
].freeze

Class Method Summary collapse

Class Method Details

.register_eventsObject



68
69
70
71
72
# File 'lib/yabeda/karafka/consumer.rb', line 68

def register_events
  messages_received
  messages_consumed
  error
end

.register_metricsObject

rubocop:disable Metrics/MethodLength



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/yabeda/karafka/consumer.rb', line 26

def register_metrics # rubocop:disable Metrics/MethodLength
  Yabeda.configure do
    group :karafka_consumer do
      counter :received_batches_total,
              tags: %i[topic partition consumer],
              comment: 'Total number of batches received'

      counter :received_messages_total,
              tags: %i[topic partition consumer],
              comment: 'Total number of messages received'

      counter :processed_batches_total,
              tags: %i[topic partition consumer],
              comment: 'Total number of batches processed'

      counter :processed_messages_total,
              tags: %i[topic partition consumer],
              comment: 'Total number of messages processed'

      histogram :batch_size,
                per: :batch,
                tags: %i[topic partition consumer],
                buckets: MESSAGE_PER_BATCH_BUCKETS,
                comment: 'Quantity of messages received per batch of messages'

      histogram :batch_processing_time,
                unit: :milliseconds,
                per: :batch,
                tags: %i[topic partition consumer],
                buckets: BATCH_PROCESSING_TIME_BUCKETS,
                comment: 'Time that took to process a given batch of messages'

      histogram :message_processing_time,
                unit: :milliseconds,
                per: :batch,
                tags: %i[topic partition consumer],
                buckets: MESSAGE_PROCESSING_TIME_BUCKETS,
                comment: 'Time that took to process message'
    end
  end
end