From 41ae4ca121e1a66c32b8be3a6ce79996917f1b7d Mon Sep 17 00:00:00 2001 From: Dmitry Anoshin Date: Wed, 10 May 2023 14:06:36 -0700 Subject: [PATCH] [chore] [exporter/splunkhec] Don't create the buffer for disabled type If logs or profiling are disable, don't create corresponding buffer --- exporter/splunkhecexporter/client.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exporter/splunkhecexporter/client.go b/exporter/splunkhecexporter/client.go index e5b4bcfa9177..8b30070c6d50 100644 --- a/exporter/splunkhecexporter/client.go +++ b/exporter/splunkhecexporter/client.go @@ -143,23 +143,23 @@ func (c *client) pushLogDataInBatches(ctx context.Context, ld plog.Logs, headers var newPermanentErrors []error if isProfilingData(ills.At(j)) { - if profilingBufState == nil { - profilingBufState = makeBlankBufferState(c.config.MaxContentLengthLogs, !c.config.DisableCompression, c.config.MaxEventSize) - } if !c.config.ProfilingDataEnabled { droppedProfilingDataRecords += ills.At(j).LogRecords().Len() continue } + if profilingBufState == nil { + profilingBufState = makeBlankBufferState(c.config.MaxContentLengthLogs, !c.config.DisableCompression, c.config.MaxEventSize) + } profilingBufState.resource, profilingBufState.library = i, j newPermanentErrors, err = c.pushLogRecords(ctx, rls, profilingBufState, profilingLocalHeaders) } else { - if bufState == nil { - bufState = makeBlankBufferState(c.config.MaxContentLengthLogs, !c.config.DisableCompression, c.config.MaxEventSize) - } if !c.config.LogDataEnabled { droppedLogRecords += ills.At(j).LogRecords().Len() continue } + if bufState == nil { + bufState = makeBlankBufferState(c.config.MaxContentLengthLogs, !c.config.DisableCompression, c.config.MaxEventSize) + } bufState.resource, bufState.library = i, j newPermanentErrors, err = c.pushLogRecords(ctx, rls, bufState, headers) }