Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVEMENT] Test metrics validity when testing Exporter #526

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion promgen/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from itertools import chain

import prometheus_client
from prometheus_client.parser import text_string_to_metric_families

import requests
from django.conf import settings
from django.contrib import messages
Expand Down Expand Up @@ -667,7 +669,16 @@ def query():
try:
result = future.result()
result.raise_for_status()
yield result.url, result.status_code
metrics = list(text_string_to_metric_families(result.text))
yield (
result.url,
{
"status_code": result.status_code,
"metric_count": len(list(metrics)),
},
)
except ValueError as e:
yield result.url, f"Unable to parse metrics: {e}"
except requests.ConnectionError as e:
logger.warning("Error connecting to server")
yield e.request.url, "Error connecting to server"
Expand Down