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

Enhance empty query case

parent 158aad8a
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!92Introduce experiment evaluation,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
...@@ -3,10 +3,13 @@ package theodolite.evaluation ...@@ -3,10 +3,13 @@ package theodolite.evaluation
import com.google.gson.Gson import com.google.gson.Gson
import khttp.get import khttp.get
import khttp.responses.Response import khttp.responses.Response
import mu.KotlinLogging
import theodolite.util.PrometheusResponse import theodolite.util.PrometheusResponse
import java.net.ConnectException import java.net.ConnectException
import java.util.* import java.util.*
private val logger = KotlinLogging.logger {}
class MetricFetcher(private val prometheusURL: String) { class MetricFetcher(private val prometheusURL: String) {
...@@ -22,8 +25,15 @@ class MetricFetcher(private val prometheusURL: String) { ...@@ -22,8 +25,15 @@ class MetricFetcher(private val prometheusURL: String) {
while (trys < 2) { while (trys < 2) {
val response = get("$prometheusURL/api/v1/query_range", params = parameter) val response = get("$prometheusURL/api/v1/query_range", params = parameter)
if (response.statusCode != 200) { if (response.statusCode != 200) {
val message = response.jsonObject.toString()
logger.warn { "Could not connect to Prometheus: $message, retrying now" }
trys++ trys++
} else { } else {
var values = parseValues(response)
if (values.data?.result.isNullOrEmpty()) {
logger.warn { "Empty query result: $values" }
throw NoSuchFieldException()
}
return parseValues(response) 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