Skip to content
Snippets Groups Projects
Commit e2b29cb1 authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Enhance empty query case

parent 332a6055
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!96Handle shutdown,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
......@@ -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)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment