Class: Goliath::Rack::Tracer

Inherits:
Object
  • Object
show all
Includes:
AsyncMiddleware
Defined in:
lib/goliath/rack/tracer.rb

Overview

Middleware to inject the tracer statistics into the response headers.

Examples:

use Goliath::Rack::Tracer

Instance Method Summary (collapse)

Methods included from AsyncMiddleware

#initialize

Constructor Details

This class inherits a constructor from Goliath::Rack::AsyncMiddleware

Instance Method Details

- (Object) call(env)



11
12
13
14
15
16
# File 'lib/goliath/rack/tracer.rb', line 11

def call(env)
  env.trace 'trace.start'
  shb = super(env)
  env.logger.info env.trace_stats.collect{|s| s.join(':')}.join(', ')
  shb
end

- (Object) post_process(env, status, headers, body)



18
19
20
21
# File 'lib/goliath/rack/tracer.rb', line 18

def post_process(env, status, headers, body)
  extra = { 'X-PostRank' => env.trace_stats.collect{|s| s.join(': ')}.join(', ')}
  [status, headers.merge(extra), body]
end