Skip to content

Commit

Permalink
reset on error
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Oct 19, 2023
1 parent f34c061 commit dc447ea
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions exporter/splunkhecexporter/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ func (c *client) fillLogsBuffer(logs plog.Logs, buf buffer, is iterState) (iterS
" content length %d bytes", l, c.config.MaxContentLengthLogs)))
return iterState{i, j, k + 1, false}, permanentErrors
}
// flush exited before resetting the buffer of the stream.
jsonStream.Reset(buf)
permanentErrors = append(permanentErrors,
consumererror.NewPermanent(fmt.Errorf("error writing the event: %w", err)))
}
Expand Down Expand Up @@ -299,6 +301,8 @@ func (c *client) fillMetricsBuffer(metrics pmetric.Metrics, buf buffer, is iterS
" content length %d bytes", jsonStream.Buffered(), c.config.MaxContentLengthMetrics)))
return iterState{i, j, k + 1, false}, permanentErrors
}
// flush exited before resetting the buffer of the stream.
jsonStream.Reset(buf)
permanentErrors = append(permanentErrors, consumererror.NewPermanent(fmt.Errorf(
"error writing the event: %w", err)))
}
Expand Down Expand Up @@ -345,6 +349,8 @@ func (c *client) fillMetricsBufferMultiMetrics(events []*splunk.Event, buf buffe
done: i+1 != len(events),
}, permanentErrors
} else if err != nil {
// flush exited before resetting the buffer of the stream.
jsonStream.Reset(buf)
permanentErrors = append(permanentErrors, consumererror.NewPermanent(fmt.Errorf(
"error writing the event: %w", err)))
}
Expand Down Expand Up @@ -398,6 +404,8 @@ func (c *client) fillTracesBuffer(traces ptrace.Traces, buf buffer, is iterState
" content length %d bytes", l, c.config.MaxContentLengthTraces)))
return iterState{i, j, k + 1, false}, permanentErrors
}
// flush exited before resetting the buffer of the stream.
jsonStream.Reset(buf)
permanentErrors = append(permanentErrors, consumererror.NewPermanent(fmt.Errorf(
"error writing the event: %w", err)))
}
Expand Down

0 comments on commit dc447ea

Please sign in to comment.