estimateMarshalledSizeFromTrace attempts to estimate the size of trace in bytes. This is used to make choose when to cut a row group during block creation. TODO: This function regularly estimates lower values then estimateProtoSize() and the size of the actual proto. It's also quite inefficient. Per
(tr *Trace)
| 290 | // of the actual proto. It's also quite inefficient. Perhaps just using static values per span or attribute |
| 291 | // would be a better choice? |
| 292 | func estimateMarshalledSizeFromTrace(tr *Trace) (size int) { |
| 293 | size += 7 // 7 trace lvl fields |
| 294 | |
| 295 | for _, rs := range tr.ResourceSpans { |
| 296 | size += estimateAttrSize(rs.Resource.Attrs) |
| 297 | size += 10 // 10 resource span lvl fields |
| 298 | |
| 299 | for _, ils := range rs.ScopeSpans { |
| 300 | size += 2 // 2 scope span lvl fields |
| 301 | |
| 302 | for _, s := range ils.Spans { |
| 303 | size += 14 // 14 span lvl fields |
| 304 | size += estimateAttrSize(s.Attrs) |
| 305 | size += estimateEventsSize(s.Events) |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | return |
| 310 | } |
| 311 | |
| 312 | func estimateAttrSize(attrs []Attribute) (size int) { |
| 313 | return len(attrs) * 7 // 7 attribute lvl fields |