Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123227
D5463.id19538.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D5463.id19538.diff
View Options
diff --git a/swh/web/common/origin_save.py b/swh/web/common/origin_save.py
--- a/swh/web/common/origin_save.py
+++ b/swh/web/common/origin_save.py
@@ -622,9 +622,25 @@
)
+# Cumulative metric on the duration of save code now request per status and visit_type
+ACCEPTED_SAVE_REQUESTS_DELAY_METRIC = "swh_web_save_requests_duration_seconds"
+
+_accepted_save_requests_delay_gauge = Gauge(
+ name=ACCEPTED_SAVE_REQUESTS_DELAY_METRIC,
+ documentation="Save Requests Duration",
+ labelnames=["load_task_status", "visit_type"],
+ registry=SWH_WEB_METRICS_REGISTRY,
+)
+
+
def compute_save_requests_metrics() -> None:
- """Compute a couple of Prometheus metrics related to
- origin save requests"""
+ """Compute Prometheus metrics related to origin save requests:
+
+ - Number of submitted origin save requests
+ - Number of accepted origin save requests
+ - Save Code Now requests duration
+
+ """
request_statuses = (
SAVE_REQUEST_ACCEPTED,
@@ -653,6 +669,14 @@
for labels in labels_set:
_accepted_save_requests_gauge.labels(*labels).set(0)
+ duration_load_task_statuses = (
+ SAVE_TASK_FAILED,
+ SAVE_TASK_SUCCEEDED,
+ )
+
+ for labels in product(duration_load_task_statuses, visit_types):
+ _accepted_save_requests_delay_gauge.labels(*labels).set(0)
+
for sor in SaveOriginRequest.objects.all():
if sor.status == SAVE_REQUEST_ACCEPTED:
_accepted_save_requests_gauge.labels(
@@ -662,3 +686,13 @@
_submitted_save_requests_gauge.labels(
status=sor.status, visit_type=sor.visit_type
).inc()
+
+ if (
+ sor.loading_task_status in (SAVE_TASK_SUCCEEDED, SAVE_TASK_FAILED)
+ and sor.visit_date is not None
+ and sor.request_date is not None
+ ):
+ duration = sor.visit_date.timestamp() - sor.request_date.timestamp()
+ _accepted_save_requests_delay_gauge.labels(
+ load_task_status=sor.loading_task_status, visit_type=sor.visit_type
+ ).inc(duration)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 18, 3:57 AM (2 d, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3230017
Attached To
D5463: Add metric to monitor "save code now" efficiency
Event Timeline
Log In to Comment