Sha256: 311a8de0357b5d82f9d81eb75b1c864ee9ae17958a067048f855dbdec48bb57a

Contents?: true

Size: 726 Bytes

Versions: 7

Compression:

Stored size: 726 Bytes

Contents

module SystemMetrics
  class Middleware
    def initialize(app, collector, path_exclude_patterns)
      @app = app
      @collector = collector
      @path_exclude_patterns = path_exclude_patterns
    end

    def call(env)
      if exclude_path? env["PATH_INFO"]
        @app.call(env)
      else
        @collector.collect do
          response = notifications.instrument "request.rack",
            :path => env["PATH_INFO"], :method => env["REQUEST_METHOD"] do
            @app.call(env)
          end
        end
      end
    end

  protected

    def exclude_path?(path)
      @path_exclude_patterns.any? { |pattern| pattern =~ path }
    end

    def notifications
      ActiveSupport::Notifications
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
system-metrics-0.2.5 lib/system_metrics/middleware.rb
system-metrics-0.2.4 lib/system_metrics/middleware.rb
system-metrics-0.2.3 lib/system_metrics/middleware.rb
system-metrics-0.2.2 lib/system_metrics/middleware.rb
system-metrics-0.2.1 lib/system_metrics/middleware.rb
system-metrics-0.2.0 lib/system_metrics/middleware.rb
system-metrics-0.1.0 lib/system_metrics/middleware.rb