Skip to content

Commit 83b23a6

Browse files
craig[bot]csgourav
andcommitted
Merge #143704
143704: roachtest: add unit and is_higher_better labels to sysbench openmetrics r=srosenberg a=csgourav This change adds unit and is_higher_better labels to metrics exported via openmetrics. Also, removes the threads metric which was getting exported, as it remains constant and is same as concurrency. Fixes: CRDB-48907 Epic: none Co-authored-by: Gourav Kumar <[email protected]>
2 parents 0872e5e + 7eba4f2 commit 83b23a6

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

pkg/cmd/roachtest/tests/sysbench.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,27 @@ type openmetricsValues struct {
374374
Time int64
375375
}
376376

377+
// Define units for sysbench metrics
378+
var units = map[string]string{
379+
// Transaction rates - operations per second
380+
"transactions": "unit=\"ops/sec\",is_higher_better=\"true\"",
381+
382+
// Query rates - queries per second
383+
"qps": "unit=\"qps\",is_higher_better=\"true\"",
384+
"read_qps": "unit=\"qps\",is_higher_better=\"true\"",
385+
"write_qps": "unit=\"qps\",is_higher_better=\"true\"",
386+
"other_qps": "unit=\"qps\",is_higher_better=\"true\"",
387+
388+
// Latency - milliseconds
389+
"p95_latency": "unit=\"ms\",is_higher_better=\"false\"",
390+
391+
// Error rates - errors per second
392+
"errors": "unit=\"errors/sec\",is_higher_better=\"false\"",
393+
394+
// Reconnection rates - reconnects per second
395+
"reconnects": "unit=\"reconnects/sec\",is_higher_better=\"false\"",
396+
}
397+
377398
// exportSysbenchResults parses the output of `sysbench` into a stats
378399
// file and writes it to the perf directory that roachperf expects. The
379400
// format of the stats file is dependent on t.ExportOpenmetrics().
@@ -495,7 +516,6 @@ func addCurrentSnapshotToOpenmetrics(
495516
metrics sysbenchMetrics, openmetricsMap map[string][]openmetricsValues,
496517
) {
497518
time := metrics.Time
498-
openmetricsMap["threads"] = append(openmetricsMap["threads"], openmetricsValues{Value: metrics.Threads, Time: time})
499519
openmetricsMap["transactions"] = append(openmetricsMap["transactions"], openmetricsValues{Value: metrics.Transactions, Time: time})
500520
openmetricsMap["qps"] = append(openmetricsMap["qps"], openmetricsValues{Value: metrics.Qps, Time: time})
501521
openmetricsMap["read_qps"] = append(openmetricsMap["read_qps"], openmetricsValues{Value: metrics.ReadQps, Time: time})
@@ -513,7 +533,12 @@ func getOpenmetricsBytes(openmetricsMap map[string][]openmetricsValues, labelStr
513533
metricName := util.SanitizeMetricName(key)
514534
metricsBuf.WriteString(roachtestutil.GetOpenmetricsGaugeType(metricName))
515535
for _, value := range values {
516-
metricsBuf.WriteString(fmt.Sprintf("%s{%s} %s %d\n", metricName, labelString, value.Value, value.Time))
536+
metricsBuf.WriteString(fmt.Sprintf("%s{%s,%s} %s %d\n",
537+
metricName,
538+
labelString,
539+
units[key],
540+
value.Value,
541+
value.Time))
517542
}
518543
}
519544

0 commit comments

Comments
 (0)