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

Function ParquetTraceToTempopbTrace

tempodb/encoding/vparquet3/schema.go:591–744  ·  view source on GitHub ↗
(meta *backend.BlockMeta, parquetTrace *Trace)

Source from the content-addressed store, hash-verified

589}
590
591func ParquetTraceToTempopbTrace(meta *backend.BlockMeta, parquetTrace *Trace) *tempopb.Trace {
592 protoTrace := &tempopb.Trace{}
593 protoTrace.ResourceSpans = make([]*v1_trace.ResourceSpans, 0, len(parquetTrace.ResourceSpans))
594
595 // dedicated attribute column assignments
596 dedicatedResourceAttributes := dedicatedColumnsToColumnMapping(meta.DedicatedColumns, backend.DedicatedColumnScopeResource)
597 dedicatedSpanAttributes := dedicatedColumnsToColumnMapping(meta.DedicatedColumns, backend.DedicatedColumnScopeSpan)
598
599 for _, rs := range parquetTrace.ResourceSpans {
600 protoBatch := &v1_trace.ResourceSpans{}
601 protoBatch.Resource = &v1_resource.Resource{
602 Attributes: parquetToProtoAttrs(rs.Resource.Attrs),
603 }
604
605 // dynamically assigned dedicated resource attribute columns
606 dedicatedResourceAttributes.forEach(func(attr string, col dedicatedColumn) {
607 val := col.readValue(&rs.Resource.DedicatedAttributes)
608 if val != nil {
609 protoBatch.Resource.Attributes = append(protoBatch.Resource.Attributes, &v1.KeyValue{
610 Key: attr,
611 Value: val,
612 })
613 }
614 })
615
616 // known resource attributes
617 if rs.Resource.ServiceName != "" {
618 protoBatch.Resource.Attributes = append(protoBatch.Resource.Attributes, &v1.KeyValue{
619 Key: LabelServiceName,
620 Value: &v1.AnyValue{
621 Value: &v1.AnyValue_StringValue{
622 StringValue: rs.Resource.ServiceName,
623 },
624 },
625 })
626 }
627 for _, attr := range []struct {
628 Key string
629 Value *string
630 }{
631 {Key: LabelCluster, Value: rs.Resource.Cluster},
632 {Key: LabelNamespace, Value: rs.Resource.Namespace},
633 {Key: LabelPod, Value: rs.Resource.Pod},
634 {Key: LabelContainer, Value: rs.Resource.Container},
635 {Key: LabelK8sClusterName, Value: rs.Resource.K8sClusterName},
636 {Key: LabelK8sNamespaceName, Value: rs.Resource.K8sNamespaceName},
637 {Key: LabelK8sPodName, Value: rs.Resource.K8sPodName},
638 {Key: LabelK8sContainerName, Value: rs.Resource.K8sContainerName},
639 } {
640 if attr.Value != nil {
641 protoBatch.Resource.Attributes = append(protoBatch.Resource.Attributes, &v1.KeyValue{
642 Key: attr.Key,
643 Value: &v1.AnyValue{
644 Value: &v1.AnyValue_StringValue{
645 StringValue: *attr.Value,
646 },
647 },
648 })

Callers 8

NextMethod · 0.92
findTraceByIDFunction · 0.70
TestProtoParquetRandoFunction · 0.70
TestFieldsAreClearedFunction · 0.70
FindTraceByIDMethod · 0.70
NextMethod · 0.70

Calls 6

UnmarshalMethod · 0.95
parquetToProtoAttrsFunction · 0.70
parquetToProtoEventsFunction · 0.70
forEachMethod · 0.45
readValueMethod · 0.45

Tested by 4

TestProtoParquetRandoFunction · 0.56
TestFieldsAreClearedFunction · 0.56