As we're adding a fairly critical database utility in #95, we'd like to be able to effectively monitor its operation with Prometheus.
Implementation
Add the following counter:
flagsmith_db_selected_replica_count_total, labeled with result (success/failure) and replica_name.
Inside using_database_replica:
- On each successful
ensure_connection() call, increment the counter: flagsmith_db_selected_replica_count_total.labels(result="success", replica_name= chosen_replica).inc()
- In each
OperationalError exception handling branch, increment the counter: flagsmith_db_selected_replica_count_total.labels(result="failure", replica_name=attempted_replica).inc()
Check how existing metrics are used and defined by searching for an existing metric, e.g. flagsmith_task_processor_enqueued_tasks_total.
Refer to developer documentation to learn how to develop and test Prometheus metrics.
As we're adding a fairly critical database utility in #95, we'd like to be able to effectively monitor its operation with Prometheus.
Implementation
Add the following counter:
flagsmith_db_selected_replica_count_total, labeled withresult(success/failure) andreplica_name.Inside
using_database_replica:ensure_connection()call, increment the counter:flagsmith_db_selected_replica_count_total.labels(result="success", replica_name= chosen_replica).inc()OperationalErrorexception handling branch, increment the counter:flagsmith_db_selected_replica_count_total.labels(result="failure", replica_name=attempted_replica).inc()Check how existing metrics are used and defined by searching for an existing metric, e.g.
flagsmith_task_processor_enqueued_tasks_total.Refer to developer documentation to learn how to develop and test Prometheus metrics.