Sha256: a6a3bda6921a25758003bad4afaf166f68110ce5431fddcb0afb704931d8be44

Contents?: true

Size: 1.56 KB

Versions: 60

Compression:

Stored size: 1.56 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
              send(:compile, r).first
            end
          end

        end
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 2 rubygems

Version Path
newrelic_rpm-3.17.1.326 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.17.0.325 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.16.3.323 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.16.2.321 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.16.1.320 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.16.0.318 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.15.2.317 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.15.1.316 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.15.0.314 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.14.3.313 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.14.2.312 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.14.1.311 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.14.0.305 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.13.2.302 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.13.1.300 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.13.0.299 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.12.1.298 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.12.0.288 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb
newrelic_rpm-3.11.2.286 lib/new_relic/agent/instrumentation/sinatra/ignorer.rb