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

Function countSpans

tempodb/encoding/vparquet3/compactor.go:363–403  ·  view source on GitHub ↗

countSpans counts the number of spans in the given trace in deconstructed parquet row format and returns traceId. It simply counts the number of values for span ID, which is always present.

(schema *parquet.Schema, row parquet.Row)

Source from the content-addressed store, hash-verified

361// parquet row format and returns traceId.
362// It simply counts the number of values for span ID, which is always present.
363func countSpans(schema *parquet.Schema, row parquet.Row) (traceID, rootSpanName, rootServiceName string, spans int) {
364 traceIDColumn, found := schema.Lookup(TraceIDColumnName)
365 if !found {
366 return "", "", "", 0
367 }
368
369 rootSpanNameColumn, found := schema.Lookup(columnPathRootSpanName)
370 if !found {
371 return "", "", "", 0
372 }
373
374 rootServiceNameColumn, found := schema.Lookup(columnPathRootServiceName)
375 if !found {
376 return "", "", "", 0
377 }
378
379 spanID, found := schema.Lookup("rs", "list", "element", "ss", "list", "element", "Spans", "list", "element", "SpanID")
380 if !found {
381 return "", "", "", 0
382 }
383
384 for _, v := range row {
385 if v.Column() == spanID.ColumnIndex {
386 spans++
387 }
388
389 if v.Column() == traceIDColumn.ColumnIndex {
390 traceID = tempoUtil.TraceIDToHexString(v.ByteArray())
391 }
392
393 if v.Column() == rootSpanNameColumn.ColumnIndex {
394 rootSpanName = v.String()
395 }
396
397 if v.Column() == rootServiceNameColumn.ColumnIndex {
398 rootServiceName = v.String()
399 }
400 }
401
402 return
403}

Callers 2

CompactMethod · 0.70
TestCountSpansFunction · 0.70

Calls 1

StringMethod · 0.45

Tested by 1

TestCountSpansFunction · 0.56