fix: Move the logs-sdk and metrics-sdk requires#1956
fix: Move the logs-sdk and metrics-sdk requires#1956BrianHawley wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
f3f72ba to
489ffc6
Compare
|
Looks like truffleruby is failing for unrelated reasons. I may look into that later. |
|
The test failures are unrelated, an incompatibility between Truffleruby and the latest json gem. So, until that gets fixed, the test suite isn't going to pass. What do we do next? The test failures were fixed by #1959 so the tests pass now. |
49d6a29 to
5924d40
Compare
|
Hi @BrianHawley, thanks for your patience on this PR. I'm able to reproduce the bug you describe in #1955, but when I run the reproduction you have with this branch, the error still appears. These are the contents of the Ruby file I'm using: require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'opentelemetry-exporter-otlp-metrics', github: 'BrianHawley/opentelemetry-ruby', branch: 'fixes_1955', glob: 'exporter/otlp-metrics/*.gemspec'
end
require 'opentelemetry-exporter-otlp-metrics'
OpenTelemetry::SDK.configure do |c|
c.use_all
endThis is the output: Fetching https://github.com/BrianHawley/opentelemetry-ruby.git
Resolving dependencies...
Fetching gem metadata from https://rubygems.org/.../opentelemetry-api-1.7.0/lib/opentelemetry.rb:7: 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.
W, [2025-12-11T16:05:24.499438 #52700] WARN -- : The otlp exporter cannot be configured - please add opentelemetry-exporter-otlp to your Gemfile, spans will not be exported
E, [2025-12-11T16:05:24.499588 #52700] ERROR -- : OpenTelemetry error: unexpected configuration error due to undefined method 'meter_provider=' for module OpenTelemetry - OpenTelemetry::SDK::ConfigurationError - .../opentelemetry-sdk-1.10.0/lib/opentelemetry/sdk.rb:74:in 'OpenTelemetry::SDK#configure'
Can you take a look? Am I misunderstanding what this PR addresses? |
|
@kaylareopelle I didn't reference the actual fixed gems in my reproduction example. Instead, I referenced the gem that you would normally reference to turn on metrics export. The actual gems with the bugs are opentelemetry-metrics-sdk and opentelemetry-logs-sdk. So the fix proof script would be: require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'opentelemetry-exporter-otlp-metrics' # the gem you would normally reference directly
# The dependency with the bug, referenced here so you can use the fixed version. You need to
# have require: false because otherwise bundler will require 'opentelemetry-metrics-sdk', which
# works around the bug. If the gem is referenced indirectly, 'opentelemetry/sdk/metrics' is
# required instead, as is the custom for these gems.
gem 'opentelemetry-metrics-sdk',
require: false,
github: 'BrianHawley/opentelemetry-ruby',
branch: 'fixes_1955',
glob: 'metrics_sdk/*.gemspec'
end
require 'opentelemetry-exporter-otlp-metrics'
OpenTelemetry::SDK.configure do |c|
c.use_all
endAnother option for the fix would be to move the logger_provider stuff from logs_api/lib/opentelemetry-logs-api.rb to logs_api/lib/opentelemetry/logs.rb, and move the meter_provider stuff from metrics_api/lib/opentelemetry-metrics-api.rb to metrics_api/lib/opentelemetry/metrics.rb. This would make the organization of the code more consistent with the opentelemetry-api and opentelemetry-sdk gems. I didn't make those changes because they are more extensive, but I can do them as well if you prefer. |
5058334 to
8e68031
Compare
|
I also added |
8e68031 to
d43ed34
Compare
9658c37 to
9c940a4
Compare
This makes it so the logs and metrics will work when you require like ```ruby require 'opentelemetry/sdk/logs' require 'opentelemetry/sdk/metrics' ``` Without getting 'opentelemetry-logs-api' or 'opentelemetry-logs-metrics' earlier. The opentelemetry-exporter-otlp-logs gem works around this, but I'm leaving that workaround there for now, so it will work with old versions of the opentelemetry-logs-sdk gem that are still locked. Also added a missing `require 'opentelemetry/sdk/metrics/version'`. To verify the fixes, I added `require: false` to the Gemfile files for the internal gem overrides. If you don't include `require: false` in the gem override declarations in the Gemfile, it will require those dependency files, which will hide bad requires in the code itself. If you specify `require: false`, the actual gem code requires will apply. [Fixes open-telemetry#1955]
9c940a4 to
802c359
Compare
This makes it so the logs and metrics will work when you require like
Without requiring 'opentelemetry-logs-api' or 'opentelemetry-logs-metrics' earlier.
The opentelemetry-exporter-otlp-logs gem works around this, but I'm leaving that workaround there for now, so it will work with old versions of the opentelemetry-logs-sdk gem that are still locked.
Also added a missing
require 'opentelemetry/sdk/metrics/version'.To verify the fixes, I added
require: falseto the Gemfile files for the internal gem overrides. If you don't includerequire: falsein the gem override declarations in the Gemfile, it will require those dependency files, which will hide bad requires in the code itself. If you specifyrequire: false, the actual gem code requires will apply.[Fixes #1955]