diff --git a/exporter/exporterhelper/logs_batch.go b/exporter/exporterhelper/logs_batch.go index 9d5c7077ca6..4e4609b18ca 100644 --- a/exporter/exporterhelper/logs_batch.go +++ b/exporter/exporterhelper/logs_batch.go @@ -37,13 +37,15 @@ func (req *logsRequest) MergeSplit(_ context.Context, cfg exporterbatcher.MaxSiz if srcReq == nil { continue } - if srcReq.ld.LogRecordCount() <= capacityLeft { + + srcCount := srcReq.ld.LogRecordCount() + if srcCount <= capacityLeft { if destReq == nil { destReq = srcReq } else { srcReq.ld.ResourceLogs().MoveAndAppendTo(destReq.ld.ResourceLogs()) } - capacityLeft -= destReq.ld.LogRecordCount() + capacityLeft -= srcCount continue } diff --git a/exporter/exporterhelper/metrics_batch.go b/exporter/exporterhelper/metrics_batch.go index 66466492932..3ec240d40a6 100644 --- a/exporter/exporterhelper/metrics_batch.go +++ b/exporter/exporterhelper/metrics_batch.go @@ -37,13 +37,15 @@ func (req *metricsRequest) MergeSplit(_ context.Context, cfg exporterbatcher.Max if srcReq == nil { continue } - if srcReq.md.DataPointCount() <= capacityLeft { + + srcCount := srcReq.md.DataPointCount() + if srcCount <= capacityLeft { if destReq == nil { destReq = srcReq } else { srcReq.md.ResourceMetrics().MoveAndAppendTo(destReq.md.ResourceMetrics()) } - capacityLeft -= destReq.md.DataPointCount() + capacityLeft -= srcCount continue } diff --git a/exporter/exporterhelper/traces_batch.go b/exporter/exporterhelper/traces_batch.go index 63535567b6a..07a3025d73a 100644 --- a/exporter/exporterhelper/traces_batch.go +++ b/exporter/exporterhelper/traces_batch.go @@ -37,13 +37,15 @@ func (req *tracesRequest) MergeSplit(_ context.Context, cfg exporterbatcher.MaxS if srcReq == nil { continue } - if srcReq.td.SpanCount() <= capacityLeft { + + srcCount := srcReq.td.SpanCount() + if srcCount <= capacityLeft { if destReq == nil { destReq = srcReq } else { srcReq.td.ResourceSpans().MoveAndAppendTo(destReq.td.ResourceSpans()) } - capacityLeft -= destReq.td.SpanCount() + capacityLeft -= srcCount continue } diff --git a/exporter/exporterhelper/xexporterhelper/profiles_batch.go b/exporter/exporterhelper/xexporterhelper/profiles_batch.go index 8fd337878be..2aa47c95043 100644 --- a/exporter/exporterhelper/xexporterhelper/profiles_batch.go +++ b/exporter/exporterhelper/xexporterhelper/profiles_batch.go @@ -37,13 +37,15 @@ func (req *profilesRequest) MergeSplit(_ context.Context, cfg exporterbatcher.Ma if srcReq == nil { continue } - if srcReq.pd.SampleCount() <= capacityLeft { + + srcCount := srcReq.pd.SampleCount() + if srcCount <= capacityLeft { if destReq == nil { destReq = srcReq } else { srcReq.pd.ResourceProfiles().MoveAndAppendTo(destReq.pd.ResourceProfiles()) } - capacityLeft -= destReq.pd.SampleCount() + capacityLeft -= srcCount continue }