Flagsmith / Flagsmith/flagsmith-common
Add Prometheus metrics for `using_database_replica`
- Dominant language
- Python
- Stars
- 2
- Forks
- 4
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 10
Description
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](https://github.com/Flagsmith/flagsmith-common?tab=readme-ov-file#guidelines) to learn how to develop and test Prometheus metrics.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.