From f6640a1a287a86c611f9f14fdd62cf9d73096c45 Mon Sep 17 00:00:00 2001 From: Artem Date: Sat, 30 Nov 2019 20:59:04 -0500 Subject: [PATCH] PR response --- src/query/api/v1/handler/fetch_options.go | 34 +- .../api/v1/handler/fetch_options_test.go | 10 +- src/query/api/v1/handler/prometheus/common.go | 19 +- .../api/v1/handler/prometheus/native/read.go | 4 +- .../prometheus/native/read_instantaneous.go | 4 +- .../prometheus/validator/handler_test.go | 2 - src/query/functions/fetch_test.go | 7 +- src/query/generated/proto/rpcpb/query.pb.go | 724 +++++++++++++----- src/query/generated/proto/rpcpb/query.proto | 11 +- src/query/storage/fanout/storage.go | 8 +- src/query/storage/index.go | 4 +- src/query/storage/m3/cluster_resolver.go | 16 +- src/query/storage/m3/cluster_resolver_test.go | 30 +- src/query/storage/restrict_fetch_options.go | 163 ++++ .../storage/restrict_fetch_options_test.go | 53 ++ src/query/storage/types.go | 106 +-- src/query/tsdb/remote/codecs.go | 115 ++- src/query/tsdb/remote/codecs_test.go | 268 ++++--- 18 files changed, 1109 insertions(+), 469 deletions(-) create mode 100644 src/query/storage/restrict_fetch_options.go create mode 100644 src/query/storage/restrict_fetch_options_test.go diff --git a/src/query/api/v1/handler/fetch_options.go b/src/query/api/v1/handler/fetch_options.go index 0dfe70babe..ce7bddaef1 100644 --- a/src/query/api/v1/handler/fetch_options.go +++ b/src/query/api/v1/handler/fetch_options.go @@ -21,6 +21,7 @@ package handler import ( + "encoding/json" "fmt" "math" "net/http" @@ -30,12 +31,8 @@ import ( "github.com/m3db/m3/src/metrics/policy" "github.com/m3db/m3/src/query/errors" - "github.com/m3db/m3/src/query/models" - parser "github.com/m3db/m3/src/query/parser/promql" "github.com/m3db/m3/src/query/storage" xhttp "github.com/m3db/m3/src/x/net/http" - - "github.com/prometheus/prometheus/promql" ) const ( @@ -118,7 +115,9 @@ func (b fetchOptionsBuilder) NewFetchOptions( } fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - fetchOpts.RestrictFetchOptions.MetricsType = mt + fetchOpts.RestrictFetchOptions.RestrictByType = + newOrExistingRestrictFetchOptionsRestrictByType(fetchOpts) + fetchOpts.RestrictFetchOptions.RestrictByType.MetricsType = mt } if str := req.Header.Get(MetricsStoragePolicyHeader); str != "" { @@ -130,23 +129,19 @@ func (b fetchOptionsBuilder) NewFetchOptions( } fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - fetchOpts.RestrictFetchOptions.StoragePolicy = sp + fetchOpts.RestrictFetchOptions.RestrictByType = + newOrExistingRestrictFetchOptionsRestrictByType(fetchOpts) + fetchOpts.RestrictFetchOptions.RestrictByType.StoragePolicy = sp } if str := req.Header.Get(FetchRestrictLabels); str != "" { - promMatchers, err := promql.ParseMetricSelector(str) - if err != nil { + var opts *storage.RestrictFetchOptions + if err := json.Unmarshal([]byte(str), opts); err != nil { return nil, xhttp.NewParseError(err, http.StatusBadRequest) } fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - // TODO: filter through TagOptions - m3Matchers, err := parser.LabelMatchersToModelMatcher(promMatchers, models.NewTagOptions()) - if err != nil { - return nil, xhttp.NewParseError(err, http.StatusBadRequest) - } - - fetchOpts.RestrictFetchOptions.MustApplyMatchers = m3Matchers + fetchOpts.RestrictFetchOptions.RestrictByTag = opts.RestrictByTag } if restrict := fetchOpts.RestrictFetchOptions; restrict != nil { @@ -186,6 +181,15 @@ func newOrExistingRestrictFetchOptions( return &storage.RestrictFetchOptions{} } +func newOrExistingRestrictFetchOptionsRestrictByType( + fetchOpts *storage.FetchOptions, +) *storage.RestrictByType { + if v := fetchOpts.RestrictFetchOptions.RestrictByType; v != nil { + return v + } + return &storage.RestrictByType{} +} + // ParseStep parses the step duration for an HTTP request. func ParseStep(r *http.Request) (time.Duration, bool, error) { step := r.FormValue(StepParam) diff --git a/src/query/api/v1/handler/fetch_options_test.go b/src/query/api/v1/handler/fetch_options_test.go index d3acd770ae..13b3e87a02 100644 --- a/src/query/api/v1/handler/fetch_options_test.go +++ b/src/query/api/v1/handler/fetch_options_test.go @@ -79,7 +79,9 @@ func TestFetchOptionsBuilder(t *testing.T) { MetricsTypeHeader: storage.UnaggregatedMetricsType.String(), }, expectedRestrict: &storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + }, }, }, { @@ -89,8 +91,10 @@ func TestFetchOptionsBuilder(t *testing.T) { MetricsStoragePolicyHeader: "1m:14d", }, expectedRestrict: &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + }, }, }, { diff --git a/src/query/api/v1/handler/prometheus/common.go b/src/query/api/v1/handler/prometheus/common.go index e4de39ebc0..a2d39fe2ba 100644 --- a/src/query/api/v1/handler/prometheus/common.go +++ b/src/query/api/v1/handler/prometheus/common.go @@ -639,22 +639,15 @@ func FilterSeriesByOptions( series []*ts.Series, opts *storage.FetchOptions, ) []*ts.Series { - if opts == nil || opts.RestrictFetchOptions == nil { + if opts == nil { return series } - matchers := opts.RestrictFetchOptions.MustApplyMatchers - if len(matchers) == 0 { - return series - } - - keys := make([][]byte, 0, len(matchers)) - for _, m := range matchers { - keys = append(keys, m.Name) - } - - for i, s := range series { - series[i].Tags = s.Tags.TagsWithoutKeys(keys) + keys := opts.RestrictFetchOptions.GetRestrictByTag().GetFilterByNames() + if len(keys) > 0 { + for i, s := range series { + series[i].Tags = s.Tags.TagsWithoutKeys(keys) + } } return series diff --git a/src/query/api/v1/handler/prometheus/native/read.go b/src/query/api/v1/handler/prometheus/native/read.go index 0c056f72e0..627dce52b0 100644 --- a/src/query/api/v1/handler/prometheus/native/read.go +++ b/src/query/api/v1/handler/prometheus/native/read.go @@ -146,7 +146,9 @@ func (h *PromReadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { QueryContextOptions: models.QueryContextOptions{ LimitMaxTimeseries: fetchOpts.Limit, }} - if restrictOpts := fetchOpts.RestrictFetchOptions; restrictOpts != nil { + + restrictOpts := fetchOpts.RestrictFetchOptions.GetRestrictByType() + if restrictOpts != nil { restrict := &models.RestrictFetchTypeQueryContextOptions{ MetricsType: uint(restrictOpts.MetricsType), StoragePolicy: restrictOpts.StoragePolicy, diff --git a/src/query/api/v1/handler/prometheus/native/read_instantaneous.go b/src/query/api/v1/handler/prometheus/native/read_instantaneous.go index a8a13094f8..574223ec4a 100644 --- a/src/query/api/v1/handler/prometheus/native/read_instantaneous.go +++ b/src/query/api/v1/handler/prometheus/native/read_instantaneous.go @@ -96,7 +96,9 @@ func (h *PromReadInstantHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques QueryContextOptions: models.QueryContextOptions{ LimitMaxTimeseries: fetchOpts.Limit, }} - if restrictOpts := fetchOpts.RestrictFetchOptions; restrictOpts != nil { + + restrictOpts := fetchOpts.RestrictFetchOptions.GetRestrictByType() + if restrictOpts != nil { restrict := &models.RestrictFetchTypeQueryContextOptions{ MetricsType: uint(restrictOpts.MetricsType), StoragePolicy: restrictOpts.StoragePolicy, diff --git a/src/query/api/v1/handler/prometheus/validator/handler_test.go b/src/query/api/v1/handler/prometheus/validator/handler_test.go index 4c5254dc72..13e6494df6 100644 --- a/src/query/api/v1/handler/prometheus/validator/handler_test.go +++ b/src/query/api/v1/handler/prometheus/validator/handler_test.go @@ -22,7 +22,6 @@ package validator import ( "encoding/json" - "fmt" "io" "net/http" "net/http/httptest" @@ -335,7 +334,6 @@ func TestValidateEndpoint(t *testing.T) { recorder := httptest.NewRecorder() debugHandler.ServeHTTP(recorder, req) - fmt.Println(recorder.Body.String()) var mismatches MismatchesJSON require.NoError(t, json.Unmarshal(recorder.Body.Bytes(), &mismatches)) assert.False(t, mismatches.Correct) diff --git a/src/query/functions/fetch_test.go b/src/query/functions/fetch_test.go index e1832950bd..09230a17da 100644 --- a/src/query/functions/fetch_test.go +++ b/src/query/functions/fetch_test.go @@ -146,7 +146,8 @@ func TestFetchWithRestrictFetch(t *testing.T) { assert.Equal(t, expected, sink.Values) fetchOpts := mockStorage.LastFetchOptions() - require.NotNil(t, fetchOpts.RestrictFetchOptions) - assert.Equal(t, storage.AggregatedMetricsType, storage.MetricsType(fetchOpts.RestrictFetchOptions.MetricsType)) - assert.Equal(t, "10s:42d", fetchOpts.RestrictFetchOptions.StoragePolicy.String()) + restrictByType := fetchOpts.RestrictFetchOptions.GetRestrictByType() + require.NotNil(t, restrictByType) + assert.Equal(t, storage.AggregatedMetricsType, storage.MetricsType(restrictByType.MetricsType)) + assert.Equal(t, "10s:42d", restrictByType.StoragePolicy.String()) } diff --git a/src/query/generated/proto/rpcpb/query.pb.go b/src/query/generated/proto/rpcpb/query.pb.go index 66e8cb275a..10924c7842 100644 --- a/src/query/generated/proto/rpcpb/query.pb.go +++ b/src/query/generated/proto/rpcpb/query.pb.go @@ -35,6 +35,8 @@ TagMatcher FetchOptions RestrictFetchOptions + RestrictFetchType + RestrictFetchTags FetchResponse Series SeriesMetadata @@ -457,9 +459,8 @@ func (m *FetchOptions) GetIncludeResolution() bool { } type RestrictFetchOptions struct { - MetricsType MetricsType `protobuf:"varint,1,opt,name=metricsType,proto3,enum=rpc.MetricsType" json:"metricsType,omitempty"` - MetricsStoragePolicy *policypb.StoragePolicy `protobuf:"bytes,2,opt,name=metricsStoragePolicy" json:"metricsStoragePolicy,omitempty"` - MustApplyMatchers *TagMatchers `protobuf:"bytes,3,opt,name=mustApplyMatchers" json:"mustApplyMatchers,omitempty"` + RestrictFetchType *RestrictFetchType `protobuf:"bytes,1,opt,name=RestrictFetchType" json:"RestrictFetchType,omitempty"` + RestrictFetchTags *RestrictFetchTags `protobuf:"bytes,2,opt,name=RestrictFetchTags" json:"RestrictFetchTags,omitempty"` } func (m *RestrictFetchOptions) Reset() { *m = RestrictFetchOptions{} } @@ -467,23 +468,64 @@ func (m *RestrictFetchOptions) String() string { return proto.Compact func (*RestrictFetchOptions) ProtoMessage() {} func (*RestrictFetchOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{6} } -func (m *RestrictFetchOptions) GetMetricsType() MetricsType { +func (m *RestrictFetchOptions) GetRestrictFetchType() *RestrictFetchType { + if m != nil { + return m.RestrictFetchType + } + return nil +} + +func (m *RestrictFetchOptions) GetRestrictFetchTags() *RestrictFetchTags { + if m != nil { + return m.RestrictFetchTags + } + return nil +} + +type RestrictFetchType struct { + MetricsType MetricsType `protobuf:"varint,1,opt,name=metricsType,proto3,enum=rpc.MetricsType" json:"metricsType,omitempty"` + MetricsStoragePolicy *policypb.StoragePolicy `protobuf:"bytes,2,opt,name=metricsStoragePolicy" json:"metricsStoragePolicy,omitempty"` +} + +func (m *RestrictFetchType) Reset() { *m = RestrictFetchType{} } +func (m *RestrictFetchType) String() string { return proto.CompactTextString(m) } +func (*RestrictFetchType) ProtoMessage() {} +func (*RestrictFetchType) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{7} } + +func (m *RestrictFetchType) GetMetricsType() MetricsType { if m != nil { return m.MetricsType } return MetricsType_UNKNOWN_METRICS_TYPE } -func (m *RestrictFetchOptions) GetMetricsStoragePolicy() *policypb.StoragePolicy { +func (m *RestrictFetchType) GetMetricsStoragePolicy() *policypb.StoragePolicy { if m != nil { return m.MetricsStoragePolicy } return nil } -func (m *RestrictFetchOptions) GetMustApplyMatchers() *TagMatchers { +type RestrictFetchTags struct { + Restrict *TagMatchers `protobuf:"bytes,1,opt,name=restrict" json:"restrict,omitempty"` + Strip [][]byte `protobuf:"bytes,2,rep,name=strip" json:"strip,omitempty"` +} + +func (m *RestrictFetchTags) Reset() { *m = RestrictFetchTags{} } +func (m *RestrictFetchTags) String() string { return proto.CompactTextString(m) } +func (*RestrictFetchTags) ProtoMessage() {} +func (*RestrictFetchTags) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{8} } + +func (m *RestrictFetchTags) GetRestrict() *TagMatchers { if m != nil { - return m.MustApplyMatchers + return m.Restrict + } + return nil +} + +func (m *RestrictFetchTags) GetStrip() [][]byte { + if m != nil { + return m.Strip } return nil } @@ -496,7 +538,7 @@ type FetchResponse struct { func (m *FetchResponse) Reset() { *m = FetchResponse{} } func (m *FetchResponse) String() string { return proto.CompactTextString(m) } func (*FetchResponse) ProtoMessage() {} -func (*FetchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{7} } +func (*FetchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{9} } func (m *FetchResponse) GetSeries() []*Series { if m != nil { @@ -523,7 +565,7 @@ type Series struct { func (m *Series) Reset() { *m = Series{} } func (m *Series) String() string { return proto.CompactTextString(m) } func (*Series) ProtoMessage() {} -func (*Series) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{8} } +func (*Series) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{10} } type isSeries_Value interface { isSeries_Value() @@ -652,7 +694,7 @@ type SeriesMetadata struct { func (m *SeriesMetadata) Reset() { *m = SeriesMetadata{} } func (m *SeriesMetadata) String() string { return proto.CompactTextString(m) } func (*SeriesMetadata) ProtoMessage() {} -func (*SeriesMetadata) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{9} } +func (*SeriesMetadata) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{11} } func (m *SeriesMetadata) GetId() []byte { if m != nil { @@ -683,7 +725,7 @@ type DecompressedSeries struct { func (m *DecompressedSeries) Reset() { *m = DecompressedSeries{} } func (m *DecompressedSeries) String() string { return proto.CompactTextString(m) } func (*DecompressedSeries) ProtoMessage() {} -func (*DecompressedSeries) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{10} } +func (*DecompressedSeries) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{12} } func (m *DecompressedSeries) GetDatapoints() []*Datapoint { if m != nil { @@ -707,7 +749,7 @@ type Datapoint struct { func (m *Datapoint) Reset() { *m = Datapoint{} } func (m *Datapoint) String() string { return proto.CompactTextString(m) } func (*Datapoint) ProtoMessage() {} -func (*Datapoint) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{11} } +func (*Datapoint) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{13} } func (m *Datapoint) GetTimestamp() int64 { if m != nil { @@ -731,7 +773,7 @@ type Tag struct { func (m *Tag) Reset() { *m = Tag{} } func (m *Tag) String() string { return proto.CompactTextString(m) } func (*Tag) ProtoMessage() {} -func (*Tag) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{12} } +func (*Tag) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{14} } func (m *Tag) GetName() []byte { if m != nil { @@ -755,7 +797,7 @@ type M3CompressedSeries struct { func (m *M3CompressedSeries) Reset() { *m = M3CompressedSeries{} } func (m *M3CompressedSeries) String() string { return proto.CompactTextString(m) } func (*M3CompressedSeries) ProtoMessage() {} -func (*M3CompressedSeries) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{13} } +func (*M3CompressedSeries) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{15} } func (m *M3CompressedSeries) GetCompressedTags() []byte { if m != nil { @@ -778,7 +820,7 @@ type M3CompressedValuesReplica struct { func (m *M3CompressedValuesReplica) Reset() { *m = M3CompressedValuesReplica{} } func (m *M3CompressedValuesReplica) String() string { return proto.CompactTextString(m) } func (*M3CompressedValuesReplica) ProtoMessage() {} -func (*M3CompressedValuesReplica) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{14} } +func (*M3CompressedValuesReplica) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{16} } func (m *M3CompressedValuesReplica) GetSegments() []*M3Segments { if m != nil { @@ -795,7 +837,7 @@ type M3Segments struct { func (m *M3Segments) Reset() { *m = M3Segments{} } func (m *M3Segments) String() string { return proto.CompactTextString(m) } func (*M3Segments) ProtoMessage() {} -func (*M3Segments) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{15} } +func (*M3Segments) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{17} } func (m *M3Segments) GetMerged() *M3Segment { if m != nil { @@ -821,7 +863,7 @@ type M3Segment struct { func (m *M3Segment) Reset() { *m = M3Segment{} } func (m *M3Segment) String() string { return proto.CompactTextString(m) } func (*M3Segment) ProtoMessage() {} -func (*M3Segment) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{16} } +func (*M3Segment) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{18} } func (m *M3Segment) GetHead() []byte { if m != nil { @@ -863,7 +905,7 @@ type SearchRequest struct { func (m *SearchRequest) Reset() { *m = SearchRequest{} } func (m *SearchRequest) String() string { return proto.CompactTextString(m) } func (*SearchRequest) ProtoMessage() {} -func (*SearchRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{17} } +func (*SearchRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{19} } type isSearchRequest_Matchers interface { isSearchRequest_Matchers() @@ -975,7 +1017,7 @@ type M3TagProperty struct { func (m *M3TagProperty) Reset() { *m = M3TagProperty{} } func (m *M3TagProperty) String() string { return proto.CompactTextString(m) } func (*M3TagProperty) ProtoMessage() {} -func (*M3TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{18} } +func (*M3TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{20} } func (m *M3TagProperty) GetId() []byte { if m != nil { @@ -998,7 +1040,7 @@ type M3TagProperties struct { func (m *M3TagProperties) Reset() { *m = M3TagProperties{} } func (m *M3TagProperties) String() string { return proto.CompactTextString(m) } func (*M3TagProperties) ProtoMessage() {} -func (*M3TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{19} } +func (*M3TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{21} } func (m *M3TagProperties) GetProperties() []*M3TagProperty { if m != nil { @@ -1015,7 +1057,7 @@ type TagProperty struct { func (m *TagProperty) Reset() { *m = TagProperty{} } func (m *TagProperty) String() string { return proto.CompactTextString(m) } func (*TagProperty) ProtoMessage() {} -func (*TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{20} } +func (*TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{22} } func (m *TagProperty) GetKey() []byte { if m != nil { @@ -1038,7 +1080,7 @@ type TagProperties struct { func (m *TagProperties) Reset() { *m = TagProperties{} } func (m *TagProperties) String() string { return proto.CompactTextString(m) } func (*TagProperties) ProtoMessage() {} -func (*TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{21} } +func (*TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{23} } func (m *TagProperties) GetProperties() []*TagProperty { if m != nil { @@ -1058,7 +1100,7 @@ type SearchResponse struct { func (m *SearchResponse) Reset() { *m = SearchResponse{} } func (m *SearchResponse) String() string { return proto.CompactTextString(m) } func (*SearchResponse) ProtoMessage() {} -func (*SearchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{22} } +func (*SearchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{24} } type isSearchResponse_Value interface { isSearchResponse_Value() @@ -1189,7 +1231,7 @@ type CompleteTagsRequestOptions struct { func (m *CompleteTagsRequestOptions) Reset() { *m = CompleteTagsRequestOptions{} } func (m *CompleteTagsRequestOptions) String() string { return proto.CompactTextString(m) } func (*CompleteTagsRequestOptions) ProtoMessage() {} -func (*CompleteTagsRequestOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{23} } +func (*CompleteTagsRequestOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{25} } func (m *CompleteTagsRequestOptions) GetType() CompleteTagsType { if m != nil { @@ -1236,7 +1278,7 @@ type CompleteTagsRequest struct { func (m *CompleteTagsRequest) Reset() { *m = CompleteTagsRequest{} } func (m *CompleteTagsRequest) String() string { return proto.CompactTextString(m) } func (*CompleteTagsRequest) ProtoMessage() {} -func (*CompleteTagsRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{24} } +func (*CompleteTagsRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{26} } type isCompleteTagsRequest_Matchers interface { isCompleteTagsRequest_Matchers() @@ -1333,7 +1375,7 @@ type TagNames struct { func (m *TagNames) Reset() { *m = TagNames{} } func (m *TagNames) String() string { return proto.CompactTextString(m) } func (*TagNames) ProtoMessage() {} -func (*TagNames) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{25} } +func (*TagNames) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{27} } func (m *TagNames) GetNames() [][]byte { if m != nil { @@ -1350,7 +1392,7 @@ type TagValue struct { func (m *TagValue) Reset() { *m = TagValue{} } func (m *TagValue) String() string { return proto.CompactTextString(m) } func (*TagValue) ProtoMessage() {} -func (*TagValue) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{26} } +func (*TagValue) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{28} } func (m *TagValue) GetKey() []byte { if m != nil { @@ -1373,7 +1415,7 @@ type TagValues struct { func (m *TagValues) Reset() { *m = TagValues{} } func (m *TagValues) String() string { return proto.CompactTextString(m) } func (*TagValues) ProtoMessage() {} -func (*TagValues) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{27} } +func (*TagValues) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{29} } func (m *TagValues) GetValues() []*TagValue { if m != nil { @@ -1393,7 +1435,7 @@ type CompleteTagsResponse struct { func (m *CompleteTagsResponse) Reset() { *m = CompleteTagsResponse{} } func (m *CompleteTagsResponse) String() string { return proto.CompactTextString(m) } func (*CompleteTagsResponse) ProtoMessage() {} -func (*CompleteTagsResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{28} } +func (*CompleteTagsResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{30} } type isCompleteTagsResponse_Value interface { isCompleteTagsResponse_Value() @@ -1522,7 +1564,7 @@ type ResultMetadata struct { func (m *ResultMetadata) Reset() { *m = ResultMetadata{} } func (m *ResultMetadata) String() string { return proto.CompactTextString(m) } func (*ResultMetadata) ProtoMessage() {} -func (*ResultMetadata) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{29} } +func (*ResultMetadata) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{31} } func (m *ResultMetadata) GetExhaustive() bool { if m != nil { @@ -1553,7 +1595,7 @@ type Warning struct { func (m *Warning) Reset() { *m = Warning{} } func (m *Warning) String() string { return proto.CompactTextString(m) } func (*Warning) ProtoMessage() {} -func (*Warning) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{30} } +func (*Warning) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{32} } func (m *Warning) GetName() []byte { if m != nil { @@ -1577,6 +1619,8 @@ func init() { proto.RegisterType((*TagMatcher)(nil), "rpc.TagMatcher") proto.RegisterType((*FetchOptions)(nil), "rpc.FetchOptions") proto.RegisterType((*RestrictFetchOptions)(nil), "rpc.RestrictFetchOptions") + proto.RegisterType((*RestrictFetchType)(nil), "rpc.RestrictFetchType") + proto.RegisterType((*RestrictFetchTags)(nil), "rpc.RestrictFetchTags") proto.RegisterType((*FetchResponse)(nil), "rpc.FetchResponse") proto.RegisterType((*Series)(nil), "rpc.Series") proto.RegisterType((*SeriesMetadata)(nil), "rpc.SeriesMetadata") @@ -2105,6 +2149,44 @@ func (m *RestrictFetchOptions) Marshal() (dAtA []byte, err error) { } func (m *RestrictFetchOptions) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.RestrictFetchType != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.RestrictFetchType.Size())) + n5, err := m.RestrictFetchType.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n5 + } + if m.RestrictFetchTags != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.RestrictFetchTags.Size())) + n6, err := m.RestrictFetchTags.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n6 + } + return i, nil +} + +func (m *RestrictFetchType) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RestrictFetchType) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -2118,21 +2200,47 @@ func (m *RestrictFetchOptions) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.MetricsStoragePolicy.Size())) - n5, err := m.MetricsStoragePolicy.MarshalTo(dAtA[i:]) + n7, err := m.MetricsStoragePolicy.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n5 + i += n7 } - if m.MustApplyMatchers != nil { - dAtA[i] = 0x1a + return i, nil +} + +func (m *RestrictFetchTags) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RestrictFetchTags) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Restrict != nil { + dAtA[i] = 0xa i++ - i = encodeVarintQuery(dAtA, i, uint64(m.MustApplyMatchers.Size())) - n6, err := m.MustApplyMatchers.MarshalTo(dAtA[i:]) + i = encodeVarintQuery(dAtA, i, uint64(m.Restrict.Size())) + n8, err := m.Restrict.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n6 + i += n8 + } + if len(m.Strip) > 0 { + for _, b := range m.Strip { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(b))) + i += copy(dAtA[i:], b) + } } return i, nil } @@ -2168,11 +2276,11 @@ func (m *FetchResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n7, err := m.Meta.MarshalTo(dAtA[i:]) + n9, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n7 + i += n9 } return i, nil } @@ -2196,18 +2304,18 @@ func (m *Series) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n8, err := m.Meta.MarshalTo(dAtA[i:]) + n10, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n8 + i += n10 } if m.Value != nil { - nn9, err := m.Value.MarshalTo(dAtA[i:]) + nn11, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn9 + i += nn11 } return i, nil } @@ -2218,11 +2326,11 @@ func (m *Series_Decompressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) - n10, err := m.Decompressed.MarshalTo(dAtA[i:]) + n12, err := m.Decompressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n10 + i += n12 } return i, nil } @@ -2232,11 +2340,11 @@ func (m *Series_Compressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) - n11, err := m.Compressed.MarshalTo(dAtA[i:]) + n13, err := m.Compressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n13 } return i, nil } @@ -2460,11 +2568,11 @@ func (m *M3Segments) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Merged.Size())) - n12, err := m.Merged.MarshalTo(dAtA[i:]) + n14, err := m.Merged.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n12 + i += n14 } if len(m.Unmerged) > 0 { for _, msg := range m.Unmerged { @@ -2537,11 +2645,11 @@ func (m *SearchRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Matchers != nil { - nn13, err := m.Matchers.MarshalTo(dAtA[i:]) + nn15, err := m.Matchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn13 + i += nn15 } if m.Start != 0 { dAtA[i] = 0x10 @@ -2557,11 +2665,11 @@ func (m *SearchRequest) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n14, err := m.Options.MarshalTo(dAtA[i:]) + n16, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n14 + i += n16 } return i, nil } @@ -2572,11 +2680,11 @@ func (m *SearchRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) - n15, err := m.TagMatchers.MarshalTo(dAtA[i:]) + n17, err := m.TagMatchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n15 + i += n17 } return i, nil } @@ -2716,21 +2824,21 @@ func (m *SearchResponse) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Value != nil { - nn16, err := m.Value.MarshalTo(dAtA[i:]) + nn18, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn16 + i += nn18 } if m.Meta != nil { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n17, err := m.Meta.MarshalTo(dAtA[i:]) + n19, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n17 + i += n19 } return i, nil } @@ -2741,11 +2849,11 @@ func (m *SearchResponse_Decompressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) - n18, err := m.Decompressed.MarshalTo(dAtA[i:]) + n20, err := m.Decompressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n18 + i += n20 } return i, nil } @@ -2755,11 +2863,11 @@ func (m *SearchResponse_Compressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) - n19, err := m.Compressed.MarshalTo(dAtA[i:]) + n21, err := m.Compressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n19 + i += n21 } return i, nil } @@ -2805,11 +2913,11 @@ func (m *CompleteTagsRequestOptions) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x2a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n20, err := m.Options.MarshalTo(dAtA[i:]) + n22, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n20 + i += n22 } return i, nil } @@ -2830,21 +2938,21 @@ func (m *CompleteTagsRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Matchers != nil { - nn21, err := m.Matchers.MarshalTo(dAtA[i:]) + nn23, err := m.Matchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn21 + i += nn23 } if m.Options != nil { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n22, err := m.Options.MarshalTo(dAtA[i:]) + n24, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n22 + i += n24 } return i, nil } @@ -2855,11 +2963,11 @@ func (m *CompleteTagsRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) - n23, err := m.TagMatchers.MarshalTo(dAtA[i:]) + n25, err := m.TagMatchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n23 + i += n25 } return i, nil } @@ -2967,21 +3075,21 @@ func (m *CompleteTagsResponse) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Value != nil { - nn24, err := m.Value.MarshalTo(dAtA[i:]) + nn26, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn24 + i += nn26 } if m.Meta != nil { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n25, err := m.Meta.MarshalTo(dAtA[i:]) + n27, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n25 + i += n27 } return i, nil } @@ -2992,11 +3100,11 @@ func (m *CompleteTagsResponse_Default) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Default.Size())) - n26, err := m.Default.MarshalTo(dAtA[i:]) + n28, err := m.Default.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n26 + i += n28 } return i, nil } @@ -3006,11 +3114,11 @@ func (m *CompleteTagsResponse_NamesOnly) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.NamesOnly.Size())) - n27, err := m.NamesOnly.MarshalTo(dAtA[i:]) + n29, err := m.NamesOnly.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n27 + i += n29 } return i, nil } @@ -3052,22 +3160,22 @@ func (m *ResultMetadata) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Resolutions) > 0 { - dAtA29 := make([]byte, len(m.Resolutions)*10) - var j28 int + dAtA31 := make([]byte, len(m.Resolutions)*10) + var j30 int for _, num1 := range m.Resolutions { num := uint64(num1) for num >= 1<<7 { - dAtA29[j28] = uint8(uint64(num)&0x7f | 0x80) + dAtA31[j30] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j28++ + j30++ } - dAtA29[j28] = uint8(num) - j28++ + dAtA31[j30] = uint8(num) + j30++ } dAtA[i] = 0x1a i++ - i = encodeVarintQuery(dAtA, i, uint64(j28)) - i += copy(dAtA[i:], dAtA29[:j28]) + i = encodeVarintQuery(dAtA, i, uint64(j30)) + i += copy(dAtA[i:], dAtA31[:j30]) } return i, nil } @@ -3216,6 +3324,20 @@ func (m *FetchOptions) Size() (n int) { } func (m *RestrictFetchOptions) Size() (n int) { + var l int + _ = l + if m.RestrictFetchType != nil { + l = m.RestrictFetchType.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.RestrictFetchTags != nil { + l = m.RestrictFetchTags.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *RestrictFetchType) Size() (n int) { var l int _ = l if m.MetricsType != 0 { @@ -3225,10 +3347,22 @@ func (m *RestrictFetchOptions) Size() (n int) { l = m.MetricsStoragePolicy.Size() n += 1 + l + sovQuery(uint64(l)) } - if m.MustApplyMatchers != nil { - l = m.MustApplyMatchers.Size() + return n +} + +func (m *RestrictFetchTags) Size() (n int) { + var l int + _ = l + if m.Restrict != nil { + l = m.Restrict.Size() n += 1 + l + sovQuery(uint64(l)) } + if len(m.Strip) > 0 { + for _, b := range m.Strip { + l = len(b) + n += 1 + l + sovQuery(uint64(l)) + } + } return n } @@ -4421,6 +4555,122 @@ func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: RestrictFetchOptions: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RestrictFetchType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RestrictFetchType == nil { + m.RestrictFetchType = &RestrictFetchType{} + } + if err := m.RestrictFetchType.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RestrictFetchTags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RestrictFetchTags == nil { + m.RestrictFetchTags = &RestrictFetchTags{} + } + if err := m.RestrictFetchTags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RestrictFetchType) 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 ErrIntOverflowQuery + } + 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: RestrictFetchType: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RestrictFetchType: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MetricsType", wireType) @@ -4473,9 +4723,59 @@ func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RestrictFetchTags) 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 ErrIntOverflowQuery + } + 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: RestrictFetchTags: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RestrictFetchTags: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MustApplyMatchers", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Restrict", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4499,13 +4799,42 @@ func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.MustApplyMatchers == nil { - m.MustApplyMatchers = &TagMatchers{} + if m.Restrict == nil { + m.Restrict = &TagMatchers{} } - if err := m.MustApplyMatchers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Restrict.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Strip", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Strip = append(m.Strip, make([]byte, postIndex-iNdEx)) + copy(m.Strip[len(m.Strip)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -7440,105 +7769,108 @@ func init() { } var fileDescriptorQuery = []byte{ - // 1596 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xdd, 0x72, 0x1b, 0xc5, - 0x12, 0xd6, 0x6a, 0xad, 0xbf, 0xd6, 0x8f, 0xe5, 0xb1, 0xcf, 0x89, 0xec, 0x93, 0xe3, 0xe3, 0xda, - 0x03, 0xc1, 0x38, 0xc1, 0x4a, 0xec, 0x84, 0x10, 0xaa, 0x08, 0xc8, 0xb6, 0x62, 0xbb, 0x62, 0x4b, - 0xce, 0x68, 0x4d, 0x02, 0x05, 0x65, 0x56, 0xab, 0x89, 0xbc, 0xe5, 0xfd, 0xcb, 0xee, 0x28, 0xc4, - 0x29, 0x1e, 0x82, 0xe2, 0x15, 0x28, 0x78, 0x82, 0x3c, 0x02, 0x17, 0x5c, 0x72, 0xc7, 0x2d, 0x15, - 0xb8, 0xe0, 0x31, 0xa8, 0x99, 0x9d, 0xfd, 0x93, 0xe4, 0x72, 0x2a, 0x77, 0x3b, 0xdd, 0x5f, 0x77, - 0x4f, 0xf7, 0xf4, 0x7c, 0x3d, 0x12, 0xdc, 0x1f, 0x1a, 0xf4, 0x74, 0xd4, 0x5f, 0xd7, 0x1d, 0xab, - 0x69, 0x6d, 0x0e, 0xfa, 0x4d, 0x6b, 0xb3, 0xe9, 0x7b, 0x7a, 0xf3, 0xd9, 0x88, 0x78, 0xe7, 0xcd, - 0x21, 0xb1, 0x89, 0xa7, 0x51, 0x32, 0x68, 0xba, 0x9e, 0x43, 0x9d, 0xa6, 0xe7, 0xea, 0x6e, 0x3f, - 0xd0, 0xad, 0x73, 0x09, 0x92, 0x3d, 0x57, 0x5f, 0xda, 0xb9, 0xc0, 0x89, 0x45, 0xa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0x1e, 0x1d, 0x56, 0x2c, - 0xc7, 0x49, 0x10, 0x7a, 0x08, 0x0b, 0x62, 0xd9, 0xa3, 0x8e, 0xa7, 0x0d, 0xc9, 0x11, 0xbf, 0x92, - 0xe2, 0x60, 0xae, 0xac, 0x87, 0x57, 0x75, 0x3d, 0xa5, 0xc6, 0x53, 0x8d, 0xd0, 0x7d, 0x98, 0xb3, - 0x46, 0x3e, 0x6d, 0xb9, 0xae, 0x79, 0x7e, 0xd9, 0xad, 0xc0, 0x93, 0x50, 0xe5, 0x6b, 0xa8, 0x8a, - 0x7b, 0x28, 0xee, 0xfb, 0xff, 0x21, 0xef, 0x13, 0xcf, 0x20, 0x61, 0x77, 0x97, 0xb9, 0x97, 0x1e, - 0x17, 0x61, 0xa1, 0x42, 0xef, 0xc1, 0x8c, 0x45, 0xa8, 0x26, 0xb6, 0x3c, 0x1f, 0xf6, 0xd2, 0xc8, - 0xa4, 0x87, 0x84, 0x6a, 0x03, 0x8d, 0x6a, 0x98, 0x03, 0x94, 0x57, 0x12, 0xe4, 0x7b, 0x69, 0x1b, - 0x29, 0x61, 0x13, 0xa8, 0xd2, 0x36, 0xe8, 0x13, 0xa8, 0x0c, 0x88, 0xee, 0x58, 0xae, 0x47, 0x7c, - 0x9f, 0x0c, 0xa2, 0xba, 0x30, 0x83, 0x9d, 0x84, 0x22, 0x30, 0xde, 0xcb, 0xe0, 0x14, 0x1c, 0xdd, - 0x03, 0x48, 0x18, 0xcb, 0x09, 0xe3, 0xc3, 0xcd, 0xed, 0x49, 0xe3, 0x04, 0x78, 0xab, 0x20, 0x6e, - 0xa2, 0xf2, 0x04, 0x6a, 0xe9, 0xad, 0xa1, 0x1a, 0x64, 0x8d, 0x81, 0xb8, 0xb6, 0x59, 0x63, 0x80, - 0xae, 0x42, 0x89, 0x53, 0x94, 0x6a, 0x58, 0x44, 0xf0, 0x53, 0x2c, 0x40, 0x0d, 0x28, 0x10, 0x7b, - 0xc0, 0x75, 0xc1, 0x7d, 0x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x60, 0x42, 0xfe, 0x8b, 0x3b, 0x4c, 0xc2, 0xe3, 0x37, 0x0d, 0x3b, 0xeb, 0xa7, - 0x86, 0x49, 0x89, 0xd7, 0xd1, 0x2c, 0xa2, 0x86, 0x34, 0x57, 0xc1, 0x63, 0xd2, 0xb8, 0x2b, 0xe5, - 0x29, 0x5d, 0x39, 0x33, 0xb5, 0x2b, 0x73, 0x97, 0x75, 0xa5, 0xf2, 0x83, 0x04, 0xf3, 0x53, 0xd2, - 0x78, 0xcb, 0x8b, 0x73, 0x2f, 0x0e, 0x1d, 0xd4, 0xfe, 0x7f, 0x13, 0x89, 0xa7, 0xeb, 0x34, 0xfd, - 0x7a, 0xac, 0x40, 0x51, 0xd5, 0x86, 0x2c, 0x71, 0x9e, 0x35, 0x23, 0xe2, 0xa0, 0x97, 0x2a, 0x38, - 0x58, 0x28, 0xb7, 0x39, 0x82, 0xb3, 0xdf, 0x25, 0xdd, 0x2a, 0x27, 0xba, 0x75, 0x03, 0x4a, 0xa1, - 0x95, 0x8f, 0xde, 0x8d, 0x40, 0x41, 0x97, 0x56, 0xc3, 0xe4, 0xb8, 0x3e, 0xb2, 0xf9, 0x51, 0x82, - 0x85, 0xf4, 0xfe, 0x45, 0x93, 0xae, 0x41, 0x61, 0x40, 0x9e, 0x6a, 0x23, 0x93, 0xa6, 0x28, 0x33, - 0x0a, 0xb0, 0x97, 0xc1, 0x21, 0x00, 0x7d, 0x00, 0x25, 0xbe, 0xef, 0xae, 0x6d, 0x86, 0xef, 0x9e, - 0x28, 0x1c, 0x4f, 0x73, 0x2f, 0x83, 0x63, 0xc4, 0x5b, 0x74, 0xe3, 0x77, 0x50, 0x4b, 0x03, 0xd0, - 0x32, 0x00, 0x79, 0x71, 0xaa, 0x8d, 0x7c, 0x6a, 0x3c, 0x0f, 0xda, 0xb0, 0x88, 0x13, 0x12, 0xb4, - 0x0a, 0xc5, 0x6f, 0x35, 0xcf, 0x36, 0xec, 0x68, 0xac, 0x56, 0x78, 0x9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b4, 0x3b, 0xad, 0xad, 0x83, 0xf6, 0x4e, 0x5d, 0x62, 0xb0, 0x40, 0xb4, 0xb3, 0xdf, - 0x0b, 0x64, 0xd9, 0xb5, 0x1b, 0x50, 0x1f, 0xe7, 0x0a, 0x54, 0x86, 0x82, 0x70, 0x57, 0xcf, 0xb0, - 0x85, 0xda, 0xda, 0xed, 0xb4, 0x0e, 0xdb, 0x75, 0x69, 0xe3, 0x6f, 0x09, 0x72, 0x8f, 0xd8, 0xef, - 0x65, 0x74, 0x0b, 0xf2, 0xc1, 0xaf, 0x59, 0x14, 0x70, 0x65, 0xea, 0xb7, 0xee, 0xd2, 0x7c, 0x4a, - 0x26, 0xba, 0xf8, 0x26, 0xe4, 0x38, 0x31, 0xa0, 0x04, 0x49, 0x84, 0x06, 0x28, 0x29, 0x0a, 0xf0, - 0x37, 0x25, 0xb4, 0xc9, 0x5e, 0xb8, 0x8c, 0xae, 0x45, 0x90, 0xd4, 0xc0, 0x5d, 0x9a, 0x4f, 0xc9, - 0x22, 0xa3, 0x36, 0x54, 0x92, 0x19, 0xa1, 0xc6, 0x45, 0xbc, 0xb0, 0xb4, 0x38, 0x45, 0x13, 0xba, - 0xd9, 0xba, 0xf2, 0xeb, 0xeb, 0x65, 0xe9, 0xb7, 0xd7, 0xcb, 0xd2, 0x1f, 0xaf, 0x97, 0xa5, 0xef, - 0xff, 0x5c, 0xce, 0x7c, 0x99, 0xe3, 0xff, 0x17, 0xf4, 0xf3, 0xfc, 0xf7, 0xfd, 0xe6, 0x3f, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x05, 0x61, 0xfd, 0x0e, 0x6c, 0x10, 0x00, 0x00, + // 1636 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xdb, 0x72, 0xdb, 0x4e, + 0x19, 0xb7, 0xac, 0xf8, 0xf4, 0xf9, 0x10, 0x67, 0x13, 0xfe, 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1, 0x05, 0x4b, 0x36, 0xd7, 0x0d, 0x3d, 0x9c, 0x23, 0x17, 0xd0, 0x63, + 0x28, 0x3b, 0xd4, 0x65, 0xc8, 0xf0, 0x78, 0x95, 0x6a, 0x77, 0x93, 0x27, 0xc4, 0x42, 0x99, 0x18, + 0x44, 0xe8, 0x8a, 0x76, 0xa1, 0x39, 0xb7, 0xac, 0xeb, 0x09, 0xd1, 0xae, 0xc3, 0xdd, 0x97, 0x79, + 0xde, 0x94, 0x1e, 0x3d, 0x86, 0xda, 0xc2, 0x24, 0xb3, 0x99, 0x43, 0x67, 0x0c, 0x76, 0x7c, 0xce, + 0x8d, 0x60, 0xce, 0xc4, 0xb4, 0x16, 0x9e, 0x9f, 0x1f, 0x27, 0xdc, 0xd0, 0x43, 0x80, 0x58, 0x50, + 0xe1, 0xb6, 0xa0, 0x98, 0x13, 0x3a, 0x84, 0xf5, 0x48, 0x62, 0x76, 0x43, 0x7f, 0x4f, 0xa7, 0xad, + 0xe2, 0x6d, 0xb1, 0x59, 0xde, 0x0c, 0xae, 0xba, 0xa9, 0xcd, 0x17, 0x53, 0x8a, 0xa9, 0x6b, 0xcd, + 0x17, 0xbc, 0xb7, 0x52, 0x5b, 0xda, 0x29, 0xe3, 0xb4, 0x41, 0xf9, 0x8b, 0x04, 0x1b, 0x59, 0xb3, + 0x42, 0x7d, 0x58, 0x4b, 0xe8, 0xd9, 0xd6, 0xf0, 0xd1, 0x57, 0xbb, 0x5f, 0xa5, 0x27, 0xcc, 0x37, + 0x2e, 0x1d, 0x90, 0xce, 0x42, 0x66, 0xae, 0xd8, 0xa7, 0xac, 0x2c, 0x64, 0xe6, 0xe2, 0x74, 0x80, + 0xf2, 0x67, 0x29, 0x63, 0x31, 0xa8, 0x0b, 0x55, 0xc1, 0x09, 0xe1, 0xda, 0x42, 0x38, 0x45, 0x7a, + 0x1c, 0x77, 0x42, 0xcf, 0x61, 0x43, 0x88, 0x63, 0xcf, 0x72, 0xc8, 0x8c, 0x9e,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 0x0e, 0x4e, 0x07, + 0xfd, 0xa6, 0xc4, 0xdc, 0x7c, 0x55, 0xff, 0x64, 0xec, 0xeb, 0xf2, 0xbb, 0xf7, 0xa1, 0xb9, 0xcc, + 0x15, 0xa8, 0x0a, 0x25, 0x91, 0xae, 0x99, 0x63, 0x82, 0xda, 0x3b, 0x1a, 0xf6, 0xce, 0x06, 0x4d, + 0xa9, 0xfb, 0x3f, 0x09, 0x0a, 0x2f, 0xd8, 0xa7, 0x3e, 0x7a, 0x08, 0x45, 0xff, 0x43, 0x1c, 0xf9, + 0x5c, 0x99, 0xf8, 0x4c, 0xdf, 0x5a, 0x4f, 0xe8, 0x04, 0x8a, 0x1f, 0x40, 0x81, 0x13, 0x03, 0x8a, + 0x91, 0x44, 0x10, 0x80, 0xe2, 0x2a, 0xdf, 0xff, 0x81, 0x84, 0xf6, 0xd9, 0x0b, 0x97, 0xd1, 0xb5, + 0x28, 0x92, 0xb8, 0x70, 0xb7, 0xd6, 0x13, 0xba, 0x30, 0x68, 0x00, 0xb5, 0x78, 0x47, 0xa8, 0x75, + 0x1b, 0x2f, 0x6c, 0x6d, 0x66, 0x58, 0x82, 0x34, 0x07, 0x77, 0xfe, 0xf9, 0x71, 0x5b, 0xfa, 0xd7, + 0xc7, 0x6d, 0xe9, 0xdf, 0x1f, 0xb7, 0xa5, 0x3f, 0xfe, 0x67, 0x3b, 0xf7, 0xeb, 0x02, 0xff, 0xab, + 0x63, 0x52, 0xe4, 0x7f, 0x4d, 0xec, 0xff, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x3a, 0x1f, 0x39, 0x6d, + 0x27, 0x11, 0x00, 0x00, } diff --git a/src/query/generated/proto/rpcpb/query.proto b/src/query/generated/proto/rpcpb/query.proto index 904c99e274..7fcd180e4d 100644 --- a/src/query/generated/proto/rpcpb/query.proto +++ b/src/query/generated/proto/rpcpb/query.proto @@ -65,9 +65,18 @@ message FetchOptions { } message RestrictFetchOptions { + RestrictFetchType RestrictFetchType = 1; + RestrictFetchTags RestrictFetchTags = 2; +} + +message RestrictFetchType { MetricsType metricsType = 1; policypb.StoragePolicy metricsStoragePolicy = 2; - TagMatchers mustApplyMatchers = 3; +} + +message RestrictFetchTags { + TagMatchers restrict = 1; + repeated bytes strip = 2; } enum MetricsType { diff --git a/src/query/storage/fanout/storage.go b/src/query/storage/fanout/storage.go index 23c2744d4d..4fd988e6ef 100644 --- a/src/query/storage/fanout/storage.go +++ b/src/query/storage/fanout/storage.go @@ -345,14 +345,14 @@ func applyOptions( return result } - matchers := opts.RestrictFetchOptions.MustApplyMatchers - if len(matchers) > 0 { + filter := opts.RestrictFetchOptions.GetRestrictByTag().GetFilterByNames() + if len(filter) > 0 { // Filter out unwanted tags inplace. filteredList := result.CompletedTags[:0] for _, s := range result.CompletedTags { skip := false - for _, filter := range matchers { - if bytes.Equal(s.Name, filter.Name) { + for _, name := range filter { + if bytes.Equal(s.Name, name) { skip = true break } diff --git a/src/query/storage/index.go b/src/query/storage/index.go index f07b558264..58a2790748 100644 --- a/src/query/storage/index.go +++ b/src/query/storage/index.go @@ -125,8 +125,8 @@ func FetchQueryToM3Query( fetchQuery *FetchQuery, options *FetchOptions, ) (index.Query, error) { - withOpts := fetchQuery.WithAppliedOptions(options) - matchers := withOpts.TagMatchers + fetchQuery = fetchQuery.WithAppliedOptions(options) + matchers := fetchQuery.TagMatchers // If no matchers provided, explicitly set this to an AllQuery. if len(matchers) == 0 { return index.Query{ diff --git a/src/query/storage/m3/cluster_resolver.go b/src/query/storage/m3/cluster_resolver.go index 7955cb08b5..b8ecf5cbf7 100644 --- a/src/query/storage/m3/cluster_resolver.go +++ b/src/query/storage/m3/cluster_resolver.go @@ -21,6 +21,7 @@ package m3 import ( + "errors" "fmt" "sort" "time" @@ -301,12 +302,22 @@ func aggregatedNamespaces( func resolveClusterNamespacesForQueryWithRestrictFetchOptions( now, start time.Time, clusters Clusters, - restrict *storage.RestrictFetchOptions, + fetchOptions *storage.RestrictFetchOptions, ) (queryFanoutType, ClusterNamespaces, error) { coversRangeFilter := newCoversRangeFilter(coversRangeFilterOptions{ now: now, queryStart: start, }) + + if fetchOptions == nil { + return 0, nil, errors.New("fetch options must not be nil") + } + + restrict := fetchOptions.RestrictByType + if restrict == nil { + return 0, nil, errors.New("fetch options type restriction must not be nil") + } + result := func( namespace ClusterNamespace, err error, @@ -314,10 +325,12 @@ func resolveClusterNamespacesForQueryWithRestrictFetchOptions( if err != nil { return 0, nil, err } + if coversRangeFilter(namespace) { return namespaceCoversAllQueryRange, ClusterNamespaces{namespace}, nil } + return namespaceCoversPartialQueryRange, ClusterNamespaces{namespace}, nil } @@ -335,6 +348,7 @@ func resolveClusterNamespacesForQueryWithRestrictFetchOptions( fmt.Errorf("could not find namespace for storage policy: %v", restrict.StoragePolicy.String())) } + return result(ns, nil) default: return result(nil, diff --git a/src/query/storage/m3/cluster_resolver_test.go b/src/query/storage/m3/cluster_resolver_test.go index b93b95facf..6bd19a861c 100644 --- a/src/query/storage/m3/cluster_resolver_test.go +++ b/src/query/storage/m3/cluster_resolver_test.go @@ -312,7 +312,9 @@ var testCases = []struct { name: "restrict to unaggregated", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + }, }, expectedType: namespaceCoversPartialQueryRange, expectedClusterNames: []string{"UNAGG"}, @@ -321,9 +323,11 @@ var testCases = []struct { name: "restrict to aggregate filtered", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy( - genResolution.String() + ":" + genRetentionFiltered.String()), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy( + genResolution.String() + ":" + genRetentionFiltered.String()), + }, }, expectedType: namespaceCoversPartialQueryRange, expectedClusterNames: []string{"AGG_FILTERED"}, @@ -332,9 +336,11 @@ var testCases = []struct { name: "restrict to aggregate unfiltered", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy( - genResolution.String() + ":" + genRetentionUnfiltered.String()), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy( + genResolution.String() + ":" + genRetentionUnfiltered.String()), + }, }, expectedType: namespaceCoversPartialQueryRange, expectedClusterNames: []string{"AGG_NO_FILTER"}, @@ -343,7 +349,9 @@ var testCases = []struct { name: "restrict with unknown metrics type", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.UnknownMetricsType, + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnknownMetricsType, + }, }, expectedErrContains: "unrecognized metrics type:", }, @@ -351,8 +359,10 @@ var testCases = []struct { name: "restrict with unknown storage policy", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy("1s:100d"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1s:100d"), + }, }, expectedErrContains: "could not find namespace for storage policy:", }, diff --git a/src/query/storage/restrict_fetch_options.go b/src/query/storage/restrict_fetch_options.go new file mode 100644 index 0000000000..17d1afab06 --- /dev/null +++ b/src/query/storage/restrict_fetch_options.go @@ -0,0 +1,163 @@ +// Copyright (c) 2019 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package storage + +import ( + "bytes" + "fmt" + + "github.com/m3db/m3/src/metrics/policy" + "github.com/m3db/m3/src/query/models" +) + +// Validate will validate the restrict fetch options. +func (o *RestrictFetchOptions) Validate() error { + if o.RestrictByType != nil { + return o.RestrictByType.Validate() + } + + return nil +} + +// GetRestrictByType provides the type restrictions if present; nil otherwise. +func (o *RestrictFetchOptions) GetRestrictByType() *RestrictByType { + if o == nil { + return nil + } + + return o.RestrictByType +} + +// GetRestrictByTag provides the tag restrictions if present; nil otherwise. +func (o *RestrictFetchOptions) GetRestrictByTag() *RestrictByTag { + if o == nil { + return nil + } + + return o.RestrictByTag +} + +// GetMatchers provides the tag matchers by which results are restricted if +// present; nil otherwise. +func (o *RestrictByTag) GetMatchers() models.Matchers { + if o == nil { + return nil + } + + return o.Restrict +} + +// Validate will validate the restrict type restrictions. +func (o *RestrictByType) Validate() error { + switch o.MetricsType { + case UnaggregatedMetricsType: + if o.StoragePolicy != policy.EmptyStoragePolicy { + return fmt.Errorf( + "expected no storage policy for unaggregated metrics type, "+ + "instead got: %v", o.StoragePolicy.String()) + } + case AggregatedMetricsType: + if v := o.StoragePolicy.Resolution().Window; v <= 0 { + return fmt.Errorf( + "expected positive resolution window, instead got: %v", v) + } + if v := o.StoragePolicy.Resolution().Precision; v <= 0 { + return fmt.Errorf( + "expected positive resolution precision, instead got: %v", v) + } + if v := o.StoragePolicy.Retention().Duration(); v <= 0 { + return fmt.Errorf( + "expected positive retention, instead got: %v", v) + } + default: + return fmt.Errorf( + "unknown metrics type: %v", o.MetricsType) + } + return nil +} + +// GetFilterByNames returns the tag names to filter out of the response. +func (o *RestrictByTag) GetFilterByNames() [][]byte { + if o == nil { + return nil + } + + if o.Strip != nil { + return o.Strip + } + + o.Strip = make([][]byte, 0, len(o.Restrict)) + for _, r := range o.Restrict { + o.Strip = append(o.Strip, r.Name) + } + + return o.Strip +} + +// WithAppliedOptions returns a copy of the fetch query applied options +// that restricts the fetch with respect to labels that must be applied. +func (q *FetchQuery) WithAppliedOptions( + opts *FetchOptions, +) *FetchQuery { + result := *q + if opts == nil { + return &result + } + + restrictOpts := opts.RestrictFetchOptions + if restrictOpts == nil { + return &result + } + + restrict := restrictOpts.GetRestrictByTag().GetMatchers() + if len(restrict) == 0 { + return &result + } + + // Since must apply matchers will always be small (usually 1) + // it's better to not allocate intermediate datastructure and just + // perform n^2 matching. + existing := result.TagMatchers + for _, existingMatcher := range result.TagMatchers { + willBeOverridden := false + for _, matcher := range restrict { + if bytes.Equal(existingMatcher.Name, matcher.Name) { + willBeOverridden = true + break + } + } + + if willBeOverridden { + // We'll override this when we append the restrict matchers. + continue + } + + existing = append(existing, existingMatcher) + } + + // Now append the must apply matchers. + result.TagMatchers = append(existing, restrict...) + return &result +} + +func (q *FetchQuery) String() string { + return q.Raw +} diff --git a/src/query/storage/restrict_fetch_options_test.go b/src/query/storage/restrict_fetch_options_test.go new file mode 100644 index 0000000000..9b59c2724b --- /dev/null +++ b/src/query/storage/restrict_fetch_options_test.go @@ -0,0 +1,53 @@ +// Copyright (c) 2019 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package storage + +import ( + "testing" + + "github.com/m3db/m3/src/query/models" + + "github.com/stretchr/testify/require" +) + +func TestGetRestrict(t *testing.T) { + var opts *RestrictFetchOptions + require.Nil(t, opts.GetRestrictByTag()) + require.Nil(t, opts.GetRestrictByType()) + + opts = &RestrictFetchOptions{} + require.Nil(t, opts.GetRestrictByTag()) + require.Nil(t, opts.GetRestrictByType()) + + opts.RestrictByTag = &RestrictByTag{} + require.NotNil(t, opts.GetRestrictByTag()) + + matcher, err := models.NewMatcher(models.MatchEqual, []byte("f"), []byte("b")) + require.NoError(t, err) + matchers := models.Matchers{matcher} + + opts.RestrictByTag.Restrict = matchers + require.Equal(t, matchers, opts.GetRestrictByTag().GetMatchers()) + + byType := &RestrictByType{} + opts.RestrictByType = byType + require.Equal(t, byType, opts.GetRestrictByType()) +} diff --git a/src/query/storage/types.go b/src/query/storage/types.go index 55215adfcb..de1a0e5b11 100644 --- a/src/query/storage/types.go +++ b/src/query/storage/types.go @@ -21,7 +21,6 @@ package storage import ( - "bytes" "context" "fmt" "time" @@ -102,53 +101,6 @@ type FetchQuery struct { Interval time.Duration `json:"interval"` } -// WithAppliedOptions returns a copy of the fetch query applied options -// that restricts the fetch with respect to labels that must be applied. -func (q *FetchQuery) WithAppliedOptions( - opts *FetchOptions, -) *FetchQuery { - result := *q - if opts == nil { - return &result - } - - if restrictOpts := opts.RestrictFetchOptions; restrictOpts != nil { - mustApplyMatchers := restrictOpts.MustApplyMatchers - if n := len(mustApplyMatchers); n > 0 { - existing := result.TagMatchers - result.TagMatchers = make(models.Matchers, 0, len(existing)+n) - // Since must apply matchers will always be small (usually 1) - // it's better to not allocate intermediate datastructure and just - // perform n^2 matching. - for _, existingMatcher := range existing { - willBeOverridden := false - for _, mustApplyMatcher := range mustApplyMatchers { - if bytes.Equal(existingMatcher.Name, mustApplyMatcher.Name) { - willBeOverridden = true - break - } - } - - if willBeOverridden { - // We'll override this when we append the must apply matchers. - continue - } - - result.TagMatchers = append(result.TagMatchers, existingMatcher) - } - - // Now append the must apply matchers. - result.TagMatchers = append(result.TagMatchers, mustApplyMatchers...) - } - } - - return &result -} - -func (q *FetchQuery) String() string { - return q.Raw -} - // FetchOptions represents the options for fetch query. type FetchOptions struct { // Remote is set when this fetch is originated by a remote grpc call. @@ -240,8 +192,10 @@ func (o *FetchOptions) QueryFetchOptions( if r.RestrictFetchOptions == nil && queryCtx.Options.RestrictFetchType != nil { v := queryCtx.Options.RestrictFetchType restrict := RestrictFetchOptions{ - MetricsType: MetricsType(v.MetricsType), - StoragePolicy: v.StoragePolicy, + RestrictByType: &RestrictByType{ + MetricsType: MetricsType(v.MetricsType), + StoragePolicy: v.StoragePolicy, + }, } if err := restrict.Validate(); err != nil { return nil, err @@ -258,46 +212,36 @@ func (o *FetchOptions) Clone() *FetchOptions { return &result } -// RestrictFetchOptions restricts the fetch to a specific set of conditions. -type RestrictFetchOptions struct { +// RestrictByType are specific restrictions to stick to a single data type. +type RestrictByType struct { // MetricsType restricts the type of metrics being returned. MetricsType MetricsType // StoragePolicy is required if metrics type is not unaggregated // to specify which storage policy metrics should be returned from. StoragePolicy policy.StoragePolicy - // MustApplyMatchers is a set of override matchers to apply to a fetch +} + +// RestrictByTag are specific restrictions to enforce behavior for given +// tags. +type RestrictByTag struct { + // Restrict is a set of override matchers to apply to a fetch // regardless of the existing fetch matchers, they should replace any // existing matchers part of a fetch if they collide. - MustApplyMatchers []models.Matcher + Restrict models.Matchers `json:"restrict"` + // Strip is a set of tag names to strip from the response. + // + // NB: If this is unset, but Restrict is set, all tag names appearing in any + // of the Restrict matchers are removed. + Strip [][]byte `json:"strip"` } -// Validate will validate the restrict fetch options. -func (o RestrictFetchOptions) Validate() error { - switch o.MetricsType { - case UnaggregatedMetricsType: - if o.StoragePolicy != policy.EmptyStoragePolicy { - return fmt.Errorf( - "expected no storage policy for unaggregated metrics type, "+ - "instead got: %v", o.StoragePolicy.String()) - } - case AggregatedMetricsType: - if v := o.StoragePolicy.Resolution().Window; v <= 0 { - return fmt.Errorf( - "expected positive resolution window, instead got: %v", v) - } - if v := o.StoragePolicy.Resolution().Precision; v <= 0 { - return fmt.Errorf( - "expected positive resolution precision, instead got: %v", v) - } - if v := o.StoragePolicy.Retention().Duration(); v <= 0 { - return fmt.Errorf( - "expected positive retention, instead got: %v", v) - } - default: - return fmt.Errorf( - "unknown metrics type: %v", o.MetricsType) - } - return nil +// RestrictFetchOptions restricts the fetch to a specific set of conditions. +type RestrictFetchOptions struct { + // RestrictByType are specific restrictions to stick to a single data type. + RestrictByType *RestrictByType + // RestrictByTag are specific restrictions to enforce behavior for given + // tags. + RestrictByTag *RestrictByTag `json:"tags"` } // Querier handles queries against a storage. diff --git a/src/query/tsdb/remote/codecs.go b/src/query/tsdb/remote/codecs.go index e9fb66d374..c11df3e6ff 100644 --- a/src/query/tsdb/remote/codecs.go +++ b/src/query/tsdb/remote/codecs.go @@ -122,9 +122,12 @@ func encodeFetchRequest( } func encodeTagMatchers(modelMatchers models.Matchers) (*rpc.TagMatchers, error) { + if modelMatchers == nil { + return nil, nil + } + matchers := make([]*rpc.TagMatcher, len(modelMatchers)) for i, matcher := range modelMatchers { - fmt.Println("matcher", matcher) t, err := encodeMatcherTypeToProto(matcher.Type) if err != nil { return nil, err @@ -200,15 +203,14 @@ func encodeFetchOptions(options *storage.FetchOptions) (*rpc.FetchOptions, error return result, nil } -func encodeRestrictFetchOptions( - o *storage.RestrictFetchOptions, -) (*rpcpb.RestrictFetchOptions, error) { +func encodeRestrictFetchOptionsByType( + o *storage.RestrictByType, +) (*rpcpb.RestrictFetchType, error) { if err := o.Validate(); err != nil { return nil, err } - result := &rpcpb.RestrictFetchOptions{} - + result := &rpcpb.RestrictFetchType{} switch o.MetricsType { case storage.UnaggregatedMetricsType: result.MetricsType = rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE @@ -223,18 +225,44 @@ func encodeRestrictFetchOptions( result.MetricsStoragePolicy = storagePolicyProto } - if len(o.MustApplyMatchers) > 0 { - fmt.Println("Applhying matchers", o.MustApplyMatchers) - matchers, err := encodeTagMatchers(o.MustApplyMatchers) - if err != nil { - return nil, err - } - fmt.Println(" matchers", matchers) + return result, nil +} - result.MustApplyMatchers = matchers +func encodeRestrictFetchOptionsByTag( + o *storage.RestrictByTag, +) (*rpcpb.RestrictFetchTags, error) { + if o == nil { + return nil, nil } - return result, nil + matchers, err := encodeTagMatchers(o.GetMatchers()) + if err != nil { + return nil, err + } + + return &rpcpb.RestrictFetchTags{ + Restrict: matchers, + Strip: o.Strip, + }, nil +} + +func encodeRestrictFetchOptions( + o *storage.RestrictFetchOptions, +) (*rpcpb.RestrictFetchOptions, error) { + byType, err := encodeRestrictFetchOptionsByType(o.GetRestrictByType()) + if err != nil { + return nil, err + } + + byTags, err := encodeRestrictFetchOptionsByTag(o.GetRestrictByTag()) + if err != nil { + return nil, err + } + + return &rpcpb.RestrictFetchOptions{ + RestrictFetchType: byType, + RestrictFetchTags: byTags, + }, nil } func encodeMatcherTypeToProto(t models.MatchType) (rpc.MatcherType, error) { @@ -346,13 +374,12 @@ func decodeFanoutOption(opt rpc.FanoutOption) (storage.FanoutOption, error) { return 0, fmt.Errorf("unknown fanout option for proto encoding: %v", opt) } -func decodeRestrictFetchOptions( - p *rpc.RestrictFetchOptions, -) (storage.RestrictFetchOptions, error) { - var result storage.RestrictFetchOptions - +func decodeRestrictFetchOptionsByType( + p *rpc.RestrictFetchType, +) (*storage.RestrictByType, error) { + result := &storage.RestrictByType{} if p == nil { - return result, errors.New("no restrict fetch options proto message") + return result, errors.New("no restrict fetch options by type") } switch p.GetMetricsType() { @@ -372,22 +399,44 @@ func decodeRestrictFetchOptions( result.StoragePolicy = storagePolicy } - matchers := p.GetMustApplyMatchers() - if len(matchers.GetTagMatchers()) > 0 { - decodedMatchers, err := decodeTagMatchers(matchers) - if err != nil { - return result, err - } + return result, nil +} + +func decodeRestrictFetchOptionsByTag( + p *rpc.RestrictFetchTags, +) (*storage.RestrictByTag, error) { + if p == nil { + return nil, nil + } - result.MustApplyMatchers = decodedMatchers + matchers, err := decodeTagMatchers(p.GetRestrict()) + if err != nil { + return nil, err } - // Validate the resulting options. - if err := result.Validate(); err != nil { - return result, err + return &storage.RestrictByTag{ + Restrict: matchers, + Strip: p.Strip, + }, nil +} + +func decodeRestrictFetchOptions( + p *rpc.RestrictFetchOptions, +) (*storage.RestrictFetchOptions, error) { + byType, err := decodeRestrictFetchOptionsByType(p.GetRestrictFetchType()) + if err != nil { + return nil, err } - return result, nil + byTag, err := decodeRestrictFetchOptionsByTag(p.GetRestrictFetchTags()) + if err != nil { + return nil, err + } + + return &storage.RestrictFetchOptions{ + RestrictByType: byType, + RestrictByTag: byTag, + }, nil } func decodeFetchOptions(rpcFetchOptions *rpc.FetchOptions) (*storage.FetchOptions, error) { @@ -426,7 +475,7 @@ func decodeFetchOptions(rpcFetchOptions *rpc.FetchOptions) (*storage.FetchOption return nil, err } - result.RestrictFetchOptions = &restrict + result.RestrictFetchOptions = restrict } if v := rpcFetchOptions.LookbackDuration; v > 0 { diff --git a/src/query/tsdb/remote/codecs_test.go b/src/query/tsdb/remote/codecs_test.go index 2d467ef0c0..71fd459de0 100644 --- a/src/query/tsdb/remote/codecs_test.go +++ b/src/query/tsdb/remote/codecs_test.go @@ -133,8 +133,10 @@ func TestEncodeFetchMessage(t *testing.T) { fetchOpts := storage.NewFetchOptions() fetchOpts.Limit = 42 fetchOpts.RestrictFetchOptions = &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + }, } lookback := time.Minute fetchOpts.LookbackDuration = &lookback @@ -155,11 +157,15 @@ func TestEncodeFetchMessage(t *testing.T) { require.NotNil(t, grpcQ.Options) assert.Equal(t, int64(42), grpcQ.Options.Limit) require.NotNil(t, grpcQ.Options.Restrict) - assert.Equal(t, rpc.MetricsType_AGGREGATED_METRICS_TYPE, grpcQ.Options.Restrict.MetricsType) - require.NotNil(t, grpcQ.Options.Restrict.MetricsStoragePolicy) - expectedStoragePolicyProto, err := fetchOpts.RestrictFetchOptions.StoragePolicy.Proto() + require.NotNil(t, grpcQ.Options.Restrict.RestrictFetchType) + assert.Equal(t, rpc.MetricsType_AGGREGATED_METRICS_TYPE, + grpcQ.Options.Restrict.RestrictFetchType.MetricsType) + require.NotNil(t, grpcQ.Options.Restrict.RestrictFetchType.MetricsStoragePolicy) + expectedStoragePolicyProto, err := fetchOpts.RestrictFetchOptions. + RestrictByType.StoragePolicy.Proto() require.NoError(t, err) - assert.Equal(t, expectedStoragePolicyProto, grpcQ.Options.Restrict.MetricsStoragePolicy) + assert.Equal(t, expectedStoragePolicyProto, grpcQ.Options.Restrict. + RestrictFetchType.MetricsStoragePolicy) assert.Equal(t, lookback, time.Duration(grpcQ.Options.LookbackDuration)) } @@ -168,8 +174,10 @@ func TestEncodeDecodeFetchQuery(t *testing.T) { fetchOpts := storage.NewFetchOptions() fetchOpts.Limit = 42 fetchOpts.RestrictFetchOptions = &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + }, } lookback := time.Minute fetchOpts.LookbackDuration = &lookback @@ -183,10 +191,12 @@ func TestEncodeDecodeFetchQuery(t *testing.T) { require.NoError(t, err) require.NotNil(t, revertedOpts) require.Equal(t, fetchOpts.Limit, revertedOpts.Limit) - require.Equal(t, fetchOpts.RestrictFetchOptions.MetricsType, - revertedOpts.RestrictFetchOptions.MetricsType) - require.Equal(t, fetchOpts.RestrictFetchOptions.StoragePolicy.String(), - revertedOpts.RestrictFetchOptions.StoragePolicy.String()) + require.Equal(t, fetchOpts.RestrictFetchOptions. + RestrictByType.MetricsType, + revertedOpts.RestrictFetchOptions.RestrictByType.MetricsType) + require.Equal(t, fetchOpts.RestrictFetchOptions. + RestrictByType.StoragePolicy.String(), + revertedOpts.RestrictFetchOptions.RestrictByType.StoragePolicy.String()) require.NotNil(t, revertedOpts.LookbackDuration) require.Equal(t, lookback, *revertedOpts.LookbackDuration) @@ -230,43 +240,61 @@ func TestRetrieveMetadata(t *testing.T) { func TestNewRestrictFetchOptionsFromProto(t *testing.T) { tests := []struct { value *rpcpb.RestrictFetchOptions - expected storage.RestrictFetchOptions + expected *storage.RestrictFetchOptions errContains string }{ { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + }, }, - expected: storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, + expected: &storage.RestrictFetchOptions{ + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + }, }, }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, }, }, - MustApplyMatchers: &rpc.TagMatchers{ - TagMatchers: []*rpc.TagMatcher{ - newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), - newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + RestrictFetchTags: &rpc.RestrictFetchTags{ + Restrict: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + }, + }, + Strip: [][]byte{ + []byte("foobar"), }, }, }, - expected: storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), - MustApplyMatchers: []models.Matcher{ - mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), - mustNewMatcher(models.MatchEqual, "baz", "qux"), + expected: &storage.RestrictFetchOptions{ + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + }, + RestrictByTag: &storage.RestrictByTag{ + Restrict: []models.Matcher{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + mustNewMatcher(models.MatchEqual, "baz", "qux"), + }, + Strip: [][]byte{ + []byte("foobar"), + }, }, }, }, @@ -276,20 +304,24 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNKNOWN_METRICS_TYPE, + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_UNKNOWN_METRICS_TYPE, + }, }, errContains: "unknown metrics type:", }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, }, }, }, @@ -297,10 +329,12 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: -1, + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: -1, + }, }, }, }, @@ -308,11 +342,13 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(-1), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(-1), + }, }, }, }, @@ -320,14 +356,16 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(-1), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(-1), + }, }, }, }, @@ -335,19 +373,19 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, } for _, test := range tests { - t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { - result, err := decodeRestrictFetchOptions(test.value) - if test.errContains == "" { - require.NoError(t, err) - assert.Equal(t, test.expected, result) - return - } + // t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { + result, err := decodeRestrictFetchOptions(test.value) + if test.errContains == "" { + require.NoError(t, err) + assert.Equal(t, test.expected, result) + return + } - require.Error(t, err) - assert.True(t, - strings.Contains(err.Error(), test.errContains), - fmt.Sprintf("err=%v, want_contains=%v", err.Error(), test.errContains)) - }) + require.Error(t, err) + assert.True(t, + strings.Contains(err.Error(), test.errContains), + fmt.Sprintf("err=%v, want_contains=%v", err.Error(), test.errContains)) + // }) } } @@ -372,66 +410,90 @@ func TestRestrictFetchOptionsProto(t *testing.T) { }{ { value: storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, - MustApplyMatchers: []models.Matcher{ - mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + }, + RestrictByTag: &storage.RestrictByTag{ + Restrict: []models.Matcher{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + }, + Strip: [][]byte{[]byte("foobar")}, }, }, expected: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, - MustApplyMatchers: &rpc.TagMatchers{ - TagMatchers: []*rpc.TagMatcher{ - newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + }, + RestrictFetchTags: &rpcpb.RestrictFetchTags{ + Restrict: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + }, }, + Strip: [][]byte{[]byte("foobar")}, }, }, }, { value: storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), - MustApplyMatchers: []models.Matcher{ - mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), - mustNewMatcher(models.MatchEqual, "baz", "qux"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + }, + RestrictByTag: &storage.RestrictByTag{ + Restrict: models.Matchers{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + mustNewMatcher(models.MatchEqual, "baz", "qux"), + }, + Strip: [][]byte{[]byte("foobar")}, }, }, expected: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, }, }, - MustApplyMatchers: &rpc.TagMatchers{ - TagMatchers: []*rpc.TagMatcher{ - newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), - newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + RestrictFetchTags: &rpcpb.RestrictFetchTags{ + Restrict: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + }, }, + Strip: [][]byte{[]byte("foobar")}, }, }, }, { value: storage.RestrictFetchOptions{ - MetricsType: storage.MetricsType(uint(math.MaxUint16)), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.MetricsType(uint(math.MaxUint16)), + }, }, errContains: "unknown metrics type:", }, { value: storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + }, }, errContains: "expected no storage policy for unaggregated metrics", }, } for _, test := range tests { - t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { + t.Run(fmt.Sprintf("%+v", test.value), func(t *testing.T) { result, err := encodeRestrictFetchOptions(&test.value) if test.errContains == "" { require.NoError(t, err)