diff --git a/go-tipb/topsql_agent.pb.go b/go-tipb/topsql_agent.pb.go index 7b135c5e..14960381 100644 --- a/go-tipb/topsql_agent.pb.go +++ b/go-tipb/topsql_agent.pb.go @@ -5,6 +5,7 @@ package tipb import ( "context" + encoding_binary "encoding/binary" "fmt" "io" "math" @@ -29,6 +30,65 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +type CollectorType int32 + +const ( + CollectorType_COLLECTOR_TYPE_UNSPECIFIED CollectorType = 0 + CollectorType_COLLECTOR_TYPE_TOPSQL CollectorType = 1 + CollectorType_COLLECTOR_TYPE_TOPRU CollectorType = 2 +) + +var CollectorType_name = map[int32]string{ + 0: "COLLECTOR_TYPE_UNSPECIFIED", + 1: "COLLECTOR_TYPE_TOPSQL", + 2: "COLLECTOR_TYPE_TOPRU", +} + +var CollectorType_value = map[string]int32{ + "COLLECTOR_TYPE_UNSPECIFIED": 0, + "COLLECTOR_TYPE_TOPSQL": 1, + "COLLECTOR_TYPE_TOPRU": 2, +} + +func (x CollectorType) String() string { + return proto.EnumName(CollectorType_name, int32(x)) +} + +func (CollectorType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_1b19f3a2fcd6965e, []int{0} +} + +type ItemInterval int32 + +const ( + ItemInterval_ITEM_INTERVAL_UNSPECIFIED ItemInterval = 0 + ItemInterval_ITEM_INTERVAL_15S ItemInterval = 15 + ItemInterval_ITEM_INTERVAL_30S ItemInterval = 30 + ItemInterval_ITEM_INTERVAL_60S ItemInterval = 60 +) + +var ItemInterval_name = map[int32]string{ + 0: "ITEM_INTERVAL_UNSPECIFIED", + 15: "ITEM_INTERVAL_15S", + 30: "ITEM_INTERVAL_30S", + 60: "ITEM_INTERVAL_60S", +} + +var ItemInterval_value = map[string]int32{ + "ITEM_INTERVAL_UNSPECIFIED": 0, + "ITEM_INTERVAL_15S": 15, + "ITEM_INTERVAL_30S": 30, + "ITEM_INTERVAL_60S": 60, +} + +func (x ItemInterval) String() string { + return proto.EnumName(ItemInterval_name, int32(x)) +} + +func (ItemInterval) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_1b19f3a2fcd6965e, []int{1} +} + type TopSQLRecord struct { SqlDigest []byte `protobuf:"bytes,1,opt,name=sql_digest,json=sqlDigest,proto3" json:"sql_digest,omitempty"` PlanDigest []byte `protobuf:"bytes,2,opt,name=plan_digest,json=planDigest,proto3" json:"plan_digest,omitempty"` @@ -97,6 +157,152 @@ func (m *TopSQLRecord) GetKeyspaceName() []byte { return nil } +// TopRURecord represents RU statistics for a single (user, sql_digest, plan_digest) combination. +type TopRURecord struct { + KeyspaceName []byte `protobuf:"bytes,1,opt,name=keyspace_name,json=keyspaceName,proto3" json:"keyspace_name,omitempty"` + User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + SqlDigest []byte `protobuf:"bytes,3,opt,name=sql_digest,json=sqlDigest,proto3" json:"sql_digest,omitempty"` + PlanDigest []byte `protobuf:"bytes,4,opt,name=plan_digest,json=planDigest,proto3" json:"plan_digest,omitempty"` + Items []*TopRURecordItem `protobuf:"bytes,5,rep,name=items,proto3" json:"items,omitempty"` +} + +func (m *TopRURecord) Reset() { *m = TopRURecord{} } +func (m *TopRURecord) String() string { return proto.CompactTextString(m) } +func (*TopRURecord) ProtoMessage() {} +func (*TopRURecord) Descriptor() ([]byte, []int) { + return fileDescriptor_1b19f3a2fcd6965e, []int{1} +} +func (m *TopRURecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TopRURecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TopRURecord.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TopRURecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_TopRURecord.Merge(m, src) +} +func (m *TopRURecord) XXX_Size() int { + return m.Size() +} +func (m *TopRURecord) XXX_DiscardUnknown() { + xxx_messageInfo_TopRURecord.DiscardUnknown(m) +} + +var xxx_messageInfo_TopRURecord proto.InternalMessageInfo + +func (m *TopRURecord) GetKeyspaceName() []byte { + if m != nil { + return m.KeyspaceName + } + return nil +} + +func (m *TopRURecord) GetUser() string { + if m != nil { + return m.User + } + return "" +} + +func (m *TopRURecord) GetSqlDigest() []byte { + if m != nil { + return m.SqlDigest + } + return nil +} + +func (m *TopRURecord) GetPlanDigest() []byte { + if m != nil { + return m.PlanDigest + } + return nil +} + +func (m *TopRURecord) GetItems() []*TopRURecordItem { + if m != nil { + return m.Items + } + return nil +} + +// TopRURecordItem represents statistics within a single time bucket. +type TopRURecordItem struct { + TimestampSec uint64 `protobuf:"varint,1,opt,name=timestamp_sec,json=timestampSec,proto3" json:"timestamp_sec,omitempty"` + TotalRu float64 `protobuf:"fixed64,2,opt,name=total_ru,json=totalRu,proto3" json:"total_ru,omitempty"` + ExecCount uint64 `protobuf:"varint,3,opt,name=exec_count,json=execCount,proto3" json:"exec_count,omitempty"` + ExecDuration uint64 `protobuf:"varint,4,opt,name=exec_duration,json=execDuration,proto3" json:"exec_duration,omitempty"` +} + +func (m *TopRURecordItem) Reset() { *m = TopRURecordItem{} } +func (m *TopRURecordItem) String() string { return proto.CompactTextString(m) } +func (*TopRURecordItem) ProtoMessage() {} +func (*TopRURecordItem) Descriptor() ([]byte, []int) { + return fileDescriptor_1b19f3a2fcd6965e, []int{2} +} +func (m *TopRURecordItem) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TopRURecordItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TopRURecordItem.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TopRURecordItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_TopRURecordItem.Merge(m, src) +} +func (m *TopRURecordItem) XXX_Size() int { + return m.Size() +} +func (m *TopRURecordItem) XXX_DiscardUnknown() { + xxx_messageInfo_TopRURecordItem.DiscardUnknown(m) +} + +var xxx_messageInfo_TopRURecordItem proto.InternalMessageInfo + +func (m *TopRURecordItem) GetTimestampSec() uint64 { + if m != nil { + return m.TimestampSec + } + return 0 +} + +func (m *TopRURecordItem) GetTotalRu() float64 { + if m != nil { + return m.TotalRu + } + return 0 +} + +func (m *TopRURecordItem) GetExecCount() uint64 { + if m != nil { + return m.ExecCount + } + return 0 +} + +func (m *TopRURecordItem) GetExecDuration() uint64 { + if m != nil { + return m.ExecDuration + } + return 0 +} + type TopSQLRecordItem struct { TimestampSec uint64 `protobuf:"varint,1,opt,name=timestamp_sec,json=timestampSec,proto3" json:"timestamp_sec,omitempty"` CpuTimeMs uint32 `protobuf:"varint,2,opt,name=cpu_time_ms,json=cpuTimeMs,proto3" json:"cpu_time_ms,omitempty"` @@ -112,7 +318,7 @@ func (m *TopSQLRecordItem) Reset() { *m = TopSQLRecordItem{} } func (m *TopSQLRecordItem) String() string { return proto.CompactTextString(m) } func (*TopSQLRecordItem) ProtoMessage() {} func (*TopSQLRecordItem) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{1} + return fileDescriptor_1b19f3a2fcd6965e, []int{3} } func (m *TopSQLRecordItem) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,7 +418,7 @@ func (m *SQLMeta) Reset() { *m = SQLMeta{} } func (m *SQLMeta) String() string { return proto.CompactTextString(m) } func (*SQLMeta) ProtoMessage() {} func (*SQLMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{2} + return fileDescriptor_1b19f3a2fcd6965e, []int{4} } func (m *SQLMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -289,7 +495,7 @@ func (m *PlanMeta) Reset() { *m = PlanMeta{} } func (m *PlanMeta) String() string { return proto.CompactTextString(m) } func (*PlanMeta) ProtoMessage() {} func (*PlanMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{3} + return fileDescriptor_1b19f3a2fcd6965e, []int{5} } func (m *PlanMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -353,7 +559,7 @@ func (m *EmptyResponse) Reset() { *m = EmptyResponse{} } func (m *EmptyResponse) String() string { return proto.CompactTextString(m) } func (*EmptyResponse) ProtoMessage() {} func (*EmptyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{4} + return fileDescriptor_1b19f3a2fcd6965e, []int{6} } func (m *EmptyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -382,14 +588,70 @@ func (m *EmptyResponse) XXX_DiscardUnknown() { var xxx_messageInfo_EmptyResponse proto.InternalMessageInfo +// TopRU-only options +type TopRUConfig struct { + // allowed: 15/30/60; server validates and applies default if 0 + ItemIntervalSeconds ItemInterval `protobuf:"varint,1,opt,name=item_interval_seconds,json=itemIntervalSeconds,proto3,enum=tipb.ItemInterval" json:"item_interval_seconds,omitempty"` +} + +func (m *TopRUConfig) Reset() { *m = TopRUConfig{} } +func (m *TopRUConfig) String() string { return proto.CompactTextString(m) } +func (*TopRUConfig) ProtoMessage() {} +func (*TopRUConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_1b19f3a2fcd6965e, []int{7} +} +func (m *TopRUConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TopRUConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TopRUConfig.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TopRUConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_TopRUConfig.Merge(m, src) +} +func (m *TopRUConfig) XXX_Size() int { + return m.Size() +} +func (m *TopRUConfig) XXX_DiscardUnknown() { + xxx_messageInfo_TopRUConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_TopRUConfig proto.InternalMessageInfo + +func (m *TopRUConfig) GetItemIntervalSeconds() ItemInterval { + if m != nil { + return m.ItemIntervalSeconds + } + return ItemInterval_ITEM_INTERVAL_UNSPECIFIED +} + type TopSQLSubRequest struct { + // Semantics: + // - collectors empty => default enable TOPSQL + // - collectors non-empty => authoritative (only those enabled) + // Examples: + // - TOPSQL only: collectors=[TOPSQL] (or empty) + // - TOPRU only: collectors=[TOPRU] + // - both: collectors=[TOPSQL, TOPRU] + Collectors []CollectorType `protobuf:"varint,1,rep,packed,name=collectors,proto3,enum=tipb.CollectorType" json:"collectors,omitempty"` + // Only used when COLLECTOR_TYPE_TOPRU is present in collectors. + Topru *TopRUConfig `protobuf:"bytes,2,opt,name=topru,proto3" json:"topru,omitempty"` } func (m *TopSQLSubRequest) Reset() { *m = TopSQLSubRequest{} } func (m *TopSQLSubRequest) String() string { return proto.CompactTextString(m) } func (*TopSQLSubRequest) ProtoMessage() {} func (*TopSQLSubRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{5} + return fileDescriptor_1b19f3a2fcd6965e, []int{8} } func (m *TopSQLSubRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -418,11 +680,26 @@ func (m *TopSQLSubRequest) XXX_DiscardUnknown() { var xxx_messageInfo_TopSQLSubRequest proto.InternalMessageInfo +func (m *TopSQLSubRequest) GetCollectors() []CollectorType { + if m != nil { + return m.Collectors + } + return nil +} + +func (m *TopSQLSubRequest) GetTopru() *TopRUConfig { + if m != nil { + return m.Topru + } + return nil +} + type TopSQLSubResponse struct { // Types that are valid to be assigned to RespOneof: // *TopSQLSubResponse_Record // *TopSQLSubResponse_SqlMeta // *TopSQLSubResponse_PlanMeta + // *TopSQLSubResponse_RuRecord RespOneof isTopSQLSubResponse_RespOneof `protobuf_oneof:"resp_oneof"` } @@ -430,7 +707,7 @@ func (m *TopSQLSubResponse) Reset() { *m = TopSQLSubResponse{} } func (m *TopSQLSubResponse) String() string { return proto.CompactTextString(m) } func (*TopSQLSubResponse) ProtoMessage() {} func (*TopSQLSubResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_1b19f3a2fcd6965e, []int{6} + return fileDescriptor_1b19f3a2fcd6965e, []int{9} } func (m *TopSQLSubResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -474,10 +751,14 @@ type TopSQLSubResponse_SqlMeta struct { type TopSQLSubResponse_PlanMeta struct { PlanMeta *PlanMeta `protobuf:"bytes,3,opt,name=plan_meta,json=planMeta,proto3,oneof" json:"plan_meta,omitempty"` } +type TopSQLSubResponse_RuRecord struct { + RuRecord *TopRURecord `protobuf:"bytes,4,opt,name=ru_record,json=ruRecord,proto3,oneof" json:"ru_record,omitempty"` +} func (*TopSQLSubResponse_Record) isTopSQLSubResponse_RespOneof() {} func (*TopSQLSubResponse_SqlMeta) isTopSQLSubResponse_RespOneof() {} func (*TopSQLSubResponse_PlanMeta) isTopSQLSubResponse_RespOneof() {} +func (*TopSQLSubResponse_RuRecord) isTopSQLSubResponse_RespOneof() {} func (m *TopSQLSubResponse) GetRespOneof() isTopSQLSubResponse_RespOneof { if m != nil { @@ -507,22 +788,35 @@ func (m *TopSQLSubResponse) GetPlanMeta() *PlanMeta { return nil } +func (m *TopSQLSubResponse) GetRuRecord() *TopRURecord { + if x, ok := m.GetRespOneof().(*TopSQLSubResponse_RuRecord); ok { + return x.RuRecord + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*TopSQLSubResponse) XXX_OneofWrappers() []interface{} { return []interface{}{ (*TopSQLSubResponse_Record)(nil), (*TopSQLSubResponse_SqlMeta)(nil), (*TopSQLSubResponse_PlanMeta)(nil), + (*TopSQLSubResponse_RuRecord)(nil), } } func init() { + proto.RegisterEnum("tipb.CollectorType", CollectorType_name, CollectorType_value) + proto.RegisterEnum("tipb.ItemInterval", ItemInterval_name, ItemInterval_value) proto.RegisterType((*TopSQLRecord)(nil), "tipb.TopSQLRecord") + proto.RegisterType((*TopRURecord)(nil), "tipb.TopRURecord") + proto.RegisterType((*TopRURecordItem)(nil), "tipb.TopRURecordItem") proto.RegisterType((*TopSQLRecordItem)(nil), "tipb.TopSQLRecordItem") proto.RegisterMapType((map[string]uint64)(nil), "tipb.TopSQLRecordItem.StmtKvExecCountEntry") proto.RegisterType((*SQLMeta)(nil), "tipb.SQLMeta") proto.RegisterType((*PlanMeta)(nil), "tipb.PlanMeta") proto.RegisterType((*EmptyResponse)(nil), "tipb.EmptyResponse") + proto.RegisterType((*TopRUConfig)(nil), "tipb.TopRUConfig") proto.RegisterType((*TopSQLSubRequest)(nil), "tipb.TopSQLSubRequest") proto.RegisterType((*TopSQLSubResponse)(nil), "tipb.TopSQLSubResponse") } @@ -530,58 +824,77 @@ func init() { func init() { proto.RegisterFile("topsql_agent.proto", fileDescriptor_1b19f3a2fcd6965e) } var fileDescriptor_1b19f3a2fcd6965e = []byte{ - // 803 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x4d, 0x6f, 0x1b, 0x55, - 0x14, 0xf5, 0xd4, 0x4e, 0x62, 0x5f, 0xdb, 0x49, 0xfb, 0x92, 0xb4, 0x96, 0x25, 0x4c, 0x65, 0x04, - 0x44, 0x50, 0x5c, 0x70, 0x25, 0xa0, 0xac, 0xc0, 0x34, 0x52, 0x22, 0xda, 0x90, 0xbe, 0xe9, 0x82, - 0xdd, 0x68, 0x66, 0x7c, 0xb1, 0x46, 0x99, 0xf7, 0xe1, 0x79, 0x6f, 0x42, 0xcd, 0xaf, 0x60, 0xc9, - 0x82, 0x0d, 0x3b, 0xc4, 0x8e, 0x1f, 0x81, 0xc4, 0xb2, 0xcb, 0x2e, 0x51, 0x22, 0xf1, 0x3b, 0xd0, - 0xbb, 0x33, 0x4e, 0xc7, 0x49, 0xaa, 0x76, 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0x7b, 0x50, 0xe3, 0x4d, 0x5d, 0x9e, 0x27, 0x1d, 0x80, - 0x0c, 0x8d, 0x0e, 0x94, 0x44, 0xf5, 0xe3, 0xf8, 0x6f, 0x0f, 0xda, 0x45, 0x86, 0x6f, 0xdc, 0x47, - 0x8f, 0x4d, 0x60, 0x9b, 0xa3, 0x56, 0x99, 0xad, 0x06, 0x33, 0xec, 0x9a, 0xb4, 0xfd, 0xed, 0x02, - 0x5b, 0xbd, 0x90, 0xda, 0x9e, 0xc7, 0xbe, 0x80, 0x6e, 0xe1, 0xb1, 0xdc, 0xbe, 0xd5, 0xec, 0xaf, - 0x17, 0x3e, 0x84, 0xcd, 0x42, 0x78, 0xb1, 0x17, 0x97, 0x1a, 0x79, 0xad, 0x74, 0x7c, 0xbc, 0xfc, - 0xf0, 0x1e, 0xe7, 0x91, 0x9f, 0x47, 0xec, 0x6b, 0x68, 0xf9, 0x79, 0x64, 0xe2, 0x2c, 0x89, 0x90, - 0xad, 0x7c, 0x36, 0x5f, 0x4d, 0xaa, 0x7f, 0xe7, 0x0a, 0xbe, 0x74, 0xfc, 0xd4, 0x9b, 0x3c, 0x7c, - 0xf9, 0x47, 0xd3, 0xfb, 0xe7, 0x6c, 0xe0, 0xbd, 0x38, 0x1b, 0x78, 0xff, 0x9e, 0x0d, 0xbc, 0x5f, - 0xce, 0x07, 0xb5, 0x5f, 0xcf, 0x07, 0xb5, 0x17, 0xe7, 0x83, 0xda, 0xcb, 0xf3, 0x41, 0x0d, 0x76, - 0x63, 0x25, 0x46, 0x3a, 0x91, 0xb3, 0x38, 0xd4, 0x23, 0x9b, 0x4c, 0x23, 0xb2, 0x3b, 0xf6, 0xa2, - 0x75, 0xfa, 0x37, 0x78, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0xbf, 0x76, 0x3d, 0x50, - 0x06, 0x00, 0x00, + // 1116 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0x41, 0x6f, 0xdb, 0x46, + 0x13, 0x15, 0x2d, 0xd9, 0x96, 0x46, 0x92, 0x25, 0xaf, 0xad, 0xc4, 0x16, 0x10, 0x7d, 0x81, 0x3e, + 0xb4, 0x31, 0x9c, 0x54, 0x71, 0x64, 0x34, 0x6d, 0x8a, 0x1e, 0x12, 0xc9, 0x0a, 0x2c, 0x54, 0x96, + 0xe5, 0xa5, 0x5c, 0xb4, 0x27, 0x82, 0xa2, 0x36, 0x02, 0x61, 0x92, 0x4b, 0x71, 0x97, 0x6e, 0xd5, + 0x3f, 0xd0, 0x6b, 0x2f, 0x05, 0x7a, 0xe8, 0xa5, 0xb7, 0x5e, 0x8b, 0xfe, 0x89, 0x1e, 0x73, 0xcc, + 0xa1, 0x87, 0xc2, 0x06, 0xfa, 0x3b, 0x8a, 0x5d, 0x92, 0x0a, 0x25, 0xda, 0x88, 0x6f, 0xe4, 0x9b, + 0x37, 0xb3, 0xef, 0xed, 0xcc, 0x10, 0x04, 0xc4, 0xa9, 0xcb, 0xa6, 0x96, 0xa6, 0x4f, 0x88, 0xc3, + 0x1b, 0xae, 0x47, 0x39, 0x45, 0x19, 0x6e, 0xba, 0xa3, 0xea, 0xf6, 0x84, 0x4e, 0xa8, 0x04, 0x9e, + 0x8a, 0xa7, 0x20, 0x56, 0x2d, 0x79, 0x3e, 0xe3, 0xf2, 0x31, 0x00, 0xea, 0xbf, 0x29, 0x50, 0x18, + 0x52, 0x57, 0x3d, 0xeb, 0x61, 0x62, 0x50, 0x6f, 0x8c, 0x1e, 0x00, 0x88, 0x82, 0x63, 0x73, 0x42, + 0x18, 0xdf, 0x51, 0x1e, 0x2a, 0x7b, 0x05, 0x9c, 0x63, 0x53, 0xeb, 0x48, 0x02, 0xe8, 0x7f, 0x90, + 0x77, 0x2d, 0xdd, 0x89, 0xe2, 0x2b, 0x32, 0x0e, 0x02, 0x0a, 0x09, 0x4f, 0x60, 0xd5, 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5, 0xe1, 0x7f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x3d, 0xfa, 0x34, 0x53, 0xa1, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -604,6 +917,8 @@ type TopSQLAgentClient interface { // ReportPlanMeta reports plan meta to the agent. // The agent should deal with plan meta similarly to SQL meta. ReportPlanMeta(ctx context.Context, opts ...grpc.CallOption) (TopSQLAgent_ReportPlanMetaClient, error) + // ReportTopRURecords is called periodically to save the in-memory TopRU records. + ReportTopRURecords(ctx context.Context, opts ...grpc.CallOption) (TopSQLAgent_ReportTopRURecordsClient, error) } type topSQLAgentClient struct { @@ -716,6 +1031,40 @@ func (x *topSQLAgentReportPlanMetaClient) CloseAndRecv() (*EmptyResponse, error) return m, nil } +func (c *topSQLAgentClient) ReportTopRURecords(ctx context.Context, opts ...grpc.CallOption) (TopSQLAgent_ReportTopRURecordsClient, error) { + stream, err := c.cc.NewStream(ctx, &_TopSQLAgent_serviceDesc.Streams[3], "/tipb.TopSQLAgent/ReportTopRURecords", opts...) + if err != nil { + return nil, err + } + x := &topSQLAgentReportTopRURecordsClient{stream} + return x, nil +} + +type TopSQLAgent_ReportTopRURecordsClient interface { + Send(*TopRURecord) error + CloseAndRecv() (*EmptyResponse, error) + grpc.ClientStream +} + +type topSQLAgentReportTopRURecordsClient struct { + grpc.ClientStream +} + +func (x *topSQLAgentReportTopRURecordsClient) Send(m *TopRURecord) error { + return x.ClientStream.SendMsg(m) +} + +func (x *topSQLAgentReportTopRURecordsClient) CloseAndRecv() (*EmptyResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(EmptyResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + // TopSQLAgentServer is the server API for TopSQLAgent service. type TopSQLAgentServer interface { // ReportTopSQLRecords is called periodically (e.g. per minute) to save the in-memory TopSQL records @@ -726,6 +1075,8 @@ type TopSQLAgentServer interface { // ReportPlanMeta reports plan meta to the agent. // The agent should deal with plan meta similarly to SQL meta. ReportPlanMeta(TopSQLAgent_ReportPlanMetaServer) error + // ReportTopRURecords is called periodically to save the in-memory TopRU records. + ReportTopRURecords(TopSQLAgent_ReportTopRURecordsServer) error } // UnimplementedTopSQLAgentServer can be embedded to have forward compatible implementations. @@ -741,6 +1092,9 @@ func (*UnimplementedTopSQLAgentServer) ReportSQLMeta(srv TopSQLAgent_ReportSQLMe func (*UnimplementedTopSQLAgentServer) ReportPlanMeta(srv TopSQLAgent_ReportPlanMetaServer) error { return status.Errorf(codes.Unimplemented, "method ReportPlanMeta not implemented") } +func (*UnimplementedTopSQLAgentServer) ReportTopRURecords(srv TopSQLAgent_ReportTopRURecordsServer) error { + return status.Errorf(codes.Unimplemented, "method ReportTopRURecords not implemented") +} func RegisterTopSQLAgentServer(s *grpc.Server, srv TopSQLAgentServer) { s.RegisterService(&_TopSQLAgent_serviceDesc, srv) @@ -824,6 +1178,32 @@ func (x *topSQLAgentReportPlanMetaServer) Recv() (*PlanMeta, error) { return m, nil } +func _TopSQLAgent_ReportTopRURecords_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TopSQLAgentServer).ReportTopRURecords(&topSQLAgentReportTopRURecordsServer{stream}) +} + +type TopSQLAgent_ReportTopRURecordsServer interface { + SendAndClose(*EmptyResponse) error + Recv() (*TopRURecord, error) + grpc.ServerStream +} + +type topSQLAgentReportTopRURecordsServer struct { + grpc.ServerStream +} + +func (x *topSQLAgentReportTopRURecordsServer) SendAndClose(m *EmptyResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *topSQLAgentReportTopRURecordsServer) Recv() (*TopRURecord, error) { + m := new(TopRURecord) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + var _TopSQLAgent_serviceDesc = grpc.ServiceDesc{ ServiceName: "tipb.TopSQLAgent", HandlerType: (*TopSQLAgentServer)(nil), @@ -844,6 +1224,11 @@ var _TopSQLAgent_serviceDesc = grpc.ServiceDesc{ Handler: _TopSQLAgent_ReportPlanMeta_Handler, ClientStreams: true, }, + { + StreamName: "ReportTopRURecords", + Handler: _TopSQLAgent_ReportTopRURecords_Handler, + ClientStreams: true, + }, }, Metadata: "topsql_agent.proto", } @@ -1009,7 +1394,7 @@ func (m *TopSQLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *TopSQLRecordItem) Marshal() (dAtA []byte, err error) { +func (m *TopRURecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1019,37 +1404,146 @@ func (m *TopSQLRecordItem) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *TopSQLRecordItem) MarshalTo(dAtA []byte) (int, error) { +func (m *TopRURecord) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *TopSQLRecordItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TopRURecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.StmtNetworkOutBytes != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtNetworkOutBytes)) - i-- - dAtA[i] = 0x40 + if len(m.Items) > 0 { + for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTopsqlAgent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } } - if m.StmtNetworkInBytes != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtNetworkInBytes)) + if len(m.PlanDigest) > 0 { + i -= len(m.PlanDigest) + copy(dAtA[i:], m.PlanDigest) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.PlanDigest))) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x22 } - if m.StmtDurationCount != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtDurationCount)) + if len(m.SqlDigest) > 0 { + i -= len(m.SqlDigest) + copy(dAtA[i:], m.SqlDigest) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.SqlDigest))) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x1a } - if m.StmtDurationSumNs != 0 { - i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtDurationSumNs)) + if len(m.User) > 0 { + i -= len(m.User) + copy(dAtA[i:], m.User) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.User))) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x12 } - if len(m.StmtKvExecCount) > 0 { + if len(m.KeyspaceName) > 0 { + i -= len(m.KeyspaceName) + copy(dAtA[i:], m.KeyspaceName) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(len(m.KeyspaceName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TopRURecordItem) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TopRURecordItem) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TopRURecordItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecDuration != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.ExecDuration)) + i-- + dAtA[i] = 0x20 + } + if m.ExecCount != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.ExecCount)) + i-- + dAtA[i] = 0x18 + } + if m.TotalRu != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.TotalRu)))) + i-- + dAtA[i] = 0x11 + } + if m.TimestampSec != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.TimestampSec)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TopSQLRecordItem) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TopSQLRecordItem) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TopSQLRecordItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.StmtNetworkOutBytes != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtNetworkOutBytes)) + i-- + dAtA[i] = 0x40 + } + if m.StmtNetworkInBytes != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtNetworkInBytes)) + i-- + dAtA[i] = 0x38 + } + if m.StmtDurationCount != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtDurationCount)) + i-- + dAtA[i] = 0x30 + } + if m.StmtDurationSumNs != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.StmtDurationSumNs)) + i-- + dAtA[i] = 0x28 + } + if len(m.StmtKvExecCount) > 0 { for k := range m.StmtKvExecCount { v := m.StmtKvExecCount[k] baseI := i @@ -1212,6 +1706,34 @@ func (m *EmptyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TopRUConfig) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TopRUConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TopRUConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ItemIntervalSeconds != 0 { + i = encodeVarintTopsqlAgent(dAtA, i, uint64(m.ItemIntervalSeconds)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *TopSQLSubRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1232,6 +1754,36 @@ func (m *TopSQLSubRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Topru != nil { + { + size, err := m.Topru.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTopsqlAgent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Collectors) > 0 { + dAtA3 := make([]byte, len(m.Collectors)*10) + var j2 int + for _, num := range m.Collectors { + for num >= 1<<7 { + dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j2++ + } + dAtA3[j2] = uint8(num) + j2++ + } + i -= j2 + copy(dAtA[i:], dAtA3[:j2]) + i = encodeVarintTopsqlAgent(dAtA, i, uint64(j2)) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -1330,6 +1882,27 @@ func (m *TopSQLSubResponse_PlanMeta) MarshalToSizedBuffer(dAtA []byte) (int, err } return len(dAtA) - i, nil } +func (m *TopSQLSubResponse_RuRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TopSQLSubResponse_RuRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.RuRecord != nil { + { + size, err := m.RuRecord.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTopsqlAgent(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} func encodeVarintTopsqlAgent(dAtA []byte, offset int, v uint64) int { offset -= sovTopsqlAgent(v) base := offset @@ -1368,6 +1941,58 @@ func (m *TopSQLRecord) Size() (n int) { return n } +func (m *TopRURecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.KeyspaceName) + if l > 0 { + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + l = len(m.User) + if l > 0 { + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + l = len(m.SqlDigest) + if l > 0 { + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + l = len(m.PlanDigest) + if l > 0 { + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + if len(m.Items) > 0 { + for _, e := range m.Items { + l = e.Size() + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + } + return n +} + +func (m *TopRURecordItem) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TimestampSec != 0 { + n += 1 + sovTopsqlAgent(uint64(m.TimestampSec)) + } + if m.TotalRu != 0 { + n += 9 + } + if m.ExecCount != 0 { + n += 1 + sovTopsqlAgent(uint64(m.ExecCount)) + } + if m.ExecDuration != 0 { + n += 1 + sovTopsqlAgent(uint64(m.ExecDuration)) + } + return n +} + func (m *TopSQLRecordItem) Size() (n int) { if m == nil { return 0 @@ -1464,12 +2089,35 @@ func (m *EmptyResponse) Size() (n int) { return n } +func (m *TopRUConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ItemIntervalSeconds != 0 { + n += 1 + sovTopsqlAgent(uint64(m.ItemIntervalSeconds)) + } + return n +} + func (m *TopSQLSubRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l + if len(m.Collectors) > 0 { + l = 0 + for _, e := range m.Collectors { + l += sovTopsqlAgent(uint64(e)) + } + n += 1 + sovTopsqlAgent(uint64(l)) + l + } + if m.Topru != nil { + l = m.Topru.Size() + n += 1 + l + sovTopsqlAgent(uint64(l)) + } return n } @@ -1521,6 +2169,18 @@ func (m *TopSQLSubResponse_PlanMeta) Size() (n int) { } return n } +func (m *TopSQLSubResponse_RuRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.RuRecord != nil { + l = m.RuRecord.Size() + n += 1 + l + sovTopsqlAgent(uint64(l)) + } + return n +} func sovTopsqlAgent(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 @@ -1586,16 +2246,386 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.SqlDigest = append(m.SqlDigest[:0], dAtA[iNdEx:postIndex]...) - if m.SqlDigest == nil { - m.SqlDigest = []byte{} + m.SqlDigest = append(m.SqlDigest[:0], dAtA[iNdEx:postIndex]...) + if m.SqlDigest == nil { + m.SqlDigest = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanDigest", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PlanDigest = append(m.PlanDigest[:0], dAtA[iNdEx:postIndex]...) + if m.PlanDigest == nil { + m.PlanDigest = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, &TopSQLRecordItem{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyspaceName", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyspaceName = append(m.KeyspaceName[:0], dAtA[iNdEx:postIndex]...) + if m.KeyspaceName == nil { + m.KeyspaceName = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTopsqlAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TopRURecord) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TopRURecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TopRURecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyspaceName", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyspaceName = append(m.KeyspaceName[:0], dAtA[iNdEx:postIndex]...) + if m.KeyspaceName == nil { + m.KeyspaceName = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.User = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SqlDigest", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SqlDigest = append(m.SqlDigest[:0], dAtA[iNdEx:postIndex]...) + if m.SqlDigest == nil { + m.SqlDigest = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PlanDigest", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PlanDigest = append(m.PlanDigest[:0], dAtA[iNdEx:postIndex]...) + if m.PlanDigest == nil { + m.PlanDigest = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Items = append(m.Items, &TopRURecordItem{}) + if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTopsqlAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TopRURecordItem) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PlanDigest", wireType) + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TopRURecordItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TopRURecordItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimestampSec", wireType) } - var byteLen int + m.TimestampSec = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTopsqlAgent @@ -1605,31 +2635,27 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.TimestampSec |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthTopsqlAgent - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTopsqlAgent + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalRu", wireType) } - if postIndex > l { + var v uint64 + if (iNdEx + 8) > l { return io.ErrUnexpectedEOF } - m.PlanDigest = append(m.PlanDigest[:0], dAtA[iNdEx:postIndex]...) - if m.PlanDigest == nil { - m.PlanDigest = []byte{} - } - iNdEx = postIndex + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.TotalRu = float64(math.Float64frombits(v)) case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecCount", wireType) } - var msglen int + m.ExecCount = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTopsqlAgent @@ -1639,31 +2665,16 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.ExecCount |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthTopsqlAgent - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTopsqlAgent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Items = append(m.Items, &TopSQLRecordItem{}) - if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KeyspaceName", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecDuration", wireType) } - var byteLen int + m.ExecDuration = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTopsqlAgent @@ -1673,26 +2684,11 @@ func (m *TopSQLRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.ExecDuration |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthTopsqlAgent - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTopsqlAgent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.KeyspaceName = append(m.KeyspaceName[:0], dAtA[iNdEx:postIndex]...) - if m.KeyspaceName == nil { - m.KeyspaceName = []byte{} - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) @@ -2412,6 +3408,75 @@ func (m *EmptyResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *TopRUConfig) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TopRUConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TopRUConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ItemIntervalSeconds", wireType) + } + m.ItemIntervalSeconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ItemIntervalSeconds |= ItemInterval(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTopsqlAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *TopSQLSubRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2441,6 +3506,111 @@ func (m *TopSQLSubRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: TopSQLSubRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType == 0 { + var v CollectorType + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= CollectorType(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Collectors = append(m.Collectors, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + if elementCount != 0 && len(m.Collectors) == 0 { + m.Collectors = make([]CollectorType, 0, elementCount) + } + for iNdEx < postIndex { + var v CollectorType + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= CollectorType(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Collectors = append(m.Collectors, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Collectors", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Topru", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Topru == nil { + m.Topru = &TopRUConfig{} + } + if err := m.Topru.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) @@ -2596,6 +3766,41 @@ func (m *TopSQLSubResponse) Unmarshal(dAtA []byte) error { } m.RespOneof = &TopSQLSubResponse_PlanMeta{v} iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RuRecord", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopsqlAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopsqlAgent + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopsqlAgent + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &TopRURecord{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.RespOneof = &TopSQLSubResponse_RuRecord{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTopsqlAgent(dAtA[iNdEx:]) diff --git a/proto/topsql_agent.proto b/proto/topsql_agent.proto index 96dd3711..44e4a320 100644 --- a/proto/topsql_agent.proto +++ b/proto/topsql_agent.proto @@ -26,6 +26,8 @@ service TopSQLAgent { // ReportPlanMeta reports plan meta to the agent. // The agent should deal with plan meta similarly to SQL meta. rpc ReportPlanMeta(stream PlanMeta) returns (EmptyResponse) {} + // ReportTopRURecords is called periodically to save the in-memory TopRU records. + rpc ReportTopRURecords(stream TopRURecord) returns (EmptyResponse) {} } message TopSQLRecord { @@ -35,6 +37,23 @@ message TopSQLRecord { bytes keyspace_name = 4; } +// TopRURecord represents RU statistics for a single (user, sql_digest, plan_digest) combination. +message TopRURecord { + bytes keyspace_name = 1; + string user = 2; + bytes sql_digest = 3; + bytes plan_digest = 4; + repeated TopRURecordItem items = 5; +} + +// TopRURecordItem represents statistics within a single time bucket. +message TopRURecordItem { + uint64 timestamp_sec = 1; // timestamp in second + double total_ru = 2; // cumulative RU consumption (RRU + WRU) + uint64 exec_count = 3; // execution count + uint64 exec_duration = 4; // cumulative execution time (nanoseconds) +} + message TopSQLRecordItem { uint64 timestamp_sec = 1; // timestamp in second uint32 cpu_time_ms = 2; // this value can be greater than 1000 when counting concurrent running SQL queries @@ -86,12 +105,45 @@ service TopSQLPubSub { rpc Subscribe(TopSQLSubRequest) returns (stream TopSQLSubResponse) {} } -message TopSQLSubRequest {} +enum CollectorType { + COLLECTOR_TYPE_UNSPECIFIED = 0; // For compatibility when this variable is not present. Defaults to COLLECTOR_TYPE_TOPSQL. + COLLECTOR_TYPE_TOPSQL = 1; + COLLECTOR_TYPE_TOPRU = 2; + // future: COLLECTOR_TYPE_XXX = 3; +} + +enum ItemInterval { + ITEM_INTERVAL_UNSPECIFIED = 0; + ITEM_INTERVAL_15S = 15; + ITEM_INTERVAL_30S = 30; + ITEM_INTERVAL_60S = 60; +} + +// TopRU-only options +message TopRUConfig { + // allowed: 15/30/60; server validates and applies default if 0 + ItemInterval item_interval_seconds = 1; +} + +message TopSQLSubRequest { + // Semantics: + // - collectors empty => default enable TOPSQL + // - collectors non-empty => authoritative (only those enabled) + // Examples: + // - TOPSQL only: collectors=[TOPSQL] (or empty) + // - TOPRU only: collectors=[TOPRU] + // - both: collectors=[TOPSQL, TOPRU] + repeated CollectorType collectors = 1; + + // Only used when COLLECTOR_TYPE_TOPRU is present in collectors. + TopRUConfig topru = 2; +} message TopSQLSubResponse { oneof resp_oneof { TopSQLRecord record = 1; SQLMeta sql_meta = 2; PlanMeta plan_meta = 3; + TopRURecord ru_record = 4; } } diff --git a/scripts/proto.lock b/scripts/proto.lock index ebed84a4..eadcc47e 100644 --- a/scripts/proto.lock +++ b/scripts/proto.lock @@ -8383,6 +8383,44 @@ { "protopath": "topsql_agent.proto", "def": { + "enums": [ + { + "name": "CollectorType", + "enum_fields": [ + { + "name": "COLLECTOR_TYPE_UNSPECIFIED" + }, + { + "name": "COLLECTOR_TYPE_TOPSQL", + "integer": 1 + }, + { + "name": "COLLECTOR_TYPE_TOPRU", + "integer": 2 + } + ] + }, + { + "name": "ItemInterval", + "enum_fields": [ + { + "name": "ITEM_INTERVAL_UNSPECIFIED" + }, + { + "name": "ITEM_INTERVAL_15S", + "integer": 15 + }, + { + "name": "ITEM_INTERVAL_30S", + "integer": 30 + }, + { + "name": "ITEM_INTERVAL_60S", + "integer": 60 + } + ] + } + ], "messages": [ { "name": "TopSQLRecord", @@ -8410,6 +8448,62 @@ } ] }, + { + "name": "TopRURecord", + "fields": [ + { + "id": 1, + "name": "keyspace_name", + "type": "bytes" + }, + { + "id": 2, + "name": "user", + "type": "string" + }, + { + "id": 3, + "name": "sql_digest", + "type": "bytes" + }, + { + "id": 4, + "name": "plan_digest", + "type": "bytes" + }, + { + "id": 5, + "name": "items", + "type": "TopRURecordItem", + "is_repeated": true + } + ] + }, + { + "name": "TopRURecordItem", + "fields": [ + { + "id": 1, + "name": "timestamp_sec", + "type": "uint64" + }, + { + "id": 2, + "name": "total_ru", + "type": "double" + }, + { + "id": 3, + "name": "exec_count", + "type": "uint64" + }, + { + "id": 4, + "name": "exec_duration", + "type": "uint64" + } + ] + }, { "name": "TopSQLRecordItem", "fields": [ @@ -8514,7 +8608,30 @@ "name": "EmptyResponse" }, { - "name": "TopSQLSubRequest" + "name": "TopRUConfig", + "fields": [ + { + "id": 1, + "name": "item_interval_seconds", + "type": "ItemInterval" + } + ] + }, + { + "name": "TopSQLSubRequest", + "fields": [ + { + "id": 1, + "name": "collectors", + "type": "CollectorType", + "is_repeated": true + }, + { + "id": 2, + "name": "topru", + "type": "TopRUConfig" + } + ] }, { "name": "TopSQLSubResponse", @@ -8536,6 +8653,12 @@ "name": "plan_meta", "type": "PlanMeta", "oneof_parent": "resp_oneof" + }, + { + "id": 4, + "name": "ru_record", + "type": "TopRURecord", + "oneof_parent": "resp_oneof" } ] } @@ -8561,6 +8684,12 @@ "in_type": "PlanMeta", "out_type": "EmptyResponse", "in_streamed": true + }, + { + "name": "ReportTopRURecords", + "in_type": "TopRURecord", + "out_type": "EmptyResponse", + "in_streamed": true } ] }, @@ -8716,4 +8845,4 @@ } } ] -} \ No newline at end of file +}