Sha256: 46765f3b6f01b5ea3574f131ac8d2725a41992e8244257198dd81f0458de7dea

Contents?: true

Size: 820 Bytes

Versions: 34

Compression:

Stored size: 820 Bytes

Contents

module Rack::Insight::Instrumentation
  class Setup
    def initialize(app)
      @app = app
    end

    def setup(env)
      instrument = Instrument.new

      PackageDefinition.start
      instrument.start(env)

      env["rack-insight.instrument"] = instrument
      Thread::current["rack-insight.instrument"] = instrument
    end

    def teardown(env, status, headers, body)
      instrument, env["rack-insight.instrument"] = env["rack-insight.instrument"], nil
      instrument.finish(env, status, headers, body)
      Thread::current["rack-insight.instrument"] = nil

      env["rack-insight.duration"] = instrument.duration
    end

    def call(env)
      setup(env)
      status, headers, body = @app.call(env)
      teardown(env, status, headers, body)
      return [status, headers, body]
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
rack-insight-0.5.13 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.12 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.11 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.10 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.9 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.8 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.7 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.6 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.5 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.4 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.3 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.2 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.1 lib/rack/insight/instrumentation/setup.rb
rack-insight-0.5.0 lib/rack/insight/instrumentation/setup.rb