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

Function ParquetTraceToTempopbTrace

tempodb/encoding/vparquet4/schema.go:776–924  ·  view source on GitHub ↗
(meta *backend.BlockMeta, parquetTrace *Trace)

Source from the content-addressed store, hash-verified

774}
775
776func ParquetTraceToTempopbTrace(meta *backend.BlockMeta, parquetTrace *Trace) *tempopb.Trace {
777 protoTrace := &tempopb.Trace{}
778 protoTrace.ResourceSpans = make([]*v1_trace.ResourceSpans, 0, len(parquetTrace.ResourceSpans))
779
780 // dedicated attribute column assignments
781 dedicatedResourceAttributes := dedicatedColumnsToColumnMapping(meta.DedicatedColumns, backend.DedicatedColumnScopeResource)
782 dedicatedSpanAttributes := dedicatedColumnsToColumnMapping(meta.DedicatedColumns, backend.DedicatedColumnScopeSpan)
783
784 for _, rs := range parquetTrace.ResourceSpans {
785 protoBatch := &v1_trace.ResourceSpans{}
786 resAttrs := parquetToProtoAttrs(rs.Resource.Attrs)
787 protoBatch.Resource = &v1_resource.Resource{
788 Attributes: resAttrs,
789 DroppedAttributesCount: uint32(rs.Resource.DroppedAttributesCount),
790 }
791
792 // dynamically assigned dedicated resource attribute columns
793 dedicatedResourceAttributes.forEach(func(attr string, col dedicatedColumn) {
794 val := col.readValue(&rs.Resource.DedicatedAttributes)
795 if val != nil {
796 protoBatch.Resource.Attributes = append(protoBatch.Resource.Attributes, &v1.KeyValue{
797 Key: attr,
798 Value: val,
799 })
800 }
801 })
802
803 // known resource attributes
804 if rs.Resource.ServiceName != "" {
805 protoBatch.Resource.Attributes = append(protoBatch.Resource.Attributes, &v1.KeyValue{
806 Key: LabelServiceName,
807 Value: &v1.AnyValue{
808 Value: &v1.AnyValue_StringValue{
809 StringValue: rs.Resource.ServiceName,
810 },
811 },
812 })
813 }
814 for _, attr := range []struct {
815 Key string
816 Value *string
817 }{
818 {Key: LabelCluster, Value: rs.Resource.Cluster},
819 {Key: LabelNamespace, Value: rs.Resource.Namespace},
820 {Key: LabelPod, Value: rs.Resource.Pod},
821 {Key: LabelContainer, Value: rs.Resource.Container},
822 {Key: LabelK8sClusterName, Value: rs.Resource.K8sClusterName},
823 {Key: LabelK8sNamespaceName, Value: rs.Resource.K8sNamespaceName},
824 {Key: LabelK8sPodName, Value: rs.Resource.K8sPodName},
825 {Key: LabelK8sContainerName, Value: rs.Resource.K8sContainerName},
826 } {
827 if attr.Value != nil {
828 protoBatch.Resource.Attributes = append(protoBatch.Resource.Attributes, &v1.KeyValue{
829 Key: attr.Key,
830 Value: &v1.AnyValue{
831 Value: &v1.AnyValue_StringValue{
832 StringValue: *attr.Value,
833 },

Callers 8

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

Calls 7

parquetToProtoAttrsFunction · 0.70
parquetToProtoEventsFunction · 0.70
parquetToProtoLinksFunction · 0.70
forEachMethod · 0.45
readValueMethod · 0.45

Tested by 4

TestProtoParquetRandoFunction · 0.56
TestFieldsAreClearedFunction · 0.56