appsignal-ruby
appsignal-ruby copied to clipboard
Add response status code to transaction metadata (Rails)
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
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 ?
Sounds good! 👍
@tombruijn so this is implemented for the elexir client but not in the ruby version?
@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
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.