@@ -5,26 +5,26 @@ import (
55
66 "github.com/prometheus/prometheus/pkg/timestamp"
77 "github.com/prometheus/prometheus/prompb"
8- "go.k6.io/k6/stats "
8+ "go.k6.io/k6/metrics "
99)
1010
1111// Note: k6 Registry is not used here since Output is getting
1212// samples only from k6 engine, hence we assume they are already vetted.
1313
1414// metricsStorage is an in-memory gather point for metrics
1515type metricsStorage struct {
16- m map [string ]stats .Sample
16+ m map [string ]metrics .Sample
1717}
1818
1919func newMetricsStorage () * metricsStorage {
2020 return & metricsStorage {
21- m : make (map [string ]stats .Sample ),
21+ m : make (map [string ]metrics .Sample ),
2222 }
2323}
2424
2525// update modifies metricsStorage and returns updated sample
2626// so that the stored metric and the returned metric hold the same value
27- func (ms * metricsStorage ) update (sample stats .Sample , add func (current , s stats .Sample ) stats .Sample ) stats .Sample {
27+ func (ms * metricsStorage ) update (sample metrics .Sample , add func (current , s metrics .Sample ) metrics .Sample ) metrics .Sample {
2828 if current , ok := ms .m [sample .Metric .Name ]; ok {
2929 if add == nil {
3030 current .Metric .Sink .Add (sample )
@@ -47,20 +47,20 @@ func (ms *metricsStorage) update(sample stats.Sample, add func(current, s stats.
4747}
4848
4949// transform k6 sample into TimeSeries for remote-write
50- func (ms * metricsStorage ) transform (mapping Mapping , sample stats .Sample , labels []prompb.Label ) ([]prompb.TimeSeries , error ) {
50+ func (ms * metricsStorage ) transform (mapping Mapping , sample metrics .Sample , labels []prompb.Label ) ([]prompb.TimeSeries , error ) {
5151 var newts []prompb.TimeSeries
5252
5353 switch sample .Metric .Type {
54- case stats .Counter :
54+ case metrics .Counter :
5555 newts = mapping .MapCounter (ms , sample , labels )
5656
57- case stats .Gauge :
57+ case metrics .Gauge :
5858 newts = mapping .MapGauge (ms , sample , labels )
5959
60- case stats .Rate :
60+ case metrics .Rate :
6161 newts = mapping .MapRate (ms , sample , labels )
6262
63- case stats .Trend :
63+ case metrics .Trend :
6464 newts = mapping .MapTrend (ms , sample , labels )
6565
6666 default :
@@ -74,10 +74,10 @@ func (ms *metricsStorage) transform(mapping Mapping, sample stats.Sample, labels
7474// remote agent. As each remote agent can use different ways to store metrics as well as
7575// expect different values on remote write endpoint, they must have their own support.
7676type Mapping interface {
77- MapCounter (ms * metricsStorage , sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries
78- MapGauge (ms * metricsStorage , sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries
79- MapRate (ms * metricsStorage , sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries
80- MapTrend (ms * metricsStorage , sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries
77+ MapCounter (ms * metricsStorage , sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries
78+ MapGauge (ms * metricsStorage , sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries
79+ MapRate (ms * metricsStorage , sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries
80+ MapTrend (ms * metricsStorage , sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries
8181
8282 // AdjustLabels(labels []prompb.Label) []prompb.Label
8383}
@@ -93,23 +93,23 @@ func NewMapping(mapping string) Mapping {
9393
9494type RawMapping struct {}
9595
96- func (rm * RawMapping ) MapCounter (ms * metricsStorage , sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries {
96+ func (rm * RawMapping ) MapCounter (ms * metricsStorage , sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries {
9797 return rm .processSample (sample , labels )
9898}
9999
100- func (rm * RawMapping ) MapGauge (ms * metricsStorage , sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries {
100+ func (rm * RawMapping ) MapGauge (ms * metricsStorage , sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries {
101101 return rm .processSample (sample , labels )
102102}
103103
104- func (rm * RawMapping ) MapRate (ms * metricsStorage , sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries {
104+ func (rm * RawMapping ) MapRate (ms * metricsStorage , sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries {
105105 return rm .processSample (sample , labels )
106106}
107107
108- func (rm * RawMapping ) MapTrend (ms * metricsStorage , sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries {
108+ func (rm * RawMapping ) MapTrend (ms * metricsStorage , sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries {
109109 return rm .processSample (sample , labels )
110110}
111111
112- func (rm * RawMapping ) processSample (sample stats .Sample , labels []prompb.Label ) []prompb.TimeSeries {
112+ func (rm * RawMapping ) processSample (sample metrics .Sample , labels []prompb.Label ) []prompb.TimeSeries {
113113 return []prompb.TimeSeries {
114114 {
115115 Labels : append (labels , prompb.Label {
0 commit comments