reevoo / sapience-rb

Hasslefree auto-configuration for logging, metrics and exception collection.
MIT License
10 stars 0 forks source link

Incorrect Grape response status getting logged #18

Closed ionut998 closed 7 years ago

ionut998 commented 8 years ago

We noticed that when including this in the tableau_api_gateway, we had the following line in the API:

module TableauApiGateway
  class API < Grape::API
    use Sapience::Extensions::Grape::Middleware::Logging, logger: Sapience[self]
...
    get :err do
      raise "hell"
    end

    rescue_from :all do |e|
      Sapience.logger.error(e.message, {}, e)
      error_response(message: e.message, status: 500)
    end

When we hit /err, we see a Runtime error and a 500 returned in the browser, but our logs show a 404:

{
          :method => "GET",
    :request_path => "/api/v1/err",
          :format => :json,
          :status => 404,  # <---------- This should be a 500
      :class_name => "TableauApiGateway::API",
          :action => "index",
            :host => "localhost",
              :ip => "::1",
              :ua => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
            :tags => [],
          :params => {},
        :runtimes => {
        :total => 8.424,
         :view => 8.424,
           :db => 0.0
    }
}
ionut998 commented 8 years ago

Note - when testing the same on client_portal-admin, we found we also saw a 404 when the actual response was 401, so it's not limited to 500's. We did see correct statuses for 201 and 200 though.

jelamo commented 7 years ago

Fix on release v2.0.3