open-telemetry/opentelemetry-ruby

Runtime exceptions from auto-instrumentation code

anandhasudhan opened this issue · 2 comments

Description of the bug
I've initialized OpenTelemetry for my Ruby on Rails application and the configured instruments have been successfully installed but I am receiving run time exceptions from the auto-instrumentation code and it crashes my application.

Error info:
From Net::HTTP instrumentation

ArgumentError
wrong number of arguments (given 3, expected 2)
image

From Sidekiq instrumentation

NameError
uninitialized constant Sidekiq::Processor
image

I believe OpenTelemetry isn't supposed to throw such errors at runtime especially since these instruments were installed successfully.
Below is an excerpt from their Error handling specification:

OpenTelemetry API is forgiving at runtime - does not fail on invalid arguments, never throws, and swallows exceptions. This way instrumentation issues do not affect application logic. Test the instrumentation to notice issues OpenTelemetry hides at runtime.

Share details about your runtime

Operating system details: Linux
RUBY_ENGINE: "ruby"
RUBY_VERSION: "2.6.10"
RUBY_DESCRIPTION: "ruby 2.6.10p210 (2022-04-12 revision 67958) [x86_64-linux]"

Share a simplified reproduction if possible

Below are the details of my opentelemetry configuration.

# Gemfile
gem 'opentelemetry-sdk', '~> 1.1.0'
gem 'opentelemetry-instrumentation-all'

# OpenTelemetry configuration
require 'opentelemetry/sdk'
require 'opentelemetry/instrumentation/all'

OpenTelemetry::SDK.configure do |c|
  c.service_name = 'my-service'
  c.use 'OpenTelemetry::Instrumentation::ActiveSupport'
  c.use 'OpenTelemetry::Instrumentation::Rack'
  c.use 'OpenTelemetry::Instrumentation::AwsSdk'
  c.use 'OpenTelemetry::Instrumentation::HTTP'
  c.use 'OpenTelemetry::Instrumentation::ConcurrentRuby'
  c.use 'OpenTelemetry::Instrumentation::Dalli'
  c.use 'OpenTelemetry::Instrumentation::Ethon'
  c.use 'OpenTelemetry::Instrumentation::Faraday'
  c.use 'OpenTelemetry::Instrumentation::HttpClient'
  c.use 'OpenTelemetry::Instrumentation::Net::HTTP'
  c.use 'OpenTelemetry::Instrumentation::Rake'
  c.use 'OpenTelemetry::Instrumentation::Redis'
  c.use 'OpenTelemetry::Instrumentation::RestClient'
  c.use 'OpenTelemetry::Instrumentation::Sidekiq'
end

Gem versions

opentelemetry-api | 1.1.0
opentelemetry-common | 0.19.7
opentelemetry-instrumentation-all | 0.33.0
opentelemetry-instrumentation-sidekiq | 0.22.1
opentelemetry-instrumentation-net_http | 0.21.1

Output after starting the application

I, [2024-02-22T11:32:15.462902 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::ActiveSupport was successfully installed with the following options {}
I, [2024-02-22T11:32:15.466470 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Rack was successfully installed with the following options {:allowed_request_headers=>[], :allowed_response_headers=>[], :application=>nil, :record_frontend_span=>false, :retain_middleware_names=>false, :untraced_endpoints=>[], :url_quantization=>nil, :untraced_requests=>nil, :response_propagators=>[]}
I, [2024-02-22T11:32:15.469063 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::AwsSdk was successfully installed with the following options {:inject_messaging_context=>false, :suppress_internal_instrumentation=>false}
I, [2024-02-22T11:32:15.470241 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::HTTP was successfully installed with the following options {}
I, [2024-02-22T11:32:15.470731 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::ConcurrentRuby was successfully installed with the following options {}
I, [2024-02-22T11:32:15.474475 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Dalli was successfully installed with the following options {:peer_service=>nil, :db_statement=>:include}
I, [2024-02-22T11:32:15.475604 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Ethon was successfully installed with the following options {:peer_service=>nil}
I, [2024-02-22T11:32:15.476559 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Faraday was successfully installed with the following options {:peer_service=>nil}
I, [2024-02-22T11:32:15.477667 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::HttpClient was successfully installed with the following options {}
I, [2024-02-22T11:32:15.478582 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Net::HTTP was successfully installed with the following options {:untraced_hosts=>[]}
I, [2024-02-22T11:32:15.479248 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Rake was successfully installed with the following options {}
I, [2024-02-22T11:32:15.480071 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Redis was successfully installed with the following options {:peer_service=>nil, :trace_root_spans=>true, :db_statement=>:obfuscate}
I, [2024-02-22T11:32:15.483030 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::RestClient was successfully installed with the following options {:peer_service=>nil}
I, [2024-02-22T11:32:15.485352 #95091]  INFO -- : Instrumentation: OpenTelemetry::Instrumentation::Sidekiq was successfully installed with the following options {:span_naming=>:queue, :propagation_style=>:link, :trace_launcher_heartbeat=>false, :trace_poller_enqueue=>false, :trace_poller_wait=>false, :trace_processor_process_one=>false, :peer_service=>nil}

Thanks for this report and I am sorry that you had to encounter this!

You are correct that the instrumentations must not cause application errors.

The exceptions here may be due to a result of incompatibility with Ruby 2.6 and unfortunately we do not provide support for EoL versions of Ruby.

You may want to try downgrading the instrumentations to much earlier versions that may have been compatible with Ruby 2.6 but there aren't any guarantees.

Thank you for the update. I can try downgrading the instrumentations to earlier versions or upgrading my Ruby version if needed.