xk6-frostfs/internal/stats/stats.go
Alex Vanin 68999e49d4 Initial commit
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2022-05-12 23:27:06 +03:00

35 lines
701 B
Go

package stats
import (
"time"
"go.k6.io/k6/js/modules"
"go.k6.io/k6/metrics"
)
func Report(vu modules.VU, metric *metrics.Metric, value float64) {
metrics.PushIfNotDone(vu.Context(), vu.State().Samples, metrics.Sample{
Metric: metric,
Time: time.Now(),
Value: value,
})
}
func ReportDataReceived(vu modules.VU, value float64) {
vu.State().BuiltinMetrics.DataReceived.Sink.Add(
metrics.Sample{
Metric: &metrics.Metric{},
Value: value,
Time: time.Now()},
)
}
func ReportDataSent(vu modules.VU, value float64) {
state := vu.State()
state.BuiltinMetrics.DataSent.Sink.Add(
metrics.Sample{
Metric: &metrics.Metric{},
Value: value,
Time: time.Now()},
)
}