Skip to content

Fix the db-specific replica metrics are not stored in logs

What does this MR do and why?

  1. Fix the Gitlab::Metrics::Subscribers::ActiveRecord.load_balancing_metric_keys to return the proper metric keys for database replicas.
  2. Change the per-database metrics to not include the db-role, from today's db_(primary|replica)_(main|ci|main_replica|ci_replica)_(metric) into db_(main|main_replica|ci|ci_replica)_(metric).

How to set up and validate locally

  1. Enable the database load balancing

  2. Start GDK with

    GITLAB_MULTIPLE_DATABASE_METRICS=true gdk start
  3. Visit any page such as http://127.0.0.1:3000

  4. In the logdevelopment_json.log` look for the following snippet

    "db_count": 2, "db_write_count": 0, "db_cached_count": 0, "db_replica_count": 2, "db_main_replica_count": 2, ...
  5. Ensure you don't have 0s everywhere and the numbers match.

MR acceptance checklist

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

Related issues

Related to #346923 (closed)

Edited by Douglas Barbosa Alexandre

Merge request reports

Loading