File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
exporter/exporterhelper/internal/sizer Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ type LogsBytesSizer struct {
3737// This is derived from opentelemetry-collector/pdata/internal/data/protogen/logs/v1/logs.pb.go
3838// which is generated with gogo/protobuf.
3939func (s * LogsBytesSizer ) DeltaSize (newItemSize int ) int {
40- return 1 + newItemSize + math_bits . Len64 (uint64 (newItemSize | 1 ) + 6 ) / 7 //nolint:gosec // disable G115
40+ return 1 + newItemSize + sov (uint64 (newItemSize )) //nolint:gosec // disable G115
4141}
4242
4343// LogsCountSizer returns the nunmber of logs entries.
@@ -66,3 +66,7 @@ func (s *LogsCountSizer) LogRecordSize(_ plog.LogRecord) int {
6666func (s * LogsCountSizer ) DeltaSize (newItemSize int ) int {
6767 return newItemSize
6868}
69+
70+ func sov (x uint64 ) int {
71+ return (math_bits .Len64 (x | 1 ) + 6 ) / 7
72+ }
Original file line number Diff line number Diff line change @@ -55,3 +55,10 @@ func TestLogsBytesSizer(t *testing.T) {
5555 lr .CopyTo (sl .LogRecords ().AppendEmpty ())
5656 require .Equal (t , sizer .ScopeLogsSize (sl ), prevSize + sizer .DeltaSize (sizer .LogRecordSize (lr )))
5757}
58+
59+ func TestLogsBytesDeltaSize (t * testing.T ) {
60+ sizer := LogsBytesSizer {}
61+ require .Equal (t , 129 , sizer .DeltaSize (127 ))
62+ require .Equal (t , 131 , sizer .DeltaSize (128 ))
63+ require .Equal (t , 242 , sizer .DeltaSize (239 ))
64+ }
You can’t perform that action at this time.
0 commit comments