Exception logging

Description of the proposal

I made this MR: !17819 (merged) that adds exceptions_json.log that persists all exceptions that are requested by developer via usage of Gitlab::Sentry:.

This was added to solve a problem of manual exception logging done in number of places of the codebase:

  1. app/services/clusters/applications/base_helm_service.rb:27,
  2. lib/gitlab/bitbucket_import/importer.rb:47,
  3. lib/gitlab/bitbucket_server_import/importer.rb:167,
  4. etc.

The proposal would be to disallow all manual exception logging, and require to only use Gitlab::Sentry.track_exception* variants. This would send exception to Sentry (if configured), and log to json file (always).

Having a structured logging actually allows the persistence of exception be useful as:

  1. we always clean backtrace,
  2. we always include correlation id,
  3. we can include some user details,
  4. later we could include information about execution context, like currently running sidekiq job.

I still wonder about the ability to have a RuboCop to prevent that, but I have no idea yet. Maybe discovering what is being executed in rescue block, idk.

  • Mention the proposal in the next backend weekly call and the #backend channel to encourage contribution
  • Proceed with the proposal once 50% of the maintainers have weighed in, and 80% of the votes are 👍
  • Once approved, mention it again in the next backend weekly call and the #backend channel

/cc @gitlab-org/maintainers/rails-backend

Edited by Kamil Trzciński