diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/ExternalSLOChecker.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt similarity index 97% rename from theodolite-quarkus/src/main/kotlin/theodolite/evaluation/ExternalSLOChecker.kt rename to theodolite-quarkus/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt index f3cbbe828de0c3f564bea091aed558aa45f5f033..fea4c3485757bc8030111cb47ed5f25959cd7229 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/ExternalSLOChecker.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/ExternalSloChecker.kt @@ -6,7 +6,7 @@ import java.net.ConnectException import java.time.Duration import java.time.Instant -class ExternalSLOChecker( +class ExternalSloChecker( private val prometheusURL: String, private val query: String, private val externalSlopeURL: String, diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SloCheckerFactory.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SloCheckerFactory.kt new file mode 100644 index 0000000000000000000000000000000000000000..2170ef7b6abdb74499d05ac623c7892ac36b72d9 --- /dev/null +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/SloCheckerFactory.kt @@ -0,0 +1,29 @@ +package theodolite.evaluation + +import java.time.Duration + +class SloCheckerFactory { + + fun create( + slotype: String, + prometheusURL: String, + query: String, + externalSlopeURL: String, + threshold: Int, + offset: Duration, + warmup: Int + ): SloChecker { + + return when (slotype) { + "lag trend" -> ExternalSloChecker( + prometheusURL = prometheusURL, + query = query, + externalSlopeURL = externalSlopeURL, + threshold = threshold, + offset = offset, + warmup = warmup + ) + else -> throw IllegalArgumentException("Slotype $slotype not found.") + } + } +} diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index e498c3decf477736cbc3810e997b72e494d1d42d..19a0cb61c7bc24a00b1c769e77f4174d2f09d2d9 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -3,7 +3,7 @@ package theodolite.execution import mu.KotlinLogging import theodolite.benchmark.Benchmark import theodolite.benchmark.BenchmarkExecution -import theodolite.evaluation.ExternalSLOChecker +import theodolite.evaluation.SloCheckerFactory import theodolite.util.ConfigurationOverride import theodolite.util.LoadDimension import theodolite.util.Resource @@ -26,17 +26,17 @@ class BenchmarkExecutorImpl( benchmarkDeployment.setup() this.waitAndLog() benchmarkDeployment.teardown() - // todo evaluate var result = false try { - result = ExternalSLOChecker( - slo.prometheusUrl, - "sum by(group)(kafka_consumergroup_group_lag >= 0)", - slo.externalSloUrl, - slo.threshold, - Duration.ofHours(slo.offset.toLong()), - slo.warmup + result = SloCheckerFactory().create( + slotype = slo.sloType, + prometheusURL = slo.prometheusUrl, + query = "sum by(group)(kafka_consumergroup_group_lag >= 0)", + externalSlopeURL = slo.externalSloUrl, + threshold = slo.threshold, + offset = Duration.ofHours(slo.offset.toLong()), + warmup = slo.warmup ) .evaluate( Instant.now().minus(executionDuration), diff --git a/theodolite-quarkus/src/main/resources/yaml/BenchmarkExecution.yaml b/theodolite-quarkus/src/main/resources/yaml/BenchmarkExecution.yaml index f1646fb21c2aacb6c0603cb1285e8095398f008b..a91d123628a03bb7fd82821d6f34d7bf1239c154 100644 --- a/theodolite-quarkus/src/main/resources/yaml/BenchmarkExecution.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/BenchmarkExecution.yaml @@ -9,7 +9,7 @@ resources: resourceValues: - 1 slos: - - sloType: "slo type" + - sloType: "lag trend" threshold: 1000 prometheusUrl: "http://localhost:32656" externalSloUrl: "http://localhost:80/evaluate-slope"