Sha256: 5229fbb073c060ffb7170c5649d44813b7543bc14bb0ecb8c8f71108ab399139

Contents?: true

Size: 738 Bytes

Versions: 17

Compression:

Stored size: 738 Bytes

Contents

require 'hallmonitor/outputter'

module Hallmonitor
  class Middleware
    def initialize(app)
      @app = app
    end

    def call(env)
      request = Rack::Request.new(env)
      @event_base_name = "http.#{request.path_info.gsub('/', '.')}.#{request.request_method}"
      if !request.path_info.match(/^\/?assets/)
        @event = Hallmonitor::TimedEvent.new("#{@event_base_name}.response_time")
        @event.start = Time.now
      else 
        @event = nil
      end

      response = @app.call(env)

      if @event
        @event.stop = Time.now
        Hallmonitor::Outputter.output(@event)
        Hallmonitor::Outputter.output(Hallmonitor::Event.new("#{@event_base_name}.count"))
      end
      response
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
hallmonitor-5.2.0 lib/hallmonitor/middleware.rb
hallmonitor-5.1.0 lib/hallmonitor/middleware.rb
hallmonitor-5.0.0 lib/hallmonitor/middleware.rb
hallmonitor-4.2.0 lib/hallmonitor/middleware.rb
hallmonitor-4.1.0 lib/hallmonitor/middleware.rb
hallmonitor-4.0.0 lib/hallmonitor/middleware.rb
hallmonitor-3.0.0 lib/hallmonitor/middleware.rb
hallmonitor-2.0.0 lib/hallmonitor/middleware.rb
hallmonitor-1.1.0 lib/hallmonitor/middleware.rb
hallmonitor-1.0.0 lib/hallmonitor/middleware.rb
hallmonitor-0.4.0 lib/hallmonitor/middleware.rb
hallmonitor-0.3.0 lib/hallmonitor/middleware.rb
hallmonitor-0.2.0 lib/hallmonitor/middleware.rb
hallmonitor-0.1.1 lib/hallmonitor/middleware.rb
hallmonitor-0.1.0 lib/hallmonitor/middleware.rb
hallmonitor-0.0.2 lib/hallmonitor/middleware.rb
hallmonitor-0.0.1 lib/hallmonitor/middleware.rb