Skip to content

Commit 19af8f5

Browse files
committed
[NO-TICKET] RFC: Add logger gem as dependency to prepare for future Ruby versions
**What does this PR do?** This PR declares a dependency from the `datadog` gem to the `logger` gem. While every PR is an RFC, I explicitly marked this one as such since adding a new dependency should never be done lightly. **Motivation:** This is needed to avoid a warning: > lib/datadog/core/configuration/settings.rb:3: warning: logger was > loaded from the standard library, but will no longer be part of the > default gems starting from Ruby 3.5.0. > You can add logger to your Gemfile or gemspec to silence this warning. **Additional Notes:** `logger` is just the latest in a long line of gems that have been refactored out in this way. See ruby/ruby@d7e558e and https://stdgems.org/ (not yet updated for 3.5 as of this writing). While in the past we've avoided adding extra dependencies due to this extraction work, I think this one does make sense to add: 1. It's supported on every Ruby version we currently support (>= 2.5) 2. It's not a small amount of code to shed/rewrite. And on the other side, I don't see a strong reason for embedding instead of depending on it. We're getting warnings for two more gems: `ostruct` and `benchmark`. From our internal discussions, we can probably get rid of our usage of them, rather than promote them to a dependency, so that's why I did not touch those warnings in this PR. **How to test the change?** The following script can be used (on Ruby 3.4 and above) to trigger the warning, and to confirm it's gone once `logger` is added as a dependency: ```ruby require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'datadog', path: '.' end puts RUBY_DESCRIPTION require 'datadog' puts Datadog::VERSION::STRING ``` Make sure to run with just `ruby example.rb` and not with `bundle exec`.
1 parent ee94c0e commit 19af8f5

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

.gitlab/install_datadog_deps.rb

+2
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@
7878
'DD_PROFILING_NO_EXTENSION' => 'true',
7979
}
8080

81+
# ADD NEW DEPENDENCIES HERE
8182
[
8283
'datadog-ruby_core_source',
8384
'ffi',
8485
'libddwaf',
8586
'msgpack',
8687
'libdatadog', # libdatadog MUST be installed before datadog to ensure libdatadog native extension is compiled
88+
'logger',
8789
'datadog',
8890
].each do |gem|
8991
version = gem_version_mapping.delete(gem)

datadog.gemspec

+10
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ Gem::Specification.new do |spec|
7171
# (and yes we have a test for it)
7272
spec.add_dependency 'libdatadog', '~> 14.3.1.1.0'
7373

74+
# Will no longer be a default gem on Ruby 3.5, see
75+
# https://github.com/ruby/ruby/commit/d7e558e3c48c213d0e8bedca4fb547db55613f7c and
76+
# https://stdgems.org/ .
77+
# We support all versions of this gem and don't particularly require any version restriction.
78+
spec.add_dependency 'logger'
79+
80+
# Tip: When adding or removing dependencies, search the codebase for the string
81+
# ADD NEW DEPENDENCIES HERE
82+
# to find out a few more places that need to be kept in-sync.
83+
7484
spec.extensions = [
7585
'ext/datadog_profiling_native_extension/extconf.rb',
7686
'ext/datadog_profiling_loader/extconf.rb',

lib-injection/host_inject_main.rb

+2
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,14 @@ def bundler_supported?
175175
injection_failure = false
176176

177177
# This is order dependent
178+
# ADD NEW DEPENDENCIES HERE
178179
[
179180
'msgpack',
180181
'ffi',
181182
'datadog-ruby_core_source',
182183
'libdatadog',
183184
'libddwaf',
185+
'logger',
184186
'datadog'
185187
].each do |gem|
186188
fork do

spec/datadog/release_gem_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@
103103
# check `install_datadog_deps.rb` for details
104104
expect(gem_version_mapping.keys).to contain_exactly(
105105
# This list MUST NOT derive from the `gemspec.dependencies`,
106-
# since it is used to alarm when dependencies modified.
106+
# since it is used to alarm when dependencies are modified.
107+
# ADD NEW DEPENDENCIES HERE
107108
'datadog',
108109
'datadog-ruby_core_source',
109110
'ffi',
110111
'libdatadog',
111112
'libddwaf',
112113
'msgpack',
114+
'logger',
113115
)
114116
end
115117
end

0 commit comments

Comments
 (0)