From 0ae52982235e98dd03c877c32feb9d8d544a7657 Mon Sep 17 00:00:00 2001 From: gernest Date: Wed, 10 Jul 2024 06:23:49 +0300 Subject: [PATCH] basic search --- gen/go/fri/v1/fri.pb.go | 263 +++++++++++------- go.mod | 4 +- go.sum | 4 +- internal/lbx/bsi.go | 7 +- internal/metrics/metricsproto/metricsproto.go | 3 +- internal/metrics/search.go | 24 +- internal/metrics/search_test.go | 2 +- internal/metrics/testdata/search.json | 178 +++--------- proto/fri/v1/fri.proto | 8 +- 9 files changed, 242 insertions(+), 251 deletions(-) diff --git a/gen/go/fri/v1/fri.pb.go b/gen/go/fri/v1/fri.pb.go index 37e8bec..9a7ce46 100644 --- a/gen/go/fri/v1/fri.pb.go +++ b/gen/go/fri/v1/fri.pb.go @@ -20,6 +20,55 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type Sample_Kind int32 + +const ( + Sample_NONE Sample_Kind = 0 + Sample_FLOAT Sample_Kind = 1 + Sample_HISTOGRAM Sample_Kind = 2 +) + +// Enum value maps for Sample_Kind. +var ( + Sample_Kind_name = map[int32]string{ + 0: "NONE", + 1: "FLOAT", + 2: "HISTOGRAM", + } + Sample_Kind_value = map[string]int32{ + "NONE": 0, + "FLOAT": 1, + "HISTOGRAM": 2, + } +) + +func (x Sample_Kind) Enum() *Sample_Kind { + p := new(Sample_Kind) + *p = x + return p +} + +func (x Sample_Kind) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Sample_Kind) Descriptor() protoreflect.EnumDescriptor { + return file_fri_v1_fri_proto_enumTypes[0].Descriptor() +} + +func (Sample_Kind) Type() protoreflect.EnumType { + return &file_fri_v1_fri_proto_enumTypes[0] +} + +func (x Sample_Kind) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Sample_Kind.Descriptor instead. +func (Sample_Kind) EnumDescriptor() ([]byte, []int) { + return file_fri_v1_fri_proto_rawDescGZIP(), []int{3, 0} +} + type FieldViewInfo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -217,13 +266,13 @@ type Sample struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Series []byte `protobuf:"bytes,1,opt,name=series,proto3" json:"series,omitempty"` - Labels []string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty"` - Exemplars []byte `protobuf:"bytes,3,opt,name=exemplars,proto3" json:"exemplars,omitempty"` - Kind bool `protobuf:"varint,4,opt,name=kind,proto3" json:"kind,omitempty"` - Value float64 `protobuf:"fixed64,5,opt,name=value,proto3" json:"value,omitempty"` - Histogram []byte `protobuf:"bytes,6,opt,name=histogram,proto3" json:"histogram,omitempty"` - Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Series []byte `protobuf:"bytes,1,opt,name=series,proto3" json:"series,omitempty"` + Labels []string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty"` + Exemplars []byte `protobuf:"bytes,3,opt,name=exemplars,proto3" json:"exemplars,omitempty"` + Kind Sample_Kind `protobuf:"varint,4,opt,name=kind,proto3,enum=v1.Sample_Kind" json:"kind,omitempty"` + Value float64 `protobuf:"fixed64,5,opt,name=value,proto3" json:"value,omitempty"` + Histogram []byte `protobuf:"bytes,6,opt,name=histogram,proto3" json:"histogram,omitempty"` + Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (x *Sample) Reset() { @@ -279,11 +328,11 @@ func (x *Sample) GetExemplars() []byte { return nil } -func (x *Sample) GetKind() bool { +func (x *Sample) GetKind() Sample_Kind { if x != nil { return x.Kind } - return false + return Sample_NONE } func (x *Sample) GetValue() float64 { @@ -664,88 +713,92 @@ var file_fri_v1_fri_proto_rawDesc = []byte{ 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x2b, 0x0a, 0x11, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x22, 0xbc, 0x01, 0x0a, 0x06, 0x53, 0x61, 0x6d, 0x70, + 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x22, 0xf9, 0x01, 0x0a, 0x06, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, - 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x69, - 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x68, - 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xe8, 0x07, 0x0a, 0x04, 0x53, 0x70, 0x61, 0x6e, 0x12, - 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x13, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, - 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x63, 0x6f, - 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x61, 0x74, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x63, - 0x6f, 0x70, 0x65, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, - 0x0a, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, - 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x73, 0x70, 0x61, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x61, 0x74, - 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, - 0x73, 0x70, 0x61, 0x6e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x1b, - 0x0a, 0x09, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x73, 0x70, 0x61, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x70, 0x61, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x73, 0x70, 0x61, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2e, 0x0a, 0x13, - 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x70, 0x61, 0x6e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, - 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x73, 0x70, 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x0f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x73, 0x70, 0x61, 0x6e, - 0x5f, 0x69, 0x64, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x6b, 0x53, - 0x70, 0x61, 0x6e, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0d, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x74, 0x72, - 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x69, - 0x6e, 0x6b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6c, 0x69, 0x6b, - 0x6e, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x11, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x0e, 0x6c, 0x69, 0x6b, 0x6e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x12, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, - 0x07, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x73, 0x70, 0x61, 0x6e, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, - 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x74, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2c, - 0x0a, 0x12, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x74, 0x72, 0x61, 0x63, - 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, - 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x17, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x70, 0x61, - 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x18, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x0d, 0x73, 0x70, 0x61, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6e, - 0x6f, 0x12, 0x22, 0x0a, 0x0d, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x61, - 0x6e, 0x6f, 0x18, 0x19, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x73, 0x70, 0x61, 0x6e, 0x45, 0x6e, - 0x64, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x73, - 0x74, 0x61, 0x72, 0x74, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6e, 0x6f, 0x12, - 0x24, 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x61, 0x6e, - 0x6f, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x63, 0x65, 0x45, 0x6e, - 0x64, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x64, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, - 0x72, 0x61, 0x63, 0x65, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, - 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x1d, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0c, 0x73, 0x70, 0x61, 0x6e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x42, 0x64, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x46, 0x72, 0x69, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x65, 0x72, 0x6e, 0x65, 0x73, 0x74, 0x2f, 0x66, 0x72, 0x69, 0x65, - 0x72, 0x65, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x66, 0x72, 0x69, 0x2f, 0x76, - 0x31, 0xa2, 0x02, 0x03, 0x56, 0x58, 0x58, 0xaa, 0x02, 0x02, 0x56, 0x31, 0xca, 0x02, 0x02, 0x56, - 0x31, 0xe2, 0x02, 0x0e, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x02, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x23, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0f, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x4b, 0x69, 0x6e, 0x64, 0x52, + 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x68, + 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, + 0x68, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x2a, 0x0a, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x12, + 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x4c, 0x4f, + 0x41, 0x54, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, + 0x4d, 0x10, 0x02, 0x22, 0xe8, 0x07, 0x0a, 0x04, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x1a, 0x0a, 0x08, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x13, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x41, + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, + 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, + 0x29, 0x0a, 0x10, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x74, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x63, 0x6f, 0x70, 0x65, + 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x63, + 0x6f, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x73, 0x63, 0x6f, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x63, 0x6f, + 0x70, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0c, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, + 0x0a, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x73, 0x70, + 0x61, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, + 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x70, 0x61, + 0x6e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x73, + 0x70, 0x61, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x73, 0x70, 0x61, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x70, 0x61, 0x6e, + 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, + 0x70, 0x61, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x70, 0x61, + 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x70, 0x61, 0x6e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x70, 0x61, + 0x6e, 0x5f, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x70, + 0x61, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, + 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x61, + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, + 0x12, 0x20, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x69, 0x64, + 0x18, 0x0f, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x6b, 0x53, 0x70, 0x61, 0x6e, + 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0d, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x74, 0x72, 0x61, 0x63, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x69, 0x6e, 0x6b, 0x54, + 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6c, 0x69, 0x6b, 0x6e, 0x5f, 0x61, + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0e, 0x6c, 0x69, 0x6b, 0x6e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, + 0x19, 0x0a, 0x08, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x12, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x74, 0x72, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x70, + 0x61, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x70, 0x61, + 0x6e, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x72, 0x6f, 0x6f, + 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x72, + 0x61, 0x63, 0x65, 0x52, 0x6f, 0x6f, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x74, + 0x72, 0x61, 0x63, 0x65, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x74, 0x72, 0x61, 0x63, 0x65, 0x52, 0x6f, + 0x6f, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x72, + 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x17, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, + 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x18, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x0d, 0x73, 0x70, 0x61, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x22, + 0x0a, 0x0d, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, + 0x19, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x73, 0x70, 0x61, 0x6e, 0x45, 0x6e, 0x64, 0x4e, 0x61, + 0x6e, 0x6f, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x74, 0x72, + 0x61, 0x63, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6e, 0x6f, 0x12, 0x24, 0x0a, 0x0e, + 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x61, 0x6e, 0x6f, 0x18, 0x1b, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x63, 0x65, 0x45, 0x6e, 0x64, 0x4e, 0x61, + 0x6e, 0x6f, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x64, 0x75, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, 0x72, 0x61, 0x63, + 0x65, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x70, 0x61, + 0x6e, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x1d, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x0c, 0x73, 0x70, 0x61, 0x6e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x64, + 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x46, 0x72, 0x69, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x67, 0x65, 0x72, 0x6e, 0x65, 0x73, 0x74, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x72, 0x65, 0x6e, + 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x66, 0x72, 0x69, 0x2f, 0x76, 0x31, 0xa2, 0x02, + 0x03, 0x56, 0x58, 0x58, 0xaa, 0x02, 0x02, 0x56, 0x31, 0xca, 0x02, 0x02, 0x56, 0x31, 0xe2, 0x02, + 0x0e, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x02, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -760,26 +813,29 @@ func file_fri_v1_fri_proto_rawDescGZIP() []byte { return file_fri_v1_fri_proto_rawDescData } +var file_fri_v1_fri_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_fri_v1_fri_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_fri_v1_fri_proto_goTypes = []interface{}{ - (*FieldViewInfo)(nil), // 0: v1.FieldViewInfo - (*Shard)(nil), // 1: v1.Shard - (*Entry)(nil), // 2: v1.Entry - (*Sample)(nil), // 3: v1.Sample - (*Span)(nil), // 4: v1.Span - nil, // 5: v1.FieldViewInfo.ShardsEntry - nil, // 6: v1.Shard.BitDepthEntry - (*Entry_StructureMetadata)(nil), // 7: v1.Entry.StructureMetadata + (Sample_Kind)(0), // 0: v1.Sample.Kind + (*FieldViewInfo)(nil), // 1: v1.FieldViewInfo + (*Shard)(nil), // 2: v1.Shard + (*Entry)(nil), // 3: v1.Entry + (*Sample)(nil), // 4: v1.Sample + (*Span)(nil), // 5: v1.Span + nil, // 6: v1.FieldViewInfo.ShardsEntry + nil, // 7: v1.Shard.BitDepthEntry + (*Entry_StructureMetadata)(nil), // 8: v1.Entry.StructureMetadata } var file_fri_v1_fri_proto_depIdxs = []int32{ - 5, // 0: v1.FieldViewInfo.shards:type_name -> v1.FieldViewInfo.ShardsEntry - 6, // 1: v1.Shard.bit_depth:type_name -> v1.Shard.BitDepthEntry - 1, // 2: v1.FieldViewInfo.ShardsEntry.value:type_name -> v1.Shard - 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 + 6, // 0: v1.FieldViewInfo.shards:type_name -> v1.FieldViewInfo.ShardsEntry + 7, // 1: v1.Shard.bit_depth:type_name -> v1.Shard.BitDepthEntry + 0, // 2: v1.Sample.kind:type_name -> v1.Sample.Kind + 2, // 3: v1.FieldViewInfo.ShardsEntry.value:type_name -> v1.Shard + 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_fri_v1_fri_proto_init() } @@ -866,13 +922,14 @@ func file_fri_v1_fri_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_fri_v1_fri_proto_rawDesc, - NumEnums: 0, + NumEnums: 1, NumMessages: 8, NumExtensions: 0, NumServices: 0, }, GoTypes: file_fri_v1_fri_proto_goTypes, DependencyIndexes: file_fri_v1_fri_proto_depIdxs, + EnumInfos: file_fri_v1_fri_proto_enumTypes, MessageInfos: file_fri_v1_fri_proto_msgTypes, }.Build() File_fri_v1_fri_proto = out.File diff --git a/go.mod b/go.mod index 0be5b1e..cf82bad 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/RoaringBitmap/roaring v1.9.4 github.com/blevesearch/vellum v1.0.10 github.com/cespare/xxhash/v2 v2.3.0 - github.com/gernest/rbf v0.22.14 + github.com/gernest/rbf v0.22.15 github.com/gernest/roaring v0.22.3 github.com/gernest/rows v1.22.9 github.com/go-kit/log v0.2.1 @@ -327,3 +327,5 @@ require ( replace github.com/gocql/gocql => github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 exclude k8s.io/client-go v8.0.0+incompatible + +replace github.com/gernest/rbf => ../fusion/rbf diff --git a/go.sum b/go.sum index 116891c..df0031c 100644 --- a/go.sum +++ b/go.sum @@ -334,8 +334,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/fsouza/fake-gcs-server v1.7.0 h1:Un0BXUXrRWYSmYyC1Rqm2e2WJfTPyDy/HGMz31emTi8= github.com/fsouza/fake-gcs-server v1.7.0/go.mod h1:5XIRs4YvwNbNoz+1JF8j6KLAyDh7RHGAyAK3EP2EsNk= -github.com/gernest/rbf v0.22.14 h1:T39F8aLSmvUpuj6WIPCqjtGf+D2iLu3K9pMvcNCGPm4= -github.com/gernest/rbf v0.22.14/go.mod h1:o6zinP4M2yB5SyskHpEYYW5nm/hkJ41gNSbFGuab0Mk= +github.com/gernest/rbf v0.22.15 h1:E2FHfPBypkEltVadIS7p8RaKfqfbAWM6Dd6eJ9/5V70= +github.com/gernest/rbf v0.22.15/go.mod h1:o6zinP4M2yB5SyskHpEYYW5nm/hkJ41gNSbFGuab0Mk= github.com/gernest/roaring v0.22.3 h1:/7uzKzgMsvtYnBndo53oVYti7dc9iQmwvaZDaU3SJ8Q= github.com/gernest/roaring v0.22.3/go.mod h1:7zYgTaDIXI0V6GCZj9u+130yQ3wK0OUxk6cLurb/jeI= github.com/gernest/rows v1.22.9 h1:lCgslJirNMnkDq1mFUBeMfcb0Dcs/yvwtKpk3CDyXR4= diff --git a/internal/lbx/bsi.go b/internal/lbx/bsi.go index 756d6b1..032cdc5 100644 --- a/internal/lbx/bsi.go +++ b/internal/lbx/bsi.go @@ -55,7 +55,8 @@ func BSI(base Data, c *rbf.Cursor, exists *rows.Row, shard uint64, f func(column } func Distinct(c *rbf.Cursor, exists *rows.Row, shard uint64, f func(value uint64, columns *rows.Row) error) error { - data := NewData(exists.Columns()) + cols := exists.Columns() + data := NewData(cols) bitDepth, err := depth(c) if err != nil { return err @@ -78,8 +79,8 @@ func Distinct(c *rbf.Cursor, exists *rows.Row, shard uint64, f func(value uint64 val = uint64((2*(int64(val)>>63) + 1) * int64(val&^(1<<63))) idx[val] = append(idx[val], columnID) } - for row, cols := range idx { - err := f(row, rows.NewRow(cols...)) + for i := range cols { + err := f(cols[i], rows.NewRow(idx[cols[i]]...)) if err != nil { return err } diff --git a/internal/metrics/metricsproto/metricsproto.go b/internal/metrics/metricsproto/metricsproto.go index 283c96f..919841e 100644 --- a/internal/metrics/metricsproto/metricsproto.go +++ b/internal/metrics/metricsproto/metricsproto.go @@ -50,7 +50,7 @@ func fromTS(ts *prompb.TimeSeries, o []*v1.Sample) []*v1.Sample { Series: id, Labels: labels, Exemplars: exemplars, - Kind: true, + Kind: v1.Sample_FLOAT, Value: ts.Samples[i].Value, Timestamp: ts.Samples[i].Timestamp, }) @@ -61,6 +61,7 @@ func fromTS(ts *prompb.TimeSeries, o []*v1.Sample) []*v1.Sample { data, _ := ts.Histograms[i].Marshal() o = append(o, &v1.Sample{ Series: id, + Kind: v1.Sample_HISTOGRAM, Labels: labels, Exemplars: exemplars, Histogram: data, diff --git a/internal/metrics/search.go b/internal/metrics/search.go index 812349d..13d624a 100644 --- a/internal/metrics/search.go +++ b/internal/metrics/search.go @@ -12,6 +12,7 @@ import ( "time" "github.com/blevesearch/vellum" + v1 "github.com/gernest/frieren/gen/go/fri/v1" "github.com/gernest/frieren/internal/lbx" "github.com/gernest/rbf" "github.com/gernest/rbf/dsl" @@ -164,7 +165,8 @@ func (s *Querier) Select(ctx context.Context, sortSeries bool, hints *storage.Se defer r.Release() isSeriesQuery := hints.Func == "series" for i := range s.shards { - r.View(s.shards[i], func(txn *tx.Tx) error { + + err := r.View(s.shards[i], func(txn *tx.Tx) error { r, err := base.Apply(txn, nil) if err != nil { return err @@ -172,6 +174,7 @@ func (s *Querier) Select(ctx context.Context, sortSeries bool, hints *storage.Se if r.IsEmpty() { return nil } + f, err := filter.Apply(txn, r) if err != nil { return err @@ -215,10 +218,17 @@ func (s *Querier) Select(ctx context.Context, sortSeries bool, hints *storage.Se } defer hc.Close() - isHistogram, err := lbx.Histograms(kind, txn) + floats, err := cursor.Row(kind, txn.Shard, uint64(v1.Sample_FLOAT)) + if err != nil { + return err + } + + histograms, err := cursor.Row(kind, txn.Shard, uint64(v1.Sample_HISTOGRAM)) if err != nil { return err } + histograms = histograms.Intersect(f) + return lbx.Distinct(series, f, txn.Shard, func(value uint64, columns *rows.Row) error { cols := columns.Columns() sx, ok := m[value] @@ -241,8 +251,8 @@ func (s *Querier) Select(ctx context.Context, sortSeries bool, hints *storage.Se mapping[cols[i]] = i } data := lbx.NewData(cols) - if isHistogram.Includes(cols[0]) { - // Histogram series + + if histograms.Includes(cols[0]) { hs := &prompb.Histogram{} err = lbx.BSI(data, ts, columns, txn.Shard, func(column uint64, value int64) { hs.Reset() @@ -256,7 +266,8 @@ func (s *Querier) Select(ctx context.Context, sortSeries bool, hints *storage.Se if err != nil { return fmt.Errorf("reading histogram %w", err) } - } else { + } + if floats.Includes(cols[0]) { err = lbx.BSI(data, ts, columns, txn.Shard, func(column uint64, value int64) { chunks[mapping[column]] = &V{ts: value} }) @@ -274,6 +285,9 @@ func (s *Querier) Select(ctx context.Context, sortSeries bool, hints *storage.Se return nil }) }) + if err != nil { + return storage.ErrSeriesSet(err) + } } return NewSeriesSet(m) diff --git a/internal/metrics/search_test.go b/internal/metrics/search_test.go index 4666dab..7f259b5 100644 --- a/internal/metrics/search_test.go +++ b/internal/metrics/search_test.go @@ -32,7 +32,7 @@ func TestSelect(t *testing.T) { require.NoError(t, err) set := qry.Select(context.TODO(), false, &storage.SelectHints{ Start: ms, End: ms, - }, labels.MustNewMatcher(labels.MatchEqual, "service_name", "test-service")) + }, labels.MustNewMatcher(labels.MatchEqual, "job", "test-service")) require.NoError(t, set.Err()) data, err := json.MarshalIndent(matrix(set), "", " ") diff --git a/internal/metrics/testdata/search.json b/internal/metrics/testdata/search.json index db273bd..686e101 100644 --- a/internal/metrics/testdata/search.json +++ b/internal/metrics/testdata/search.json @@ -1,212 +1,136 @@ [ { "metric": { - "__name__": "test_histogram_bucket", - "foo_bar": "baz", + "__name__": "test_histogram_count", "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "le": "2", - "service_instance_id": "test-instance", - "service_name": "test-service" + "le": "5" }, "values": [ [ 1136214240, - "6" + "10" ] ] }, { "metric": { - "__name__": "test_histogram_bucket", + "__name__": "test_histogram_count", "foo_bar": "baz", "host_name": "test-host", - "instance": "test-instance", "job": "test-service", - "le": "+Inf", - "service_instance_id": "test-instance", - "service_name": "test-service" + "le": "1" }, - "values": [ + "histograms": [ [ - 1136214240, - "10" + 0, + { + "count": "0", + "sum": "0" + } ] ] }, { "metric": { - "__name__": "test_histogram_sum", + "__name__": "test_histogram_count", "foo_bar": "baz", "host_name": "test-host", "instance": "test-instance", "job": "test-service", - "service_instance_id": "test-instance", - "service_name": "test-service" + "le": "1" }, "values": [ [ 1136214240, - "30" + "1" ] ] }, { "metric": { - "__name__": "test_exponential_histogram", + "__name__": "test_histogram_count", "foo_bar": "baz", "host_name": "test-host", "instance": "test-instance", "job": "test-service", - "service_instance_id": "test-instance", - "service_name": "test-service" + "le": "1" }, - "histograms": [ + "values": [ [ 1136214240, - { - "count": "10", - "sum": "30", - "buckets": [ - [ - 3, - "-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", - "2" - ], - [ - 0, - "1", - "1.189207115002721", - "2" - ], - [ - 0, - "1.189207115002721", - "1.414213562373095", - "2" - ], - [ - 0, - "1.414213562373095", - "1.6817928305074288", - "2" - ], - [ - 0, - "1.6817928305074288", - "2", - "2" - ], - [ - 0, - "2", - "2.378414230005442", - "2" - ] - ] - } + "10" ] ] }, { "metric": { - "__name__": "test_histogram_bucket", - "foo_bar": "baz", - "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "le": "0", - "service_instance_id": "test-instance", - "service_name": "test-service" + "__name__": "test_histogram_bucket" }, "values": [ [ 1136214240, - "2" + "12" ] ] }, { "metric": { - "__name__": "test_histogram_bucket", - "foo_bar": "baz", - "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "le": "3", - "service_instance_id": "test-instance", - "service_name": "test-service" + "foo_bar": "baz" }, "values": [ [ 1136214240, - "8" + "10" ] ] }, { "metric": { - "__name__": "test_gauge", - "foo_bar": "baz", - "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "service_instance_id": "test-instance", - "service_name": "test-service" + "instance": "test-instance" }, "values": [ [ 1136214240, - "10" + "2" ] ] }, { "metric": { - "__name__": "test_histogram_count", - "foo_bar": "baz", - "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "service_instance_id": "test-instance", - "service_name": "test-service" + "instance": "test-instance" }, "values": [ [ 1136214240, - "10" + "4" ] ] }, { "metric": { - "__name__": "test_histogram_bucket", - "foo_bar": "baz", - "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "le": "4", - "service_instance_id": "test-instance", - "service_name": "test-service" + "job": "test-service" }, "values": [ [ 1136214240, - "10" + "6" ] ] }, { "metric": { - "__name__": "test_counter_total", - "foo_bar": "baz", - "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "service_instance_id": "test-instance", - "service_name": "test-service" + "le": "+Inf" + }, + "values": [ + [ + 1136214240, + "8" + ] + ] + }, + { + "metric": { + "__name__": "test_exponential_histogram" }, "values": [ [ @@ -217,37 +141,23 @@ }, { "metric": { - "__name__": "test_histogram_bucket", - "foo_bar": "baz", - "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "le": "5", - "service_instance_id": "test-instance", - "service_name": "test-service" + "__name__": "target_info" }, "values": [ [ 1136214240, - "12" + "10" ] ] }, { "metric": { - "__name__": "test_histogram_bucket", - "foo_bar": "baz", - "host_name": "test-host", - "instance": "test-instance", - "job": "test-service", - "le": "1", - "service_instance_id": "test-instance", - "service_name": "test-service" + "host_name": "test-host" }, "values": [ [ 1136214240, - "4" + "30" ] ] } diff --git a/proto/fri/v1/fri.proto b/proto/fri/v1/fri.proto index b02d430..6b9203f 100644 --- a/proto/fri/v1/fri.proto +++ b/proto/fri/v1/fri.proto @@ -33,10 +33,16 @@ message Sample { bytes series = 1; repeated string labels = 2; bytes exemplars = 3; - bool kind = 4; + Kind kind = 4; double value = 5; bytes histogram = 6; int64 timestamp = 7; + + enum Kind { + NONE = 0; + FLOAT = 1; + HISTOGRAM = 2; + } } // Span models tempo spans. When retrieving trace by ID we recostruct the