Class: Labkit::Middleware::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/labkit/middleware/rack.rb

Overview

This is a rack middleware to be inserted in GitLab-rails It makes sure that there’s always a root context containing the correlation id. Since this context always get’s cleaned up by this middleware, we can be sure that any nested contexts will also be cleaned up.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Rack

Returns a new instance of Rack.



13
14
15
# File 'lib/labkit/middleware/rack.rb', line 13

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
# File 'lib/labkit/middleware/rack.rb', line 17

def call(env)
  Labkit::Context.with_context(Labkit::Context::CORRELATION_ID_KEY => correlation_id(env)) do
    @app.call(env)
  end
end