diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt index 883ead52c785722033ce9f8a4b86dd803f755fd5..da70ab10b1270c05dc467d98f615d4046f4c3992 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt @@ -3,10 +3,13 @@ package theodolite.evaluation import com.google.gson.Gson import khttp.get import khttp.responses.Response +import mu.KotlinLogging import theodolite.util.PrometheusResponse import java.net.ConnectException import java.util.* +private val logger = KotlinLogging.logger {} + class MetricFetcher(private val prometheusURL: String) { @@ -22,8 +25,15 @@ class MetricFetcher(private val prometheusURL: String) { while (trys < 2) { val response = get("$prometheusURL/api/v1/query_range", params = parameter) if (response.statusCode != 200) { + val message = response.jsonObject.toString() + logger.warn { "Could not connect to Prometheus: $message, retrying now" } trys++ } else { + var values = parseValues(response) + if (values.data?.result.isNullOrEmpty()) { + logger.warn { "Empty query result: $values" } + throw NoSuchFieldException() + } return parseValues(response) } }