Skip to content

Add exception details to GraphQL request logs

Heinrich Lee Yu requested to merge improve-graphql-error-logging into master

What does this MR do and why?

Adds exception details to development_json.log / production_json.log for GraphQL requests.

In GraphqlController, we rescue exceptions and log them to exceptions_json.log. But that makes it harder to find the specific errors of requests. You'd have to search for the associated log entry by correlation id.

With this change, it would be easy to search errors from a certain operation name, etc..

Example:

This is a GraphQL request that 500d: https://log.gprd.gitlab.net/app/discover#/doc/7092c4e2-4eb5-46f2-8305-a7da2edad090/pubsub-rails-inf-gprd-007400?id=R1eLo30BEjdhcJkcpmwV and the error is logged here https://log.gprd.gitlab.net/app/discover#/doc/7092c4e2-4eb5-46f2-8305-a7da2edad090/pubsub-rails-inf-gprd-007400?id=BleLo30BEjdhcJkcpmwU separately.

How to set up and validate locally

  1. Execute a GraphQL query that would raise an error
  2. Check development_json.log

You should see a log entry that contains exception.class, exception.message, and exception.backtrace.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Heinrich Lee Yu

Merge request reports

Loading