Documentation can be found on shrinerb.com/docs/plugins/instrumentation
Classes and Modules
Constants
EVENTS | = | %i[upload download open exists delete metadata].freeze | ||
LOG_SUBSCRIBER | = | -> (event) { LogSubscriber.call(event) } |
We use a proc in order to be able identify listeners. |
Public Class methods
configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts)
[show source]
# File lib/shrine/plugins/instrumentation.rb 12 def self.configure(uploader, log_subscriber: LOG_SUBSCRIBER, **opts) 13 uploader.opts[:instrumentation] ||= { log_events: EVENTS, subscribers: {} } 14 uploader.opts[:instrumentation].merge!(opts) 15 begin 16 uploader.opts[:instrumentation][:notifications] ||= ::ActiveSupport::Notifications 17 rescue NameError 18 fail Error, "default notifications library is ActiveSupport::Notifications, but activesupport gem is not installed" 19 end 20 21 uploader.opts[:instrumentation][:log_events].each do |event_name| 22 uploader.subscribe(event_name, &log_subscriber) 23 end 24 end