module Strelka::App::NewRelic
Strelka::App
plugin module for reporting application performance to New Relic.
Constants
- REVISION
Version-control revision constant
- VERSION
Library version constant
Public Class Methods
configure( config=nil )
click to toggle source
Configurability API – configure this class with the appropriate section of the universal config when it's installed.
Calls superclass method
# File lib/strelka/app/newrelic.rb, line 56 def self::configure( config=nil ) if config logger = Loggability[ NewRelic ] ra_logger = NewRelic::Agent::AgentLogger.new( {:log_level => 'debug'}, '', logger ) NewRelic::Agent.logger = ra_logger self.log.info "Applying NewRelic config: %p" % [ config.to_hash ] NewRelic::Agent.config.apply_config( config.to_hash, 1 ) end super end
Public Instance Methods
handle_request( request )
click to toggle source
Mark and time the app.
Calls superclass method
# File lib/strelka/app/newrelic.rb, line 92 def handle_request( request ) response = nil self.log.debug "[:newrelic] Instrumenting with NewRelic." request.notes[:rum_header] = NewRelic::Agent.browser_timing_header request.notes[:rum_footer] = NewRelic::Agent.browser_timing_footer txname = if !request.notes[:routing][:route].empty? note = request.notes[:routing][:route] self.log.debug "Making route name out of the route notes: %p" % [ note ] self.make_route_name( note ) else self.log.debug "Making route name out of the verb (%p) and app path (%p)" % [ request.verb, request.app_path ] "handle_request" end options = { name: txname.to_s, request: request, category: 'Controller/Strelka', } return self.perform_action_with_newrelic_trace( options ) do super end rescue => err NewRelic::Agent.notice_error( err.message ) raise end
make_route_name( route )
click to toggle source
Make a normalized transaction name from the specified route
.
# File lib/strelka/app/newrelic.rb, line 125 def make_route_name( route ) action_method = route[:action] or return '(Unknown)' return action_method.name end
run( * )
click to toggle source
Set up the NewRelic
agent.
Calls superclass method
# File lib/strelka/app/newrelic.rb, line 71 def run( * ) self.start_newrelic_agent super end
start_newrelic_agent()
click to toggle source
Starts the New Relic agent in a background thread.
# File lib/strelka/app/newrelic.rb, line 78 def start_newrelic_agent options = { framework: :ruby, dispatcher: :strelka } self.log.info "Starting the NewRelic agent with options: %p." % [ options ] NewRelic::Agent.manual_start( options ) return self end