Module: NewRelic::Agent::Instrumentation::Sinatra

Includes:
ControllerInstrumentation
Defined in:
lib/new_relic/agent/instrumentation/sinatra.rb

Overview

NewRelic instrumentation for Sinatra applications. Sinatra actions will appear in the UI similar to controller actions, and have breakdown charts and transaction traces.

The actions in the UI will correspond to the pattern expression used to match them. HTTP operations are not distinguished. Multiple matches will all be tracked as separate actions.

Defined Under Namespace

Modules: NewRelic

Constant Summary

Constants included from QueueTime

QueueTime::ALL_MIDDLEWARE_METRIC, QueueTime::ALL_QUEUE_METRIC, QueueTime::ALL_SERVER_METRIC, QueueTime::ALT_QUEUE_HEADER, QueueTime::APP_HEADER, QueueTime::HEADER_REGEX, QueueTime::HEROKU_QUEUE_HEADER, QueueTime::MAIN_HEADER, QueueTime::MIDDLEWARE_HEADER, QueueTime::MIDDLEWARE_METRIC, QueueTime::QUEUE_HEADER, QueueTime::SERVER_METRIC

Instance Method Summary collapse

Methods included from ControllerInstrumentation

included, #newrelic_metric_path, #perform_action_with_newrelic_trace

Methods included from QueueTime

#parse_frontend_headers

Instance Method Details

#dispatch_with_newrelicObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/new_relic/agent/instrumentation/sinatra.rb', line 38

def dispatch_with_newrelic
  txn_name = NewRelic.transaction_name(self.class.routes, @request) do |pattern, keys, conditions|
    process_route(pattern, keys, conditions) do
      pattern.source
    end
  end

  perform_action_with_newrelic_trace(:category => :sinatra,
                                     :name => txn_name,
                                     :params => @request.params) do
    result = dispatch_without_newrelic

    # Will only see an error raised if :show_exceptions is true, but
    # will always see them in the env hash if they occur
    had_error = env.has_key?('sinatra.error')
    ::NewRelic::Agent.notice_error(env['sinatra.error']) if had_error

    result
  end
end

#newrelic_request_headersObject

Define Request Header accessor for Sinatra



60
61
62
# File 'lib/new_relic/agent/instrumentation/sinatra.rb', line 60

def newrelic_request_headers
  request.env
end