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

Function countSpans

tempodb/encoding/vparquet5/compactor.go:384–424  ·  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

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

Callers 2

CompactMethod · 0.70
TestCountSpansFunction · 0.70

Calls 1

StringMethod · 0.45

Tested by 1

TestCountSpansFunction · 0.56