WaterDrop Instrumentation Events¶
This page lists all available instrumentation events for WaterDrop.
Overview¶
WaterDrop uses a notification system that allows you to monitor and hook into various stages of message processing and producer operations. You can subscribe to any of these events to add custom monitoring, logging, or other functionality.
Available Events¶
Below is the complete list of instrumentation events available in WaterDrop:
Buffer Events¶
buffer.flushed_asyncbuffer.flushed_syncbuffer.purged
Error Events¶
error.occurred
Message Events¶
message.acknowledgedmessage.bufferedmessage.produced_asyncmessage.produced_syncmessage.purged
Messages Events¶
messages.bufferedmessages.produced_asyncmessages.produced_sync
Oauthbearer Events¶
oauthbearer.token_refresh
Producer Events¶
producer.closedproducer.closingproducer.connectedproducer.disconnectedproducer.disconnectingproducer.reloadproducer.reloaded
Statistics Events¶
statistics.emitted
Transaction Events¶
transaction.abortedtransaction.committedtransaction.finishedtransaction.marked_as_consumedtransaction.started
Usage Example¶
To subscribe to any of these events, you can use the instrumentation monitor:
WaterDrop::App.monitor.subscribe('event.name') do |event|
# Your custom logic here
puts "Event: #{event.id}"
puts "Payload: #{event.payload}"
end
For more information about using instrumentation, please refer to the main documentation.
Class-Level Events¶
WaterDrop also provides class-level instrumentation that allows you to monitor events across all producer instances. This is useful for external libraries and monitoring tools that need to hook into producer lifecycle events without requiring specific producer instance references.
Available Class-Level Events¶
Connection_pool Events¶
connection_pool.createdconnection_pool.reloadconnection_pool.reloadedconnection_pool.setupconnection_pool.shutdown
Producer Events¶
producer.configuredproducer.created
Class-Level Usage Example¶
# Subscribe to global producer lifecycle events
WaterDrop.monitor.subscribe('producer.configured') do |event|
producer = event[:producer]
puts "Producer configured: #{producer.id}"
# Example: Add middleware after producer is fully configured
producer.middleware.append do |message|
message
end
end
# All producers will now trigger the above callback
producer = WaterDrop::Producer.new do |config|
config.kafka = { 'bootstrap.servers': 'localhost:9092' }
end
For more details on class-level instrumentation patterns, see the Monitoring and Logging documentation.
Last modified: 2025-12-08 17:38:16