Class: OpenTelemetry::Instrumentation::Rack::Instrumentation

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

Overview

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

Instance Method Summary collapse

Instance Method Details

#middleware_argsArray

Temporary Helper for Sinatra and ActionPack middleware to use during installation

Examples:

Default usage

Rack::Builder.new do
  use *OpenTelemetry::Instrumentation::Rack::Instrumenation.instance.middleware_args
  run lambda { |_arg| [200, { 'Content-Type' => 'text/plain' }, body] }
end

Returns:

  • (Array)

    consisting of a middleware and arguments used in rack builders



42
43
44
45
46
47
48
# File 'lib/opentelemetry/instrumentation/rack/instrumentation.rb', line 42

def middleware_args
  if config.fetch(:use_rack_events, false) == true && defined?(OpenTelemetry::Instrumentation::Rack::Middlewares::EventHandler)
    [::Rack::Events, [OpenTelemetry::Instrumentation::Rack::Middlewares::EventHandler.new]]
  else
    [OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware]
  end
end