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

Function countSpans

tempodb/encoding/vparquet4/compactor.go:387–427  ·  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

385// parquet row format and returns traceId.
386// It simply counts the number of values for span ID, which is always present.
387func countSpans(schema *parquet.Schema, row parquet.Row) (traceID, rootSpanName, rootServiceName string, spans int) {
388 traceIDColumn, found := schema.Lookup(TraceIDColumnName)
389 if !found {
390 return "", "", "", 0
391 }
392
393 rootSpanNameColumn, found := schema.Lookup(columnPathRootSpanName)
394 if !found {
395 return "", "", "", 0
396 }
397
398 rootServiceNameColumn, found := schema.Lookup(columnPathRootServiceName)
399 if !found {
400 return "", "", "", 0
401 }
402
403 spanID, found := schema.Lookup("rs", "list", "element", "ss", "list", "element", "Spans", "list", "element", "SpanID")
404 if !found {
405 return "", "", "", 0
406 }
407
408 for _, v := range row {
409 if v.Column() == spanID.ColumnIndex {
410 spans++
411 }
412
413 if v.Column() == traceIDColumn.ColumnIndex {
414 traceID = tempoUtil.TraceIDToHexString(v.ByteArray())
415 }
416
417 if v.Column() == rootSpanNameColumn.ColumnIndex {
418 rootSpanName = v.String()
419 }
420
421 if v.Column() == rootServiceNameColumn.ColumnIndex {
422 rootServiceName = v.String()
423 }
424 }
425
426 return
427}

Callers 2

CompactMethod · 0.70
TestCountSpansFunction · 0.70

Calls 1

StringMethod · 0.45

Tested by 1

TestCountSpansFunction · 0.56