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

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

Constant Summary collapse

EVENT_NAME_TO_METHOD_NAME =
{
  'cache_fetch_hit.active_support' => 'fetch_hit',
  'cache_generate.active_support' => 'generate',
  'cache_read.active_support' => 'read',
  'cache_write.active_support' => 'write',
  'cache_delete.active_support' => 'delete',
  'cache_exist?.active_support' => 'exist?',
  'cache_read_multi.active_support' => 'read_multi',
  'cache_write_multi.active_support' => 'write_multi',
  'cache_delete_multi.active_support' => 'delete_multi',
  'cache_delete_matched.active_support' => 'delete_matched',
  'cache_cleanup.active_support' => 'cleanup',
  'cache_increment.active_support' => 'increment',
  'cache_decrement.active_support' => 'decrement',
  'cache_prune.active_support' => 'prune',
  'message_serializer_fallback.active_support' => 'message_serializer_fallback'
}.freeze

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



29
30
31
32
33
34
35
# File 'lib/new_relic/agent/instrumentation/active_support_subscriber.rb', line 29

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_name(name) ⇒ Object



43
44
45
# File 'lib/new_relic/agent/instrumentation/active_support_subscriber.rb', line 43

def method_name(name)
  EVENT_NAME_TO_METHOD_NAME.fetch(name, name.delete_prefix('cache_').delete_suffix('.active_support'))
end

#metric_name(name, payload) ⇒ Object



37
38
39
40
41
# File 'lib/new_relic/agent/instrumentation/active_support_subscriber.rb', line 37

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