From 197b251ae6affb24714f28c894a52026c6d24d16 Mon Sep 17 00:00:00 2001 From: Tami Takamiya Date: Tue, 9 Jul 2024 13:22:25 -0400 Subject: [PATCH] Add more buckets to Prometheus histgrams for WCA APIs --- .../ai/api/model_client/wca_client.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ansible_ai_connect/ai/api/model_client/wca_client.py b/ansible_ai_connect/ai/api/model_client/wca_client.py index 9e4cc6cec..481c1b5b1 100644 --- a/ansible_ai_connect/ai/api/model_client/wca_client.py +++ b/ansible_ai_connect/ai/api/model_client/wca_client.py @@ -67,32 +67,58 @@ WCA_REQUEST_ID_HEADER = "X-Request-ID" +# from django_prometheus.middleware.DEFAULT_LATENCY_BUCKETS +DEFAULT_LATENCY_BUCKETS = ( + 0.01, + 0.025, + 0.05, + 0.075, + 0.1, + 0.25, + 0.5, + 0.75, + 1.0, + 2.5, + 5.0, + 7.5, + 10.0, + 25.0, + 50.0, + 75.0, + float("inf"), +) + logger = logging.getLogger(__name__) wca_codegen_hist = Histogram( "wca_codegen_latency_seconds", "Histogram of WCA codegen API processing time", namespace=NAMESPACE, + buckets=DEFAULT_LATENCY_BUCKETS, ) wca_codematch_hist = Histogram( "wca_codematch_latency_seconds", "Histogram of WCA codematch API processing time", namespace=NAMESPACE, + buckets=DEFAULT_LATENCY_BUCKETS, ) wca_codegen_playbook_hist = Histogram( "wca_codegen_playbook_latency_seconds", "Histogram of WCA codegen-playbook API processing time", namespace=NAMESPACE, + buckets=DEFAULT_LATENCY_BUCKETS, ) wca_explain_playbook_hist = Histogram( "wca_explain_playbook_latency_seconds", "Histogram of WCA explain-playbook API processing time", namespace=NAMESPACE, + buckets=DEFAULT_LATENCY_BUCKETS, ) ibm_cloud_identity_token_hist = Histogram( "wca_ibm_identity_token_latency_seconds", "Histogram of IBM Cloud identity token API processing time", namespace=NAMESPACE, + buckets=DEFAULT_LATENCY_BUCKETS, ) wca_codegen_retry_counter = Counter( "wca_codegen_retries",