Module: NewRelic::Agent::Instrumentation::Roda::Tracer

Includes:
ControllerInstrumentation
Included in:
Build::Prepend, Prepend
Defined in:
lib/new_relic/agent/instrumentation/roda/instrumentation.rb

Constant Summary collapse

INSTRUMENTATION_NAME =
'Roda'

Constants included from ControllerInstrumentation

ControllerInstrumentation::NR_DEFAULT_OPTIONS, ControllerInstrumentation::NR_DO_NOT_TRACE_KEY, ControllerInstrumentation::NR_IGNORE_APDEX_KEY, ControllerInstrumentation::NR_IGNORE_ENDUSER_KEY

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ControllerInstrumentation

#perform_action_with_newrelic_trace

Methods included from ControllerInstrumentation::ClassMethods

#add_transaction_tracer, #already_added_transaction_tracer?, #build_method_names, #generate_argument_list, #newrelic_ignore, #newrelic_ignore_apdex, #newrelic_ignore_aspect, #newrelic_ignore_enduser, #newrelic_read_attr, #newrelic_write_attr, #parse_punctuation

Class Method Details

.included(clazz) ⇒ Object



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

def self.included(clazz)
  clazz.extend(self)
end

Instance Method Details

#_roda_handle_main_route_with_tracing(*args) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/new_relic/agent/instrumentation/roda/instrumentation.rb', line 43

def _roda_handle_main_route_with_tracing(*args)
  NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

  perform_action_with_newrelic_trace(
    category: :roda,
    name: ::NewRelic::Agent::Instrumentation::Roda::TransactionNamer.transaction_name(request),
    params: ::NewRelic::Agent::ParameterFiltering::apply_filters(request.env, rack_request_params)
  ) do
    yield
  end
end

#build_rack_app_with_tracingObject



24
25
26
27
28
29
30
31
# File 'lib/new_relic/agent/instrumentation/roda/instrumentation.rb', line 24

def build_rack_app_with_tracing
  unless NewRelic::Agent.config[:disable_roda_auto_middleware]
    newrelic_middlewares.each do |middleware_class|
      self.use middleware_class
    end
  end
  yield
end

#do_not_trace?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/new_relic/agent/instrumentation/roda/instrumentation.rb', line 55

def do_not_trace?
  NewRelic::Agent::Instrumentation::Roda::Ignorer.should_ignore?(self, :routes)
end

#ignore_apdex?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/new_relic/agent/instrumentation/roda/instrumentation.rb', line 59

def ignore_apdex?
  NewRelic::Agent::Instrumentation::Roda::Ignorer.should_ignore?(self, :apdex)
end

#ignore_enduser?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/new_relic/agent/instrumentation/roda/instrumentation.rb', line 63

def ignore_enduser?
  NewRelic::Agent::Instrumentation::Roda::Ignorer.should_ignore?(self, :enduser)
end

#newrelic_middlewaresObject



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

def newrelic_middlewares
  middlewares = [NewRelic::Rack::BrowserMonitoring]
  if NewRelic::Rack::AgentHooks.needed?
    middlewares << NewRelic::Rack::AgentHooks
  end
  middlewares
end

#rack_request_paramsObject

Roda makes use of Rack, so we can get params from the request object



34
35
36
37
38
39
40
41
# File 'lib/new_relic/agent/instrumentation/roda/instrumentation.rb', line 34

def rack_request_params
  begin
    @_request.params
  rescue => e
    NewRelic::Agent.logger.debug('Failed to get params from Rack request.', e)
    NewRelic::EMPTY_HASH
  end
end