Skip to content

Commit

Permalink
Update xk6-output-prometheus-remote to its latest main commit
Browse files Browse the repository at this point in the history
This allows us to make all TrendSink properties private and finish that refactoring effort.
  • Loading branch information
na-- committed Jul 19, 2023
1 parent ac9c6bc commit 11349b3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/gorilla/websocket v1.5.0
github.com/grafana/xk6-browser v0.10.0
github.com/grafana/xk6-grpc v0.1.2
github.com/grafana/xk6-output-prometheus-remote v0.2.1
github.com/grafana/xk6-output-prometheus-remote v0.2.2-0.20230719110733-69f101ee8ade
github.com/grafana/xk6-redis v0.1.1
github.com/grafana/xk6-timers v0.1.2
github.com/grafana/xk6-webcrypto v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ github.com/grafana/xk6-browser v0.10.0 h1:Mnx0Ho+mlyFGlV7zW7zXkN0njRglh9JflLV+Oz
github.com/grafana/xk6-browser v0.10.0/go.mod h1:ax6OHARpNEu9hSGYOAI4grAwiRapsNPi9TBQxDYurKw=
github.com/grafana/xk6-grpc v0.1.2 h1:gNN3PYV2dIPoq1zTVz8YOxrWhl1D15jhRR0EA9ZYhBw=
github.com/grafana/xk6-grpc v0.1.2/go.mod h1:iq6qHN64XgAEmDHKf0OXZ4mvoqF4Udr22fiCIXNpXA0=
github.com/grafana/xk6-output-prometheus-remote v0.2.1 h1:/JOMHwByfCkFe17iokUDKCIjh8e5g0gqqnrg8zSnxf4=
github.com/grafana/xk6-output-prometheus-remote v0.2.1/go.mod h1:JWUOn1fY8Yp3dM+IaPSNMM6t+sF3aJ2AA7Qzs6lKGww=
github.com/grafana/xk6-output-prometheus-remote v0.2.2-0.20230719110733-69f101ee8ade h1:DY8H7hMVBpP4yuKlNnPBykL+WJ4hBobwT0BG8nDcFLw=
github.com/grafana/xk6-output-prometheus-remote v0.2.2-0.20230719110733-69f101ee8ade/go.mod h1:rI7naMHdQ+vLVoonZ6LYkrXz8ZiWIptTstVbV2CSahY=
github.com/grafana/xk6-redis v0.1.1 h1:rvWnLanRB2qzDwuY6NMBe6PXei3wJ3kjYvfCwRJ+q+8=
github.com/grafana/xk6-redis v0.1.1/go.mod h1:z7el1Tz8advY+ex419KfLbENzSQYgaA2lQYwMlt9yMM=
github.com/grafana/xk6-timers v0.1.2 h1:YVM6hPDgvy4SkdZQpd+/r9M0kDi1g+QdbSxW5ClfwDk=
Expand Down
2 changes: 1 addition & 1 deletion metrics/engine/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestIngesterOutputFlushMetrics(t *testing.T) {
assert.Equal(t, testMetric, metric)

sink := metric.Sink.(*metrics.TrendSink) //nolint:forcetypeassert
assert.Equal(t, 42.0, sink.Sum)
assert.Equal(t, 42.0, sink.Total())
}

func TestIngesterOutputFlushSubmetrics(t *testing.T) {
Expand Down
10 changes: 4 additions & 6 deletions metrics/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ type TrendSink struct {

count uint64
min, max float64
// TODO: unexport after this dependency is removed:
// https://github.com/grafana/xk6-output-prometheus-remote/blob/v0.2.1/pkg/remotewrite/remotewrite.go#L173
Sum float64
sum float64
}

// IsEmpty indicates whether the TrendSink is empty.
Expand All @@ -122,7 +120,7 @@ func (t *TrendSink) Add(s Sample) {
t.values = append(t.values, s.Value)
t.sorted = false
t.count++
t.Sum += s.Value
t.sum += s.Value
}

// P calculates the given percentile from sink values.
Expand Down Expand Up @@ -167,14 +165,14 @@ func (t *TrendSink) Count() uint64 {
// Avg returns the average (i.e. mean) value.
func (t *TrendSink) Avg() float64 {
if t.count > 0 {
return t.Sum / float64(t.count)
return t.sum / float64(t.count)
}
return 0
}

// Total returns the total (i.e. "sum") value for all measurements.
func (t *TrendSink) Total() float64 {
return t.Sum
return t.sum
}

func (t *TrendSink) Format(tt time.Duration) map[string]float64 {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ github.com/grafana/xk6-browser/storage
## explicit; go 1.19
github.com/grafana/xk6-grpc/grpc
github.com/grafana/xk6-grpc/lib/netext/grpcext
# github.com/grafana/xk6-output-prometheus-remote v0.2.1
# github.com/grafana/xk6-output-prometheus-remote v0.2.2-0.20230719110733-69f101ee8ade
## explicit; go 1.18
github.com/grafana/xk6-output-prometheus-remote/pkg/remote
github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite
Expand Down

0 comments on commit 11349b3

Please sign in to comment.