Module: Datadog::Tracing::Contrib::Sinatra::DefaultMiddlewarePatch

Defined in:
lib/datadog/tracing/contrib/sinatra/patcher.rb

Overview

Hook into builder before the middleware list gets frozen

Constant Summary collapse

ONLY_ONCE_PER_APP =
Hash.new { |h, key| h[key] = Core::Utils::OnlyOnce.new }

Instance Method Summary collapse

Instance Method Details

#setup_middleware(*args, &block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/datadog/tracing/contrib/sinatra/patcher.rb', line 29

def setup_middleware(*args, &block)
  builder = args.first

  super.tap do
    ONLY_ONCE_PER_APP[self].run do
      Contrib::Sinatra::Framework.add_middleware(Contrib::Rack::TraceMiddleware, builder)
      Contrib::Sinatra::Framework.inspect_middlewares(builder)
    end
  end
end