Class: Yabeda::Karafka::Producer

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

Constant Summary collapse

MESSAGE_TRANMISSION_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
]

Class Method Summary collapse

Class Method Details

.register_eventsObject



32
33
34
35
36
37
# File 'lib/yabeda/karafka/producer.rb', line 32

def register_events
  %w[sync async].each do |type|
    message_sent(type)
    message_batch_sent(type)
  end
end

.register_metricsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/yabeda/karafka/producer.rb', line 15

def register_metrics
  Yabeda.configure do
    group :karafka_producer do
      counter :sent_messages_total,
              tags: %i[topic type],
              comment: 'Total number of kafka messages produced'

      histogram :message_send_time,
                unit: :milliseconds,
                per: :message,
                tags: %i[topic type],
                buckets: MESSAGE_TRANMISSION_TIME_BUCKETS,
                comment: 'Time that took to send a message'
    end
  end
end