Skip to content

Add dogstatsd/ruby entrypoint so Bundler.require loads the gem - #334

Open
corsonknowles wants to merge 1 commit into
DataDog:masterfrom
corsonknowles:conventional-bundler-entrypoint
Open

corsonknowles wants to merge 1 commit into
DataDog:masterfrom
corsonknowles:conventional-bundler-entrypoint

Conversation

@corsonknowles

Copy link
Copy Markdown

Summary

This adds lib/dogstatsd/ruby.rb, a one-line convenience entrypoint so Bundler.require loads the gem from a plain gem '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 a LoadError for 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::Statsd is only defined if something else requires datadog/statsd. To get it loaded, consumers currently have to write gem 'dogstatsd-ruby', require: 'datadog/statsd' or add a manual require.

Change

lib/dogstatsd/ruby.rb contains only:

# frozen_string_literal: true

require_relative '../datadog/statsd'
  • Purely additive and backward compatible. It adds no new constants, and requiring both paths loads the code once.
  • It ships automatically, because s.files already includes lib/**/*.rb.
  • I didn't touch the CHANGELOG or the version, since both look like they're updated at release time.

Verification

$ ruby -Ilib -e "require 'dogstatsd/ruby'; p defined?(Datadog::Statsd); p Datadog::Statsd::VERSION"
"constant"
"5.7.1"

I tested Bundler.require with installed gems in an isolated BUNDLE_PATH, using a Gemfile containing only gem 'dogstatsd-ruby', '5.7.1' with no require:, then Bundler.require; p defined?(Datadog::Statsd):

  • released 5.7.1 from rubygems.org: nil
  • gem built from this branch: "constant"

(A path: Gemfile is no good for the "before" case. Evaluating the gemspec requires lib/datadog/statsd/version.rb, which loads enough of the library to define Datadog::Statsd before Bundler.require even runs.)

rubocop lib/dogstatsd/ruby.rb reports no offenses.

🤖 Generated with Claude Code

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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@corsonknowles
corsonknowles requested a review from a team as a code owner October 27, 2026 23:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T23:13:29.974929Z 9862bca PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant