aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_storage/service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/active_storage/service.rb')
-rw-r--r--lib/active_storage/service.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/active_storage/service.rb b/lib/active_storage/service.rb
index 86f867c293..f50849b694 100644
--- a/lib/active_storage/service.rb
+++ b/lib/active_storage/service.rb
@@ -1,3 +1,5 @@
+require_relative "log_subscriber"
+
# Abstract class serving as an interface for concrete services.
#
# The available services are:
@@ -35,6 +37,8 @@ class ActiveStorage::Service
extend ActiveSupport::Autoload
autoload :Configurator
+ class_attribute :logger
+
class << self
# Configure an Active Storage service by name from a set of configurations,
# typically loaded from a YAML file. The Active Storage engine uses this
@@ -73,4 +77,16 @@ class ActiveStorage::Service
def url(key, expires_in:, disposition:, filename:)
raise NotImplementedError
end
+
+ private
+ def instrument(operation, key, payload = {}, &block)
+ ActiveSupport::Notifications.instrument(
+ "service_#{operation}.active_storage",
+ payload.merge(key: key, service: service_name), &block)
+ end
+
+ def service_name
+ # ActiveStorage::Service::DiskService => Disk
+ self.class.name.split("::").third.remove("Service")
+ end
end