Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fallback for applications that bypass RubyGem to load dependencies #947

Closed
arielvalentin opened this issue Sep 18, 2021 · 1 comment
Closed

Comments

@arielvalentin
Copy link
Contributor

arielvalentin commented Sep 18, 2021

The GitHub monolith bypasses RubyGems to load dependencies and as a result is unable to install any auto-instrumentation gems that use Gem.loaded_specs to determine compatibility.

@ericmustin implemented several fixes in ddtrace to mitigate this issue. We discussed introducing a helper method but then also pointed out that there are some cases where gem authors do not include a VERSION constant or follow a consistent pattern to namespace the constant.

We may want to consider adding a helper similar to what @ericmustin described in one of the PRs:

# This allows instrumentation authors to provide a default value
Datadog::Utils::Gem.loaded_specs_version('dogstatsd-ruby') { Datadog::Statsd::VERSION }

That would make it so instrumentation authors could do something like this:

module OpenTelemetry
  module Instrumentation
    module MyGem
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        compatible do
          loaded_specs_version("my-gem") { MyGem::VERSION } <= "2.0.1"
        end
      end
    end
  end
end

Longer term I propose that the Instrumentation::Base DSL could possibly include a declaration that uses RubyGems pessimistic version constraint e.g.:

module OpenTelemetry
  module Instrumentation
    module MyGem
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        supported_versions '>= 2.2.0', '< 2.3.0'
      end
    end
  end
end

# When the version is located in an submodule:  
module OpenTelemetry
  module Instrumentation
    module MyGem
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        supported_versions '>= 2.2.0', '< 2.3.0', "MyGem::ChildModule::GrandChild::VERSION"
      end
    end
  end
end

Related

cc: @SophieDeBenedetto @wogri

fbogsany pushed a commit that referenced this issue Sep 22, 2021
* fix: Use Kafka::VERSION fallback for compatibility

Some applications bypass Ruby Gems when loading dependencies,
which results in a `nil` variable being returned by `Gem.loaded_specs`.

This change adds a fallback to use `Kafka::VERSION` constant to check
the minimum version when one is not available in Ruby Gems.

See #947

* chore: Linter fixes
@arielvalentin
Copy link
Contributor Author

Instead of falling back programmatically we will rely on gemspec declarations for default compatibility checks:

#1016 (comment)

robertlaurin added a commit that referenced this issue Apr 12, 2022
* feat: RubyGems Fallback

The GitHub Monolith bypasses RubyGems when loading dependencies, which results in a `nil` variable being returned by `Gem.loaded_specs`.

This change fallsback to using `Gem::Version.new(<VERSION>)` where possible.

See #947

Related https://github.com/open-telemetry/opentelemetry-ruby/issues/988#issuecomment-1018676853

* chore: Allow test to run from host machine

Prior to this commit developers had to either run tests from within a container,
or independently run services from their host machine.

Developers may now use docker-compose for all services and run tests from their host machine.

Co-authored-by: Robert <[email protected]>
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

No branches or pull requests

1 participant