Skip to content

Conversation

@arielvalentin
Copy link
Contributor

@arielvalentin arielvalentin commented Jun 8, 2023

Fixes #518

When attempting to use the Rack Events Handler via ActionPack, the install process raises the following error:

Failure/Error: Rails.application.initialize!

NameError:
  uninitialized constant OpenTelemetry::Instrumentation::Rack::Middlewares::EventHandler

              [::Rack::Events, [OpenTelemetry::Instrumentation::Rack::Middlewares::EventHandler.new]]
                                                                                 ^^^^^^^^^^^^^^
# /usr/local/rvm/gems/ruby-3.1.4/gems/opentelemetry-instrumentation-rack-0.23.1/lib/opentelemetry/instrumentation/rack/instrumentation.rb:44:in `middleware_args'
# /usr/local/rvm/gems/ruby-3.1.4/gems/opentelemetry-instrumentation-action_pack-0.7.0/lib/opentelemetry/instrumentation/action_pack/railtie.rb:17:in `block in <class:Railtie>'

This is due to constant value shadowing occurring in the instrumentation namespace, where the defined check in require_dependencies is not searching the root namespace and is instead searching the OpenTelemetry::Instrumentation::Rack namespace:

Rack::Events
(ruby) defined?(Rack::Events)
nil
(ruby) defined?(::Rack::Events)
"constant"

This results in the Event Handler source not being loaded.

@arielvalentin arielvalentin merged commit 823883b into open-telemetry:main Jun 8, 2023
@arielvalentin arielvalentin deleted the fix-rack-events-middleware branch June 8, 2023 15:36
@github-actions github-actions bot mentioned this pull request Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NameError: uninitialized constant OpenTelemetry::Instrumentation::Rack::Middlewares::EventHandler

2 participants