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
# 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