diff --git a/api/proto/common/yagpcc_metrics.pb.go b/api/proto/common/yagpcc_metrics.pb.go index d44e896..9c51276 100644 --- a/api/proto/common/yagpcc_metrics.pb.go +++ b/api/proto/common/yagpcc_metrics.pb.go @@ -850,25 +850,21 @@ type NetworkStat struct { // // Importance: major // Aggregation: sum - TotalBytes uint32 `protobuf:"varint,1,opt,name=total_bytes,json=totalBytes,proto3" json:"total_bytes,omitempty"` + TotalBytes uint64 `protobuf:"varint,1,opt,name=total_bytes,json=totalBytes,proto3" json:"total_bytes,omitempty"` // tuple_bytes: total number of tuples only bytes (without headers) that all of backend processes // associated with query or session sent/received to/from the network layer. // // Importance: minor // Aggregation: sum - TupleBytes uint32 `protobuf:"varint,2,opt,name=tuple_bytes,json=tupleBytes,proto3" json:"tuple_bytes,omitempty"` + TupleBytes uint64 `protobuf:"varint,2,opt,name=tuple_bytes,json=tupleBytes,proto3" json:"tuple_bytes,omitempty"` // chunks: total number of chunks (tuples only) that all of backend processes // associated with query or session sent/received to/from the network layer. // // Importance: normal // Aggregation: sum - Chunks uint32 `protobuf:"varint,3,opt,name=chunks,proto3" json:"chunks,omitempty"` - // the stats here is the same except uses uint64, uint32 is too snal for aggregated stat - TotalBytesLong uint64 `protobuf:"varint,4,opt,name=total_bytes_long,json=totalBytesLong,proto3" json:"total_bytes_long,omitempty"` - TupleBytesLong uint64 `protobuf:"varint,5,opt,name=tuple_bytes_long,json=tupleBytesLong,proto3" json:"tuple_bytes_long,omitempty"` - ChunksLong uint64 `protobuf:"varint,6,opt,name=chunks_long,json=chunksLong,proto3" json:"chunks_long,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + Chunks uint64 `protobuf:"varint,3,opt,name=chunks,proto3" json:"chunks,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *NetworkStat) Reset() { @@ -901,48 +897,27 @@ func (*NetworkStat) Descriptor() ([]byte, []int) { return file_api_proto_common_yagpcc_metrics_proto_rawDescGZIP(), []int{7} } -func (x *NetworkStat) GetTotalBytes() uint32 { +func (x *NetworkStat) GetTotalBytes() uint64 { if x != nil { return x.TotalBytes } return 0 } -func (x *NetworkStat) GetTupleBytes() uint32 { +func (x *NetworkStat) GetTupleBytes() uint64 { if x != nil { return x.TupleBytes } return 0 } -func (x *NetworkStat) GetChunks() uint32 { +func (x *NetworkStat) GetChunks() uint64 { if x != nil { return x.Chunks } return 0 } -func (x *NetworkStat) GetTotalBytesLong() uint64 { - if x != nil { - return x.TotalBytesLong - } - return 0 -} - -func (x *NetworkStat) GetTupleBytesLong() uint64 { - if x != nil { - return x.TupleBytesLong - } - return 0 -} - -func (x *NetworkStat) GetChunksLong() uint64 { - if x != nil { - return x.ChunksLong - } - return 0 -} - // InterconnectStat: detailed interconnect statistics. type InterconnectStat struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1667,17 +1642,13 @@ const file_api_proto_common_yagpcc_metrics_proto_rawDesc = "" + "read_bytes\x18\f \x01(\x04R\treadBytes\x12\x1f\n" + "\vwrite_bytes\x18\r \x01(\x04R\n" + "writeBytes\x122\n" + - "\x15cancelled_write_bytes\x18\x0e \x01(\x04R\x13cancelledWriteBytes\"\xdc\x01\n" + + "\x15cancelled_write_bytes\x18\x0e \x01(\x04R\x13cancelledWriteBytes\"\xaa\x01\n" + "\vNetworkStat\x12\x1f\n" + - "\vtotal_bytes\x18\x01 \x01(\rR\n" + + "\vtotal_bytes\x18\x01 \x01(\x04R\n" + "totalBytes\x12\x1f\n" + - "\vtuple_bytes\x18\x02 \x01(\rR\n" + + "\vtuple_bytes\x18\x02 \x01(\x04R\n" + "tupleBytes\x12\x16\n" + - "\x06chunks\x18\x03 \x01(\rR\x06chunks\x12(\n" + - "\x10total_bytes_long\x18\x04 \x01(\x04R\x0etotalBytesLong\x12(\n" + - "\x10tuple_bytes_long\x18\x05 \x01(\x04R\x0etupleBytesLong\x12\x1f\n" + - "\vchunks_long\x18\x06 \x01(\x04R\n" + - "chunksLong\"\xfb\x05\n" + + "\x06chunks\x18\x03 \x01(\x04R\x06chunksJ\x04\b\x04\x10\x05J\x04\b\x05\x10\x06J\x04\b\x06\x10\aR\x10total_bytes_longR\x10tuple_bytes_longR\vchunks_long\"\xfb\x05\n" + "\x10InterconnectStat\x121\n" + "\x15total_recv_queue_size\x18\x01 \x01(\x04R\x12totalRecvQueueSize\x12@\n" + "\x1drecv_queue_size_counting_time\x18\x02 \x01(\x04R\x19recvQueueSizeCountingTime\x12%\n" + diff --git a/api/proto/common/yagpcc_metrics.proto b/api/proto/common/yagpcc_metrics.proto index a8d6736..5795639 100644 --- a/api/proto/common/yagpcc_metrics.proto +++ b/api/proto/common/yagpcc_metrics.proto @@ -252,27 +252,21 @@ message NetworkStat { // // Importance: major // Aggregation: sum - uint32 total_bytes = 1; + uint64 total_bytes = 1; // tuple_bytes: total number of tuples only bytes (without headers) that all of backend processes // associated with query or session sent/received to/from the network layer. // // Importance: minor // Aggregation: sum - uint32 tuple_bytes = 2; + uint64 tuple_bytes = 2; // chunks: total number of chunks (tuples only) that all of backend processes // associated with query or session sent/received to/from the network layer. // // Importance: normal // Aggregation: sum - uint32 chunks = 3; - - // the stats here is the same except uses uint64, uint32 is too snal for aggregated stat - uint64 total_bytes_long = 4; - uint64 tuple_bytes_long = 5; - uint64 chunks_long = 6; - + uint64 chunks = 3; } // InterconnectStat: detailed interconnect statistics. diff --git a/internal/grpc/get_master_info.go b/internal/grpc/get_master_info.go index 2d3f0d2..e10b2c6 100644 --- a/internal/grpc/get_master_info.go +++ b/internal/grpc/get_master_info.go @@ -1065,10 +1065,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.TotalMetrics != nil && p.TotalMetrics.Instrumentation != nil && p.TotalMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.TotalMetrics.Instrumentation.Sent.TotalBytes), p.TotalMetrics.Instrumentation.Sent.TotalBytesLong) + left = p.TotalMetrics.Instrumentation.Sent.TotalBytes } if q.TotalMetrics != nil && q.TotalMetrics.Instrumentation != nil && q.TotalMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.TotalMetrics.Instrumentation.Sent.TotalBytes), q.TotalMetrics.Instrumentation.Sent.TotalBytesLong) + right = q.TotalMetrics.Instrumentation.Sent.TotalBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -1080,10 +1080,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.TotalMetrics != nil && p.TotalMetrics.Instrumentation != nil && p.TotalMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.TotalMetrics.Instrumentation.Sent.TupleBytes), p.TotalMetrics.Instrumentation.Sent.TupleBytesLong) + left = p.TotalMetrics.Instrumentation.Sent.TupleBytes } if q.TotalMetrics != nil && q.TotalMetrics.Instrumentation != nil && q.TotalMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.TotalMetrics.Instrumentation.Sent.TupleBytes), q.TotalMetrics.Instrumentation.Sent.TupleBytesLong) + right = q.TotalMetrics.Instrumentation.Sent.TupleBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -1095,10 +1095,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.TotalMetrics != nil && p.TotalMetrics.Instrumentation != nil && p.TotalMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.TotalMetrics.Instrumentation.Sent.Chunks), p.TotalMetrics.Instrumentation.Sent.ChunksLong) + left = p.TotalMetrics.Instrumentation.Sent.Chunks } if q.TotalMetrics != nil && q.TotalMetrics.Instrumentation != nil && q.TotalMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.TotalMetrics.Instrumentation.Sent.Chunks), q.TotalMetrics.Instrumentation.Sent.ChunksLong) + right = q.TotalMetrics.Instrumentation.Sent.Chunks } if less(ms.Fields[k].Order, left, right) { return true @@ -1110,10 +1110,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.TotalMetrics != nil && p.TotalMetrics.Instrumentation != nil && p.TotalMetrics.Instrumentation.Received != nil { - left = max(uint64(p.TotalMetrics.Instrumentation.Received.TotalBytes), p.TotalMetrics.Instrumentation.Received.TotalBytesLong) + left = p.TotalMetrics.Instrumentation.Received.TotalBytes } if q.TotalMetrics != nil && q.TotalMetrics.Instrumentation != nil && q.TotalMetrics.Instrumentation.Received != nil { - right = max(uint64(q.TotalMetrics.Instrumentation.Received.TotalBytes), q.TotalMetrics.Instrumentation.Received.TotalBytesLong) + right = q.TotalMetrics.Instrumentation.Received.TotalBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -1125,10 +1125,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.TotalMetrics != nil && p.TotalMetrics.Instrumentation != nil && p.TotalMetrics.Instrumentation.Received != nil { - left = max(uint64(p.TotalMetrics.Instrumentation.Received.TupleBytes), p.TotalMetrics.Instrumentation.Received.TupleBytesLong) + left = p.TotalMetrics.Instrumentation.Received.TupleBytes } if q.TotalMetrics != nil && q.TotalMetrics.Instrumentation != nil && q.TotalMetrics.Instrumentation.Received != nil { - right = max(uint64(q.TotalMetrics.Instrumentation.Received.TupleBytes), q.TotalMetrics.Instrumentation.Received.TupleBytesLong) + right = q.TotalMetrics.Instrumentation.Received.TupleBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -1140,10 +1140,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.TotalMetrics != nil && p.TotalMetrics.Instrumentation != nil && p.TotalMetrics.Instrumentation.Received != nil { - left = max(uint64(p.TotalMetrics.Instrumentation.Received.Chunks), p.TotalMetrics.Instrumentation.Received.ChunksLong) + left = p.TotalMetrics.Instrumentation.Received.Chunks } if q.TotalMetrics != nil && q.TotalMetrics.Instrumentation != nil && q.TotalMetrics.Instrumentation.Received != nil { - right = max(uint64(q.TotalMetrics.Instrumentation.Received.Chunks), q.TotalMetrics.Instrumentation.Received.ChunksLong) + right = q.TotalMetrics.Instrumentation.Received.Chunks } if less(ms.Fields[k].Order, left, right) { return true @@ -1650,10 +1650,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.LastMetrics != nil && p.LastMetrics.Instrumentation != nil && p.LastMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.LastMetrics.Instrumentation.Sent.TotalBytes), p.LastMetrics.Instrumentation.Sent.TotalBytesLong) + left = p.LastMetrics.Instrumentation.Sent.TotalBytes } if q.LastMetrics != nil && q.LastMetrics.Instrumentation != nil && q.LastMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.LastMetrics.Instrumentation.Sent.TotalBytes), q.LastMetrics.Instrumentation.Sent.TotalBytesLong) + right = q.LastMetrics.Instrumentation.Sent.TotalBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -1665,10 +1665,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.LastMetrics != nil && p.LastMetrics.Instrumentation != nil && p.LastMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.LastMetrics.Instrumentation.Sent.TupleBytes), p.LastMetrics.Instrumentation.Sent.TupleBytesLong) + left = p.LastMetrics.Instrumentation.Sent.TupleBytes } if q.LastMetrics != nil && q.LastMetrics.Instrumentation != nil && q.LastMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.LastMetrics.Instrumentation.Sent.TupleBytes), q.LastMetrics.Instrumentation.Sent.TupleBytesLong) + right = q.LastMetrics.Instrumentation.Sent.TupleBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -1680,10 +1680,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.LastMetrics != nil && p.LastMetrics.Instrumentation != nil && p.LastMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.LastMetrics.Instrumentation.Sent.Chunks), p.LastMetrics.Instrumentation.Sent.ChunksLong) + left = p.LastMetrics.Instrumentation.Sent.Chunks } if q.LastMetrics != nil && q.LastMetrics.Instrumentation != nil && q.LastMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.LastMetrics.Instrumentation.Sent.Chunks), q.LastMetrics.Instrumentation.Sent.ChunksLong) + right = q.LastMetrics.Instrumentation.Sent.Chunks } if less(ms.Fields[k].Order, left, right) { return true @@ -1695,10 +1695,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.LastMetrics != nil && p.LastMetrics.Instrumentation != nil && p.LastMetrics.Instrumentation.Received != nil { - left = max(uint64(p.LastMetrics.Instrumentation.Received.TotalBytes), p.LastMetrics.Instrumentation.Received.TotalBytesLong) + left = p.LastMetrics.Instrumentation.Received.TotalBytes } if q.LastMetrics != nil && q.LastMetrics.Instrumentation != nil && q.LastMetrics.Instrumentation.Received != nil { - right = max(uint64(q.LastMetrics.Instrumentation.Received.TotalBytes), q.LastMetrics.Instrumentation.Received.TotalBytesLong) + right = q.LastMetrics.Instrumentation.Received.TotalBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -1710,10 +1710,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.LastMetrics != nil && p.LastMetrics.Instrumentation != nil && p.LastMetrics.Instrumentation.Received != nil { - left = max(uint64(p.LastMetrics.Instrumentation.Received.TupleBytes), p.LastMetrics.Instrumentation.Received.TupleBytesLong) + left = p.LastMetrics.Instrumentation.Received.TupleBytes } if q.LastMetrics != nil && q.LastMetrics.Instrumentation != nil && q.LastMetrics.Instrumentation.Received != nil { - right = max(uint64(q.LastMetrics.Instrumentation.Received.TupleBytes), q.LastMetrics.Instrumentation.Received.TupleBytesLong) + right = q.LastMetrics.Instrumentation.Received.TupleBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -1725,10 +1725,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.LastMetrics != nil && p.LastMetrics.Instrumentation != nil && p.LastMetrics.Instrumentation.Received != nil { - left = max(uint64(p.LastMetrics.Instrumentation.Received.Chunks), p.LastMetrics.Instrumentation.Received.ChunksLong) + left = p.LastMetrics.Instrumentation.Received.Chunks } if q.LastMetrics != nil && q.LastMetrics.Instrumentation != nil && q.LastMetrics.Instrumentation.Received != nil { - right = max(uint64(q.LastMetrics.Instrumentation.Received.Chunks), q.LastMetrics.Instrumentation.Received.ChunksLong) + right = q.LastMetrics.Instrumentation.Received.Chunks } if less(ms.Fields[k].Order, left, right) { return true @@ -2235,10 +2235,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.QueryMetrics != nil && p.QueryMetrics.Instrumentation != nil && p.QueryMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.QueryMetrics.Instrumentation.Sent.TotalBytes), p.QueryMetrics.Instrumentation.Sent.TotalBytesLong) + left = p.QueryMetrics.Instrumentation.Sent.TotalBytes } if q.QueryMetrics != nil && q.QueryMetrics.Instrumentation != nil && q.QueryMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.QueryMetrics.Instrumentation.Sent.TotalBytes), q.QueryMetrics.Instrumentation.Sent.TotalBytesLong) + right = q.QueryMetrics.Instrumentation.Sent.TotalBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -2250,10 +2250,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.QueryMetrics != nil && p.QueryMetrics.Instrumentation != nil && p.QueryMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.QueryMetrics.Instrumentation.Sent.TupleBytes), p.QueryMetrics.Instrumentation.Sent.TupleBytesLong) + left = p.QueryMetrics.Instrumentation.Sent.TupleBytes } if q.QueryMetrics != nil && q.QueryMetrics.Instrumentation != nil && q.QueryMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.QueryMetrics.Instrumentation.Sent.TupleBytes), q.QueryMetrics.Instrumentation.Sent.TupleBytesLong) + right = q.QueryMetrics.Instrumentation.Sent.TupleBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -2265,10 +2265,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.QueryMetrics != nil && p.QueryMetrics.Instrumentation != nil && p.QueryMetrics.Instrumentation.Sent != nil { - left = max(uint64(p.QueryMetrics.Instrumentation.Sent.Chunks), p.QueryMetrics.Instrumentation.Sent.ChunksLong) + left = p.QueryMetrics.Instrumentation.Sent.Chunks } if q.QueryMetrics != nil && q.QueryMetrics.Instrumentation != nil && q.QueryMetrics.Instrumentation.Sent != nil { - right = max(uint64(q.QueryMetrics.Instrumentation.Sent.Chunks), q.QueryMetrics.Instrumentation.Sent.ChunksLong) + right = q.QueryMetrics.Instrumentation.Sent.Chunks } if less(ms.Fields[k].Order, left, right) { return true @@ -2280,10 +2280,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.QueryMetrics != nil && p.QueryMetrics.Instrumentation != nil && p.QueryMetrics.Instrumentation.Received != nil { - left = max(uint64(p.QueryMetrics.Instrumentation.Received.TotalBytes), p.QueryMetrics.Instrumentation.Received.TotalBytesLong) + left = p.QueryMetrics.Instrumentation.Received.TotalBytes } if q.QueryMetrics != nil && q.QueryMetrics.Instrumentation != nil && q.QueryMetrics.Instrumentation.Received != nil { - right = max(uint64(q.QueryMetrics.Instrumentation.Received.TotalBytes), q.QueryMetrics.Instrumentation.Received.TotalBytesLong) + right = q.QueryMetrics.Instrumentation.Received.TotalBytes } if less(ms.Fields[k].Order, left, right) { return true @@ -2295,10 +2295,10 @@ func (ms *MultipleSorter) Less(i, j int) bool { left, right := uint64(0), uint64(0) if p.QueryMetrics != nil && p.QueryMetrics.Instrumentation != nil && p.QueryMetrics.Instrumentation.Received != nil { - left = max(uint64(p.QueryMetrics.Instrumentation.Received.TupleBytes), p.QueryMetrics.Instrumentation.Received.TupleBytesLong) + left = p.QueryMetrics.Instrumentation.Received.TupleBytes } if q.QueryMetrics != nil && q.QueryMetrics.Instrumentation != nil && q.QueryMetrics.Instrumentation.Received != nil { - right = max(uint64(q.QueryMetrics.Instrumentation.Received.TupleBytes), q.QueryMetrics.Instrumentation.Received.TupleBytesLong) + right = q.QueryMetrics.Instrumentation.Received.TupleBytes } if less(ms.Fields[k].Order, left, right) { return true diff --git a/internal/grpc/get_master_info_test.go b/internal/grpc/get_master_info_test.go index e47cd00..cf49e4f 100644 --- a/internal/grpc/get_master_info_test.go +++ b/internal/grpc/get_master_info_test.go @@ -236,79 +236,11 @@ func TestSortAndFilterSessions(t *testing.T) { require.NoError(t, err) assert.Equal(t, 3, len(sessions)) assert.Nil(t, sessions[0].TotalMetrics) - assert.Equal(t, uint32(5), sessions[1].TotalMetrics.Instrumentation.Sent.TotalBytes) - assert.Equal(t, uint32(10), sessions[2].TotalMetrics.Instrumentation.Sent.TotalBytes) + assert.Equal(t, uint64(5), sessions[1].TotalMetrics.Instrumentation.Sent.TotalBytes) + assert.Equal(t, uint64(10), sessions[2].TotalMetrics.Instrumentation.Sent.TotalBytes) }) } -func TestSortNetworkStatLongFields(t *testing.T) { - type F = pbm.SessionField - for _, tc := range []struct { - f F - slot string - sent bool - kind string - }{ - {F(pbm.SessionField_TOTAL_NET_SENT_TOTAL_BYTES), "total", true, "bytes"}, - {F(pbm.SessionField_TOTAL_NET_SENT_TUPLE_BYTES), "total", true, "tuple"}, - {F(pbm.SessionField_TOTAL_NET_SENT_CHUNKS), "total", true, "chunks"}, - {F(pbm.SessionField_TOTAL_NET_RECV_TOTAL_BYTES), "total", false, "bytes"}, - {F(pbm.SessionField_TOTAL_NET_RECV_TUPLE_BYTES), "total", false, "tuple"}, - {F(pbm.SessionField_TOTAL_NET_RECV_CHUNKS), "total", false, "chunks"}, - {F(pbm.SessionField_LAST_NET_SENT_TOTAL_BYTES), "last", true, "bytes"}, - {F(pbm.SessionField_LAST_NET_SENT_TUPLE_BYTES), "last", true, "tuple"}, - {F(pbm.SessionField_LAST_NET_SENT_CHUNKS), "last", true, "chunks"}, - {F(pbm.SessionField_LAST_NET_RECV_TOTAL_BYTES), "last", false, "bytes"}, - {F(pbm.SessionField_LAST_NET_RECV_TUPLE_BYTES), "last", false, "tuple"}, - {F(pbm.SessionField_LAST_NET_RECV_CHUNKS), "last", false, "chunks"}, - {F(pbm.SessionField_QUERY_NET_SENT_TOTAL_BYTES), "query", true, "bytes"}, - {F(pbm.SessionField_QUERY_NET_SENT_TUPLE_BYTES), "query", true, "tuple"}, - {F(pbm.SessionField_QUERY_NET_SENT_CHUNKS), "query", true, "chunks"}, - {F(pbm.SessionField_QUERY_NET_RECV_TOTAL_BYTES), "query", false, "bytes"}, - {F(pbm.SessionField_QUERY_NET_RECV_TUPLE_BYTES), "query", false, "tuple"}, - } { - t.Run(tc.f.String(), func(t *testing.T) { - stat := func(u32 uint32, u64 uint64) *pbc.NetworkStat { - switch tc.kind { - case "tuple": - return &pbc.NetworkStat{TupleBytes: u32, TupleBytesLong: u64} - case "chunks": - return &pbc.NetworkStat{Chunks: u32, ChunksLong: u64} - default: - return &pbc.NetworkStat{TotalBytes: u32, TotalBytesLong: u64} - } - } - stat1, stat2 := stat(5, 5_000_000_000), stat(10, 3_000_000_000) - - mk := func(id int64, s *pbc.NetworkStat) *pbc.SessionState { - instr := &pbc.MetricInstrumentation{} - if tc.sent { - instr.Sent = s - } else { - instr.Received = s - } - st := &pbc.SessionState{SessionKey: &pbc.SessionKey{SessId: id}} - m := &pbc.GPMetrics{Instrumentation: instr} - switch tc.slot { - case "total": - st.TotalMetrics = m - case "last": - st.LastMetrics = m - case "query": - st.QueryMetrics = m - } - return st - } - - sessions := []*pbc.SessionState{mk(1, stat1), mk(2, stat2)} - fields := []*pbm.SessionFieldWrapper{{FieldName: tc.f, Order: pbm.SortOrder_SORT_DESC}} - require.NoError(t, grpc.SortResult(&sessions, fields)) - assert.Equal(t, int64(1), sessions[0].SessionKey.SessId) - assert.Equal(t, int64(2), sessions[1].SessionKey.SessId) - }) - } -} - func TestMasterMethods(t *testing.T) { ctrl := gomock.NewController(t) sessionMocker := NewMockStatActivityLister(ctrl) diff --git a/internal/storage/util.go b/internal/storage/util.go index e1a5147..f7c0bf2 100644 --- a/internal/storage/util.go +++ b/internal/storage/util.go @@ -166,9 +166,6 @@ func GroupGPMetrics(dest *pbc.GPMetrics, source *pbc.GPMetrics, aggKind Aggregat dest.Instrumentation.Sent.TotalBytes += source.Instrumentation.Sent.TotalBytes dest.Instrumentation.Sent.TupleBytes += source.Instrumentation.Sent.TupleBytes dest.Instrumentation.Sent.Chunks += source.Instrumentation.Sent.Chunks - dest.Instrumentation.Sent.TotalBytesLong += source.Instrumentation.Sent.TotalBytesLong - dest.Instrumentation.Sent.TupleBytesLong += source.Instrumentation.Sent.TupleBytesLong - dest.Instrumentation.Sent.ChunksLong += source.Instrumentation.Sent.ChunksLong } } @@ -179,9 +176,6 @@ func GroupGPMetrics(dest *pbc.GPMetrics, source *pbc.GPMetrics, aggKind Aggregat dest.Instrumentation.Received.TotalBytes += source.Instrumentation.Received.TotalBytes dest.Instrumentation.Received.TupleBytes += source.Instrumentation.Received.TupleBytes dest.Instrumentation.Received.Chunks += source.Instrumentation.Received.Chunks - dest.Instrumentation.Received.TotalBytesLong += source.Instrumentation.Received.TotalBytesLong - dest.Instrumentation.Received.TupleBytesLong += source.Instrumentation.Received.TupleBytesLong - dest.Instrumentation.Received.ChunksLong += source.Instrumentation.Received.ChunksLong } } @@ -332,26 +326,20 @@ func MergeGPMetrics(dest *pbc.GPMetrics, source *pbc.GPMetrics) error { if source.Instrumentation.Sent != nil { if dest.Instrumentation.Sent == nil { dest.Instrumentation.Sent = proto.Clone(source.Instrumentation.Sent).(*pbc.NetworkStat) - dest.Instrumentation.Sent.TotalBytesLong = max(uint64(source.Instrumentation.Sent.TotalBytes), source.Instrumentation.Sent.TotalBytesLong) - dest.Instrumentation.Sent.TupleBytesLong = max(uint64(source.Instrumentation.Sent.TupleBytes), source.Instrumentation.Sent.TupleBytesLong) - dest.Instrumentation.Sent.ChunksLong = max(uint64(source.Instrumentation.Sent.Chunks), source.Instrumentation.Sent.ChunksLong) } else { - dest.Instrumentation.Sent.TotalBytesLong = max(max(uint64(source.Instrumentation.Sent.TotalBytes), source.Instrumentation.Sent.TotalBytesLong), dest.Instrumentation.Sent.TotalBytesLong) - dest.Instrumentation.Sent.TupleBytesLong = max(max(uint64(source.Instrumentation.Sent.TupleBytes), source.Instrumentation.Sent.TupleBytesLong), dest.Instrumentation.Sent.TupleBytesLong) - dest.Instrumentation.Sent.ChunksLong = max(max(uint64(source.Instrumentation.Sent.Chunks), source.Instrumentation.Sent.ChunksLong), dest.Instrumentation.Sent.ChunksLong) + dest.Instrumentation.Sent.TotalBytes = max(source.Instrumentation.Sent.TotalBytes, dest.Instrumentation.Sent.TotalBytes) + dest.Instrumentation.Sent.TupleBytes = max(source.Instrumentation.Sent.TupleBytes, dest.Instrumentation.Sent.TupleBytes) + dest.Instrumentation.Sent.Chunks = max(source.Instrumentation.Sent.Chunks, dest.Instrumentation.Sent.Chunks) } } if source.Instrumentation.Received != nil { if dest.Instrumentation.Received == nil { dest.Instrumentation.Received = proto.Clone(source.Instrumentation.Received).(*pbc.NetworkStat) - dest.Instrumentation.Received.TotalBytesLong = max(uint64(source.Instrumentation.Received.TotalBytes), source.Instrumentation.Received.TotalBytesLong) - dest.Instrumentation.Received.TupleBytesLong = max(uint64(source.Instrumentation.Received.TupleBytes), source.Instrumentation.Received.TupleBytesLong) - dest.Instrumentation.Received.ChunksLong = max(uint64(source.Instrumentation.Received.Chunks), source.Instrumentation.Received.ChunksLong) } else { - dest.Instrumentation.Received.TotalBytesLong = max(max(uint64(source.Instrumentation.Received.TotalBytes), source.Instrumentation.Received.TotalBytesLong), dest.Instrumentation.Received.TotalBytesLong) - dest.Instrumentation.Received.TupleBytesLong = max(max(uint64(source.Instrumentation.Received.TupleBytes), source.Instrumentation.Received.TupleBytesLong), dest.Instrumentation.Received.TupleBytesLong) - dest.Instrumentation.Received.ChunksLong = max(max(uint64(source.Instrumentation.Received.Chunks), source.Instrumentation.Received.ChunksLong), dest.Instrumentation.Received.ChunksLong) + dest.Instrumentation.Received.TotalBytes = max(source.Instrumentation.Received.TotalBytes, dest.Instrumentation.Received.TotalBytes) + dest.Instrumentation.Received.TupleBytes = max(source.Instrumentation.Received.TupleBytes, dest.Instrumentation.Received.TupleBytes) + dest.Instrumentation.Received.Chunks = max(source.Instrumentation.Received.Chunks, dest.Instrumentation.Received.Chunks) } }