Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/kafka/consumer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ def each_message(min_bytes: 1, max_bytes: 10485760, max_wait_time: 1, automatica
)

batches.each do |batch|
unless batch.empty?
@instrumenter.instrument("fetch_batch.consumer", {
topic: batch.topic,
partition: batch.partition,
offset_lag: batch.offset_lag,
highwater_mark_offset: batch.highwater_mark_offset,
message_count: batch.messages.count,
})
end
batch.messages.each do |message|
notification = {
topic: message.topic,
Expand Down
12 changes: 12 additions & 0 deletions spec/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@
]
}

it "instruments" do
expect(instrumenter).to receive(:instrument).once.with('fetch_batch.consumer', anything)
expect(instrumenter).to receive(:instrument).once.with('start_process_message.consumer', anything)
expect(instrumenter).to receive(:instrument).once.with('process_message.consumer', anything)

allow(instrumenter).to receive(:instrument).and_call_original

consumer.each_message do |message|
consumer.stop
end
end

it "raises ProcessingError if the processing code fails" do
expect {
consumer.each_message do |message|
Expand Down