From cc20cafd0a65d894c47b5df3190d9a4c06c1f70f Mon Sep 17 00:00:00 2001 From: Arthur Silva Sens Date: Fri, 13 Dec 2024 16:42:58 -0300 Subject: [PATCH] lint Signed-off-by: Arthur Silva Sens --- exporter/prometheusremotewriteexporter/exporter.go | 10 +++++----- exporter/prometheusremotewriteexporter/helper.go | 4 ++-- exporter/prometheusremotewriteexporter/helper_test.go | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/exporter/prometheusremotewriteexporter/exporter.go b/exporter/prometheusremotewriteexporter/exporter.go index 90e0e397607e..cb3b88986930 100644 --- a/exporter/prometheusremotewriteexporter/exporter.go +++ b/exporter/prometheusremotewriteexporter/exporter.go @@ -85,10 +85,10 @@ type prwExporter struct { exporterSettings prometheusremotewrite.Settings telemetry prwTelemetry - // When concurrency is enabled, concurrent goroutines would potentially + // When concurrency is enabled, concurrent goroutines would potentially // fight over the same batchState object. To avoid this, we use a pool // to provide each goroutine with its own state. - batchStatePool sync.Pool + batchStatePool sync.Pool } func newPRWTelemetry(set exporter.Settings) (prwTelemetry, error) { @@ -143,7 +143,7 @@ func newPRWExporter(cfg *Config, set exporter.Settings) (*prwExporter, error) { AddMetricSuffixes: cfg.AddMetricSuffixes, SendMetadata: cfg.SendMetadata, }, - telemetry: prwTelemetry, + telemetry: prwTelemetry, batchStatePool: sync.Pool{New: func() any { return newBatchTimeSericesState() }}, } @@ -232,10 +232,10 @@ func (prwe *prwExporter) handleExport(ctx context.Context, tsMap map[string]*pro return nil } - state := prwe.batchStatePool.Get().(batchTimeSeriesState) + state := prwe.batchStatePool.Get().(*batchTimeSeriesState) defer prwe.batchStatePool.Put(state) // Calls the helper function to convert and batch the TsMap to the desired format - requests, err := batchTimeSeries(tsMap, prwe.maxBatchSizeBytes, m, &state) + requests, err := batchTimeSeries(tsMap, prwe.maxBatchSizeBytes, m, state) if err != nil { return err } diff --git a/exporter/prometheusremotewriteexporter/helper.go b/exporter/prometheusremotewriteexporter/helper.go index 5819aefc4fe8..26def2570eff 100644 --- a/exporter/prometheusremotewriteexporter/helper.go +++ b/exporter/prometheusremotewriteexporter/helper.go @@ -19,8 +19,8 @@ type batchTimeSeriesState struct { nextRequestBufferSize int } -func newBatchTimeSericesState() batchTimeSeriesState { - return batchTimeSeriesState{ +func newBatchTimeSericesState() *batchTimeSeriesState { + return &batchTimeSeriesState{ nextTimeSeriesBufferSize: math.MaxInt, nextMetricMetadataBufferSize: math.MaxInt, nextRequestBufferSize: 0, diff --git a/exporter/prometheusremotewriteexporter/helper_test.go b/exporter/prometheusremotewriteexporter/helper_test.go index f464c25071b0..aa7714ca297d 100644 --- a/exporter/prometheusremotewriteexporter/helper_test.go +++ b/exporter/prometheusremotewriteexporter/helper_test.go @@ -59,7 +59,7 @@ func Test_batchTimeSeries(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { state := newBatchTimeSericesState() - requests, err := batchTimeSeries(tt.tsMap, tt.maxBatchByteSize, nil, &state) + requests, err := batchTimeSeries(tt.tsMap, tt.maxBatchByteSize, nil, state) if tt.returnErr { assert.Error(t, err) return @@ -97,7 +97,7 @@ func Test_batchTimeSeriesUpdatesStateForLargeBatches(t *testing.T) { tsMap1 := getTimeseriesMap(tsArray) state := newBatchTimeSericesState() - requests, err := batchTimeSeries(tsMap1, 1000000, nil, &state) + requests, err := batchTimeSeries(tsMap1, 1000000, nil, state) assert.NoError(t, err) assert.Len(t, requests, 18) @@ -132,7 +132,7 @@ func Benchmark_batchTimeSeries(b *testing.B) { state := newBatchTimeSericesState() // Run batchTimeSeries 100 times with a 1mb max request size for i := 0; i < b.N; i++ { - requests, err := batchTimeSeries(tsMap1, 1000000, nil, &state) + requests, err := batchTimeSeries(tsMap1, 1000000, nil, state) assert.NoError(b, err) assert.Len(b, requests, 18) }