Class: Goliath::Rack::Tracer
- Inherits:
-
Object
- Object
- Goliath::Rack::Tracer
- Defined in:
- lib/goliath/rack/tracer.rb
Overview
Middleware to inject the tracer statistics into the response headers.
Instance Method Summary (collapse)
- - (Object) call(env)
-
- (Tracer) initialize(app)
constructor
A new instance of Tracer.
- - (Object) post_process(env, status, headers, body)
Constructor Details
- (Tracer) initialize(app)
A new instance of Tracer
9 10 11 |
# File 'lib/goliath/rack/tracer.rb', line 9 def initialize(app) @app = app end |
Instance Method Details
- (Object) call(env)
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/goliath/rack/tracer.rb', line 13 def call(env) async_cb = env['async.callback'] env['async.callback'] = Proc.new do |status, headers, body| async_cb.call(post_process(env, status, headers, body)) env.logger.info env.trace_stats.collect{|s| s.join(':')}.join(', ') end status, headers, body = @app.call(env) post_process(env, status, headers, body) end |
- (Object) post_process(env, status, headers, body)
25 26 27 28 |
# File 'lib/goliath/rack/tracer.rb', line 25 def post_process(env, status, headers, body) extra = { 'X-PostRank' => env.trace_stats.collect{|s| s.join(': ')}.join(', ')} [status, headers.merge(extra), body] end |