Skip to content

Commit

Permalink
move Reset() to reset internal call
Browse files Browse the repository at this point in the history
  • Loading branch information
edma2 committed Nov 5, 2024
1 parent 62cfc35 commit 863436d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion exporter/prometheusremotewriteexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func (prwe *prwExporter) PushMetrics(ctx context.Context, md pmetric.Metrics) er
return errors.New("shutdown has been called")
default:
converter := converterPool.Get().(*prometheusremotewrite.PrometheusConverter)
converter.Reset()
defer converterPool.Put(converter)

tsMap, err := converter.FromMetrics(md, prwe.exporterSettings)
Expand Down
3 changes: 2 additions & 1 deletion pkg/translator/prometheusremotewrite/metrics_to_prw.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Settings struct {

// FromMetrics converts pmetric.Metrics to Prometheus remote write format.
func (c *PrometheusConverter) FromMetrics(md pmetric.Metrics, settings Settings) (map[string]*prompb.TimeSeries, error) {
c.reset()
errs := c.fromMetrics(md, settings)
tss := c.timeSeries()
out := make(map[string]*prompb.TimeSeries, len(tss))
Expand Down Expand Up @@ -60,7 +61,7 @@ func NewPrometheusConverter() *PrometheusConverter {
}
}

func (c *PrometheusConverter) Reset() {
func (c *PrometheusConverter) reset() {
clear(c.labels)
c.labels = c.labels[:0]
clear(c.unique)
Expand Down
3 changes: 1 addition & 2 deletions pkg/translator/prometheusremotewrite/metrics_to_prw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func BenchmarkFromMetrics(b *testing.B) {
tsMap, err := c.FromMetrics(payload.Metrics(), Settings{})
require.NoError(b, err)
require.NotNil(b, tsMap)
c.Reset()
}
})
}
Expand Down Expand Up @@ -79,7 +78,7 @@ func BenchmarkPrometheusConverter_FromMetrics(b *testing.B) {
for i := 0; i < b.N; i++ {
require.NoError(b, c.fromMetrics(payload.Metrics(), Settings{}))
require.NotNil(b, c.timeSeries())
c.Reset()
c.reset()
}
})
}
Expand Down

0 comments on commit 863436d

Please sign in to comment.