Class: NewRelic::Agent::Instrumentation::ActiveSupportSubscriber

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

Constant Summary collapse

PATTERN =
/\Acache_([^\.]*)\.active_support\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
15
16
17
# File 'lib/new_relic/agent/instrumentation/active_support_subscriber.rb', line 11

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

#method_from_name(name) ⇒ Object



35
36
37
# File 'lib/new_relic/agent/instrumentation/active_support_subscriber.rb', line 35

def method_from_name(name)
  METHOD_NAME_MAPPING[name]
end

#metric_name(name, payload) ⇒ Object



19
20
21
22
23
# File 'lib/new_relic/agent/instrumentation/active_support_subscriber.rb', line 19

def metric_name(name, payload)
  store = payload[:store]
  method = method_from_name(name)
  "Ruby/ActiveSupport#{"/#{store}" if store}/#{method}"
end