Skip to content

Commit 480ffc8

Browse files
roachtest/tpce: add unit and is_higher_better labels for tpce benchmark metrics
The golang perf dashboards require unit and is_higher_better labels for correctly plotting the comparison metrics. This relevant change awas added to the aggregated metrics change for histograms. Since the tpce benchmark doesn't emit a histogram from the workload binary, this commit aims to manually add the labels while emitting the metrics. Epic: CRDB-48908 Release note: None
1 parent cd1e806 commit 480ffc8

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

pkg/cmd/roachtest/tests/tpce.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func exportTPCEResults(t test.Test, c cluster.Cluster, result string) error {
368368
"workload": "tpce",
369369
}
370370
labelString := roachtestutil.GetOpenmetricsLabelString(t, c, labels)
371-
metricBytes = getOpenMetrics(metrics, fields[5], labelString)
371+
metricBytes = GetTpceOpenmetricsBytes(metrics, fields[5], labelString)
372372
} else {
373373
metricBytes, err = json.Marshal(metrics)
374374
}
@@ -389,19 +389,29 @@ func exportTPCEResults(t test.Test, c cluster.Cluster, result string) error {
389389
return errors.Errorf("exportTPCEResults: found no lines starting with TradeResult")
390390
}
391391

392-
func getOpenMetrics(metrics tpceMetrics, countOfLatencies string, labelString string) []byte {
392+
func GetTpceOpenmetricsBytes(
393+
metrics tpceMetrics, countOfLatencies string, labelString string,
394+
) []byte {
393395

394396
var buffer bytes.Buffer
395397
now := timeutil.Now().Unix()
396398

397399
buffer.WriteString("# TYPE tpce_latency summary\n")
398400
buffer.WriteString("# HELP tpce_latency Latency metrics for TPC-E transactions\n")
399-
buffer.WriteString(fmt.Sprintf("tpce_latency{%s,quantile=\"0.5\"} %s %d\n", labelString, metrics.P50Latency, now))
400-
buffer.WriteString(fmt.Sprintf("tpce_latency{%s,quantile=\"0.9\"} %s %d\n", labelString, metrics.P90Latency, now))
401-
buffer.WriteString(fmt.Sprintf("tpce_latency{%s,quantile=\"0.99\"} %s %d\n", labelString, metrics.P99Latency, now))
402-
buffer.WriteString(fmt.Sprintf("tpce_latency{%s,quantile=\"1.0\"} %s %d\n", labelString, metrics.PMaxLatency, now))
401+
402+
latencyString := func(quantile, latency string) string {
403+
return fmt.Sprintf(`tpce_latency{%s,unit="ms",is_higher_better="false",quantile="%s"} %s %d\n`, labelString, quantile, latency, now)
404+
}
405+
406+
buffer.WriteString(latencyString("0.5", metrics.P50Latency))
407+
buffer.WriteString(latencyString("0.9", metrics.P90Latency))
408+
buffer.WriteString(latencyString("0.99", metrics.P99Latency))
409+
buffer.WriteString(latencyString("1.0", metrics.PMaxLatency))
410+
// Sum is hardcoded is zero to denote null values, since we don't have exact values
403411
buffer.WriteString(fmt.Sprintf("tpce_latency_sum{%s} %d %d\n", labelString, 0, now))
404412
buffer.WriteString(fmt.Sprintf("tpce_latency_count{%s} %s %d\n", labelString, countOfLatencies, now))
413+
buffer.WriteString("# TYPE tpce_avg_latency gauge\n")
414+
buffer.WriteString(fmt.Sprintf(`tpce_avg_latency{%s,unit="ms",is_higher_better="false"} %s %d\n`, labelString, metrics.AvgLatency, now))
405415
buffer.WriteString("# EOF")
406416

407417
metricsBytes := buffer.Bytes()

0 commit comments

Comments
 (0)