Skip to content

Add Prometheus metrics for using_database_replica #98

@khvn26

Description

@khvn26

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions