module NewRelic::Agent::Instrumentation::Sinatra::Ignorer

Public Class Methods

should_ignore?(app, type) click to toggle source
# File lib/new_relic/agent/instrumentation/sinatra/ignorer.rb, line 8
def self.should_ignore?(app, type)
  return false if !app.settings.respond_to?(:newrelic_ignores)

  app.settings.newrelic_ignores[type].any? do |pattern|
    pattern.match(app.request.path_info)
  end
end

Public Instance Methods

newrelic_ignore(*routes) click to toggle source
# File lib/new_relic/agent/instrumentation/sinatra/ignorer.rb, line 16
def newrelic_ignore(*routes)
  set_newrelic_ignore(:routes, *routes)
end
newrelic_ignore_apdex(*routes) click to toggle source
# File lib/new_relic/agent/instrumentation/sinatra/ignorer.rb, line 20
def newrelic_ignore_apdex(*routes)
  set_newrelic_ignore(:apdex, *routes)
end
newrelic_ignore_enduser(*routes) click to toggle source
# File lib/new_relic/agent/instrumentation/sinatra/ignorer.rb, line 24
def newrelic_ignore_enduser(*routes)
  set_newrelic_ignore(:enduser, *routes)
end

Private Instance Methods

set_newrelic_ignore(type, *routes) click to toggle source
# File lib/new_relic/agent/instrumentation/sinatra/ignorer.rb, line 30
def set_newrelic_ignore(type, *routes)
  # Important to default this in the context of the actual app
  # If it's done at register time, ignores end up shared between apps.
  set(:newrelic_ignores, Hash.new([])) if !respond_to?(:newrelic_ignores)

  # If we call an ignore without a route, it applies to the whole app
  routes = [::NewRelic::ASTERISK] if routes.empty?

  settings.newrelic_ignores[type] += routes.map do |r|
    # Ugly sending to private Base#compile, but we want to mimic
    # exactly Sinatra's mapping of route text to regex
    Array(send(:compile, r)).first
  end
end