@@ -167,7 +167,10 @@ func isProfilingData(sl plog.ScopeLogs) bool {
167
167
// ld log records are parsed to Splunk events.
168
168
func (c * client ) pushLogDataInBatches (ctx context.Context , ld plog.Logs , headers map [string ]string ) error {
169
169
buf := c .bufferPool .get ()
170
- defer c .bufferPool .put (buf )
170
+ buf .OnClose (func () error {
171
+ c .bufferPool .put (buf )
172
+ return nil
173
+ })
171
174
is := iterState {}
172
175
var permanentErrors []error
173
176
@@ -374,7 +377,10 @@ func (c *client) fillTracesBuffer(traces ptrace.Traces, buf buffer, is iterState
374
377
// md metrics are parsed to Splunk events.
375
378
func (c * client ) pushMultiMetricsDataInBatches (ctx context.Context , md pmetric.Metrics , headers map [string ]string ) error {
376
379
buf := c .bufferPool .get ()
377
- defer c .bufferPool .put (buf )
380
+ buf .OnClose (func () error {
381
+ c .bufferPool .put (buf )
382
+ return nil
383
+ })
378
384
is := iterState {}
379
385
380
386
var permanentErrors []error
@@ -419,7 +425,10 @@ func (c *client) pushMultiMetricsDataInBatches(ctx context.Context, md pmetric.M
419
425
// md metrics are parsed to Splunk events.
420
426
func (c * client ) pushMetricsDataInBatches (ctx context.Context , md pmetric.Metrics , headers map [string ]string ) error {
421
427
buf := c .bufferPool .get ()
422
- defer c .bufferPool .put (buf )
428
+ buf .OnClose (func () error {
429
+ c .bufferPool .put (buf )
430
+ return nil
431
+ })
423
432
is := iterState {}
424
433
var permanentErrors []error
425
434
0 commit comments