Sha256: 3aab53fb3c77d84daef0a9968cfbe95b28dd4cd35cb350e316327db0c74d9f15

Contents?: true

Size: 1.57 KB

Versions: 33

Compression:

Stored size: 1.57 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module NewRelic
  module Agent
    module Instrumentation
      module Sinatra
        module Ignorer

          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

          def newrelic_ignore(*routes)
            set_newrelic_ignore(:routes, *routes)
          end

          def newrelic_ignore_apdex(*routes)
            set_newrelic_ignore(:apdex, *routes)
          end

          def newrelic_ignore_enduser(*routes)
            set_newrelic_ignore(:enduser, *routes)
          end

          private

          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 = ["*"] 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

        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
newrelic_rpm-6.11.0.365 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.10.0.364 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.9.0.363 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.8.0.360 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.7.0.359 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.6.0.358 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.5.0.357 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.4.0.356 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.3.0.355 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.2.0.354 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.1.0.352 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-6.0.0.351 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-5.7.0.350 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-5.6.0.349 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-5.5.0.348 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-5.4.0.347 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-5.3.0.346 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-5.2.0.345 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-5.1.0.344 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-5.0.0.342 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb