Skip to content
Snippets Groups Projects
Commit 45348ebe authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

Fix creation of JSON to request external slo

parent a88c3ea5
Branches
Tags
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!137Allow multiple repititions of an experiment,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
...@@ -46,6 +46,13 @@ def execute(results, threshold, warmup): ...@@ -46,6 +46,13 @@ def execute(results, threshold, warmup):
@app.post("/evaluate-slope",response_model=bool) @app.post("/evaluate-slope",response_model=bool)
async def evaluate_slope(request: Request): async def evaluate_slope(request: Request):
data = json.loads(await request.body()) data = json.loads(await request.body())
return execute(data['total_lag'], data['threshold'], data['warmup']) results = []
for total_lag in data['total_lags']:
results.append(execute(total_lag, data['threshold'], data['warmup'] ))
for result in results:
if not result:
return False
return True
logger.info("Slope evaluator is online") logger.info("Slope evaluator is online")
\ No newline at end of file
fastapi==0.55.1 fastapi==0.55.1
scikit-learn==0.20.3 scikit-learn==0.20.3
pandas==1.0.3 pandas==1.0.3
uvicorn
...@@ -20,7 +20,7 @@ class AnalysisExecutor(private val slo: BenchmarkExecution.Slo) { ...@@ -20,7 +20,7 @@ class AnalysisExecutor(private val slo: BenchmarkExecution.Slo) {
var result = false var result = false
val exporter = CsvExporter() val exporter = CsvExporter()
val prometheusData = executionIntervals.map { interval -> fetcher.fetchMetric( start = interval.first, end = interval.second, query = "sum by(group)(kafka_consumergroup_group_lag >= 0)") } val prometheusData = executionIntervals.map { interval -> fetcher.fetchMetric( start = interval.first, end = interval.second, query = "sum by(group)(kafka_consumergroup_group_lag >= 0)") }
var repetitionCounter = 0 var repetitionCounter = 1
prometheusData.forEach{ data -> exporter.toCsv(name = "${load.get()}_${res.get()}_${slo.sloType}_rep_${repetitionCounter++}", prom = data) } prometheusData.forEach{ data -> exporter.toCsv(name = "${load.get()}_${res.get()}_${slo.sloType}_rep_${repetitionCounter++}", prom = data) }
prometheusData.forEach { logger.info { "prom-data: $it" }} prometheusData.forEach { logger.info { "prom-data: $it" }}
......
...@@ -21,14 +21,14 @@ class ExternalSloChecker( ...@@ -21,14 +21,14 @@ class ExternalSloChecker(
override fun evaluate(fetchedData: List<PrometheusResponse>): Boolean { override fun evaluate(fetchedData: List<PrometheusResponse>): Boolean {
var counter = 0 var counter = 0
var requestData = fetchedData.map { entry -> Gson().toJson(mapOf("total_lag" to entry.data?.result)) }.toMutableList()
requestData.add(mapOf("threshold" to threshold).toString())
requestData.add(mapOf("warmup" to warmup).toString())
val data = Gson().toJson(mapOf(
"total_lags" to fetchedData.map { it.data?.result },
"threshold" to threshold,
"warmup" to warmup))
while (counter < RETRIES) { while (counter < RETRIES) {
val result = post(externalSlopeURL, data = requestData, timeout = TIMEOUT) val result = post(externalSlopeURL, data = data, timeout = TIMEOUT)
if (result.statusCode != 200) { if (result.statusCode != 200) {
counter++ counter++
logger.error { "Could not reach external slope analysis" } logger.error { "Could not reach external slope analysis" }
......
...@@ -25,6 +25,7 @@ class BenchmarkExecutorImpl( ...@@ -25,6 +25,7 @@ class BenchmarkExecutorImpl(
val executionIntervals: MutableList<Pair<Instant, Instant>> = ArrayList(repetitions) val executionIntervals: MutableList<Pair<Instant, Instant>> = ArrayList(repetitions)
for (i in 1.rangeTo(repetitions)) { for (i in 1.rangeTo(repetitions)) {
logger.info { "Run repetition $i/$repetitions" }
if (this.run.get()) { if (this.run.get()) {
executionIntervals.add(runSingleExperiment(load,res)) executionIntervals.add(runSingleExperiment(load,res))
} else { } else {
...@@ -33,7 +34,6 @@ class BenchmarkExecutorImpl( ...@@ -33,7 +34,6 @@ class BenchmarkExecutorImpl(
} }
if (this.run.get()) { if (this.run.get()) {
executionIntervals.forEach{ logger.info { "interval for evaluation; from: ${it.first}, to: ${it.second}"}}
result =AnalysisExecutor(slo = slo) result =AnalysisExecutor(slo = slo)
.analyze(load = load, res = res, executionIntervals = executionIntervals) .analyze(load = load, res = res, executionIntervals = executionIntervals)
this.results.setResult(Pair(load, res), result) this.results.setResult(Pair(load, res), result)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment