Przeglądaj źródła

feat(api): introduce metric for failed pdns requests

Nils Wisiol 2 lat temu
rodzic
commit
3f26bd9cdc
2 zmienionych plików z 8 dodań i 0 usunięć
  1. 5 0
      api/desecapi/metrics.py
  2. 3 0
      api/desecapi/pdns.py

+ 5 - 0
api/desecapi/metrics.py

@@ -67,6 +67,11 @@ set_counter(
     "number of times pdns request was successful",
     ["method", "status"],
 )
+set_counter(
+    "desecapi_pdns_request_failure",
+    "number of times pdns request failed",
+    ["method", "path", "status"],
+)
 set_counter("desecapi_pdns_keys_fetched", "number of times pdns keys were fetched")
 
 # pdns_change_tracker.py metrics

+ 3 - 0
api/desecapi/pdns.py

@@ -99,6 +99,9 @@ def _pdns_request(
         method, _config[server]["base_url"] + path, data=data, headers=headers
     )
     if r.status_code not in range(200, 300):
+        metrics.get("desecapi_pdns_request_failure").labels(
+            method, path, r.status_code
+        ).inc()
         raise PDNSException(response=r)
     metrics.get("desecapi_pdns_request_success").labels(method, r.status_code).inc()
     return r