Skip to content

Commit 82be91f

Browse files
📝 Add docstrings to codex/create-json-dashboards-and-configure-alerts (#133)
Docstrings generation was requested by @shayancoin. * #76 (comment) The following files were modified: * `backend/api/main.py` * `backend/api/metrics.py` * `backend/api/routes_observability.py` * `backend/tests/test_observability_metrics.py` * `frontend/src/app/reportWebVitals.ts` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Shayan <shayan@coin.link>
1 parent 63f5433 commit 82be91f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎backend/api/metrics.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@ def observe_http_request(
6464
status: str,
6565
duration_seconds: float,
6666
) -> None:
67-
"""Record a single HTTP request observation."""
67+
"""
68+
Record a single HTTP request observation for Prometheus metrics.
69+
70+
Parameters:
71+
service (str): Logical name of the service handling the request (e.g., "api", "frontend").
72+
route (str): HTTP route or path being requested (e.g., "/users/{id}").
73+
method (str): HTTP method used for the request (e.g., "GET", "POST").
74+
status (str): HTTP response status code or status label (e.g., "200", "500").
75+
duration_seconds (float): Request duration in seconds to record in the latency histogram.
76+
"""
6877

6978
http_requests_total.labels(
7079
service=service, route=route, method=method, status=status

‎backend/tests/test_observability_metrics.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def _get_sample(name: str, labels: dict[str, str]) -> float:
2424

2525

2626
def test_lcp_ingest_records_histogram() -> None:
27+
"""
28+
Verify posting an LCP web-vital increments the LCP count histogram for the specified app.
29+
30+
Sends an LCP payload to the observability ingest endpoint and asserts the `web_vitals_lcp_count` metric for `app="frontend"` increases by 1.
31+
"""
2732
before = _get_sample("web_vitals_lcp_count", {"app": "frontend"})
2833

2934
response = client.post(

0 commit comments

Comments
 (0)