appsignal-ruby icon indicating copy to clipboard operation
appsignal-ruby copied to clipboard

Add response status code to transaction metadata (Rails)

Open matsimitsu opened this issue 9 years ago • 11 comments

Response status codes (200,202 etc.) could help debug performance issues. e.g. short-returning a 404-not found could have a different impact on your app then returning a 200 with a body. While it might be clear from the event timeline, I think it's nice to have as additional metadata.


Blocked by https://github.com/appsignal/appsignal-ruby/issues/329

Instrumentations

Response status reporting will be supported in https://github.com/appsignal/appsignal-ruby/pull/1090 through the Rack EventHandler. This will only work for Rails first, as it's the first instrumentation to use that. As we port other instrumentations over to use Rack EventHandler, more libraries will be supported.

  • [x] pure-Rack - EventHandler
  • [x] Rails #1090
  • [x] Sinatra - #1100
  • [x] Hanami - #1113
  • [x] Grape - needs docs change
  • [ ] Padrino?
  • [x] ~Webmachine?~ Not doing this

matsimitsu avatar Oct 06 '16 13:10 matsimitsu

We can get the status code from the @app.call(env) response like in the code below when we would add it to the rails_instrumentation.rb

@app.call(env).tap do |status, _, __|
  transaction.set_metadata("status", status)
end

This would work for any Rack application since they are required to return the response triplet: status code, headers, and body (in that order). So we can add it for Rack, Sinatra and Grape too.

Is this what you had in mind, @matsimitsu ?

tombruijn avatar Oct 25 '16 11:10 tombruijn

Sounds good! 👍

matsimitsu avatar Oct 25 '16 11:10 matsimitsu

@tombruijn so this is implemented for the elexir client but not in the ruby version?

phoet avatar May 13 '19 15:05 phoet

@phoet correct. For us to capture all response codes we need to rework how our middleware works. Currently we would only get part of the response codes. When there’s middleware before AppSignal’s we would not track them, giving an incomplete picture.

We want to improve that in issue https://github.com/appsignal/appsignal-ruby/issues/329

tombruijn avatar May 14 '19 11:05 tombruijn

This would be very helpful. I was hoping to see throughput and response time graphs by HTTP response code out-of-the box with AppSignal.

richardonrails avatar May 21 '21 01:05 richardonrails