From 02650e398f170d9bf01ed99e598a9354f0ca71a2 Mon Sep 17 00:00:00 2001 From: simont1 Date: Thu, 29 Feb 2024 11:47:20 -0500 Subject: [PATCH 01/14] proto change to add is_parent_root --- pkg/proto/datadog/trace/stats.proto | 2 + pkg/proto/pbgo/trace/stats.pb.go | 96 ++++++++++++++++------------- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/pkg/proto/datadog/trace/stats.proto b/pkg/proto/datadog/trace/stats.proto index 45a2351c35c65..495c6f6be8f06 100644 --- a/pkg/proto/datadog/trace/stats.proto +++ b/pkg/proto/datadog/trace/stats.proto @@ -49,6 +49,8 @@ message ClientStatsPayload { string git_commit_sha = 13; // The image tag is obtained from a container's set of tags. string image_tag = 14; + // This field is filled by the span's parentID value. + bool is_parent_root = 15; } // ClientStatsBucket is a time bucket containing aggregated stats. diff --git a/pkg/proto/pbgo/trace/stats.pb.go b/pkg/proto/pbgo/trace/stats.pb.go index b3ffa3ab127a3..8d5d0807794dc 100644 --- a/pkg/proto/pbgo/trace/stats.pb.go +++ b/pkg/proto/pbgo/trace/stats.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc v4.25.3 // source: datadog/trace/stats.proto package trace @@ -145,6 +145,8 @@ type ClientStatsPayload struct { GitCommitSha string `protobuf:"bytes,13,opt,name=git_commit_sha,json=gitCommitSha,proto3" json:"git_commit_sha,omitempty"` // The image tag is obtained from a container's set of tags. ImageTag string `protobuf:"bytes,14,opt,name=image_tag,json=imageTag,proto3" json:"image_tag,omitempty"` + // This field is filled by the span's parentID value. + IsParentRoot bool `protobuf:"varint,15,opt,name=is_parent_root,json=isParentRoot,proto3" json:"is_parent_root,omitempty"` } func (x *ClientStatsPayload) Reset() { @@ -277,6 +279,13 @@ func (x *ClientStatsPayload) GetImageTag() string { return "" } +func (x *ClientStatsPayload) GetIsParentRoot() bool { + if x != nil { + return x.IsParentRoot + } + return false +} + // ClientStatsBucket is a time bucket containing aggregated stats. type ClientStatsBucket struct { state protoimpl.MessageState @@ -535,7 +544,7 @@ var file_datadog_trace_stats_proto_rawDesc = []byte{ 0x28, 0x08, 0x52, 0x0e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x50, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xc7, 0x03, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xed, 0x03, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, @@ -564,47 +573,50 @@ var file_datadog_trace_stats_proto_rawDesc = []byte{ 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x54, 0x61, 0x67, - 0x22, 0xa6, 0x01, 0x0a, 0x11, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, - 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x1a, 0x0a, 0x08, - 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, - 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x64, 0x6f, - 0x67, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, - 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, - 0x69, 0x66, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x22, 0xc3, 0x03, 0x0a, 0x12, 0x43, 0x6c, + 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x6f, + 0x6f, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x50, 0x61, 0x72, 0x65, + 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xa6, 0x01, 0x0a, 0x11, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, + 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, + 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, + 0x64, 0x61, 0x74, 0x61, 0x64, 0x6f, 0x67, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, - 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x48, 0x54, - 0x54, 0x50, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x48, 0x54, 0x54, 0x50, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x44, 0x42, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x44, 0x42, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, 0x74, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x04, 0x68, 0x69, 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12, 0x1a, 0x0a, - 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x6b, 0x53, - 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6f, 0x6b, - 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x73, - 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0a, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x74, - 0x6f, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x48, 0x69, 0x74, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x0c, 0x74, 0x6f, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x48, 0x69, 0x74, 0x73, 0x12, - 0x1b, 0x0a, 0x09, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x0f, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x73, 0x70, 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1b, 0x0a, 0x09, - 0x70, 0x65, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x65, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x4a, 0x04, 0x08, 0x0e, 0x10, 0x0f, 0x42, - 0x16, 0x5a, 0x14, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x67, - 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x22, + 0xc3, 0x03, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x65, + 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x12, 0x28, 0x0a, 0x10, 0x48, 0x54, 0x54, 0x50, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, + 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x48, 0x54, 0x54, 0x50, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, + 0x0a, 0x07, 0x44, 0x42, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x44, 0x42, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, 0x74, 0x73, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x68, 0x69, 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x1c, 0x0a, 0x09, 0x6f, 0x6b, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x09, 0x6f, 0x6b, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x22, 0x0a, + 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x73, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, + 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x6f, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x48, 0x69, 0x74, + 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x74, 0x6f, 0x70, 0x4c, 0x65, 0x76, 0x65, + 0x6c, 0x48, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6b, 0x69, + 0x6e, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x70, 0x61, 0x6e, 0x4b, 0x69, + 0x6e, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, + 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x65, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x4a, + 0x04, 0x08, 0x0e, 0x10, 0x0f, 0x42, 0x16, 0x5a, 0x14, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 844c8dbbda5d3bf5707f88e6e794e67cb7d6e6a6 Mon Sep 17 00:00:00 2001 From: simont1 Date: Thu, 29 Feb 2024 12:46:37 -0500 Subject: [PATCH 02/14] move field --- pkg/proto/datadog/trace/stats.proto | 3 +- pkg/proto/pbgo/trace/stats.pb.go | 101 ++++++++++++++-------------- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/pkg/proto/datadog/trace/stats.proto b/pkg/proto/datadog/trace/stats.proto index 495c6f6be8f06..1d307e3209815 100644 --- a/pkg/proto/datadog/trace/stats.proto +++ b/pkg/proto/datadog/trace/stats.proto @@ -49,8 +49,6 @@ message ClientStatsPayload { string git_commit_sha = 13; // The image tag is obtained from a container's set of tags. string image_tag = 14; - // This field is filled by the span's parentID value. - bool is_parent_root = 15; } // ClientStatsBucket is a time bucket containing aggregated stats. @@ -84,4 +82,5 @@ message ClientGroupedStats { // peer_tags are supplementary tags that further describe a peer entity // E.g., `grpc.target` to describe the name of a gRPC peer, or `db.hostname` to describe the name of peer DB repeated string peer_tags = 16; + bool is_parent_root = 17; // this field's value is equal to span's ParentID == 0. } diff --git a/pkg/proto/pbgo/trace/stats.pb.go b/pkg/proto/pbgo/trace/stats.pb.go index 8d5d0807794dc..72a2d187cd49a 100644 --- a/pkg/proto/pbgo/trace/stats.pb.go +++ b/pkg/proto/pbgo/trace/stats.pb.go @@ -145,8 +145,6 @@ type ClientStatsPayload struct { GitCommitSha string `protobuf:"bytes,13,opt,name=git_commit_sha,json=gitCommitSha,proto3" json:"git_commit_sha,omitempty"` // The image tag is obtained from a container's set of tags. ImageTag string `protobuf:"bytes,14,opt,name=image_tag,json=imageTag,proto3" json:"image_tag,omitempty"` - // This field is filled by the span's parentID value. - IsParentRoot bool `protobuf:"varint,15,opt,name=is_parent_root,json=isParentRoot,proto3" json:"is_parent_root,omitempty"` } func (x *ClientStatsPayload) Reset() { @@ -279,13 +277,6 @@ func (x *ClientStatsPayload) GetImageTag() string { return "" } -func (x *ClientStatsPayload) GetIsParentRoot() bool { - if x != nil { - return x.IsParentRoot - } - return false -} - // ClientStatsBucket is a time bucket containing aggregated stats. type ClientStatsBucket struct { state protoimpl.MessageState @@ -383,7 +374,8 @@ type ClientGroupedStats struct { SpanKind string `protobuf:"bytes,15,opt,name=span_kind,json=spanKind,proto3" json:"span_kind,omitempty"` // value of the span.kind tag on the span // peer_tags are supplementary tags that further describe a peer entity // E.g., `grpc.target` to describe the name of a gRPC peer, or `db.hostname` to describe the name of peer DB - PeerTags []string `protobuf:"bytes,16,rep,name=peer_tags,json=peerTags,proto3" json:"peer_tags,omitempty"` + PeerTags []string `protobuf:"bytes,16,rep,name=peer_tags,json=peerTags,proto3" json:"peer_tags,omitempty"` + IsParentRoot bool `protobuf:"varint,17,opt,name=is_parent_root,json=isParentRoot,proto3" json:"is_parent_root,omitempty"` // this field's value is equal to span's ParentID == 0. } func (x *ClientGroupedStats) Reset() { @@ -523,6 +515,13 @@ func (x *ClientGroupedStats) GetPeerTags() []string { return nil } +func (x *ClientGroupedStats) GetIsParentRoot() bool { + if x != nil { + return x.IsParentRoot + } + return false +} + var File_datadog_trace_stats_proto protoreflect.FileDescriptor var file_datadog_trace_stats_proto_rawDesc = []byte{ @@ -544,7 +543,7 @@ var file_datadog_trace_stats_proto_rawDesc = []byte{ 0x28, 0x08, 0x52, 0x0e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x50, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xed, 0x03, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xc7, 0x03, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, @@ -573,47 +572,47 @@ var file_datadog_trace_stats_proto_rawDesc = []byte{ 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x54, 0x61, 0x67, - 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x6f, - 0x6f, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x50, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x22, 0xa6, 0x01, 0x0a, 0x11, 0x43, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x74, 0x61, - 0x72, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, - 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, - 0x64, 0x61, 0x74, 0x61, 0x64, 0x6f, 0x67, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x43, 0x6c, + 0x22, 0xa6, 0x01, 0x0a, 0x11, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, + 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x1a, 0x0a, 0x08, + 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, + 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x64, 0x6f, + 0x67, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, + 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, + 0x69, 0x66, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x22, 0xe9, 0x03, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, - 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x22, - 0xc3, 0x03, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x65, - 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x12, 0x28, 0x0a, 0x10, 0x48, 0x54, 0x54, 0x50, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, - 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x48, 0x54, 0x54, 0x50, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, - 0x0a, 0x07, 0x44, 0x42, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x44, 0x42, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, 0x74, 0x73, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x68, 0x69, 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1c, 0x0a, 0x09, 0x6f, 0x6b, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x09, 0x6f, 0x6b, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x22, 0x0a, - 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0b, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, - 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x73, 0x18, - 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, - 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x6f, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x48, 0x69, 0x74, - 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x74, 0x6f, 0x70, 0x4c, 0x65, 0x76, 0x65, - 0x6c, 0x48, 0x69, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6b, 0x69, - 0x6e, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x70, 0x61, 0x6e, 0x4b, 0x69, - 0x6e, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, - 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x65, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x4a, + 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, + 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x48, 0x54, + 0x54, 0x50, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x48, 0x54, 0x54, 0x50, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x44, 0x42, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x44, 0x42, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x69, 0x74, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x04, 0x68, 0x69, 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12, 0x1a, 0x0a, + 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x6b, 0x53, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6f, 0x6b, + 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x73, + 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x0a, 0x73, 0x79, 0x6e, 0x74, 0x68, 0x65, 0x74, 0x69, 0x63, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x74, + 0x6f, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x48, 0x69, 0x74, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0c, 0x74, 0x6f, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x48, 0x69, 0x74, 0x73, 0x12, + 0x1b, 0x0a, 0x09, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x0f, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x73, 0x70, 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1b, 0x0a, 0x09, + 0x70, 0x65, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x08, 0x70, 0x65, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, + 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x0c, 0x69, 0x73, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x4a, 0x04, 0x08, 0x0e, 0x10, 0x0f, 0x42, 0x16, 0x5a, 0x14, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, From f215f6d3e66aac1aab5100af7d247fb55bd2ad44 Mon Sep 17 00:00:00 2001 From: simont1 Date: Fri, 1 Mar 2024 09:55:08 -0500 Subject: [PATCH 03/14] proto and isParentRoot usage in the bucketAggKey --- pkg/proto/pbgo/trace/stats_gen.go | 36 +++++++++++++++++++--- pkg/proto/pbgo/trace/stats_vtproto.pb.go | 35 +++++++++++++++++++++ pkg/trace/stats/aggregation.go | 16 +++++----- pkg/trace/stats/client_stats_aggregator.go | 19 +++++++----- pkg/trace/stats/statsraw.go | 1 + 5 files changed, 87 insertions(+), 20 deletions(-) diff --git a/pkg/proto/pbgo/trace/stats_gen.go b/pkg/proto/pbgo/trace/stats_gen.go index 2975ea578f271..0afb280bd0203 100644 --- a/pkg/proto/pbgo/trace/stats_gen.go +++ b/pkg/proto/pbgo/trace/stats_gen.go @@ -127,6 +127,12 @@ func (z *ClientGroupedStats) DecodeMsg(dc *msgp.Reader) (err error) { return } } + case "IsParentRoot": + z.IsParentRoot, err = dc.ReadBool() + if err != nil { + err = msgp.WrapError(err, "IsParentRoot") + return + } default: err = dc.Skip() if err != nil { @@ -140,9 +146,9 @@ func (z *ClientGroupedStats) DecodeMsg(dc *msgp.Reader) (err error) { // EncodeMsg implements msgp.Encodable func (z *ClientGroupedStats) EncodeMsg(en *msgp.Writer) (err error) { - // map header, size 15 + // map header, size 16 // write "Service" - err = en.Append(0x8f, 0xa7, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65) + err = en.Append(0xde, 0x0, 0x10, 0xa7, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65) if err != nil { return } @@ -298,15 +304,25 @@ func (z *ClientGroupedStats) EncodeMsg(en *msgp.Writer) (err error) { return } } + // write "IsParentRoot" + err = en.Append(0xac, 0x49, 0x73, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74) + if err != nil { + return + } + err = en.WriteBool(z.IsParentRoot) + if err != nil { + err = msgp.WrapError(err, "IsParentRoot") + return + } return } // MarshalMsg implements msgp.Marshaler func (z *ClientGroupedStats) MarshalMsg(b []byte) (o []byte, err error) { o = msgp.Require(b, z.Msgsize()) - // map header, size 15 + // map header, size 16 // string "Service" - o = append(o, 0x8f, 0xa7, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65) + o = append(o, 0xde, 0x0, 0x10, 0xa7, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65) o = msgp.AppendString(o, z.Service) // string "Name" o = append(o, 0xa4, 0x4e, 0x61, 0x6d, 0x65) @@ -353,6 +369,9 @@ func (z *ClientGroupedStats) MarshalMsg(b []byte) (o []byte, err error) { for za0001 := range z.PeerTags { o = msgp.AppendString(o, z.PeerTags[za0001]) } + // string "IsParentRoot" + o = append(o, 0xac, 0x49, 0x73, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74) + o = msgp.AppendBool(o, z.IsParentRoot) return } @@ -477,6 +496,12 @@ func (z *ClientGroupedStats) UnmarshalMsg(bts []byte) (o []byte, err error) { return } } + case "IsParentRoot": + z.IsParentRoot, bts, err = msgp.ReadBoolBytes(bts) + if err != nil { + err = msgp.WrapError(err, "IsParentRoot") + return + } default: bts, err = msgp.Skip(bts) if err != nil { @@ -491,10 +516,11 @@ func (z *ClientGroupedStats) UnmarshalMsg(bts []byte) (o []byte, err error) { // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message func (z *ClientGroupedStats) Msgsize() (s int) { - s = 1 + 8 + msgp.StringPrefixSize + len(z.Service) + 5 + msgp.StringPrefixSize + len(z.Name) + 9 + msgp.StringPrefixSize + len(z.Resource) + 15 + msgp.Uint32Size + 5 + msgp.StringPrefixSize + len(z.Type) + 7 + msgp.StringPrefixSize + len(z.DBType) + 5 + msgp.Uint64Size + 7 + msgp.Uint64Size + 9 + msgp.Uint64Size + 10 + msgp.BytesPrefixSize + len(z.OkSummary) + 13 + msgp.BytesPrefixSize + len(z.ErrorSummary) + 11 + msgp.BoolSize + 13 + msgp.Uint64Size + 9 + msgp.StringPrefixSize + len(z.SpanKind) + 9 + msgp.ArrayHeaderSize + s = 3 + 8 + msgp.StringPrefixSize + len(z.Service) + 5 + msgp.StringPrefixSize + len(z.Name) + 9 + msgp.StringPrefixSize + len(z.Resource) + 15 + msgp.Uint32Size + 5 + msgp.StringPrefixSize + len(z.Type) + 7 + msgp.StringPrefixSize + len(z.DBType) + 5 + msgp.Uint64Size + 7 + msgp.Uint64Size + 9 + msgp.Uint64Size + 10 + msgp.BytesPrefixSize + len(z.OkSummary) + 13 + msgp.BytesPrefixSize + len(z.ErrorSummary) + 11 + msgp.BoolSize + 13 + msgp.Uint64Size + 9 + msgp.StringPrefixSize + len(z.SpanKind) + 9 + msgp.ArrayHeaderSize for za0001 := range z.PeerTags { s += msgp.StringPrefixSize + len(z.PeerTags[za0001]) } + s += 13 + msgp.BoolSize return } diff --git a/pkg/proto/pbgo/trace/stats_vtproto.pb.go b/pkg/proto/pbgo/trace/stats_vtproto.pb.go index c29eadf308e72..f63e21c97a2c6 100644 --- a/pkg/proto/pbgo/trace/stats_vtproto.pb.go +++ b/pkg/proto/pbgo/trace/stats_vtproto.pb.go @@ -329,6 +329,18 @@ func (m *ClientGroupedStats) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if m.IsParentRoot { + i-- + if m.IsParentRoot { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } if len(m.PeerTags) > 0 { for iNdEx := len(m.PeerTags) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.PeerTags[iNdEx]) @@ -624,6 +636,9 @@ func (m *ClientGroupedStats) SizeVT() (n int) { n += 2 + l + sov(uint64(l)) } } + if m.IsParentRoot { + n += 3 + } n += len(m.unknownFields) return n } @@ -1915,6 +1930,26 @@ func (m *ClientGroupedStats) UnmarshalVT(dAtA []byte) error { } m.PeerTags = append(m.PeerTags, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsParentRoot", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsParentRoot = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/pkg/trace/stats/aggregation.go b/pkg/trace/stats/aggregation.go index 543fa9bf154b9..1cdb8358f8cc2 100644 --- a/pkg/trace/stats/aggregation.go +++ b/pkg/trace/stats/aggregation.go @@ -39,6 +39,7 @@ type BucketsAggregationKey struct { StatusCode uint32 Synthetics bool PeerTagsHash uint64 + isParentRoot bool } // PayloadAggregationKey specifies the key by which a payload is aggregated. @@ -80,13 +81,14 @@ func NewAggregationFromSpan(s *pb.Span, origin string, aggKey PayloadAggregation agg := Aggregation{ PayloadAggregationKey: aggKey, BucketsAggregationKey: BucketsAggregationKey{ - Resource: s.Resource, - Service: s.Service, - Name: s.Name, - SpanKind: s.Meta[tagSpanKind], - Type: s.Type, - StatusCode: getStatusCode(s), - Synthetics: synthetics, + Resource: s.Resource, + Service: s.Service, + Name: s.Name, + SpanKind: s.Meta[tagSpanKind], + Type: s.Type, + StatusCode: getStatusCode(s), + Synthetics: synthetics, + isParentRoot: s.ParentID == 0, }, } var peerTags []string diff --git a/pkg/trace/stats/client_stats_aggregator.go b/pkg/trace/stats/client_stats_aggregator.go index ef84920187c64..64a4e8463268b 100644 --- a/pkg/trace/stats/client_stats_aggregator.go +++ b/pkg/trace/stats/client_stats_aggregator.go @@ -6,9 +6,10 @@ package stats import ( - "github.com/DataDog/datadog-agent/pkg/trace/version" "time" + "github.com/DataDog/datadog-agent/pkg/trace/version" + pb "github.com/DataDog/datadog-agent/pkg/proto/pbgo/trace" "github.com/DataDog/datadog-agent/pkg/trace/config" "github.com/DataDog/datadog-agent/pkg/trace/log" @@ -294,6 +295,7 @@ func (b *bucket) aggregationToPayloads() []*pb.ClientStatsPayload { HTTPStatusCode: aggrKey.StatusCode, Type: aggrKey.Type, Synthetics: aggrKey.Synthetics, + IsParentRoot: aggrKey.isParentRoot, PeerTags: counts.peerTags, Hits: counts.hits, Errors: counts.errors, @@ -332,13 +334,14 @@ func newPayloadAggregationKey(env, hostname, version, cid string, gitCommitSha s func newBucketAggregationKey(b *pb.ClientGroupedStats, enablePeerTagsAgg bool) BucketsAggregationKey { k := BucketsAggregationKey{ - Service: b.Service, - Name: b.Name, - SpanKind: b.SpanKind, - Resource: b.Resource, - Type: b.Type, - Synthetics: b.Synthetics, - StatusCode: b.HTTPStatusCode, + Service: b.Service, + Name: b.Name, + SpanKind: b.SpanKind, + Resource: b.Resource, + Type: b.Type, + Synthetics: b.Synthetics, + StatusCode: b.HTTPStatusCode, + isParentRoot: b.IsParentRoot, } if enablePeerTagsAgg { k.PeerTagsHash = peerTagsHash(b.GetPeerTags()) diff --git a/pkg/trace/stats/statsraw.go b/pkg/trace/stats/statsraw.go index 8e8d7e8958481..24fb0e7b20543 100644 --- a/pkg/trace/stats/statsraw.go +++ b/pkg/trace/stats/statsraw.go @@ -76,6 +76,7 @@ func (s *groupedStats) export(a Aggregation) (*pb.ClientGroupedStats, error) { Synthetics: a.Synthetics, SpanKind: a.SpanKind, PeerTags: s.peerTags, + IsParentRoot: a.isParentRoot, }, nil } From 013b15641f733f922b10b2538f888d32c63c21cd Mon Sep 17 00:00:00 2001 From: simont1 Date: Mon, 4 Mar 2024 10:19:06 -0500 Subject: [PATCH 04/14] test fixes --- pkg/trace/stats/aggregation_test.go | 18 +++++++++--------- .../stats/client_stats_aggregator_test.go | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/trace/stats/aggregation_test.go b/pkg/trace/stats/aggregation_test.go index 2dda81a7e2e74..8e600fac76ff4 100644 --- a/pkg/trace/stats/aggregation_test.go +++ b/pkg/trace/stats/aggregation_test.go @@ -68,14 +68,14 @@ func TestNewAggregation(t *testing.T) { "nil case, peer tag aggregation disabled", &pb.Span{}, false, - Aggregation{}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{isParentRoot: true}}, nil, }, { "nil case, peer tag aggregation enabled", &pb.Span{}, true, - Aggregation{}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{isParentRoot: true}}, nil, }, { @@ -85,7 +85,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "peer.service": "remote-service"}, }, false, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client"}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", isParentRoot: true}}, nil, }, { @@ -95,7 +95,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a"}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", isParentRoot: true}}, nil, }, { @@ -105,7 +105,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash, isParentRoot: true}}, []string{"peer.service:remote-service"}, }, { @@ -115,7 +115,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "producer", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "producer", PeerTagsHash: peerSvcOnlyHash}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "producer", PeerTagsHash: peerSvcOnlyHash, isParentRoot: true}}, []string{"peer.service:remote-service"}, }, { @@ -125,7 +125,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "remote-service", "db.instance": "i-1234", "db.system": "postgres"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerTagsHash}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerTagsHash, isParentRoot: true}}, []string{"db.instance:i-1234", "db.system:postgres", "peer.service:remote-service"}, }, { @@ -135,7 +135,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "", "db.instance": "", "db.system": ""}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: 0}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: 0, isParentRoot: true}}, nil, }, { @@ -145,7 +145,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "remote-service", "db.instance": "", "db.system": ""}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash, isParentRoot: true}}, []string{"peer.service:remote-service"}, }, } { diff --git a/pkg/trace/stats/client_stats_aggregator_test.go b/pkg/trace/stats/client_stats_aggregator_test.go index 915aae4d88674..3eead2f9c0412 100644 --- a/pkg/trace/stats/client_stats_aggregator_test.go +++ b/pkg/trace/stats/client_stats_aggregator_test.go @@ -747,6 +747,7 @@ func deepCopyGroupedStats(s []*proto.ClientGroupedStats) []*proto.ClientGroupedS TopLevelHits: b.GetTopLevelHits(), SpanKind: b.GetSpanKind(), PeerTags: b.GetPeerTags(), + IsParentRoot: b.GetIsParentRoot(), } if b.OkSummary != nil { new[i].OkSummary = make([]byte, len(b.OkSummary)) From aab1a27d1a6262e3dfdf21193b3cf8775ac9a90d Mon Sep 17 00:00:00 2001 From: simont1 Date: Mon, 4 Mar 2024 11:21:59 -0500 Subject: [PATCH 05/14] test fixes --- pkg/trace/stats/aggregation.go | 4 +-- pkg/trace/stats/aggregation_test.go | 18 +++++++------- pkg/trace/stats/client_stats_aggregator.go | 4 +-- pkg/trace/stats/concentrator_test.go | 14 +++++++++++ pkg/trace/stats/statsraw.go | 2 +- pkg/trace/stats/statsraw_test.go | 29 +++++++++++++--------- 6 files changed, 45 insertions(+), 26 deletions(-) diff --git a/pkg/trace/stats/aggregation.go b/pkg/trace/stats/aggregation.go index 1cdb8358f8cc2..d9300d7a86cd7 100644 --- a/pkg/trace/stats/aggregation.go +++ b/pkg/trace/stats/aggregation.go @@ -39,7 +39,7 @@ type BucketsAggregationKey struct { StatusCode uint32 Synthetics bool PeerTagsHash uint64 - isParentRoot bool + IsParentRoot bool } // PayloadAggregationKey specifies the key by which a payload is aggregated. @@ -88,7 +88,7 @@ func NewAggregationFromSpan(s *pb.Span, origin string, aggKey PayloadAggregation Type: s.Type, StatusCode: getStatusCode(s), Synthetics: synthetics, - isParentRoot: s.ParentID == 0, + IsParentRoot: s.ParentID == 0, }, } var peerTags []string diff --git a/pkg/trace/stats/aggregation_test.go b/pkg/trace/stats/aggregation_test.go index 8e600fac76ff4..4529849dfd5e9 100644 --- a/pkg/trace/stats/aggregation_test.go +++ b/pkg/trace/stats/aggregation_test.go @@ -68,14 +68,14 @@ func TestNewAggregation(t *testing.T) { "nil case, peer tag aggregation disabled", &pb.Span{}, false, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{IsParentRoot: true}}, nil, }, { "nil case, peer tag aggregation enabled", &pb.Span{}, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{IsParentRoot: true}}, nil, }, { @@ -85,7 +85,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "peer.service": "remote-service"}, }, false, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", IsParentRoot: true}}, nil, }, { @@ -95,7 +95,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", IsParentRoot: true}}, nil, }, { @@ -105,7 +105,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash, isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash, IsParentRoot: true}}, []string{"peer.service:remote-service"}, }, { @@ -115,7 +115,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "producer", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "producer", PeerTagsHash: peerSvcOnlyHash, isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "producer", PeerTagsHash: peerSvcOnlyHash, IsParentRoot: true}}, []string{"peer.service:remote-service"}, }, { @@ -125,7 +125,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "remote-service", "db.instance": "i-1234", "db.system": "postgres"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerTagsHash, isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerTagsHash, IsParentRoot: true}}, []string{"db.instance:i-1234", "db.system:postgres", "peer.service:remote-service"}, }, { @@ -135,7 +135,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "", "db.instance": "", "db.system": ""}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: 0, isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: 0, IsParentRoot: true}}, nil, }, { @@ -145,7 +145,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "remote-service", "db.instance": "", "db.system": ""}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash, isParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash, IsParentRoot: true}}, []string{"peer.service:remote-service"}, }, } { diff --git a/pkg/trace/stats/client_stats_aggregator.go b/pkg/trace/stats/client_stats_aggregator.go index 64a4e8463268b..c400ad142557c 100644 --- a/pkg/trace/stats/client_stats_aggregator.go +++ b/pkg/trace/stats/client_stats_aggregator.go @@ -295,7 +295,7 @@ func (b *bucket) aggregationToPayloads() []*pb.ClientStatsPayload { HTTPStatusCode: aggrKey.StatusCode, Type: aggrKey.Type, Synthetics: aggrKey.Synthetics, - IsParentRoot: aggrKey.isParentRoot, + IsParentRoot: aggrKey.IsParentRoot, PeerTags: counts.peerTags, Hits: counts.hits, Errors: counts.errors, @@ -341,7 +341,7 @@ func newBucketAggregationKey(b *pb.ClientGroupedStats, enablePeerTagsAgg bool) B Type: b.Type, Synthetics: b.Synthetics, StatusCode: b.HTTPStatusCode, - isParentRoot: b.IsParentRoot, + IsParentRoot: b.IsParentRoot, } if enablePeerTagsAgg { k.PeerTagsHash = peerTagsHash(b.GetPeerTags()) diff --git a/pkg/trace/stats/concentrator_test.go b/pkg/trace/stats/concentrator_test.go index 28b75860d7a1e..47c7a52620f71 100644 --- a/pkg/trace/stats/concentrator_test.go +++ b/pkg/trace/stats/concentrator_test.go @@ -267,6 +267,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 6, TopLevelHits: 6, Errors: 0, + IsParentRoot: true, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -304,6 +305,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 5, TopLevelHits: 5, Errors: 0, + IsParentRoot: true, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -324,6 +326,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, + IsParentRoot: true, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -433,6 +436,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 4, TopLevelHits: 4, Errors: 1, + IsParentRoot: true, }, { Service: "A2", @@ -443,6 +447,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 2, TopLevelHits: 2, Errors: 2, + IsParentRoot: true, }, { Service: "A2", @@ -453,6 +458,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, + IsParentRoot: true, }, { Service: "A1", @@ -464,6 +470,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, + IsParentRoot: true, }, { Service: "A1", @@ -475,6 +482,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, + IsParentRoot: true, }, } // 1-bucket old flush @@ -488,6 +496,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, + IsParentRoot: true, }, { Service: "A1", @@ -498,6 +507,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, + IsParentRoot: true, }, { Service: "A2", @@ -508,6 +518,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, + IsParentRoot: true, }, { Service: "A2", @@ -518,6 +529,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, + IsParentRoot: true, }, { Service: "A2", @@ -528,6 +540,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, + IsParentRoot: true, }, } // last bucket to be flushed @@ -541,6 +554,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, + IsParentRoot: true, }, } expectedCountValByKeyByTime[alignedNow+testBucketInterval] = []*pb.ClientGroupedStats{} diff --git a/pkg/trace/stats/statsraw.go b/pkg/trace/stats/statsraw.go index 24fb0e7b20543..487f6759e4dbc 100644 --- a/pkg/trace/stats/statsraw.go +++ b/pkg/trace/stats/statsraw.go @@ -76,7 +76,7 @@ func (s *groupedStats) export(a Aggregation) (*pb.ClientGroupedStats, error) { Synthetics: a.Synthetics, SpanKind: a.SpanKind, PeerTags: s.peerTags, - IsParentRoot: a.isParentRoot, + IsParentRoot: a.IsParentRoot, }, nil } diff --git a/pkg/trace/stats/statsraw_test.go b/pkg/trace/stats/statsraw_test.go index d802d08d89de6..b86f1bfde4857 100644 --- a/pkg/trace/stats/statsraw_test.go +++ b/pkg/trace/stats/statsraw_test.go @@ -30,9 +30,10 @@ func TestGrain(t *testing.T) { ContainerID: "cid", }, BucketsAggregationKey: BucketsAggregationKey{ - Service: "thing", - Name: "other", - Resource: "yo", + Service: "thing", + Name: "other", + Resource: "yo", + IsParentRoot: true, }, }, aggr) } @@ -59,10 +60,11 @@ func TestGrainWithPeerTags(t *testing.T) { ContainerID: "cid", }, BucketsAggregationKey: BucketsAggregationKey{ - Service: "thing", - SpanKind: "client", - Name: "other", - Resource: "yo", + Service: "thing", + SpanKind: "client", + Name: "other", + Resource: "yo", + IsParentRoot: true, }, }, aggr) assert.Nil(et) @@ -93,6 +95,7 @@ func TestGrainWithPeerTags(t *testing.T) { Name: "other", Resource: "yo", PeerTagsHash: 13698082192712149795, + IsParentRoot: true, }, }, aggr) assert.Equal([]string{"aws.s3.bucket:bucket-a", "peer.service:aws-s3"}, et) @@ -123,6 +126,7 @@ func TestGrainWithPeerTags(t *testing.T) { Name: "other", Resource: "yo", PeerTagsHash: 5537613849774405073, + IsParentRoot: true, }, }, aggr) assert.Equal([]string{"db.instance:dynamo.test.us1", "db.system:dynamodb", "peer.service:aws-dynamodb"}, et) @@ -146,11 +150,12 @@ func TestGrainWithSynthetics(t *testing.T) { ContainerID: "cid", }, BucketsAggregationKey: BucketsAggregationKey{ - Service: "thing", - Resource: "yo", - Name: "other", - StatusCode: 418, - Synthetics: true, + Service: "thing", + Resource: "yo", + Name: "other", + StatusCode: 418, + Synthetics: true, + IsParentRoot: true, }, }, aggr) } From 1200d8bd5d89fae3a4120861c609e96172716e76 Mon Sep 17 00:00:00 2001 From: simont1 Date: Mon, 11 Mar 2024 13:57:16 -0400 Subject: [PATCH 06/14] rename to isTraceRoot and refactor tests --- pkg/proto/datadog/trace/stats.proto | 2 +- pkg/proto/pbgo/trace/stats.pb.go | 22 ++++++------ pkg/proto/pbgo/trace/stats_gen.go | 28 +++++++-------- pkg/proto/pbgo/trace/stats_vtproto.pb.go | 10 +++--- pkg/trace/stats/aggregation.go | 18 +++++----- pkg/trace/stats/aggregation_test.go | 22 ++++++------ pkg/trace/stats/client_stats_aggregator.go | 18 +++++----- .../stats/client_stats_aggregator_test.go | 2 +- pkg/trace/stats/concentrator_test.go | 28 +++++++-------- pkg/trace/stats/statsraw.go | 2 +- pkg/trace/stats/statsraw_test.go | 34 +++++++++---------- 11 files changed, 94 insertions(+), 92 deletions(-) diff --git a/pkg/proto/datadog/trace/stats.proto b/pkg/proto/datadog/trace/stats.proto index 1d307e3209815..c581a54598773 100644 --- a/pkg/proto/datadog/trace/stats.proto +++ b/pkg/proto/datadog/trace/stats.proto @@ -82,5 +82,5 @@ message ClientGroupedStats { // peer_tags are supplementary tags that further describe a peer entity // E.g., `grpc.target` to describe the name of a gRPC peer, or `db.hostname` to describe the name of peer DB repeated string peer_tags = 16; - bool is_parent_root = 17; // this field's value is equal to span's ParentID == 0. + bool is_trace_root = 17; // this field's value is equal to span's ParentID == 0. } diff --git a/pkg/proto/pbgo/trace/stats.pb.go b/pkg/proto/pbgo/trace/stats.pb.go index 72a2d187cd49a..c49b1b789377a 100644 --- a/pkg/proto/pbgo/trace/stats.pb.go +++ b/pkg/proto/pbgo/trace/stats.pb.go @@ -374,8 +374,8 @@ type ClientGroupedStats struct { SpanKind string `protobuf:"bytes,15,opt,name=span_kind,json=spanKind,proto3" json:"span_kind,omitempty"` // value of the span.kind tag on the span // peer_tags are supplementary tags that further describe a peer entity // E.g., `grpc.target` to describe the name of a gRPC peer, or `db.hostname` to describe the name of peer DB - PeerTags []string `protobuf:"bytes,16,rep,name=peer_tags,json=peerTags,proto3" json:"peer_tags,omitempty"` - IsParentRoot bool `protobuf:"varint,17,opt,name=is_parent_root,json=isParentRoot,proto3" json:"is_parent_root,omitempty"` // this field's value is equal to span's ParentID == 0. + PeerTags []string `protobuf:"bytes,16,rep,name=peer_tags,json=peerTags,proto3" json:"peer_tags,omitempty"` + IsTraceRoot bool `protobuf:"varint,17,opt,name=is_trace_root,json=isTraceRoot,proto3" json:"is_trace_root,omitempty"` // this field's value is equal to span's ParentID == 0. } func (x *ClientGroupedStats) Reset() { @@ -515,9 +515,9 @@ func (x *ClientGroupedStats) GetPeerTags() []string { return nil } -func (x *ClientGroupedStats) GetIsParentRoot() bool { +func (x *ClientGroupedStats) GetIsTraceRoot() bool { if x != nil { - return x.IsParentRoot + return x.IsTraceRoot } return false } @@ -582,7 +582,7 @@ var file_datadog_trace_stats_proto_rawDesc = []byte{ 0x6f, 0x75, 0x70, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x22, 0xe9, 0x03, 0x0a, 0x12, 0x43, 0x6c, + 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x22, 0xe7, 0x03, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, @@ -610,12 +610,12 @@ var file_datadog_trace_stats_proto_rawDesc = []byte{ 0x1b, 0x0a, 0x09, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x70, 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x65, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, - 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0c, 0x69, 0x73, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x4a, - 0x04, 0x08, 0x0e, 0x10, 0x0f, 0x42, 0x16, 0x5a, 0x14, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x08, 0x70, 0x65, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x73, 0x5f, + 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0b, 0x69, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x4a, 0x04, 0x08, + 0x0e, 0x10, 0x0f, 0x42, 0x16, 0x5a, 0x14, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x70, 0x62, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/proto/pbgo/trace/stats_gen.go b/pkg/proto/pbgo/trace/stats_gen.go index 0afb280bd0203..2fc1d65a1a64c 100644 --- a/pkg/proto/pbgo/trace/stats_gen.go +++ b/pkg/proto/pbgo/trace/stats_gen.go @@ -127,10 +127,10 @@ func (z *ClientGroupedStats) DecodeMsg(dc *msgp.Reader) (err error) { return } } - case "IsParentRoot": - z.IsParentRoot, err = dc.ReadBool() + case "IsTraceRoot": + z.IsTraceRoot, err = dc.ReadBool() if err != nil { - err = msgp.WrapError(err, "IsParentRoot") + err = msgp.WrapError(err, "IsTraceRoot") return } default: @@ -304,14 +304,14 @@ func (z *ClientGroupedStats) EncodeMsg(en *msgp.Writer) (err error) { return } } - // write "IsParentRoot" - err = en.Append(0xac, 0x49, 0x73, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74) + // write "IsTraceRoot" + err = en.Append(0xab, 0x49, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74) if err != nil { return } - err = en.WriteBool(z.IsParentRoot) + err = en.WriteBool(z.IsTraceRoot) if err != nil { - err = msgp.WrapError(err, "IsParentRoot") + err = msgp.WrapError(err, "IsTraceRoot") return } return @@ -369,9 +369,9 @@ func (z *ClientGroupedStats) MarshalMsg(b []byte) (o []byte, err error) { for za0001 := range z.PeerTags { o = msgp.AppendString(o, z.PeerTags[za0001]) } - // string "IsParentRoot" - o = append(o, 0xac, 0x49, 0x73, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x6f, 0x6f, 0x74) - o = msgp.AppendBool(o, z.IsParentRoot) + // string "IsTraceRoot" + o = append(o, 0xab, 0x49, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74) + o = msgp.AppendBool(o, z.IsTraceRoot) return } @@ -496,10 +496,10 @@ func (z *ClientGroupedStats) UnmarshalMsg(bts []byte) (o []byte, err error) { return } } - case "IsParentRoot": - z.IsParentRoot, bts, err = msgp.ReadBoolBytes(bts) + case "IsTraceRoot": + z.IsTraceRoot, bts, err = msgp.ReadBoolBytes(bts) if err != nil { - err = msgp.WrapError(err, "IsParentRoot") + err = msgp.WrapError(err, "IsTraceRoot") return } default: @@ -520,7 +520,7 @@ func (z *ClientGroupedStats) Msgsize() (s int) { for za0001 := range z.PeerTags { s += msgp.StringPrefixSize + len(z.PeerTags[za0001]) } - s += 13 + msgp.BoolSize + s += 12 + msgp.BoolSize return } diff --git a/pkg/proto/pbgo/trace/stats_vtproto.pb.go b/pkg/proto/pbgo/trace/stats_vtproto.pb.go index f63e21c97a2c6..005977438d42f 100644 --- a/pkg/proto/pbgo/trace/stats_vtproto.pb.go +++ b/pkg/proto/pbgo/trace/stats_vtproto.pb.go @@ -329,9 +329,9 @@ func (m *ClientGroupedStats) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if m.IsParentRoot { + if m.IsTraceRoot { i-- - if m.IsParentRoot { + if m.IsTraceRoot { dAtA[i] = 1 } else { dAtA[i] = 0 @@ -636,7 +636,7 @@ func (m *ClientGroupedStats) SizeVT() (n int) { n += 2 + l + sov(uint64(l)) } } - if m.IsParentRoot { + if m.IsTraceRoot { n += 3 } n += len(m.unknownFields) @@ -1932,7 +1932,7 @@ func (m *ClientGroupedStats) UnmarshalVT(dAtA []byte) error { iNdEx = postIndex case 17: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsParentRoot", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IsTraceRoot", wireType) } var v int for shift := uint(0); ; shift += 7 { @@ -1949,7 +1949,7 @@ func (m *ClientGroupedStats) UnmarshalVT(dAtA []byte) error { break } } - m.IsParentRoot = bool(v != 0) + m.IsTraceRoot = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/pkg/trace/stats/aggregation.go b/pkg/trace/stats/aggregation.go index d9300d7a86cd7..84e6854133d30 100644 --- a/pkg/trace/stats/aggregation.go +++ b/pkg/trace/stats/aggregation.go @@ -39,7 +39,7 @@ type BucketsAggregationKey struct { StatusCode uint32 Synthetics bool PeerTagsHash uint64 - IsParentRoot bool + IsTraceRoot bool } // PayloadAggregationKey specifies the key by which a payload is aggregated. @@ -81,14 +81,14 @@ func NewAggregationFromSpan(s *pb.Span, origin string, aggKey PayloadAggregation agg := Aggregation{ PayloadAggregationKey: aggKey, BucketsAggregationKey: BucketsAggregationKey{ - Resource: s.Resource, - Service: s.Service, - Name: s.Name, - SpanKind: s.Meta[tagSpanKind], - Type: s.Type, - StatusCode: getStatusCode(s), - Synthetics: synthetics, - IsParentRoot: s.ParentID == 0, + Resource: s.Resource, + Service: s.Service, + Name: s.Name, + SpanKind: s.Meta[tagSpanKind], + Type: s.Type, + StatusCode: getStatusCode(s), + Synthetics: synthetics, + IsTraceRoot: s.ParentID == 0, }, } var peerTags []string diff --git a/pkg/trace/stats/aggregation_test.go b/pkg/trace/stats/aggregation_test.go index 4529849dfd5e9..ca48d111ff50e 100644 --- a/pkg/trace/stats/aggregation_test.go +++ b/pkg/trace/stats/aggregation_test.go @@ -68,14 +68,14 @@ func TestNewAggregation(t *testing.T) { "nil case, peer tag aggregation disabled", &pb.Span{}, false, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{IsParentRoot: true}}, + Aggregation{}, nil, }, { "nil case, peer tag aggregation enabled", &pb.Span{}, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{IsParentRoot: true}}, + Aggregation{}, nil, }, { @@ -85,7 +85,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "peer.service": "remote-service"}, }, false, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", IsParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client"}}, nil, }, { @@ -95,7 +95,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", IsParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a"}}, nil, }, { @@ -105,7 +105,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash, IsParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash}}, []string{"peer.service:remote-service"}, }, { @@ -115,7 +115,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "producer", "peer.service": "remote-service"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "producer", PeerTagsHash: peerSvcOnlyHash, IsParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "producer", PeerTagsHash: peerSvcOnlyHash}}, []string{"peer.service:remote-service"}, }, { @@ -125,7 +125,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "remote-service", "db.instance": "i-1234", "db.system": "postgres"}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerTagsHash, IsParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerTagsHash}}, []string{"db.instance:i-1234", "db.system:postgres", "peer.service:remote-service"}, }, { @@ -135,7 +135,7 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "", "db.instance": "", "db.system": ""}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: 0, IsParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: 0}}, nil, }, { @@ -145,12 +145,14 @@ func TestNewAggregation(t *testing.T) { Meta: map[string]string{"span.kind": "client", "field1": "val1", "peer.service": "remote-service", "db.instance": "", "db.system": ""}, }, true, - Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash, IsParentRoot: true}}, + Aggregation{BucketsAggregationKey: BucketsAggregationKey{Service: "a", SpanKind: "client", PeerTagsHash: peerSvcOnlyHash}}, []string{"peer.service:remote-service"}, }, } { agg, et := NewAggregationFromSpan(tt.in, "", PayloadAggregationKey{}, tt.enablePeerTagsAgg, peerTags) - assert.Equal(t, tt.resAgg, agg, tt.name) + assert.Equal(t, tt.resAgg.Service, agg.Service, tt.name) + assert.Equal(t, tt.resAgg.SpanKind, agg.SpanKind, tt.name) + assert.Equal(t, tt.resAgg.PeerTagsHash, agg.PeerTagsHash, tt.name) assert.Equal(t, tt.resPeerTags, et, tt.name) } } diff --git a/pkg/trace/stats/client_stats_aggregator.go b/pkg/trace/stats/client_stats_aggregator.go index c400ad142557c..f1e6f0672c43e 100644 --- a/pkg/trace/stats/client_stats_aggregator.go +++ b/pkg/trace/stats/client_stats_aggregator.go @@ -295,7 +295,7 @@ func (b *bucket) aggregationToPayloads() []*pb.ClientStatsPayload { HTTPStatusCode: aggrKey.StatusCode, Type: aggrKey.Type, Synthetics: aggrKey.Synthetics, - IsParentRoot: aggrKey.IsParentRoot, + IsTraceRoot: aggrKey.IsTraceRoot, PeerTags: counts.peerTags, Hits: counts.hits, Errors: counts.errors, @@ -334,14 +334,14 @@ func newPayloadAggregationKey(env, hostname, version, cid string, gitCommitSha s func newBucketAggregationKey(b *pb.ClientGroupedStats, enablePeerTagsAgg bool) BucketsAggregationKey { k := BucketsAggregationKey{ - Service: b.Service, - Name: b.Name, - SpanKind: b.SpanKind, - Resource: b.Resource, - Type: b.Type, - Synthetics: b.Synthetics, - StatusCode: b.HTTPStatusCode, - IsParentRoot: b.IsParentRoot, + Service: b.Service, + Name: b.Name, + SpanKind: b.SpanKind, + Resource: b.Resource, + Type: b.Type, + Synthetics: b.Synthetics, + StatusCode: b.HTTPStatusCode, + IsTraceRoot: b.IsTraceRoot, } if enablePeerTagsAgg { k.PeerTagsHash = peerTagsHash(b.GetPeerTags()) diff --git a/pkg/trace/stats/client_stats_aggregator_test.go b/pkg/trace/stats/client_stats_aggregator_test.go index 3eead2f9c0412..0e0225edb550f 100644 --- a/pkg/trace/stats/client_stats_aggregator_test.go +++ b/pkg/trace/stats/client_stats_aggregator_test.go @@ -747,7 +747,7 @@ func deepCopyGroupedStats(s []*proto.ClientGroupedStats) []*proto.ClientGroupedS TopLevelHits: b.GetTopLevelHits(), SpanKind: b.GetSpanKind(), PeerTags: b.GetPeerTags(), - IsParentRoot: b.GetIsParentRoot(), + IsTraceRoot: b.GetIsTraceRoot(), } if b.OkSummary != nil { new[i].OkSummary = make([]byte, len(b.OkSummary)) diff --git a/pkg/trace/stats/concentrator_test.go b/pkg/trace/stats/concentrator_test.go index 47c7a52620f71..cb17c9478e925 100644 --- a/pkg/trace/stats/concentrator_test.go +++ b/pkg/trace/stats/concentrator_test.go @@ -267,7 +267,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 6, TopLevelHits: 6, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -305,7 +305,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 5, TopLevelHits: 5, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -326,7 +326,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -436,7 +436,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 4, TopLevelHits: 4, Errors: 1, - IsParentRoot: true, + IsTraceRoot: true, }, { Service: "A2", @@ -447,7 +447,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 2, TopLevelHits: 2, Errors: 2, - IsParentRoot: true, + IsTraceRoot: true, }, { Service: "A2", @@ -458,7 +458,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, { Service: "A1", @@ -470,7 +470,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, { Service: "A1", @@ -482,7 +482,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, } // 1-bucket old flush @@ -496,7 +496,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, - IsParentRoot: true, + IsTraceRoot: true, }, { Service: "A1", @@ -507,7 +507,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, { Service: "A2", @@ -518,7 +518,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, - IsParentRoot: true, + IsTraceRoot: true, }, { Service: "A2", @@ -529,7 +529,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, - IsParentRoot: true, + IsTraceRoot: true, }, { Service: "A2", @@ -540,7 +540,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, } // last bucket to be flushed @@ -554,7 +554,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsParentRoot: true, + IsTraceRoot: true, }, } expectedCountValByKeyByTime[alignedNow+testBucketInterval] = []*pb.ClientGroupedStats{} diff --git a/pkg/trace/stats/statsraw.go b/pkg/trace/stats/statsraw.go index 487f6759e4dbc..d1407dfb8d3ed 100644 --- a/pkg/trace/stats/statsraw.go +++ b/pkg/trace/stats/statsraw.go @@ -76,7 +76,7 @@ func (s *groupedStats) export(a Aggregation) (*pb.ClientGroupedStats, error) { Synthetics: a.Synthetics, SpanKind: a.SpanKind, PeerTags: s.peerTags, - IsParentRoot: a.IsParentRoot, + IsTraceRoot: a.IsTraceRoot, }, nil } diff --git a/pkg/trace/stats/statsraw_test.go b/pkg/trace/stats/statsraw_test.go index b86f1bfde4857..f238721d9af2b 100644 --- a/pkg/trace/stats/statsraw_test.go +++ b/pkg/trace/stats/statsraw_test.go @@ -30,10 +30,10 @@ func TestGrain(t *testing.T) { ContainerID: "cid", }, BucketsAggregationKey: BucketsAggregationKey{ - Service: "thing", - Name: "other", - Resource: "yo", - IsParentRoot: true, + Service: "thing", + Name: "other", + Resource: "yo", + IsTraceRoot: true, }, }, aggr) } @@ -60,11 +60,11 @@ func TestGrainWithPeerTags(t *testing.T) { ContainerID: "cid", }, BucketsAggregationKey: BucketsAggregationKey{ - Service: "thing", - SpanKind: "client", - Name: "other", - Resource: "yo", - IsParentRoot: true, + Service: "thing", + SpanKind: "client", + Name: "other", + Resource: "yo", + IsTraceRoot: true, }, }, aggr) assert.Nil(et) @@ -95,7 +95,7 @@ func TestGrainWithPeerTags(t *testing.T) { Name: "other", Resource: "yo", PeerTagsHash: 13698082192712149795, - IsParentRoot: true, + IsTraceRoot: true, }, }, aggr) assert.Equal([]string{"aws.s3.bucket:bucket-a", "peer.service:aws-s3"}, et) @@ -126,7 +126,7 @@ func TestGrainWithPeerTags(t *testing.T) { Name: "other", Resource: "yo", PeerTagsHash: 5537613849774405073, - IsParentRoot: true, + IsTraceRoot: true, }, }, aggr) assert.Equal([]string{"db.instance:dynamo.test.us1", "db.system:dynamodb", "peer.service:aws-dynamodb"}, et) @@ -150,12 +150,12 @@ func TestGrainWithSynthetics(t *testing.T) { ContainerID: "cid", }, BucketsAggregationKey: BucketsAggregationKey{ - Service: "thing", - Resource: "yo", - Name: "other", - StatusCode: 418, - Synthetics: true, - IsParentRoot: true, + Service: "thing", + Resource: "yo", + Name: "other", + StatusCode: 418, + Synthetics: true, + IsTraceRoot: true, }, }, aggr) } From 4f7fdd8c8406e5c9a6885a474d031cdbbde46c91 Mon Sep 17 00:00:00 2001 From: simont1 Date: Wed, 13 Mar 2024 13:15:00 -0400 Subject: [PATCH 07/14] unit tests --- pkg/trace/stats/aggregation_test.go | 27 +++++++++++++++++++++++++++ pkg/trace/stats/concentrator_test.go | 10 +++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/pkg/trace/stats/aggregation_test.go b/pkg/trace/stats/aggregation_test.go index ca48d111ff50e..7d123ed51a043 100644 --- a/pkg/trace/stats/aggregation_test.go +++ b/pkg/trace/stats/aggregation_test.go @@ -177,3 +177,30 @@ func TestSpanKindIsConsumerOrProducer(t *testing.T) { assert.Equal(t, tc.res, clientOrProducer(tc.input)) } } + +func TestIsRootSpan(t *testing.T) { + for _, tt := range []struct { + in *pb.Span + isTraceRoot bool + }{ + { + &pb.Span{}, + true, + }, + { + &pb.Span{ + ParentID: 0, + }, + true, + }, + { + &pb.Span{ + ParentID: 123, + }, + false, + }, + } { + agg, _ := NewAggregationFromSpan(tt.in, "", PayloadAggregationKey{}, true, []string{}) + assert.Equal(t, tt.isTraceRoot, agg.IsTraceRoot) + } +} diff --git a/pkg/trace/stats/concentrator_test.go b/pkg/trace/stats/concentrator_test.go index cb17c9478e925..05bc3fa1560e2 100644 --- a/pkg/trace/stats/concentrator_test.go +++ b/pkg/trace/stats/concentrator_test.go @@ -411,8 +411,8 @@ func TestConcentratorStatsCounts(t *testing.T) { // 2 buckets old, part of the first flush testSpan(now, 1, 0, 24, 2, "A1", "resource1", 0, nil), testSpan(now, 2, 0, 12, 2, "A1", "resource1", 2, nil), - testSpan(now, 3, 0, 40, 2, "A2", "resource2", 2, nil), - testSpan(now, 4, 0, 300000000000, 2, "A2", "resource2", 2, nil), // 5 minutes trace + testSpan(now, 3, 1, 40, 2, "A2", "resource2", 2, nil), + testSpan(now, 4, 1, 300000000000, 2, "A2", "resource2", 2, nil), // 5 minutes trace testSpan(now, 5, 0, 30, 2, "A2", "resourcefoo", 0, nil), // 1 bucket old, part of the second flush testSpan(now, 6, 0, 24, 1, "A1", "resource2", 0, nil), @@ -421,7 +421,7 @@ func TestConcentratorStatsCounts(t *testing.T) { testSpan(now, 9, 0, 30, 1, "A2", "resource2", 2, nil), testSpan(now, 10, 0, 3600000000000, 1, "A2", "resourcefoo", 0, nil), // 1 hour trace // present data, part of the third flush - testSpan(now, 6, 0, 24, 0, "A1", "resource2", 0, nil), + testSpan(now, 6, 100, 24, 0, "A1", "resource2", 0, nil), } expectedCountValByKeyByTime := make(map[int64][]*pb.ClientGroupedStats) @@ -447,7 +447,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 2, TopLevelHits: 2, Errors: 2, - IsTraceRoot: true, + IsTraceRoot: false, }, { Service: "A2", @@ -554,7 +554,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: false, }, } expectedCountValByKeyByTime[alignedNow+testBucketInterval] = []*pb.ClientGroupedStats{} From a462c1f9bdbb3fad60e0d2c6dd576e51f994bc97 Mon Sep 17 00:00:00 2001 From: simont1 Date: Tue, 19 Mar 2024 10:48:18 -0400 Subject: [PATCH 08/14] root_tag unit tests --- pkg/trace/stats/concentrator_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/trace/stats/concentrator_test.go b/pkg/trace/stats/concentrator_test.go index 05bc3fa1560e2..1c9e8ac81bb8e 100644 --- a/pkg/trace/stats/concentrator_test.go +++ b/pkg/trace/stats/concentrator_test.go @@ -409,7 +409,7 @@ func TestConcentratorStatsCounts(t *testing.T) { testSpan(now, 11, 0, 333, 3, "A1", "resource3", 0, map[string]string{"span.kind": "client"}), testSpan(now, 12, 0, 444, 3, "A1", "resource3", 0, map[string]string{"span.kind": "server"}), // 2 buckets old, part of the first flush - testSpan(now, 1, 0, 24, 2, "A1", "resource1", 0, nil), + testSpan(now, 1, 100, 24, 2, "A1", "resource1", 0, nil), testSpan(now, 2, 0, 12, 2, "A1", "resource1", 2, nil), testSpan(now, 3, 1, 40, 2, "A2", "resource2", 2, nil), testSpan(now, 4, 1, 300000000000, 2, "A2", "resource2", 2, nil), // 5 minutes trace @@ -432,12 +432,23 @@ func TestConcentratorStatsCounts(t *testing.T) { Resource: "resource1", Type: "db", Name: "query", - Duration: 369, - Hits: 4, + Duration: 345, + Hits: 3, TopLevelHits: 4, Errors: 1, IsTraceRoot: true, }, + { + Service: "A1", + Resource: "resource1", + Type: "db", + Name: "query", + Duration: 24, + Hits: 1, + TopLevelHits: 1, + Errors: 0, + IsTraceRoot: false, + }, { Service: "A2", Resource: "resource2", From a99799826f8cba018cc5c0419c1b425ebf01585b Mon Sep 17 00:00:00 2001 From: simont1 Date: Tue, 19 Mar 2024 17:37:05 -0400 Subject: [PATCH 09/14] change isTraceRoot from bool to enum --- pkg/proto/datadog/trace/stats.proto | 8 +- pkg/proto/pbgo/trace/stats.pb.go | 106 ++++++++++++++++++----- pkg/proto/pbgo/trace/stats_gen.go | 82 +++++++++++++++--- pkg/proto/pbgo/trace/stats_vtproto.pb.go | 18 ++-- pkg/trace/stats/aggregation.go | 10 ++- pkg/trace/stats/aggregation_test.go | 8 +- pkg/trace/stats/concentrator_test.go | 30 +++---- pkg/trace/stats/statsraw_test.go | 10 +-- 8 files changed, 198 insertions(+), 74 deletions(-) diff --git a/pkg/proto/datadog/trace/stats.proto b/pkg/proto/datadog/trace/stats.proto index c581a54598773..fae5d8d0b439f 100644 --- a/pkg/proto/datadog/trace/stats.proto +++ b/pkg/proto/datadog/trace/stats.proto @@ -62,6 +62,12 @@ message ClientStatsBucket { int64 agentTimeShift = 4; } +enum TraceRootFlag { + NOT_SET = 0; + TRUE = 1; + FALSE = 2; +} + // ClientGroupedStats aggregate stats on spans grouped by service, name, resource, status_code, type message ClientGroupedStats { string service = 1; @@ -82,5 +88,5 @@ message ClientGroupedStats { // peer_tags are supplementary tags that further describe a peer entity // E.g., `grpc.target` to describe the name of a gRPC peer, or `db.hostname` to describe the name of peer DB repeated string peer_tags = 16; - bool is_trace_root = 17; // this field's value is equal to span's ParentID == 0. + TraceRootFlag is_trace_root = 17; // this field's value is equal to span's ParentID == 0. } diff --git a/pkg/proto/pbgo/trace/stats.pb.go b/pkg/proto/pbgo/trace/stats.pb.go index c49b1b789377a..f1d02751721b2 100644 --- a/pkg/proto/pbgo/trace/stats.pb.go +++ b/pkg/proto/pbgo/trace/stats.pb.go @@ -20,6 +20,55 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type TraceRootFlag int32 + +const ( + TraceRootFlag_NOT_SET TraceRootFlag = 0 + TraceRootFlag_TRUE TraceRootFlag = 1 + TraceRootFlag_FALSE TraceRootFlag = 2 +) + +// Enum value maps for TraceRootFlag. +var ( + TraceRootFlag_name = map[int32]string{ + 0: "NOT_SET", + 1: "TRUE", + 2: "FALSE", + } + TraceRootFlag_value = map[string]int32{ + "NOT_SET": 0, + "TRUE": 1, + "FALSE": 2, + } +) + +func (x TraceRootFlag) Enum() *TraceRootFlag { + p := new(TraceRootFlag) + *p = x + return p +} + +func (x TraceRootFlag) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (TraceRootFlag) Descriptor() protoreflect.EnumDescriptor { + return file_datadog_trace_stats_proto_enumTypes[0].Descriptor() +} + +func (TraceRootFlag) Type() protoreflect.EnumType { + return &file_datadog_trace_stats_proto_enumTypes[0] +} + +func (x TraceRootFlag) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use TraceRootFlag.Descriptor instead. +func (TraceRootFlag) EnumDescriptor() ([]byte, []int) { + return file_datadog_trace_stats_proto_rawDescGZIP(), []int{0} +} + // StatsPayload is the payload used to send stats from the agent to the backend. type StatsPayload struct { state protoimpl.MessageState @@ -374,8 +423,8 @@ type ClientGroupedStats struct { SpanKind string `protobuf:"bytes,15,opt,name=span_kind,json=spanKind,proto3" json:"span_kind,omitempty"` // value of the span.kind tag on the span // peer_tags are supplementary tags that further describe a peer entity // E.g., `grpc.target` to describe the name of a gRPC peer, or `db.hostname` to describe the name of peer DB - PeerTags []string `protobuf:"bytes,16,rep,name=peer_tags,json=peerTags,proto3" json:"peer_tags,omitempty"` - IsTraceRoot bool `protobuf:"varint,17,opt,name=is_trace_root,json=isTraceRoot,proto3" json:"is_trace_root,omitempty"` // this field's value is equal to span's ParentID == 0. + PeerTags []string `protobuf:"bytes,16,rep,name=peer_tags,json=peerTags,proto3" json:"peer_tags,omitempty"` + IsTraceRoot TraceRootFlag `protobuf:"varint,17,opt,name=is_trace_root,json=isTraceRoot,proto3,enum=datadog.trace.TraceRootFlag" json:"is_trace_root,omitempty"` // this field's value is equal to span's ParentID == 0. } func (x *ClientGroupedStats) Reset() { @@ -515,11 +564,11 @@ func (x *ClientGroupedStats) GetPeerTags() []string { return nil } -func (x *ClientGroupedStats) GetIsTraceRoot() bool { +func (x *ClientGroupedStats) GetIsTraceRoot() TraceRootFlag { if x != nil { return x.IsTraceRoot } - return false + return TraceRootFlag_NOT_SET } var File_datadog_trace_stats_proto protoreflect.FileDescriptor @@ -582,7 +631,7 @@ var file_datadog_trace_stats_proto_rawDesc = []byte{ 0x6f, 0x75, 0x70, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x22, 0xe7, 0x03, 0x0a, 0x12, 0x43, 0x6c, + 0x54, 0x69, 0x6d, 0x65, 0x53, 0x68, 0x69, 0x66, 0x74, 0x22, 0x85, 0x04, 0x0a, 0x12, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, @@ -610,12 +659,17 @@ var file_datadog_trace_stats_proto_rawDesc = []byte{ 0x1b, 0x0a, 0x09, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x70, 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x65, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x73, 0x5f, - 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0b, 0x69, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x4a, 0x04, 0x08, - 0x0e, 0x10, 0x0f, 0x42, 0x16, 0x5a, 0x14, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2f, 0x70, 0x62, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x08, 0x70, 0x65, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73, 0x12, 0x40, 0x0a, 0x0d, 0x69, 0x73, 0x5f, + 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x1c, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x64, 0x6f, 0x67, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, + 0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x0b, + 0x69, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x4a, 0x04, 0x08, 0x0e, 0x10, + 0x0f, 0x2a, 0x31, 0x0a, 0x0d, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x46, 0x6c, + 0x61, 0x67, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x4f, 0x54, 0x5f, 0x53, 0x45, 0x54, 0x10, 0x00, 0x12, + 0x08, 0x0a, 0x04, 0x54, 0x52, 0x55, 0x45, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x4c, + 0x53, 0x45, 0x10, 0x02, 0x42, 0x16, 0x5a, 0x14, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2f, 0x70, 0x62, 0x67, 0x6f, 0x2f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -630,22 +684,25 @@ func file_datadog_trace_stats_proto_rawDescGZIP() []byte { return file_datadog_trace_stats_proto_rawDescData } +var file_datadog_trace_stats_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_datadog_trace_stats_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_datadog_trace_stats_proto_goTypes = []interface{}{ - (*StatsPayload)(nil), // 0: datadog.trace.StatsPayload - (*ClientStatsPayload)(nil), // 1: datadog.trace.ClientStatsPayload - (*ClientStatsBucket)(nil), // 2: datadog.trace.ClientStatsBucket - (*ClientGroupedStats)(nil), // 3: datadog.trace.ClientGroupedStats + (TraceRootFlag)(0), // 0: datadog.trace.TraceRootFlag + (*StatsPayload)(nil), // 1: datadog.trace.StatsPayload + (*ClientStatsPayload)(nil), // 2: datadog.trace.ClientStatsPayload + (*ClientStatsBucket)(nil), // 3: datadog.trace.ClientStatsBucket + (*ClientGroupedStats)(nil), // 4: datadog.trace.ClientGroupedStats } var file_datadog_trace_stats_proto_depIdxs = []int32{ - 1, // 0: datadog.trace.StatsPayload.stats:type_name -> datadog.trace.ClientStatsPayload - 2, // 1: datadog.trace.ClientStatsPayload.stats:type_name -> datadog.trace.ClientStatsBucket - 3, // 2: datadog.trace.ClientStatsBucket.stats:type_name -> datadog.trace.ClientGroupedStats - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 2, // 0: datadog.trace.StatsPayload.stats:type_name -> datadog.trace.ClientStatsPayload + 3, // 1: datadog.trace.ClientStatsPayload.stats:type_name -> datadog.trace.ClientStatsBucket + 4, // 2: datadog.trace.ClientStatsBucket.stats:type_name -> datadog.trace.ClientGroupedStats + 0, // 3: datadog.trace.ClientGroupedStats.is_trace_root:type_name -> datadog.trace.TraceRootFlag + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_datadog_trace_stats_proto_init() } @@ -708,13 +765,14 @@ func file_datadog_trace_stats_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_datadog_trace_stats_proto_rawDesc, - NumEnums: 0, + NumEnums: 1, NumMessages: 4, NumExtensions: 0, NumServices: 0, }, GoTypes: file_datadog_trace_stats_proto_goTypes, DependencyIndexes: file_datadog_trace_stats_proto_depIdxs, + EnumInfos: file_datadog_trace_stats_proto_enumTypes, MessageInfos: file_datadog_trace_stats_proto_msgTypes, }.Build() File_datadog_trace_stats_proto = out.File diff --git a/pkg/proto/pbgo/trace/stats_gen.go b/pkg/proto/pbgo/trace/stats_gen.go index 2fc1d65a1a64c..2f594f9f81447 100644 --- a/pkg/proto/pbgo/trace/stats_gen.go +++ b/pkg/proto/pbgo/trace/stats_gen.go @@ -128,10 +128,14 @@ func (z *ClientGroupedStats) DecodeMsg(dc *msgp.Reader) (err error) { } } case "IsTraceRoot": - z.IsTraceRoot, err = dc.ReadBool() - if err != nil { - err = msgp.WrapError(err, "IsTraceRoot") - return + { + var zb0003 int32 + zb0003, err = dc.ReadInt32() + if err != nil { + err = msgp.WrapError(err, "IsTraceRoot") + return + } + z.IsTraceRoot = TraceRootFlag(zb0003) } default: err = dc.Skip() @@ -309,7 +313,7 @@ func (z *ClientGroupedStats) EncodeMsg(en *msgp.Writer) (err error) { if err != nil { return } - err = en.WriteBool(z.IsTraceRoot) + err = en.WriteInt32(int32(z.IsTraceRoot)) if err != nil { err = msgp.WrapError(err, "IsTraceRoot") return @@ -371,7 +375,7 @@ func (z *ClientGroupedStats) MarshalMsg(b []byte) (o []byte, err error) { } // string "IsTraceRoot" o = append(o, 0xab, 0x49, 0x73, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74) - o = msgp.AppendBool(o, z.IsTraceRoot) + o = msgp.AppendInt32(o, int32(z.IsTraceRoot)) return } @@ -497,10 +501,14 @@ func (z *ClientGroupedStats) UnmarshalMsg(bts []byte) (o []byte, err error) { } } case "IsTraceRoot": - z.IsTraceRoot, bts, err = msgp.ReadBoolBytes(bts) - if err != nil { - err = msgp.WrapError(err, "IsTraceRoot") - return + { + var zb0003 int32 + zb0003, bts, err = msgp.ReadInt32Bytes(bts) + if err != nil { + err = msgp.WrapError(err, "IsTraceRoot") + return + } + z.IsTraceRoot = TraceRootFlag(zb0003) } default: bts, err = msgp.Skip(bts) @@ -520,7 +528,7 @@ func (z *ClientGroupedStats) Msgsize() (s int) { for za0001 := range z.PeerTags { s += msgp.StringPrefixSize + len(z.PeerTags[za0001]) } - s += 12 + msgp.BoolSize + s += 12 + msgp.Int32Size return } @@ -1730,3 +1738,55 @@ func (z *StatsPayload) Msgsize() (s int) { s += 13 + msgp.StringPrefixSize + len(z.AgentVersion) + 15 + msgp.BoolSize + 13 + msgp.BoolSize return } + +// DecodeMsg implements msgp.Decodable +func (z *TraceRootFlag) DecodeMsg(dc *msgp.Reader) (err error) { + { + var zb0001 int32 + zb0001, err = dc.ReadInt32() + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = TraceRootFlag(zb0001) + } + return +} + +// EncodeMsg implements msgp.Encodable +func (z TraceRootFlag) EncodeMsg(en *msgp.Writer) (err error) { + err = en.WriteInt32(int32(z)) + if err != nil { + err = msgp.WrapError(err) + return + } + return +} + +// MarshalMsg implements msgp.Marshaler +func (z TraceRootFlag) MarshalMsg(b []byte) (o []byte, err error) { + o = msgp.Require(b, z.Msgsize()) + o = msgp.AppendInt32(o, int32(z)) + return +} + +// UnmarshalMsg implements msgp.Unmarshaler +func (z *TraceRootFlag) UnmarshalMsg(bts []byte) (o []byte, err error) { + { + var zb0001 int32 + zb0001, bts, err = msgp.ReadInt32Bytes(bts) + if err != nil { + err = msgp.WrapError(err) + return + } + (*z) = TraceRootFlag(zb0001) + } + o = bts + return +} + +// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message +func (z TraceRootFlag) Msgsize() (s int) { + s = msgp.Int32Size + return +} diff --git a/pkg/proto/pbgo/trace/stats_vtproto.pb.go b/pkg/proto/pbgo/trace/stats_vtproto.pb.go index 005977438d42f..16eefd4d30896 100644 --- a/pkg/proto/pbgo/trace/stats_vtproto.pb.go +++ b/pkg/proto/pbgo/trace/stats_vtproto.pb.go @@ -329,13 +329,8 @@ func (m *ClientGroupedStats) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if m.IsTraceRoot { - i-- - if m.IsTraceRoot { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } + if m.IsTraceRoot != 0 { + i = encodeVarint(dAtA, i, uint64(m.IsTraceRoot)) i-- dAtA[i] = 0x1 i-- @@ -636,8 +631,8 @@ func (m *ClientGroupedStats) SizeVT() (n int) { n += 2 + l + sov(uint64(l)) } } - if m.IsTraceRoot { - n += 3 + if m.IsTraceRoot != 0 { + n += 2 + sov(uint64(m.IsTraceRoot)) } n += len(m.unknownFields) return n @@ -1934,7 +1929,7 @@ func (m *ClientGroupedStats) UnmarshalVT(dAtA []byte) error { if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field IsTraceRoot", wireType) } - var v int + m.IsTraceRoot = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflow @@ -1944,12 +1939,11 @@ func (m *ClientGroupedStats) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.IsTraceRoot |= TraceRootFlag(b&0x7F) << shift if b < 0x80 { break } } - m.IsTraceRoot = bool(v != 0) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/pkg/trace/stats/aggregation.go b/pkg/trace/stats/aggregation.go index 84e6854133d30..5f0fe342e9feb 100644 --- a/pkg/trace/stats/aggregation.go +++ b/pkg/trace/stats/aggregation.go @@ -39,7 +39,7 @@ type BucketsAggregationKey struct { StatusCode uint32 Synthetics bool PeerTagsHash uint64 - IsTraceRoot bool + IsTraceRoot pb.TraceRootFlag } // PayloadAggregationKey specifies the key by which a payload is aggregated. @@ -78,6 +78,12 @@ func clientOrProducer(spanKind string) bool { // NewAggregationFromSpan creates a new aggregation from the provided span and env func NewAggregationFromSpan(s *pb.Span, origin string, aggKey PayloadAggregationKey, enablePeerTagsAgg bool, peerTagKeys []string) (Aggregation, []string) { synthetics := strings.HasPrefix(origin, tagSynthetics) + var isTraceRoot pb.TraceRootFlag + if s.ParentID == 0 { + isTraceRoot = pb.TraceRootFlag_TRUE + } else { + isTraceRoot = pb.TraceRootFlag_FALSE + } agg := Aggregation{ PayloadAggregationKey: aggKey, BucketsAggregationKey: BucketsAggregationKey{ @@ -88,7 +94,7 @@ func NewAggregationFromSpan(s *pb.Span, origin string, aggKey PayloadAggregation Type: s.Type, StatusCode: getStatusCode(s), Synthetics: synthetics, - IsTraceRoot: s.ParentID == 0, + IsTraceRoot: isTraceRoot, }, } var peerTags []string diff --git a/pkg/trace/stats/aggregation_test.go b/pkg/trace/stats/aggregation_test.go index 7d123ed51a043..6e2b1efc24a87 100644 --- a/pkg/trace/stats/aggregation_test.go +++ b/pkg/trace/stats/aggregation_test.go @@ -181,23 +181,23 @@ func TestSpanKindIsConsumerOrProducer(t *testing.T) { func TestIsRootSpan(t *testing.T) { for _, tt := range []struct { in *pb.Span - isTraceRoot bool + isTraceRoot pb.TraceRootFlag }{ { &pb.Span{}, - true, + pb.TraceRootFlag_TRUE, }, { &pb.Span{ ParentID: 0, }, - true, + pb.TraceRootFlag_TRUE, }, { &pb.Span{ ParentID: 123, }, - false, + pb.TraceRootFlag_FALSE, }, } { agg, _ := NewAggregationFromSpan(tt.in, "", PayloadAggregationKey{}, true, []string{}) diff --git a/pkg/trace/stats/concentrator_test.go b/pkg/trace/stats/concentrator_test.go index 1c9e8ac81bb8e..7d91bb2b91c8f 100644 --- a/pkg/trace/stats/concentrator_test.go +++ b/pkg/trace/stats/concentrator_test.go @@ -267,7 +267,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 6, TopLevelHits: 6, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -305,7 +305,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 5, TopLevelHits: 5, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -326,7 +326,7 @@ func TestConcentratorOldestTs(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, } assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) @@ -436,7 +436,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 3, TopLevelHits: 4, Errors: 1, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, { Service: "A1", @@ -447,7 +447,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: false, + IsTraceRoot: pb.TraceRootFlag_FALSE, }, { Service: "A2", @@ -458,7 +458,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 2, TopLevelHits: 2, Errors: 2, - IsTraceRoot: false, + IsTraceRoot: pb.TraceRootFlag_FALSE, }, { Service: "A2", @@ -469,7 +469,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, { Service: "A1", @@ -481,7 +481,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, { Service: "A1", @@ -493,7 +493,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, } // 1-bucket old flush @@ -507,7 +507,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, { Service: "A1", @@ -518,7 +518,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, { Service: "A2", @@ -529,7 +529,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, { Service: "A2", @@ -540,7 +540,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 1, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, { Service: "A2", @@ -551,7 +551,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, } // last bucket to be flushed @@ -565,7 +565,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: false, + IsTraceRoot: pb.TraceRootFlag_FALSE, }, } expectedCountValByKeyByTime[alignedNow+testBucketInterval] = []*pb.ClientGroupedStats{} diff --git a/pkg/trace/stats/statsraw_test.go b/pkg/trace/stats/statsraw_test.go index f238721d9af2b..fc6378c0a646c 100644 --- a/pkg/trace/stats/statsraw_test.go +++ b/pkg/trace/stats/statsraw_test.go @@ -33,7 +33,7 @@ func TestGrain(t *testing.T) { Service: "thing", Name: "other", Resource: "yo", - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, }, aggr) } @@ -64,7 +64,7 @@ func TestGrainWithPeerTags(t *testing.T) { SpanKind: "client", Name: "other", Resource: "yo", - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, }, aggr) assert.Nil(et) @@ -95,7 +95,7 @@ func TestGrainWithPeerTags(t *testing.T) { Name: "other", Resource: "yo", PeerTagsHash: 13698082192712149795, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, }, aggr) assert.Equal([]string{"aws.s3.bucket:bucket-a", "peer.service:aws-s3"}, et) @@ -126,7 +126,7 @@ func TestGrainWithPeerTags(t *testing.T) { Name: "other", Resource: "yo", PeerTagsHash: 5537613849774405073, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, }, aggr) assert.Equal([]string{"db.instance:dynamo.test.us1", "db.system:dynamodb", "peer.service:aws-dynamodb"}, et) @@ -155,7 +155,7 @@ func TestGrainWithSynthetics(t *testing.T) { Name: "other", StatusCode: 418, Synthetics: true, - IsTraceRoot: true, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, }, aggr) } From 45dde44d8b511536d4211817f6c3c691e43095c0 Mon Sep 17 00:00:00 2001 From: simont1 Date: Wed, 20 Mar 2024 09:39:55 -0400 Subject: [PATCH 10/14] made root tags a separate test in concentrator_test.go --- pkg/trace/stats/concentrator_test.go | 65 ++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/pkg/trace/stats/concentrator_test.go b/pkg/trace/stats/concentrator_test.go index 7d91bb2b91c8f..bb073b3b1f848 100644 --- a/pkg/trace/stats/concentrator_test.go +++ b/pkg/trace/stats/concentrator_test.go @@ -409,10 +409,10 @@ func TestConcentratorStatsCounts(t *testing.T) { testSpan(now, 11, 0, 333, 3, "A1", "resource3", 0, map[string]string{"span.kind": "client"}), testSpan(now, 12, 0, 444, 3, "A1", "resource3", 0, map[string]string{"span.kind": "server"}), // 2 buckets old, part of the first flush - testSpan(now, 1, 100, 24, 2, "A1", "resource1", 0, nil), + testSpan(now, 1, 0, 24, 2, "A1", "resource1", 0, nil), testSpan(now, 2, 0, 12, 2, "A1", "resource1", 2, nil), - testSpan(now, 3, 1, 40, 2, "A2", "resource2", 2, nil), - testSpan(now, 4, 1, 300000000000, 2, "A2", "resource2", 2, nil), // 5 minutes trace + testSpan(now, 3, 0, 40, 2, "A2", "resource2", 2, nil), + testSpan(now, 4, 0, 300000000000, 2, "A2", "resource2", 2, nil), // 5 minutes trace testSpan(now, 5, 0, 30, 2, "A2", "resourcefoo", 0, nil), // 1 bucket old, part of the second flush testSpan(now, 6, 0, 24, 1, "A1", "resource2", 0, nil), @@ -432,23 +432,12 @@ func TestConcentratorStatsCounts(t *testing.T) { Resource: "resource1", Type: "db", Name: "query", - Duration: 345, - Hits: 3, + Duration: 369, + Hits: 4, TopLevelHits: 4, Errors: 1, IsTraceRoot: pb.TraceRootFlag_TRUE, }, - { - Service: "A1", - Resource: "resource1", - Type: "db", - Name: "query", - Duration: 24, - Hits: 1, - TopLevelHits: 1, - Errors: 0, - IsTraceRoot: pb.TraceRootFlag_FALSE, - }, { Service: "A2", Resource: "resource2", @@ -458,7 +447,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 2, TopLevelHits: 2, Errors: 2, - IsTraceRoot: pb.TraceRootFlag_FALSE, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, { Service: "A2", @@ -609,6 +598,48 @@ func TestConcentratorStatsCounts(t *testing.T) { } } +// TestRootTag tests that an aggregation will be slit up by the IsTraceRoot aggKey +func TestRootTag(t *testing.T) { + now := time.Now() + spans := []*pb.Span{ + testSpan(now, 1, 0, 40, 10, "A1", "resource1", 0, nil), + testSpan(now, 1, 0, 40, 10, "A1", "resource1", 0, nil), + testSpan(now, 1, 100, 30, 10, "A1", "resource1", 0, nil), + } + traceutil.ComputeTopLevel(spans) + testTrace := toProcessedTrace(spans, "none", "", "", "", "") + c := NewTestConcentrator(now) + c.addNow(testTrace, "") + + expected := []*pb.ClientGroupedStats{ + { + Service: "A1", + Resource: "resource1", + Type: "db", + Name: "query", + Duration: 80, + Hits: 2, + TopLevelHits: 2, + Errors: 0, + IsTraceRoot: pb.TraceRootFlag_TRUE, + }, + { + Service: "A1", + Resource: "resource1", + Type: "db", + Name: "query", + Duration: 30, + Hits: 1, + TopLevelHits: 1, + Errors: 0, + IsTraceRoot: pb.TraceRootFlag_FALSE, + }, + } + + stats := c.flushNow(now.UnixNano()+int64(c.bufferLen)*testBucketInterval, false) + assertCountsEqual(t, expected, stats.Stats[0].Stats[0].Stats) +} + func generateDistribution(t *testing.T, now time.Time, generator func(i int) int64) *ddsketch.DDSketch { assert := assert.New(t) c := NewTestConcentrator(now) From 7dad82ad7e621fd4192ad32ca499bcd40e3fd578 Mon Sep 17 00:00:00 2001 From: simont1 Date: Wed, 20 Mar 2024 09:45:50 -0400 Subject: [PATCH 11/14] release notes --- ...trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml diff --git a/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml b/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml new file mode 100644 index 0000000000000..1083dec6090ff --- /dev/null +++ b/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml @@ -0,0 +1,11 @@ +# Each section from every release note are combined when the +# CHANGELOG.rst is rendered. So the text needs to be worded so that +# it does not depend on any information only available in another +# section. This may mean repeating some details, but each section +# must be readable independently of the other. +# +# Each section note must be formatted as reStructuredText. +--- +features: + - | + APM Stats will now include an is_trace_root field to indicate if the stats are from the root span of a trace. \ No newline at end of file From 542fa80759176e438147c607d6d5699ea84d39f3 Mon Sep 17 00:00:00 2001 From: simont1 Date: Wed, 20 Mar 2024 09:46:20 -0400 Subject: [PATCH 12/14] whitespace --- ...adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml b/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml index 1083dec6090ff..f5d04f74e5f1a 100644 --- a/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml +++ b/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml @@ -8,4 +8,4 @@ --- features: - | - APM Stats will now include an is_trace_root field to indicate if the stats are from the root span of a trace. \ No newline at end of file + APM Stats will now include an is_trace_root field to indicate if the stats are from the root span of a trace. From b32b08fead1b7480a2ccea87a7dfed3a0fe50514 Mon Sep 17 00:00:00 2001 From: Simon Tsui <88simont@gmail.com> Date: Wed, 20 Mar 2024 11:14:22 -0400 Subject: [PATCH 13/14] Update releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml Co-authored-by: Rosa Trieu <107086888+rtrieu@users.noreply.github.com> --- ...adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml b/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml index f5d04f74e5f1a..d6b7b26ea2971 100644 --- a/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml +++ b/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml @@ -8,4 +8,4 @@ --- features: - | - APM Stats will now include an is_trace_root field to indicate if the stats are from the root span of a trace. + APM Stats now includes an is_trace_root field to indicate if the stats are from the root span of a trace. From 5cd8e8cb92067b8ea45422baaec6b2ad97dba042 Mon Sep 17 00:00:00 2001 From: simont1 Date: Thu, 21 Mar 2024 11:53:32 -0400 Subject: [PATCH 14/14] changes --- pkg/trace/stats/concentrator_test.go | 13 +++++++------ ...ace_root-tag-for-APM-Stats-f3f4384105897d11.yaml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/trace/stats/concentrator_test.go b/pkg/trace/stats/concentrator_test.go index bb073b3b1f848..5380558675271 100644 --- a/pkg/trace/stats/concentrator_test.go +++ b/pkg/trace/stats/concentrator_test.go @@ -421,7 +421,7 @@ func TestConcentratorStatsCounts(t *testing.T) { testSpan(now, 9, 0, 30, 1, "A2", "resource2", 2, nil), testSpan(now, 10, 0, 3600000000000, 1, "A2", "resourcefoo", 0, nil), // 1 hour trace // present data, part of the third flush - testSpan(now, 6, 100, 24, 0, "A1", "resource2", 0, nil), + testSpan(now, 6, 0, 24, 0, "A1", "resource2", 0, nil), } expectedCountValByKeyByTime := make(map[int64][]*pb.ClientGroupedStats) @@ -554,7 +554,7 @@ func TestConcentratorStatsCounts(t *testing.T) { Hits: 1, TopLevelHits: 1, Errors: 0, - IsTraceRoot: pb.TraceRootFlag_FALSE, + IsTraceRoot: pb.TraceRootFlag_TRUE, }, } expectedCountValByKeyByTime[alignedNow+testBucketInterval] = []*pb.ClientGroupedStats{} @@ -603,8 +603,9 @@ func TestRootTag(t *testing.T) { now := time.Now() spans := []*pb.Span{ testSpan(now, 1, 0, 40, 10, "A1", "resource1", 0, nil), - testSpan(now, 1, 0, 40, 10, "A1", "resource1", 0, nil), - testSpan(now, 1, 100, 30, 10, "A1", "resource1", 0, nil), + testSpan(now, 2, 1, 30, 10, "A1", "resource1", 0, nil), + testSpan(now, 3, 2, 20, 10, "A1", "resource1", 0, map[string]string{"span.kind": "client"}), + testSpan(now, 4, 1000, 10, 10, "A1", "resource1", 0, nil), } traceutil.ComputeTopLevel(spans) testTrace := toProcessedTrace(spans, "none", "", "", "", "") @@ -617,7 +618,7 @@ func TestRootTag(t *testing.T) { Resource: "resource1", Type: "db", Name: "query", - Duration: 80, + Duration: 60, Hits: 2, TopLevelHits: 2, Errors: 0, @@ -628,7 +629,7 @@ func TestRootTag(t *testing.T) { Resource: "resource1", Type: "db", Name: "query", - Duration: 30, + Duration: 10, Hits: 1, TopLevelHits: 1, Errors: 0, diff --git a/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml b/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml index d6b7b26ea2971..8a1317705a06c 100644 --- a/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml +++ b/releasenotes/notes/apm-adding-is_trace_root-tag-for-APM-Stats-f3f4384105897d11.yaml @@ -8,4 +8,4 @@ --- features: - | - APM Stats now includes an is_trace_root field to indicate if the stats are from the root span of a trace. + APM stats now include an is_trace_root field to indicate if the stats are from the root span of a trace.