Skip to content

Marginalia inclusion

Balakumar requested to merge sribalakumar/gitlab:marginalia into master

What does this MR do?

Includes Marginalia gem which generates query comments containing various application related context information in the comment. It is very useful for backtracking problematic queries back to the application source. A DB Engineer during an on-call incident will have full context of a query and its application source from the comments.

Implementation uses flipper to enable/disable feature.

Turn on Annotation

Feature.enable(:marginalia)

Turn off Annotation

Feature.disable(:marginalia)

When feature is on and temporarily inline disable annotation

Marginalia.without_annotation do 
  ...
end

With the feature on snippets from development.log :

i) Front requests will include application, controller, action, correlation_id, line in comment -

Example:

SELECT "project_features".* FROM "project_features" WHERE "project_features"."project_id" = $1 LIMIT $2 /*application:Webapp,controller:jobs,action:trace,correlation_id:rYF4mey9CH3,line:/app/policies/project_policy.rb:504:in `feature_available?'*/ [["project_id", 5], ["LIMIT", 1]]

ii) Sidekiq worker jobs will include application, jid, job_class, correlation_id, line -

Example:

SELECT "ci_pipelines".* FROM "ci_pipelines" WHERE "ci_pipelines"."id" = $1 LIMIT $2 /*application:Sidekiq,jid:e7d6668a39a991e323009833,job_class:ExpireJobCacheWorker,correlation_id:rYF4mey9CH3,line:/app/workers/expire_job_cache_worker.rb:14:in `perform'*/ [["id", 64], ["LIMIT", 1]]

This MR closes #27857 (closed)
Edited by Andreas Brandl

Merge request reports