appsignal/appsignal-ruby

Don't report errors in HTTP gem instrumentation

benedikt opened this issue · 3 comments

I've been banging my head against an issue where we'd see a HTTP::TimeoutError exception pop up in AppSignal even though we're explicitly handling it in the code that initiates the request.

Eventually, I noticed that the error was actually re-raised from somewhere and started digging. It turns out that the instrumentation for the http gem is adding some error handling as well.

In comparison, the net/http instrumentation doesn't do any error handling.

Adding error handling for libraries like Sidekiq, or DelayedJob makes sense, as they are ultimately wrapping my own code. Any mistakes in there, should ultimately end up in AppSignal.

However, for HTTP libraries my own code is wrapping the library and I'd like to keep control over what gets reported into AppSignal and what doesn't. With the current implementation, I can add as much error handling as I want and I'll still get an error reported.

Example code

# Add this to a controller or a background job

require 'http'

begin 
  HTTP.timeout(1).get('http://localhost:12345')
rescue 
  Rails.logger.error "Something went wrong"
end 

Expected behavior

No exception in AppSignal

Actual behavior

Exception tracked in AppSignal

Hi @benedikt, removing the error handling there makes sense. It's making a request, it's not receiving requests. When it makes a request we should assume it's already in an instrumented context with its own error handling, so apps can decide whether to handle the error or report it to us.

I'll have a look at what we can do.

Released in Ruby gem 3.13.0.

Thank you!