Skip to content

Commit

Permalink
add generated tests for metrics endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lilioid committed Feb 12, 2024
1 parent 91fb68c commit 1fb8bf7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.shortcuts import resolve_url
from django.test import Client


def test_metric_endpoint_returns_200(client: Client):
response = client.get(resolve_url("prometheus_metrics"))
assert response.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ def get(self, request: HttpRequest) -> HttpResponse:
if not self.is_allowed(request):
return HttpResponse(status=HTTPStatus.FORBIDDEN)

encode, content_type = prometheus_client.exposition.choose_encoder(request.META["HTTP_ACCEPT"])
encode, content_type = prometheus_client.exposition.choose_encoder(request.META.get("HTTP_ACCEPT"))
content = encode(REGISTRY)
return HttpResponse(status=HTTPStatus.OK, content=content, content_type=content_type)

0 comments on commit 1fb8bf7

Please sign in to comment.