2022-05-12 19:37:38 +00:00
|
|
|
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{
|
2023-05-23 08:16:59 +00:00
|
|
|
TimeSeries: metrics.TimeSeries{
|
|
|
|
Metric: metric,
|
|
|
|
},
|
|
|
|
Time: time.Now(),
|
|
|
|
Value: value,
|
2022-05-12 19:37:38 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func ReportDataReceived(vu modules.VU, value float64) {
|
|
|
|
vu.State().BuiltinMetrics.DataReceived.Sink.Add(
|
|
|
|
metrics.Sample{
|
2023-05-23 08:16:59 +00:00
|
|
|
TimeSeries: metrics.TimeSeries{
|
|
|
|
Metric: &metrics.Metric{},
|
|
|
|
},
|
|
|
|
Value: value,
|
|
|
|
Time: time.Now()},
|
2022-05-12 19:37:38 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ReportDataSent(vu modules.VU, value float64) {
|
|
|
|
state := vu.State()
|
|
|
|
state.BuiltinMetrics.DataSent.Sink.Add(
|
|
|
|
metrics.Sample{
|
2023-05-23 08:16:59 +00:00
|
|
|
TimeSeries: metrics.TimeSeries{
|
|
|
|
Metric: &metrics.Metric{},
|
|
|
|
},
|
|
|
|
Value: value,
|
|
|
|
Time: time.Now()},
|
2022-05-12 19:37:38 +00:00
|
|
|
)
|
|
|
|
}
|