estimateMarshalledSizeFromTrace estimates the size of this trace when written to parquet. This is used to determine when to cut a row group during block creation. This function is about 85% accurate.
(tr *Trace)
| 288 | // estimateMarshalledSizeFromTrace estimates the size of this trace when written to parquet. This is used to |
| 289 | // determine when to cut a row group during block creation. This function is about 85% accurate. |
| 290 | func estimateMarshalledSizeFromTrace(tr *Trace) (size int) { |
| 291 | size += 7 // 7 trace lvl fields |
| 292 | size += len(tr.TraceID) |
| 293 | |
| 294 | for _, rs := range tr.ResourceSpans { |
| 295 | size += estimateAttrSize(rs.Resource.Attrs) |
| 296 | size += 21 // 21 resource lvl fields including dedicated attributes |
| 297 | size += 10 // 10 dedicated columns |
| 298 | |
| 299 | for _, ils := range rs.ScopeSpans { |
| 300 | size += 2 // 2 scope span lvl fields |
| 301 | size += 4 // 4 scope fields |
| 302 | size += estimateAttrSize(ils.Scope.Attrs) |
| 303 | |
| 304 | for _, s := range ils.Spans { |
| 305 | size += 35 // 35 span lvl fields including dedicated attributes |
| 306 | size += 10 // 10 dedicated columns |
| 307 | size += len(s.SpanID) + len(s.ParentSpanID) |
| 308 | size += estimateAttrSize(s.Attrs) |
| 309 | size += estimateEventsSize(s.Events) |
| 310 | size += estimateLinksSize(s.Links) |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | return |
| 315 | } |
| 316 | |
| 317 | func estimateAttrSize(attrs []Attribute) (size int) { |
| 318 | size += len(attrs) * 7 // 7 attribute lvl fields |