Skip to content

Commit 2b5a190

Browse files
fix: don't send empty aggregated metric payloads (backport k237) (#15810)
Co-authored-by: Trevor Whitney <trevorjwhitney@gmail.com>
1 parent efd3ec3 commit 2b5a190

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎pkg/pattern/aggregation/push.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ func (p *Push) buildPayload(ctx context.Context) ([]byte, error) {
177177
defer sp.Finish()
178178

179179
entries := p.entries.reset()
180+
if len(entries) == 0 {
181+
return nil, nil
182+
}
180183

181184
entriesByStream := make(map[string][]logproto.Entry)
182185
for _, e := range entries {
@@ -219,6 +222,10 @@ func (p *Push) buildPayload(ctx context.Context) ([]byte, error) {
219222
}
220223
}
221224

225+
if len(streams) == 0 {
226+
return nil, nil
227+
}
228+
222229
req := &logproto.PushRequest{
223230
Streams: streams,
224231
}
@@ -268,6 +275,10 @@ func (p *Push) run(pushPeriod time.Duration) {
268275
continue
269276
}
270277

278+
if len(payload) == 0 {
279+
continue
280+
}
281+
271282
// We will use a timeout within each attempt to send
272283
backoff := backoff.New(context.Background(), *p.backoff)
273284

0 commit comments

Comments
 (0)