Split structured logs db_duration fields between primary database and secondary databases
Database duration field should be split in our rails and sidekiq logs, between primary and replica access.
This would help us with analysis of database problems associated with the postgres primary instance.
To avoid adding too many new fields, I think we should only add the durations, db_primary_duration_s
and db_replica_duration_s
, not the other fields.
Before
"json.db_duration_s": 0.00334,
"json.db_count": 2,
"json.db_write_count": 0,
"json.db_cached_count": 0,
After
"json.db_duration_s": ..,
"json.db_count": ..,
"json.db_write_count": ..,
"json.db_cached_count": ..,
"json.db_primary_duration_s": ..,
"json.db_replica_duration_s": ..,
See also gitlab-com/gl-infra/scalability#871 (moved), which is this issue, for metrics.
Edited by Andrew Newdigate