@@ -5,26 +5,26 @@ import (
5
5
6
6
"github.com/prometheus/prometheus/pkg/timestamp"
7
7
"github.com/prometheus/prometheus/prompb"
8
- "go.k6.io/k6/stats "
8
+ "go.k6.io/k6/metrics "
9
9
)
10
10
11
11
// Note: k6 Registry is not used here since Output is getting
12
12
// samples only from k6 engine, hence we assume they are already vetted.
13
13
14
14
// metricsStorage is an in-memory gather point for metrics
15
15
type metricsStorage struct {
16
- m map [string ]stats .Sample
16
+ m map [string ]metrics .Sample
17
17
}
18
18
19
19
func newMetricsStorage () * metricsStorage {
20
20
return & metricsStorage {
21
- m : make (map [string ]stats .Sample ),
21
+ m : make (map [string ]metrics .Sample ),
22
22
}
23
23
}
24
24
25
25
// update modifies metricsStorage and returns updated sample
26
26
// 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 {
28
28
if current , ok := ms .m [sample .Metric .Name ]; ok {
29
29
if add == nil {
30
30
current .Metric .Sink .Add (sample )
@@ -47,20 +47,20 @@ func (ms *metricsStorage) update(sample stats.Sample, add func(current, s stats.
47
47
}
48
48
49
49
// 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 ) {
51
51
var newts []prompb.TimeSeries
52
52
53
53
switch sample .Metric .Type {
54
- case stats .Counter :
54
+ case metrics .Counter :
55
55
newts = mapping .MapCounter (ms , sample , labels )
56
56
57
- case stats .Gauge :
57
+ case metrics .Gauge :
58
58
newts = mapping .MapGauge (ms , sample , labels )
59
59
60
- case stats .Rate :
60
+ case metrics .Rate :
61
61
newts = mapping .MapRate (ms , sample , labels )
62
62
63
- case stats .Trend :
63
+ case metrics .Trend :
64
64
newts = mapping .MapTrend (ms , sample , labels )
65
65
66
66
default :
@@ -74,10 +74,10 @@ func (ms *metricsStorage) transform(mapping Mapping, sample stats.Sample, labels
74
74
// remote agent. As each remote agent can use different ways to store metrics as well as
75
75
// expect different values on remote write endpoint, they must have their own support.
76
76
type 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
81
81
82
82
// AdjustLabels(labels []prompb.Label) []prompb.Label
83
83
}
@@ -93,23 +93,23 @@ func NewMapping(mapping string) Mapping {
93
93
94
94
type RawMapping struct {}
95
95
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 {
97
97
return rm .processSample (sample , labels )
98
98
}
99
99
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 {
101
101
return rm .processSample (sample , labels )
102
102
}
103
103
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 {
105
105
return rm .processSample (sample , labels )
106
106
}
107
107
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 {
109
109
return rm .processSample (sample , labels )
110
110
}
111
111
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 {
113
113
return []prompb.TimeSeries {
114
114
{
115
115
Labels : append (labels , prompb.Label {
0 commit comments