Fix missing DB duration keys for multiple databases
What does this MR do and why?
Because of addition to support database_tasks: false
(!82902 (merged)), we accidentally
skipped the ci key, and stopped emitting DB duration / count metrics for
logs.
Added specs for this regression
To reproduce
Open any page in development, and observe log/development_json.log
, it should have db_ci_*
keys.
On master:
{"method":"GET","path":"/","format":"html","controller":"RootController","action":"index","status":200,"time":"2022-04-21T23:44:42.441Z","params":[],"correlation_id":"01G1786TKQHM9Z94PPRGW92YP5","meta.user":"root","meta.client_id":"user/1","meta.caller_id":"RootController#index","meta.remote_ip":"127.0.0.1","meta.feature_category":"projects","remote_ip":"127.0.0.1","user_id":1,"username":"root","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","queue_duration_s":0.403126,"request_urgency":"default","target_duration_s":1,"gitaly_calls":8,"gitaly_duration_s":0.109831,"redis_calls":103,"redis_duration_s":0.016210000000000002,"redis_read_bytes":6707,"redis_write_bytes":447353,"redis_cache_calls":97,"redis_cache_duration_s":0.014356,"redis_cache_read_bytes":6458,"redis_cache_write_bytes":446061,"redis_shared_state_calls":3,"redis_shared_state_duration_s":0.0004,"redis_shared_state_write_bytes":190,"redis_sessions_calls":3,"redis_sessions_duration_s":0.001454,"redis_sessions_read_bytes":249,"redis_sessions_write_bytes":1102,"db_count":72,"db_write_count":0,"db_cached_count":19,"db_replica_count":0,"db_primary_count":72,"db_main_count":60,"db_main_replica_count":0,"db_replica_cached_count":0,"db_primary_cached_count":19,"db_main_cached_count":19,"db_main_replica_cached_count":0,"db_replica_wal_count":0,"db_primary_wal_count":0,"db_main_wal_count":0,"db_main_replica_wal_count":0,"db_replica_wal_cached_count":0,"db_primary_wal_cached_count":0,"db_main_wal_cached_count":0,"db_main_replica_wal_cached_count":0,"db_replica_duration_s":0.0,"db_primary_duration_s":0.145,"db_main_duration_s":0.109,"db_main_replica_duration_s":0.0,"external_http_count":1,"external_http_duration_s":0.19882399999187328,"cpu_s":4.398838,"pid":60240,"db_duration_s":0.09991,"view_duration_s":1.38638,"duration_s":4.9204}
On this branch:
{"method":"GET","path":"/","format":"html","controller":"RootController","action":"index","status":200,"time":"2022-04-22T00:03:30.489Z","params":[],"correlation_id":"01G17998TBE7ANQ6K1GTWD7ZVA","meta.user":"root","meta.client_id":"user/1","meta.caller_id":"RootController#index","meta.remote_ip":"127.0.0.1","meta.feature_category":"projects","remote_ip":"127.0.0.1","user_id":1,"username":"root","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0","queue_duration_s":2.659144,"request_urgency":"default","target_duration_s":1,"gitaly_calls":8,"gitaly_duration_s":0.068593,"redis_calls":80,"redis_duration_s":0.008258,"redis_read_bytes":12816,"redis_write_bytes":381335,"redis_cache_calls":77,"redis_cache_duration_s":0.007995,"redis_cache_read_bytes":12571,"redis_cache_write_bytes":380143,"redis_shared_state_calls":2,"redis_shared_state_duration_s":0.000112,"redis_shared_state_write_bytes":104,"redis_sessions_calls":1,"redis_sessions_duration_s":0.000151,"redis_sessions_read_bytes":245,"redis_sessions_write_bytes":1088,"db_count":108,"db_write_count":0,"db_cached_count":0,"db_replica_count":0,"db_primary_count":108,"db_main_count":84,"db_main_replica_count":0,"db_ci_count":24,"db_ci_replica_count":0,"db_replica_cached_count":0,"db_primary_cached_count":0,"db_main_cached_count":0,"db_main_replica_cached_count":0,"db_ci_cached_count":0,"db_ci_replica_cached_count":0,"db_replica_wal_count":0,"db_primary_wal_count":0,"db_main_wal_count":0,"db_main_replica_wal_count":0,"db_ci_wal_count":0,"db_ci_replica_wal_count":0,"db_replica_wal_cached_count":0,"db_primary_wal_cached_count":0,"db_main_wal_cached_count":0,"db_main_replica_wal_cached_count":0,"db_ci_wal_cached_count":0,"db_ci_replica_wal_cached_count":0,"db_replica_duration_s":0.0,"db_primary_duration_s":0.174,"db_main_duration_s":0.13,"db_main_replica_duration_s":0.0,"db_ci_duration_s":0.044,"db_ci_replica_duration_s":0.0,"external_http_count":1,"external_http_duration_s":0.008505999983754009,"cpu_s":4.399919,"pid":60240,"db_duration_s":0.05617,"view_duration_s":0.9641,"duration_s":1.53026}
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Thanks to @igorwwwwwwwwwwwwwwwwwwww for the initial bug report
Edited by Thong Kuah