module Mmtrix::Agent::Instrumentation::Sinatra::Ignorer

Public Class Methods

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

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

Public Instance Methods

mmtrix_ignore(*routes) click to toggle source
# File lib/mmtrix/agent/instrumentation/sinatra/ignorer.rb, line 19
def mmtrix_ignore(*routes)
  set_mmtrix_ignore(:routes, *routes)
end
mmtrix_ignore_apdex(*routes) click to toggle source
# File lib/mmtrix/agent/instrumentation/sinatra/ignorer.rb, line 23
def mmtrix_ignore_apdex(*routes)
  set_mmtrix_ignore(:apdex, *routes)
end
mmtrix_ignore_enduser(*routes) click to toggle source
# File lib/mmtrix/agent/instrumentation/sinatra/ignorer.rb, line 27
def mmtrix_ignore_enduser(*routes)
  set_mmtrix_ignore(:enduser, *routes)
end

Private Instance Methods

set_mmtrix_ignore(type, *routes) click to toggle source
# File lib/mmtrix/agent/instrumentation/sinatra/ignorer.rb, line 33
def set_mmtrix_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 :mmtrix_ignores, Hash.new([]) if !respond_to?(:mmtrix_ignores)

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

  settings.mmtrix_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
    send(:compile, r).first
  end
end