Module: Woods::Observability::Instrumentation
- Defined in:
- lib/woods/observability/instrumentation.rb
Overview
Lightweight instrumentation wrapper that delegates to ActiveSupport::Notifications when available, and falls back to a simple yield otherwise.
Class Method Summary collapse
-
.instrument(event, payload = {}) {|payload| ... } ⇒ Object
Instrument a block of code with an event name and payload.
Class Method Details
.instrument(event, payload = {}) {|payload| ... } ⇒ Object
Instrument a block of code with an event name and payload.
Delegates to ActiveSupport::Notifications.instrument when available. Otherwise, yields the block directly.
25 26 27 28 29 30 31 |
# File 'lib/woods/observability/instrumentation.rb', line 25 def instrument(event, payload = {}, &block) if defined?(ActiveSupport::Notifications) ActiveSupport::Notifications.instrument(event, payload, &block) elsif block yield payload end end |