Skip to content

Commit c753516

Browse files
authored
Merge pull request #442 from Elyahou/lag-statsd
Report consumer lag to StatsD when processing batches
2 parents b9af903 + 351cf4e commit c753516

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/kafka/statsd.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def process_message(event)
9797
end
9898

9999
def process_batch(event)
100+
lag = event.payload.fetch(:offset_lag)
100101
messages = event.payload.fetch(:message_count)
101102
client = event.payload.fetch(:client_id)
102103
group_id = event.payload.fetch(:group_id)
@@ -109,6 +110,8 @@ def process_batch(event)
109110
timing("consumer.#{client}.#{group_id}.#{topic}.#{partition}.process_batch.latency", event.duration)
110111
count("consumer.#{client}.#{group_id}.#{topic}.#{partition}.messages", messages)
111112
end
113+
114+
gauge("consumer.#{client}.#{group_id}.#{topic}.#{partition}.lag", lag)
112115
end
113116

114117
def join_group(event)

0 commit comments

Comments
 (0)