module NewRelic::Agent::Instrumentation::Roda::Ignorer

Public Class Methods

should_ignore?(app, type) click to toggle source
# File lib/new_relic/agent/instrumentation/roda/ignorer.rb, line 8
def self.should_ignore?(app, type)
  return false unless app.opts.include?(:newrelic_ignores)

  app.opts[:newrelic_ignores][type].any? do |pattern|
    pattern === app.request.path_info
  end
end

Public Instance Methods

newrelic_ignore(*routes) click to toggle source
# File lib/new_relic/agent/instrumentation/roda/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/roda/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/roda/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/roda/ignorer.rb, line 30
def set_newrelic_ignore(type, *routes)
  # Create a newrelic_ignores hash if one doesn't exist
  opts[:newrelic_ignores] = Hash.new([]) if !opts.include?(:newrelic_ignores)

  if routes.empty?
    opts[:newrelic_ignores][type] += [Regexp.new('.*')]
  else
    opts[:newrelic_ignores][type] += routes.map do |r|
      # Roda adds leading slashes to routes, so we need to do the same
      "#{'/' unless r.start_with?('/')}#{r}"
    end
  end
end