MCPcopy
hub / github.com/grafana/tempo / estimateMarshalledSizeFromTrace

Function estimateMarshalledSizeFromTrace

tempodb/encoding/vparquet4/create.go:292–310  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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?
292func 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
312func estimateAttrSize(attrs []Attribute) (size int) {
313 return len(attrs) * 7 // 7 attribute lvl fields

Callers 3

estimateRowSizeFunction · 0.70
AppendTraceMethod · 0.70
AddMethod · 0.70

Calls 2

estimateAttrSizeFunction · 0.70
estimateEventsSizeFunction · 0.70

Tested by 1

estimateRowSizeFunction · 0.56