Sha256: 7f0850d4fb855ba5216a8c602147506e14c9e33782ec5055e7d6f12a6007bca7
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
module Scrooge module Middleware class Tracker < Scrooge::Base class << self # Around Filter compatible implementation for Rails as Dispatcher is # the root Rack application and as such don't provide access to the Rails # Routing internals from other middleware. # def filter( controller, &block ) Scrooge::Base.profile.tracker.track( Thread.scrooge_resource ) do begin Scrooge::Base.profile.framework.resource( {}, controller.request ) Scrooge::Base.profile.log "Track for Resource #{Thread.scrooge_resource.inspect}" block.call ensure Thread.reset_scrooge_resource! end end end end def initialize(app, options = {}) @app = app end # Assign a default Resource Tracker instance to Thread.current[:scrooge_resource] # and supplement it with request specific details ( format, action && controller ) # after yielding to the app.Flush Thread.current[:scrooge_resource] on completion. # def call(env) Scrooge::Base.profile.tracker.track( Thread.scrooge_resource ) do begin result = @app.call(env) Scrooge::Base.profile.framework.resource( env ) result ensure Thread.reset_scrooge_resource! end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
methodmissing-scrooge-1.0.0 | lib/scrooge/middleware/tracker.rb |
methodmissing-scrooge-1.0.1 | lib/scrooge/middleware/tracker.rb |