Class: HubStep::Rack::Middleware
- Inherits:
-
Object
- Object
- HubStep::Rack::Middleware
- Defined in:
- lib/hubstep/rack/middleware.rb
Overview
Rack middleware for wrapping a request in a span.
Constant Summary collapse
- SPAN =
"#{name}.span"
Class Method Summary collapse
-
.get_span(env) ⇒ Object
Get the span that represents this request.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, tracer, enable_if) ⇒ Middleware
constructor
Create a Middleware.
Constructor Details
#initialize(app, tracer, enable_if) ⇒ Middleware
Create a Middleware
tracer - a HubStep::Tracer instance enable_if - Proc that is passed the env for each request. If the Proc
returns true, the tracer will be enabled for the duration
of the request. If the Proc returns false, the tracer will
be disabled for the duration of the request.
27 28 29 30 31 |
# File 'lib/hubstep/rack/middleware.rb', line 27 def initialize(app, tracer, enable_if) @app = app @tracer = tracer @enable_if = enable_if end |
Class Method Details
Instance Method Details
#call(env) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/hubstep/rack/middleware.rb', line 33 def call(env) @tracer.with_enabled(@enable_if.call(env)) do trace(env) do @app.call(env) end end end |