Repository navigation
Add dogstatsd/ruby entrypoint so Bundler.require loads the gem - #334
corsonknowles wants to merge 3 commits into
Conversation
Bundler.require tries require 'dogstatsd-ruby', then 'dogstatsd/ruby'. Neither path existed, so the gem was skipped silently unless the Gemfile set require: 'datadog/statsd'. The new file only requires datadog/statsd; that remains the documented require path.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@rayz @StephenWakely Can you help out on how to merge here? |
9862bca to
8d9c288
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the convenience entrypoint that lets Bundler load dogstatsd-ruby without an explicit Gemfile require option.
No open issues 🎉
What changed in this PR
Adds a convenience entrypoint so Bundler.require loads dogstatsd-ruby without an explicit require: option in the Gemfile.
Changes:
- Adds
dogstatsd/ruby, which delegates to the existing library entrypoint. - Preserves
datadog/statsdas the documented require path.
| File | Description |
|---|---|
lib/dogstatsd/ruby.rb |
Adds Bundler’s fallback require path and loads datadog/statsd. |
Review effort: Balanced
|
@corsonknowles Hopefully merging master should fix CI now. |
|
@StephenWakely Thansk! Main is merged |
Summary
This adds
lib/dogstatsd/ruby.rb, a one-line convenience entrypoint soBundler.requireloads the gem from a plaingem 'dogstatsd-ruby'Gemfile line.require 'datadog/statsd'stays the documented require path, and nothing about it changes.Why
Bundler's autorequire first tries
require 'dogstatsd-ruby'. When that raises aLoadErrorfor exactly that path and the name contains dashes, it retries with every-replaced by/, i.e.require 'dogstatsd/ruby'. If that also fails, Bundler skips the gem without a warning.Neither path exists today, so in an app that relies on
Bundler.require(Rails does by default),Datadog::Statsdis only defined if something else requiresdatadog/statsd. To get it loaded, consumers currently have to writegem 'dogstatsd-ruby', require: 'datadog/statsd'or add a manual require.Change
lib/dogstatsd/ruby.rbcontains only:s.filesalready includeslib/**/*.rb.Verification
I tested
Bundler.requirewith installed gems in an isolatedBUNDLE_PATH, using a Gemfile containing onlygem 'dogstatsd-ruby', '5.7.1'with norequire:, thenBundler.require; p defined?(Datadog::Statsd):nil"constant"(A
path:Gemfile is no good for the "before" case. Evaluating the gemspec requireslib/datadog/statsd/version.rb, which loads enough of the library to defineDatadog::StatsdbeforeBundler.requireeven runs.)rubocop lib/dogstatsd/ruby.rbreports no offenses.