Class: NewRelic::Agent::Instrumentation::ActiveStorageSubscriber

Inherits:
NotificationsSubscriber show all
Defined in:
lib/new_relic/agent/instrumentation/active_storage_subscriber.rb

Constant Summary collapse

PATTERN =
/\Aservice_([^\.]*)\.active_storage\z/
METHOD_NAME_MAPPING =
Hash.new do |h, k|
  if PATTERN =~ k
    h[k] = $1
  else
    h[k] = NewRelic::UNKNOWN
  end
end

Instance Method Summary collapse

Methods inherited from NotificationsSubscriber

#define_exception_method, find_all_subscribers, #finish, #finish_segment, #initialize, #log_notification_error, #pop_segment, #push_segment, #segment_stack, #start, #start_segment, #state, subscribe, subscribed?

Constructor Details

This class inherits a constructor from NewRelic::Agent::Instrumentation::NotificationsSubscriber

Instance Method Details

#add_segment_params(segment, payload) ⇒ Object



11
12
13
14
# File 'lib/new_relic/agent/instrumentation/active_storage_subscriber.rb', line 11

def add_segment_params(segment, payload)
  segment.params[:key] = payload[:key]
  segment.params[:exist] = payload[:exist] if payload.key?(:exist)
end

#method_from_name(name) ⇒ Object



32
33
34
# File 'lib/new_relic/agent/instrumentation/active_storage_subscriber.rb', line 32

def method_from_name(name)
  METHOD_NAME_MAPPING[name]
end

#metric_name(name, payload) ⇒ Object



16
17
18
19
20
# File 'lib/new_relic/agent/instrumentation/active_storage_subscriber.rb', line 16

def metric_name(name, payload)
  service = payload[:service]
  method = method_from_name(name)
  "Ruby/ActiveStorage/#{service}Service/#{method}"
end