Skip to content

Commit 547eaf1

Browse files
committed
improve metric naming
1 parent b976e60 commit 547eaf1

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ Flagsmith uses Prometheus to track performance metrics.
6464
The following default metrics are exposed:
6565

6666
- `flagsmith_build_info`: Has the labels `version` and `ci_commit_sha`.
67-
- `http_request_duration_seconds`: Histogram labeled with `method`, `path`, and `response_status`.
68-
- `http_requests_total`: Counter labeled with `method`, `path`, and `response_status`.
67+
- `http_server_request_duration_seconds`: Histogram labeled with `method`, `path`, and `response_status`.
68+
- `http_server_requests_total`: Counter labeled with `method`, `path`, and `response_status`.
6969

7070
##### Guidelines
7171

src/common/gunicorn/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def access(
6060
"method": environ.get("REQUEST_METHOD"),
6161
"response_status": resp.status_code,
6262
}
63-
with_labels(metrics.http_request_duration_seconds, **labels).observe(
63+
with_labels(metrics.http_server_request_duration_seconds, **labels).observe(
6464
duration_seconds
6565
)
66-
with_labels(metrics.http_requests_total, **labels).inc()
66+
with_labels(metrics.http_server_requests_total, **labels).inc()
6767

6868

6969
class GunicornJsonCapableLogger(PrometheusGunicornLogger):

src/common/gunicorn/metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import prometheus_client
22
from django.conf import settings
33

4-
http_requests_total = prometheus_client.Counter(
5-
"http_requests_total",
4+
http_server_requests_total = prometheus_client.Counter(
5+
"http_server_requests_total",
66
"Total number of HTTP requests",
77
["path", "method", "response_status"],
88
)
9-
http_request_duration_seconds = prometheus_client.Histogram(
10-
"http_request_duration_seconds",
9+
http_server_request_duration_seconds = prometheus_client.Histogram(
10+
"http_server_request_duration_seconds",
1111
"HTTP request duration in seconds",
1212
["path", "method", "response_status"],
1313
buckets=settings.PROMETHEUS_HISTOGRAM_BUCKETS,

tests/unit/common/gunicorn/test_logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ def test_gunicorn_prometheus_gunicorn_logger__expected_metrics(
9797

9898
# Then
9999
assert_metric(
100-
name="http_requests_total",
100+
name="http_server_requests_total",
101101
value=1.0,
102102
labels={"method": "GET", "path": "^health", "response_status": "200"},
103103
)
104104
assert_metric(
105-
name="http_request_duration_seconds_sum",
105+
name="http_server_request_duration_seconds_sum",
106106
value=0.101,
107107
labels={"method": "GET", "path": "^health", "response_status": "200"},
108108
)

0 commit comments

Comments
 (0)