From 6f1b6b97eb5d317bee3d20bcf1a8a96ceabdbd6b Mon Sep 17 00:00:00 2001 From: Dmitrii Anoshin Date: Tue, 16 May 2023 09:15:20 -0700 Subject: [PATCH] [chore] [exporter/splunkhec] Simplify for loops (#21997) --- exporter/splunkhecexporter/client.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/exporter/splunkhecexporter/client.go b/exporter/splunkhecexporter/client.go index 3cb785df7631..aa40d1244032 100644 --- a/exporter/splunkhecexporter/client.go +++ b/exporter/splunkhecexporter/client.go @@ -172,7 +172,7 @@ func (c *client) pushLogDataInBatches(ctx context.Context, ld plog.Logs, headers is := iterState{} var permanentErrors []error - for { + for !is.done { bufState.reset() latestIterState, batchPermanentErrors := c.fillLogsBuffer(ld, bufState, is) permanentErrors = append(permanentErrors, batchPermanentErrors...) @@ -181,9 +181,6 @@ func (c *client) pushLogDataInBatches(ctx context.Context, ld plog.Logs, headers return consumererror.NewLogs(err, subLogs(ld, is)) } } - if latestIterState.done { - break - } is = latestIterState } @@ -347,7 +344,7 @@ func (c *client) pushMetricsDataInBatches(ctx context.Context, md pmetric.Metric is := iterState{} var permanentErrors []error - for { + for !is.done { bufState.reset() latestIterState, batchPermanentErrors := c.fillMetricsBuffer(md, bufState, is) permanentErrors = append(permanentErrors, batchPermanentErrors...) @@ -356,9 +353,6 @@ func (c *client) pushMetricsDataInBatches(ctx context.Context, md pmetric.Metric return consumererror.NewMetrics(err, subMetrics(md, is)) } } - if latestIterState.done { - break - } is = latestIterState } @@ -374,7 +368,7 @@ func (c *client) pushTracesDataInBatches(ctx context.Context, td ptrace.Traces, is := iterState{} var permanentErrors []error - for { + for !is.done { bufState.reset() latestIterState, batchPermanentErrors := c.fillTracesBuffer(td, bufState, is) permanentErrors = append(permanentErrors, batchPermanentErrors...) @@ -383,9 +377,6 @@ func (c *client) pushTracesDataInBatches(ctx context.Context, td ptrace.Traces, return consumererror.NewTraces(err, subTraces(td, is)) } } - if latestIterState.done { - break - } is = latestIterState }