module Shrine::Plugins::Instrumentation
Documentation can be found on shrinerb.com/docs/plugins/instrumentation
Constants
- EVENTS
- LOG_SUBSCRIBER
We use a proc in order to be able identify listeners.
Public Class Methods
configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 12 def self.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) uploader.opts[:instrumentation] ||= { log_events: EVENTS, subscribers: {} } uploader.opts[:instrumentation].merge!(opts) begin uploader.opts[:instrumentation][:notifications] ||= ::ActiveSupport::Notifications rescue NameError fail Error, "default notifications library is ActiveSupport::Notifications, but activesupport gem is not installed" end uploader.opts[:instrumentation][:log_events].each do |event_name| uploader.subscribe(event_name, &log_subscriber) end end