forked from TrueCloudLab/xk6-frostfs
Evgenii Stratonikov
1025e80f11
See https://github.com/grafana/k6/pull/3075/, it is not yet in any release. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
41 lines
819 B
Go
41 lines
819 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{
|
|
TimeSeries: metrics.TimeSeries{
|
|
Metric: metric,
|
|
},
|
|
Time: time.Now(),
|
|
Value: value,
|
|
})
|
|
}
|
|
|
|
func ReportDataReceived(vu modules.VU, value float64) {
|
|
vu.State().BuiltinMetrics.DataReceived.Sink.Add(
|
|
metrics.Sample{
|
|
TimeSeries: metrics.TimeSeries{
|
|
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{
|
|
TimeSeries: metrics.TimeSeries{
|
|
Metric: &metrics.Metric{},
|
|
},
|
|
Value: value,
|
|
Time: time.Now()},
|
|
)
|
|
}
|