-
Notifications
You must be signed in to change notification settings - Fork 46
Description
I'm getting an error,
time="2025-04-11T17:46:54Z" level=error msg="Can't compress record below required maximum packet size and it will be discarded."
This is occurring about once per second in my environment.
It stems from, https://github.com/newrelic/newrelic-fluent-bit-output/blob/master/record/record.go#L129, and the TODO seems to hit the nail on the head:
// TODO Check Ian/Brian: I do believe that this should be compresssedData.Len(), let's confirm it before changing. compressedSize := int64(compressedData.Cap()) if compressedSize >= maxPacketSize && len(records) == 1 {
It seems the TODO(?) is correct, .Cap() is not the correct function here. Package bytes,
Cap returns the capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data.
vs .Len() Package bytes
Len returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()).
For generating the packet, use .Len() to get the length of data that will be put into the packet.