Add log_comment metadata to ClickHouse queries

What does this MR do and why?

Adds log_comment tracing metadata to ClickHouse queries for traceability from system.query_log back to the originating request.

Example payload:

{
  "correlation_id":"4b809c12c639dbec87b37274337aae0d",
  "user_id":1,
  "root_namespace_id":22,
  "organization_id":1,
  "application":"web",
  "feature_category":"database"
}

Source: LabKit + adding one extra field if namespace is present (best effort, it does not add extra SQL queries): root_namespace_id.

Related issue: https://gitlab.com/groups/gitlab-com/gl-infra/finops/-/work_items/129+

Note: I'll open follow-up issue for properly attributing all ClickHouse queries (Aggregation Engines, CI metrics, etc.)

Edited by Adam Hegyi

Merge request reports

Loading
Loading