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

Function traceToParquetWithMapping

tempodb/encoding/vparquet5/schema.go:391–545  ·  view source on GitHub ↗
(id common.ID, tr *tempopb.Trace, ot *Trace, dedicatedResourceAttributes, dedicatedSpanAttributes, dedicatedEventAttributes dedicatedColumnMapping)

Source from the content-addressed store, hash-verified

389}
390
391func traceToParquetWithMapping(id common.ID, tr *tempopb.Trace, ot *Trace, dedicatedResourceAttributes, dedicatedSpanAttributes, dedicatedEventAttributes dedicatedColumnMapping) (*Trace, bool) {
392 if ot == nil {
393 ot = &Trace{}
394 }
395
396 ot.TraceIDText = util.TraceIDToHexString(id)
397 ot.TraceID = util.PadTraceIDTo16Bytes(id)
398
399 // Trace-level items
400 traceStart := uint64(0)
401 traceEnd := uint64(0)
402 var rootSpan *v1_trace.Span
403 var rootBatch *v1_trace.ResourceSpans
404
405 ot.ResourceSpans = extendReuseSlice(len(tr.ResourceSpans), ot.ResourceSpans)
406 for ib, b := range tr.ResourceSpans {
407 ob := &ot.ResourceSpans[ib]
408 // Clear out any existing fields in case they were set on the original
409 ob.Resource.DroppedAttributesCount = 0
410 ob.Resource.ServiceName = ""
411 ob.Resource.DedicatedAttributes.Reset()
412
413 if b.Resource != nil {
414 ob.Resource.Attrs = extendReuseSlice(len(b.Resource.Attributes), ob.Resource.Attrs)
415 ob.Resource.DroppedAttributesCount = int32(b.Resource.DroppedAttributesCount)
416
417 attrCount := 0
418 for _, a := range b.Resource.Attributes {
419 var written bool
420 if strVal, ok := a.Value.Value.(*v1.AnyValue_StringValue); ok && a.Key == LabelServiceName {
421 ob.Resource.ServiceName = strVal.StringValue
422 written = true
423 }
424
425 if !written {
426 // Dynamically assigned dedicated resource attribute columns
427 if spareColumn, exists := dedicatedResourceAttributes.get(a.Key); exists {
428 written = spareColumn.writeValue(&ob.Resource.DedicatedAttributes, a.Value)
429 }
430 }
431
432 if !written {
433 // Other attributes put in generic columns
434 attrToParquet(a, &ob.Resource.Attrs[attrCount])
435 attrCount++
436 }
437 }
438 ob.Resource.Attrs = ob.Resource.Attrs[:attrCount]
439 }
440
441 ob.ScopeSpans = extendReuseSlice(len(b.ScopeSpans), ob.ScopeSpans)
442 for iils, ils := range b.ScopeSpans {
443 oils := &ob.ScopeSpans[iils]
444 instrumentationScopeToParquet(ils.Scope, &oils.Scope)
445
446 oils.Spans = extendReuseSlice(len(ils.Spans), oils.Spans)
447 oils.SpanCount = int32(len(ils.Spans))
448 for is, s := range ils.Spans {

Callers 3

traceToParquetFunction · 0.70
AppendTraceMethod · 0.70
CreateBlockFunction · 0.70

Calls 15

TraceIDToHexStringFunction · 0.92
PadTraceIDTo16BytesFunction · 0.92
writeAttrsFunction · 0.85
GetStringValueMethod · 0.80
extendReuseSliceFunction · 0.70
attrToParquetFunction · 0.70
eventToParquetFunction · 0.70
linkToParquetFunction · 0.70
finalizeTraceFunction · 0.70
ResetMethod · 0.65
IntervalMethod · 0.65

Tested by

no test coverage detected