Class: OpenTelemetry::Instrumentation::Sinatra::Instrumentation

Inherits:
Base
  • Object
show all
Defined in:
lib/opentelemetry/instrumentation/sinatra/instrumentation.rb

Overview

The Instrumentation class contains logic to detect and install the Sinatra instrumentation

Installation and configuration of this instrumentation is done within the OpenTelemetry::SDK#configure block, calling use() or use_all().

Configuration keys and options

:install_rack

Default is true. Specifies whether or not to install the Rack instrumentation as part of installing the Sinatra instrumentation. This is useful in cases where you have multiple Rack applications but want to manually specify where to insert the tracing middleware.

Examples:

Manually install Rack instrumentation.

OpenTelemetry::SDK.configure do |c|
  c.use_all({
    'OpenTelemetry::Instrumentation::Rack' => { },
    'OpenTelemetry::Instrumentation::Sinatra' => {
      install_rack: false
    },
  })
end

Instance Method Summary collapse

Instance Method Details

#install_middleware(app) ⇒ Object



53
54
55
56
# File 'lib/opentelemetry/instrumentation/sinatra/instrumentation.rb', line 53

def install_middleware(app)
  app.use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args) if config[:install_rack]
  app.use(Middlewares::TracerMiddleware)
end