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:, include_urls: false) ⇒ Middleware
constructor
Create a Middleware.
Constructor Details
#initialize(app, tracer:, enable_if:, include_urls: false) ⇒ 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.
include_urls - Boolean specifying whether the ‘http.url` tag should be
added to the spans this middleware creates. URLs can
contain sensitive information, so they are omitted by
default.
31 32 33 34 35 36 |
# File 'lib/hubstep/rack/middleware.rb', line 31 def initialize(app, tracer:, enable_if:, include_urls: false) @app = app @tracer = tracer @enable_if = enable_if @include_urls = include_urls end |
Class Method Details
Instance Method Details
#call(env) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/hubstep/rack/middleware.rb', line 38 def call(env) @tracer.with_enabled(@enable_if.call(env)) do trace(env) do @app.call(env) end end end |