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)
| 259 | // of the actual proto. It's also quite inefficient. Perhaps just using static values per span or attribute |
| 260 | // would be a better choice? |
| 261 | func estimateMarshalledSizeFromTrace(tr *Trace) (size int) { |
| 262 | size += 7 // 7 trace lvl fields |
| 263 | |
| 264 | for _, rs := range tr.ResourceSpans { |
| 265 | size += estimateAttrSize(rs.Resource.Attrs) |
| 266 | size += 10 // 10 resource span lvl fields |
| 267 | |
| 268 | for _, ils := range rs.ScopeSpans { |
| 269 | size += 2 // 2 scope span lvl fields |
| 270 | |
| 271 | for _, s := range ils.Spans { |
| 272 | size += 14 // 14 span lvl fields |
| 273 | size += estimateAttrSize(s.Attrs) |
| 274 | size += estimateEventsSize(s.Events) |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | return |
| 279 | } |
| 280 | |
| 281 | func estimateAttrSize(attrs []Attribute) (size int) { |
| 282 | return len(attrs) * 7 // 7 attribute lvl fields |