Skip to content

Commit

Permalink
[chore] [exporter/splunkhec] Simplify for loops (#21997)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryax authored May 16, 2023
1 parent d0820aa commit 6f1b6b9
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions exporter/splunkhecexporter/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand All @@ -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
}

Expand Down Expand Up @@ -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...)
Expand All @@ -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
}

Expand All @@ -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...)
Expand All @@ -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
}

Expand Down

0 comments on commit 6f1b6b9

Please sign in to comment.