diff --git a/.bingo/minio.sum b/.bingo/minio.sum index e2b5ea4006..670abcfc3b 100644 --- a/.bingo/minio.sum +++ b/.bingo/minio.sum @@ -727,7 +727,6 @@ github.com/goccy/go-json v0.9.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGF github.com/gocql/gocql v0.0.0-20220224095938-0eacd3183625/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofiber/fiber/v2 v2.11.0/go.mod h1:oZTLWqYnqpMMuF922SjGbsYZsdpE1MCfh416HNdweIM= github.com/gofrs/flock v0.0.0-20190320160742-5135e617513b/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= diff --git a/cmd/thanos/query.go b/cmd/thanos/query.go index bbdc3c5d32..c80db1cd23 100644 --- a/cmd/thanos/query.go +++ b/cmd/thanos/query.go @@ -796,7 +796,7 @@ func runQuery( infoSrv := info.NewInfoServer( component.Query.String(), - info.WithLabelSetFunc(func() []labelpb.LabelSet { return proxyStore.LabelSet() }), + info.WithLabelSetFunc(func() []labelpb.ZLabelSet { return proxyStore.LabelSet() }), info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) { if httpProbe.IsReady() { mint, maxt := proxyStore.TimeRange() diff --git a/cmd/thanos/receive.go b/cmd/thanos/receive.go index 985c15bc1e..47d63802a0 100644 --- a/cmd/thanos/receive.go +++ b/cmd/thanos/receive.go @@ -343,7 +343,7 @@ func runReceive( infoSrv := info.NewInfoServer( component.Receive.String(), - info.WithLabelSetFunc(func() []labelpb.LabelSet { return proxy.LabelSet() }), + info.WithLabelSetFunc(func() []labelpb.ZLabelSet { return proxy.LabelSet() }), info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) { if httpProbe.IsReady() { minTime, maxTime := proxy.TimeRange() diff --git a/cmd/thanos/rule.go b/cmd/thanos/rule.go index 10f687c2ee..3fcc452ac6 100644 --- a/cmd/thanos/rule.go +++ b/cmd/thanos/rule.go @@ -739,7 +739,7 @@ func runRule( tsdbStore := store.NewTSDBStore(logger, tsdbDB, component.Rule, conf.lset) infoOptions = append( infoOptions, - info.WithLabelSetFunc(func() []labelpb.LabelSet { + info.WithLabelSetFunc(func() []labelpb.ZLabelSet { return tsdbStore.LabelSet() }), info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) { diff --git a/cmd/thanos/sidecar.go b/cmd/thanos/sidecar.go index b5ce27f94b..91f7feee54 100644 --- a/cmd/thanos/sidecar.go +++ b/cmd/thanos/sidecar.go @@ -312,7 +312,7 @@ func runSidecar( infoSrv := info.NewInfoServer( component.Sidecar.String(), - info.WithLabelSetFunc(func() []labelpb.LabelSet { + info.WithLabelSetFunc(func() []labelpb.ZLabelSet { return promStore.LabelSet() }), info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) { diff --git a/cmd/thanos/store.go b/cmd/thanos/store.go index dbd9886007..d626fe55d8 100644 --- a/cmd/thanos/store.go +++ b/cmd/thanos/store.go @@ -496,7 +496,7 @@ func runStore( infoSrv := info.NewInfoServer( component.Store.String(), - info.WithLabelSetFunc(func() []labelpb.LabelSet { + info.WithLabelSetFunc(func() []labelpb.ZLabelSet { return bs.LabelSet() }), info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) { diff --git a/docs/components/receive.md b/docs/components/receive.md index a8cdf7f350..aedfb3f5af 100644 --- a/docs/components/receive.md +++ b/docs/components/receive.md @@ -311,7 +311,7 @@ Please see the metric `thanos_receive_forward_delay_seconds` to see if you need The following formula is used for calculating quorum: -```go mdox-exec="sed -n '996,1006p' pkg/receive/handler.go" +```go mdox-exec="sed -n '999,1008p' pkg/receive/handler.go" func (h *Handler) writeQuorum() int { // NOTE(GiedriusS): this is here because otherwise RF=2 doesn't make sense as all writes // would need to succeed all the time. Another way to think about it is when migrating @@ -322,7 +322,6 @@ func (h *Handler) writeQuorum() int { } return int((h.options.ReplicationFactor / 2) + 1) } - ``` So, if the replication factor is 2 then at least one write must succeed. With RF=3, two writes must succeed, and so on. diff --git a/go.mod b/go.mod index 15259cea37..c3b72969a2 100644 --- a/go.mod +++ b/go.mod @@ -121,6 +121,7 @@ require ( github.com/onsi/gomega v1.34.2 github.com/prometheus-community/prom-label-proxy v0.8.1-0.20240127162815-c1195f9aabc0 go.opentelemetry.io/contrib/propagators/autoprop v0.54.0 + go4.org/intern v0.0.0-20230525184215-6c62f75575cb golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 ) @@ -263,7 +264,6 @@ require ( go.opentelemetry.io/otel/metric v1.29.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/multierr v1.11.0 // indirect - go4.org/intern v0.0.0-20230525184215-6c62f75575cb golang.org/x/mod v0.20.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect golang.org/x/sys v0.25.0 // indirect diff --git a/pkg/api/query/grpc.go b/pkg/api/query/grpc.go index 7d43022f53..093457dd06 100644 --- a/pkg/api/query/grpc.go +++ b/pkg/api/query/grpc.go @@ -130,7 +130,7 @@ func (g *GRPCAPI) Query(request *querypb.QueryRequest, server querypb.Query_Quer for _, sample := range vector { floats, histograms := prompb.SamplesFromPromqlSamples(sample) series := &prompb.TimeSeries{ - Labels: labelpb.PromLabelsToLabelpbLabels(sample.Metric), + Labels: labelpb.ZLabelsFromPromLabels(sample.Metric), Samples: floats, Histograms: histograms, } @@ -243,7 +243,7 @@ func (g *GRPCAPI) QueryRange(request *querypb.QueryRangeRequest, srv querypb.Que for _, series := range value { floats, histograms := prompb.SamplesFromPromqlSeries(series) series := &prompb.TimeSeries{ - Labels: labelpb.PromLabelsToLabelpbLabels(series.Metric), + Labels: labelpb.ZLabelsFromPromLabels(series.Metric), Samples: floats, Histograms: histograms, } @@ -255,7 +255,7 @@ func (g *GRPCAPI) QueryRange(request *querypb.QueryRangeRequest, srv querypb.Que for _, sample := range value { floats, histograms := prompb.SamplesFromPromqlSamples(sample) series := &prompb.TimeSeries{ - Labels: labelpb.PromLabelsToLabelpbLabels(sample.Metric), + Labels: labelpb.ZLabelsFromPromLabels(sample.Metric), Samples: floats, Histograms: histograms, } diff --git a/pkg/api/query/v1_test.go b/pkg/api/query/v1_test.go index bc94d4d35b..923a9cf411 100644 --- a/pkg/api/query/v1_test.go +++ b/pkg/api/query/v1_test.go @@ -1790,7 +1790,7 @@ func TestRulesHandler(t *testing.T) { EvaluationDurationSeconds: 12, Health: "x", Query: "sum(up)", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label"}}}, LastError: "err1", }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ @@ -1799,7 +1799,7 @@ func TestRulesHandler(t *testing.T) { EvaluationDurationSeconds: 12, Health: "x", Query: "sum(up1)", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label2"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label2"}}}, }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "3", @@ -1809,12 +1809,12 @@ func TestRulesHandler(t *testing.T) { Query: "sum(up2) == 2", DurationSeconds: 101, KeepFiringForSeconds: 102, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label3"}}}, - Annotations: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "ann", Value: "a1"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label3"}}}, + Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "ann", Value: "a1"}}}, Alerts: []*rulespb.AlertInstance{ { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "inside", Value: "1"}}}, - Annotations: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "insideann", Value: "2"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "inside", Value: "1"}}}, + Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "insideann", Value: "2"}}}, State: rulespb.AlertState_FIRING, ActiveAt: &twoHAgo, Value: "1", @@ -1822,8 +1822,8 @@ func TestRulesHandler(t *testing.T) { PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "inside", Value: "3"}}}, - Annotations: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "insideann", Value: "4"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "inside", Value: "3"}}}, + Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "insideann", Value: "4"}}}, State: rulespb.AlertState_PENDING, ActiveAt: nil, Value: "2", @@ -1841,7 +1841,7 @@ func TestRulesHandler(t *testing.T) { DurationSeconds: 102, KeepFiringForSeconds: 103, Query: "sum(up3) == 3", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label4"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label4"}}}, State: rulespb.AlertState_INACTIVE, }), rulespb.NewAlertingRule(&rulespb.Alert{ @@ -1852,7 +1852,7 @@ func TestRulesHandler(t *testing.T) { DurationSeconds: 61, KeepFiringForSeconds: 62, Query: "sum(up4) == 4", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label5"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label5"}}}, State: rulespb.AlertState_INACTIVE, }), } @@ -1913,7 +1913,7 @@ func TestRulesHandler(t *testing.T) { testpromcompatibility.RecordingRule{ Name: all[0].GetRecording().Name, Query: all[0].GetRecording().Query, - Labels: labelpb.LabelpbLabelsToPromLabels(all[0].GetRecording().Labels.Labels), + Labels: labelpb.ZLabelsToPromLabels(all[0].GetRecording().Labels.Labels), Health: rules.RuleHealth(all[0].GetRecording().Health), LastError: all[0].GetRecording().LastError, LastEvaluation: all[0].GetRecording().LastEvaluation, @@ -1923,7 +1923,7 @@ func TestRulesHandler(t *testing.T) { testpromcompatibility.RecordingRule{ Name: all[1].GetRecording().Name, Query: all[1].GetRecording().Query, - Labels: labelpb.LabelpbLabelsToPromLabels(all[1].GetRecording().Labels.Labels), + Labels: labelpb.ZLabelsToPromLabels(all[1].GetRecording().Labels.Labels), Health: rules.RuleHealth(all[1].GetRecording().Health), LastError: all[1].GetRecording().LastError, LastEvaluation: all[1].GetRecording().LastEvaluation, @@ -1934,26 +1934,26 @@ func TestRulesHandler(t *testing.T) { State: strings.ToLower(all[2].GetAlert().State.String()), Name: all[2].GetAlert().Name, Query: all[2].GetAlert().Query, - Labels: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Labels.Labels), + Labels: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Labels.Labels), Health: rules.RuleHealth(all[2].GetAlert().Health), LastError: all[2].GetAlert().LastError, LastEvaluation: all[2].GetAlert().LastEvaluation, EvaluationTime: all[2].GetAlert().EvaluationDurationSeconds, Duration: all[2].GetAlert().DurationSeconds, KeepFiringFor: all[2].GetAlert().KeepFiringForSeconds, - Annotations: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Annotations.Labels), + Annotations: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Annotations.Labels), Alerts: []*testpromcompatibility.Alert{ { - Labels: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Alerts[0].Labels.Labels), - Annotations: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Alerts[0].Annotations.Labels), + Labels: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[0].Labels.Labels), + Annotations: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[0].Annotations.Labels), State: strings.ToLower(all[2].GetAlert().Alerts[0].State.String()), ActiveAt: all[2].GetAlert().Alerts[0].ActiveAt, Value: all[2].GetAlert().Alerts[0].Value, PartialResponseStrategy: all[2].GetAlert().Alerts[0].PartialResponseStrategy.String(), }, { - Labels: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Alerts[1].Labels.Labels), - Annotations: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Alerts[1].Annotations.Labels), + Labels: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[1].Labels.Labels), + Annotations: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[1].Annotations.Labels), State: strings.ToLower(all[2].GetAlert().Alerts[1].State.String()), ActiveAt: all[2].GetAlert().Alerts[1].ActiveAt, Value: all[2].GetAlert().Alerts[1].Value, @@ -1966,7 +1966,7 @@ func TestRulesHandler(t *testing.T) { State: strings.ToLower(all[3].GetAlert().State.String()), Name: all[3].GetAlert().Name, Query: all[3].GetAlert().Query, - Labels: labelpb.LabelpbLabelsToPromLabels(all[3].GetAlert().Labels.Labels), + Labels: labelpb.ZLabelsToPromLabels(all[3].GetAlert().Labels.Labels), Health: rules.RuleHealth(all[2].GetAlert().Health), LastError: all[3].GetAlert().LastError, LastEvaluation: all[3].GetAlert().LastEvaluation, @@ -1981,7 +1981,7 @@ func TestRulesHandler(t *testing.T) { State: strings.ToLower(all[4].GetAlert().State.String()), Name: all[4].GetAlert().Name, Query: all[4].GetAlert().Query, - Labels: labelpb.LabelpbLabelsToPromLabels(all[4].GetAlert().Labels.Labels), + Labels: labelpb.ZLabelsToPromLabels(all[4].GetAlert().Labels.Labels), Health: rules.RuleHealth(all[2].GetAlert().Health), LastError: all[4].GetAlert().LastError, LastEvaluation: all[4].GetAlert().LastEvaluation, diff --git a/pkg/exemplars/exemplars.go b/pkg/exemplars/exemplars.go index 3e16fa2a7b..9638074bd0 100644 --- a/pkg/exemplars/exemplars.go +++ b/pkg/exemplars/exemplars.go @@ -110,7 +110,7 @@ func dedupExemplarsResponse(exemplarsData []*exemplarspb.ExemplarData, replicaLa continue } e.SeriesLabels.Labels = removeReplicaLabels(e.SeriesLabels.Labels, replicaLabels) - h := labelpb.LabelpbLabelsToPromLabels(e.SeriesLabels.Labels).Hash() + h := labelpb.ZLabelsToPromLabels(e.SeriesLabels.Labels).Hash() if ref, ok := hashToExemplar[h]; ok { ref.Exemplars = append(ref.Exemplars, e.Exemplars...) } else { @@ -155,11 +155,11 @@ func dedupExemplars(exemplars []*exemplarspb.Exemplar) []*exemplarspb.Exemplar { return exemplars[:i+1] } -func removeReplicaLabels(labels []labelpb.Label, replicaLabels map[string]struct{}) []labelpb.Label { +func removeReplicaLabels(labels []labelpb.ZLabel, replicaLabels map[string]struct{}) []labelpb.ZLabel { if len(replicaLabels) == 0 { return labels } - newLabels := make([]labelpb.Label, 0, len(labels)) + newLabels := make([]labelpb.ZLabel, 0, len(labels)) for _, l := range labels { if _, ok := replicaLabels[l.Name]; !ok { newLabels = append(newLabels, l) diff --git a/pkg/exemplars/exemplars_test.go b/pkg/exemplars/exemplars_test.go index ef9535ca02..daea15182a 100644 --- a/pkg/exemplars/exemplars_test.go +++ b/pkg/exemplars/exemplars_test.go @@ -36,7 +36,7 @@ func TestDedupExemplarsResponse(t *testing.T) { name: "empty exemplars data", exemplars: []*exemplarspb.ExemplarData{ { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__name__", Value: "test_exemplar_metric_total"}, {Name: "instance", Value: "localhost:8090"}, {Name: "job", Value: "prometheus"}, @@ -51,7 +51,7 @@ func TestDedupExemplarsResponse(t *testing.T) { replicaLabels: []string{"replica"}, exemplars: []*exemplarspb.ExemplarData{ { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__name__", Value: "test_exemplar_metric_total"}, {Name: "instance", Value: "localhost:8090"}, {Name: "job", Value: "prometheus"}, @@ -60,14 +60,14 @@ func TestDedupExemplarsResponse(t *testing.T) { }}, Exemplars: []*exemplarspb.Exemplar{ { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "EpTxMJ40fUus7aGY"}, }}, Value: 19, Ts: 1600096955479, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "EpTxMJ40fUus7aGY"}, }}, Value: 19, @@ -76,7 +76,7 @@ func TestDedupExemplarsResponse(t *testing.T) { }, }, { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__name__", Value: "test_exemplar_metric_total"}, {Name: "instance", Value: "localhost:8090"}, {Name: "job", Value: "prometheus"}, @@ -85,7 +85,7 @@ func TestDedupExemplarsResponse(t *testing.T) { }}, Exemplars: []*exemplarspb.Exemplar{ { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "EpTxMJ40fUus7aGY"}, }}, Value: 19, @@ -96,7 +96,7 @@ func TestDedupExemplarsResponse(t *testing.T) { }, want: []*exemplarspb.ExemplarData{ { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__name__", Value: "test_exemplar_metric_total"}, {Name: "instance", Value: "localhost:8090"}, {Name: "job", Value: "prometheus"}, @@ -104,7 +104,7 @@ func TestDedupExemplarsResponse(t *testing.T) { }}, Exemplars: []*exemplarspb.Exemplar{ { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "EpTxMJ40fUus7aGY"}, }}, Value: 19, @@ -119,7 +119,7 @@ func TestDedupExemplarsResponse(t *testing.T) { replicaLabels: []string{"replica"}, exemplars: []*exemplarspb.ExemplarData{ { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__name__", Value: "test_exemplar_metric_total"}, {Name: "instance", Value: "localhost:8090"}, {Name: "job", Value: "prometheus"}, @@ -128,14 +128,14 @@ func TestDedupExemplarsResponse(t *testing.T) { }}, Exemplars: []*exemplarspb.Exemplar{ { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "EpTxMJ40fUus7aGY"}, }}, Value: 19, Ts: 1600096955479, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "foo"}, }}, Value: 19, @@ -144,7 +144,7 @@ func TestDedupExemplarsResponse(t *testing.T) { }, }, { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__name__", Value: "test_exemplar_metric_total"}, {Name: "instance", Value: "localhost:8090"}, {Name: "job", Value: "prometheus"}, @@ -153,14 +153,14 @@ func TestDedupExemplarsResponse(t *testing.T) { }}, Exemplars: []*exemplarspb.Exemplar{ { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "bar"}, }}, Value: 19, Ts: 1600096955579, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "EpTxMJ40fUus7aGY"}, }}, Value: 19, @@ -168,7 +168,7 @@ func TestDedupExemplarsResponse(t *testing.T) { }, // Same ts but different labels, cannot dedup. { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "test"}, }}, Value: 19, @@ -179,7 +179,7 @@ func TestDedupExemplarsResponse(t *testing.T) { }, want: []*exemplarspb.ExemplarData{ { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__name__", Value: "test_exemplar_metric_total"}, {Name: "instance", Value: "localhost:8090"}, {Name: "job", Value: "prometheus"}, @@ -187,28 +187,28 @@ func TestDedupExemplarsResponse(t *testing.T) { }}, Exemplars: []*exemplarspb.Exemplar{ { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "foo"}, }}, Value: 19, Ts: 1600096955470, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "EpTxMJ40fUus7aGY"}, }}, Value: 19, Ts: 1600096955479, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "test"}, }}, Value: 19, Ts: 1600096955479, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "traceID", Value: "bar"}, }}, Value: 19, diff --git a/pkg/exemplars/exemplarspb/custom.go b/pkg/exemplars/exemplarspb/custom.go index 14d8dd6a12..b636d98faf 100644 --- a/pkg/exemplars/exemplarspb/custom.go +++ b/pkg/exemplars/exemplarspb/custom.go @@ -23,7 +23,7 @@ type ExemplarStore struct { // UnmarshalJSON implements json.Unmarshaler. func (m *Exemplar) UnmarshalJSON(b []byte) error { v := struct { - Labels labelpb.LabelSet + Labels labelpb.ZLabelSet TimeStamp model.Time Value model.SampleValue }{} @@ -45,7 +45,7 @@ func (m *Exemplar) MarshalJSON() ([]byte, error) { TimeStamp model.Time `json:"timestamp"` Value model.SampleValue `json:"value"` }{ - Labels: labelpb.LabelpbLabelsToPromLabels(m.Labels.Labels), + Labels: labelpb.ZLabelsToPromLabels(m.Labels.Labels), TimeStamp: model.Time(m.Ts), Value: model.SampleValue(m.Value), } @@ -74,10 +74,10 @@ func (s1 *ExemplarData) Compare(s2 *ExemplarData) int { } func (s *ExemplarData) SetSeriesLabels(ls labels.Labels) { - var result labelpb.LabelSet + var result labelpb.ZLabelSet if !ls.IsEmpty() { - result = labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(ls)} + result = labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(ls)} } s.SeriesLabels = result @@ -102,7 +102,7 @@ func ExemplarsFromPromExemplars(exemplars []exemplar.Exemplar) []*Exemplar { ex := make([]*Exemplar, 0, len(exemplars)) for _, e := range exemplars { ex = append(ex, &Exemplar{ - Labels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(e.Labels)}, + Labels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(e.Labels)}, Value: e.Value, Ts: e.Ts, }) diff --git a/pkg/exemplars/exemplarspb/rpc.pb.go b/pkg/exemplars/exemplarspb/rpc.pb.go index 784c966649..886a140aea 100644 --- a/pkg/exemplars/exemplarspb/rpc.pb.go +++ b/pkg/exemplars/exemplarspb/rpc.pb.go @@ -157,8 +157,8 @@ func (*ExemplarsResponse) XXX_OneofWrappers() []interface{} { } type ExemplarData struct { - SeriesLabels labelpb.LabelSet `protobuf:"bytes,1,opt,name=seriesLabels,proto3" json:"seriesLabels"` - Exemplars []*Exemplar `protobuf:"bytes,2,rep,name=exemplars,proto3" json:"exemplars"` + SeriesLabels labelpb.ZLabelSet `protobuf:"bytes,1,opt,name=seriesLabels,proto3" json:"seriesLabels"` + Exemplars []*Exemplar `protobuf:"bytes,2,rep,name=exemplars,proto3" json:"exemplars"` } func (m *ExemplarData) Reset() { *m = ExemplarData{} } @@ -195,9 +195,9 @@ func (m *ExemplarData) XXX_DiscardUnknown() { var xxx_messageInfo_ExemplarData proto.InternalMessageInfo type Exemplar struct { - Labels labelpb.LabelSet `protobuf:"bytes,1,opt,name=labels,proto3" json:"labels"` - Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value"` - Ts int64 `protobuf:"varint,3,opt,name=ts,proto3" json:"timestamp"` + Labels labelpb.ZLabelSet `protobuf:"bytes,1,opt,name=labels,proto3" json:"labels"` + Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value"` + Ts int64 `protobuf:"varint,3,opt,name=ts,proto3" json:"timestamp"` } func (m *Exemplar) Reset() { *m = Exemplar{} } @@ -243,36 +243,37 @@ func init() { func init() { proto.RegisterFile("exemplars/exemplarspb/rpc.proto", fileDescriptor_fd9ad2a40bac3cc9) } var fileDescriptor_fd9ad2a40bac3cc9 = []byte{ - // 462 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0xbd, 0x49, 0x1b, 0xea, 0x69, 0xa9, 0xc2, 0x2a, 0x12, 0x4e, 0x24, 0xec, 0x28, 0xa7, - 0xc0, 0x21, 0x46, 0xe1, 0xc2, 0x85, 0x8b, 0x05, 0x52, 0x85, 0x90, 0x40, 0xdb, 0x1b, 0x1c, 0xaa, - 0x0d, 0x1d, 0x85, 0x48, 0x8e, 0xbd, 0xdd, 0x9d, 0x00, 0xb9, 0xf3, 0x00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x7f, 0x57, 0x21, 0xfb, 0xb9, 0x0e, 0xbd, 0xeb, - 0x75, 0xe8, 0xfd, 0x59, 0x87, 0xde, 0xc7, 0xe3, 0xca, 0x9b, 0x18, 0x35, 0x8a, 0xcb, 0xfb, 0xe2, - 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xab, 0x57, 0xa1, 0x33, 0x03, 0x00, 0x00, + // 465 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0xbd, 0x49, 0x1b, 0xea, 0x49, 0xa9, 0xd2, 0x55, 0x24, 0x9c, 0x48, 0xd8, 0x51, 0x4e, + 0x81, 0x43, 0x8c, 0xc2, 0x89, 0x03, 0x17, 0x0b, 0xa4, 0x4a, 0x20, 0x81, 0xb6, 0xb7, 0x72, 0xa8, + 0x36, 0x74, 0x14, 0x22, 0x39, 0xf6, 0x76, 0x77, 0x02, 0xe4, 0x01, 0xb8, 0x73, 0xe6, 0x1d, 0x78, + 0x8f, 0x1c, 0x7b, 0xe4, 0x14, 0x41, 0x72, 0xcb, 0x53, 0xa0, 0xec, 0xda, 0x69, 0x1a, 0x55, 0xea, + 0xc5, 0x3b, 0xf3, 0xcf, 0x67, 0xef, 0x3f, 0x3b, 0x6b, 0x88, 0xf0, 0x3b, 0x4e, 0x54, 0x2a, 0xb5, + 0x89, 0xb7, 0x91, 0x1a, 0xc6, 0x5a, 0x7d, 0xee, 0x2b, 0x9d, 0x53, 0xce, 0x6b, 0xf4, 0x45, 0x66, + 0xb9, 0x69, 0xb7, 0x0c, 0xe5, 0x1a, 0x63, 0xfb, 0x54, 0xc3, 0x98, 0x66, 0x0a, 0x8d, 0x43, 0xca, + 0x52, 0x2a, 0x87, 0x98, 0xee, 0x95, 0x9a, 0xa3, 0x7c, 0x94, 0xdb, 0x30, 0xde, 0x44, 0x4e, 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x70, 0x50, 0xe9, 0x54, 0x7b, 0xf5, 0x41, 0x63, 0xdf, 0x74, 0xf2, 0x78, + 0xbd, 0x88, 0x6e, 0x31, 0x71, 0x1b, 0x76, 0x7f, 0x30, 0x38, 0x2a, 0x31, 0xfe, 0x0a, 0x6a, 0xe9, + 0x03, 0x96, 0x4e, 0x0a, 0x4b, 0x05, 0x28, 0x8a, 0x95, 0x47, 0x70, 0xf8, 0x55, 0xa6, 0x53, 0xb4, + 0x07, 0xc1, 0x12, 0x7f, 0xbd, 0x88, 0x9c, 0x20, 0xdc, 0xc2, 0x9f, 0x42, 0x85, 0x8c, 0x1b, 0xad, + 0xb3, 0x43, 0xe3, 0x09, 0x1a, 0x92, 0x13, 0x25, 0x2a, 0x64, 0x06, 0x1f, 0xc0, 0xdf, 0xce, 0x82, + 0x27, 0xbb, 0x49, 0xb0, 0xdf, 0x4d, 0x79, 0xb5, 0xda, 0xad, 0x7b, 0x2a, 0x6e, 0x8a, 0x2f, 0x58, + 0xf2, 0x6c, 0xfe, 0x2f, 0xf4, 0xe6, 0xcb, 0x90, 0xdd, 0x2c, 0x43, 0xf6, 0x77, 0x19, 0xb2, 0x9f, + 0xab, 0xd0, 0xbb, 0x59, 0x85, 0xde, 0x9f, 0x55, 0xe8, 0x5d, 0xd4, 0x77, 0xfe, 0x8a, 0x61, 0xcd, + 0x5e, 0xdf, 0x97, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x15, 0xe4, 0x68, 0x35, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/pkg/exemplars/exemplarspb/rpc.proto b/pkg/exemplars/exemplarspb/rpc.proto index b02e642485..50dc94fa09 100644 --- a/pkg/exemplars/exemplarspb/rpc.proto +++ b/pkg/exemplars/exemplarspb/rpc.proto @@ -43,12 +43,12 @@ message ExemplarsResponse { } message ExemplarData { - LabelSet seriesLabels = 1 [(gogoproto.jsontag) = "seriesLabels", (gogoproto.nullable) = false]; + ZLabelSet seriesLabels = 1 [(gogoproto.jsontag) = "seriesLabels", (gogoproto.nullable) = false]; repeated Exemplar exemplars = 2 [(gogoproto.jsontag) = "exemplars"]; } message Exemplar { - LabelSet labels = 1 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false]; + ZLabelSet labels = 1 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false]; double value = 2 [(gogoproto.jsontag) = "value"]; int64 ts = 3 [(gogoproto.jsontag) = "timestamp"]; } diff --git a/pkg/exemplars/proxy_test.go b/pkg/exemplars/proxy_test.go index 581d97abde..0e0ca58f8e 100644 --- a/pkg/exemplars/proxy_test.go +++ b/pkg/exemplars/proxy_test.go @@ -130,7 +130,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -143,7 +143,7 @@ func TestProxy(t *testing.T) { server: &testExemplarServer{}, wantResponses: []*exemplarspb.ExemplarsResponse{ exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -158,7 +158,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -171,7 +171,7 @@ func TestProxy(t *testing.T) { server: &testExemplarServer{}, wantResponses: []*exemplarspb.ExemplarsResponse{ exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -206,7 +206,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -228,7 +228,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -239,7 +239,7 @@ func TestProxy(t *testing.T) { server: &testExemplarServer{}, wantResponses: []*exemplarspb.ExemplarsResponse{ exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -254,7 +254,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -264,7 +264,7 @@ func TestProxy(t *testing.T) { server: &testExemplarServer{}, wantResponses: []*exemplarspb.ExemplarsResponse{ exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"__name__": "http_request_duration_bucket"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -279,7 +279,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -288,7 +288,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 2}}, }), }, @@ -298,7 +298,7 @@ func TestProxy(t *testing.T) { server: &testExemplarServer{}, wantResponses: []*exemplarspb.ExemplarsResponse{ exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -313,7 +313,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), }, @@ -322,7 +322,7 @@ func TestProxy(t *testing.T) { { ExemplarsClient: &testExemplarClient{ response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 2}}, }), }, @@ -332,11 +332,11 @@ func TestProxy(t *testing.T) { server: &testExemplarServer{}, wantResponses: []*exemplarspb.ExemplarsResponse{ exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 1}}, }), exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, + SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))}, Exemplars: []*exemplarspb.Exemplar{{Value: 2}}, }), }, diff --git a/pkg/exemplars/tsdb.go b/pkg/exemplars/tsdb.go index ca569372bc..be824dd8f8 100644 --- a/pkg/exemplars/tsdb.go +++ b/pkg/exemplars/tsdb.go @@ -70,8 +70,8 @@ func (t *TSDB) Exemplars(matchers [][]*labels.Matcher, start, end int64, s exemp for _, e := range exemplars { exd := exemplarspb.ExemplarData{ - SeriesLabels: labelpb.LabelSet{ - Labels: labelpb.PromLabelsToLabelpbLabels(labelpb.ExtendSortedLabels(e.SeriesLabels, t.getExtLabels())), + SeriesLabels: labelpb.ZLabelSet{ + Labels: labelpb.ZLabelsFromPromLabels(labelpb.ExtendSortedLabels(e.SeriesLabels, t.getExtLabels())), }, Exemplars: exemplarspb.ExemplarsFromPromExemplars(e.Exemplars), } diff --git a/pkg/info/info.go b/pkg/info/info.go index 7ee65a43f8..0b5feaa113 100644 --- a/pkg/info/info.go +++ b/pkg/info/info.go @@ -20,7 +20,7 @@ type InfoServer struct { component string - getLabelSet func() []labelpb.LabelSet + getLabelSet func() []labelpb.ZLabelSet getStoreInfo func() (*infopb.StoreInfo, error) getExemplarsInfo func() *infopb.ExemplarsInfo getRulesInfo func() *infopb.RulesInfo @@ -38,7 +38,7 @@ func NewInfoServer( srv := &InfoServer{ component: component, // By default, do not return info for any API. - getLabelSet: func() []labelpb.LabelSet { return nil }, + getLabelSet: func() []labelpb.ZLabelSet { return nil }, getStoreInfo: func() (*infopb.StoreInfo, error) { return nil, nil }, getExemplarsInfo: func() *infopb.ExemplarsInfo { return nil }, getRulesInfo: func() *infopb.RulesInfo { return nil }, @@ -60,10 +60,10 @@ type ServerOptionFunc func(*InfoServer) // WithLabelSetFunc determines the function that should be executed to obtain // the label set information. If no function is provided, the default empty // label set is returned. Only the first function from the list is considered. -func WithLabelSetFunc(getLabelSet ...func() []labelpb.LabelSet) ServerOptionFunc { +func WithLabelSetFunc(getLabelSet ...func() []labelpb.ZLabelSet) ServerOptionFunc { if len(getLabelSet) == 0 { return func(s *InfoServer) { - s.getLabelSet = func() []labelpb.LabelSet { return []labelpb.LabelSet{} } + s.getLabelSet = func() []labelpb.ZLabelSet { return []labelpb.ZLabelSet{} } } } diff --git a/pkg/info/infopb/custom.pb.go b/pkg/info/infopb/custom.pb.go index f4432d8b20..8d50ee2c4b 100644 --- a/pkg/info/infopb/custom.pb.go +++ b/pkg/info/infopb/custom.pb.go @@ -8,9 +8,9 @@ import ( "github.com/thanos-io/thanos/pkg/store/labelpb" ) -func NewTSDBInfo(mint, maxt int64, lbls []labelpb.Label) TSDBInfo { +func NewTSDBInfo(mint, maxt int64, lbls []labelpb.ZLabel) TSDBInfo { return TSDBInfo{ - Labels: labelpb.LabelSet{ + Labels: labelpb.ZLabelSet{ Labels: lbls, }, MinTime: mint, @@ -33,7 +33,7 @@ func (infos TSDBInfos) MaxT() int64 { func (infos TSDBInfos) LabelSets() []labels.Labels { lsets := make([]labels.Labels, 0, len(infos)) for _, info := range infos { - lsets = append(lsets, labelpb.LabelpbLabelsToPromLabels(info.Labels.Labels)) + lsets = append(lsets, labelpb.ZLabelsToPromLabels(info.Labels.Labels)) } return lsets diff --git a/pkg/info/infopb/rpc.pb.go b/pkg/info/infopb/rpc.pb.go index 9bdce73435..c88be63cfc 100644 --- a/pkg/info/infopb/rpc.pb.go +++ b/pkg/info/infopb/rpc.pb.go @@ -66,8 +66,8 @@ func (m *InfoRequest) XXX_DiscardUnknown() { var xxx_messageInfo_InfoRequest proto.InternalMessageInfo type InfoResponse struct { - LabelSets []labelpb.LabelSet `protobuf:"bytes,1,rep,name=label_sets,json=labelSets,proto3" json:"label_sets"` - ComponentType string `protobuf:"bytes,2,opt,name=ComponentType,proto3" json:"ComponentType,omitempty"` + LabelSets []labelpb.ZLabelSet `protobuf:"bytes,1,rep,name=label_sets,json=labelSets,proto3" json:"label_sets"` + ComponentType string `protobuf:"bytes,2,opt,name=ComponentType,proto3" json:"ComponentType,omitempty"` // StoreInfo holds the metadata related to Store API if exposed by the component otherwise it will be null. Store *StoreInfo `protobuf:"bytes,3,opt,name=store,proto3" json:"store,omitempty"` // RulesInfo holds the metadata related to Rules API if exposed by the component otherwise it will be null. @@ -347,9 +347,9 @@ func (m *QueryAPIInfo) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAPIInfo proto.InternalMessageInfo type TSDBInfo struct { - Labels labelpb.LabelSet `protobuf:"bytes,1,opt,name=labels,proto3" json:"labels"` - MinTime int64 `protobuf:"varint,2,opt,name=min_time,json=minTime,proto3" json:"min_time,omitempty"` - MaxTime int64 `protobuf:"varint,3,opt,name=max_time,json=maxTime,proto3" json:"max_time,omitempty"` + Labels labelpb.ZLabelSet `protobuf:"bytes,1,opt,name=labels,proto3" json:"labels"` + MinTime int64 `protobuf:"varint,2,opt,name=min_time,json=minTime,proto3" json:"min_time,omitempty"` + MaxTime int64 `protobuf:"varint,3,opt,name=max_time,json=maxTime,proto3" json:"max_time,omitempty"` } func (m *TSDBInfo) Reset() { *m = TSDBInfo{} } @@ -400,44 +400,44 @@ func init() { func init() { proto.RegisterFile("info/infopb/rpc.proto", fileDescriptor_a1214ec45d2bf952) } var fileDescriptor_a1214ec45d2bf952 = []byte{ - // 586 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x8e, 0xd2, 0x40, - 0x1c, 0xc7, 0xe9, 0xf2, 0xaf, 0xfc, 0x58, 0x56, 0x9c, 0xec, 0x9a, 0x42, 0x4c, 0x21, 0xcd, 0x1e, - 0x48, 0x34, 0x6d, 0x82, 0x31, 0x31, 0x7a, 0x92, 0x95, 0xc4, 0x35, 0x6e, 0xa2, 0x85, 0xc4, 0xc4, - 0x4b, 0x53, 0x60, 0x16, 0x9a, 0xb4, 0x9d, 0xd9, 0xce, 0x10, 0xe1, 0x2d, 0x7c, 0x14, 0x1f, 0x83, - 0xe3, 0x1e, 0x3d, 0x19, 0x85, 0x87, 0xf0, 0x6a, 0x66, 0xa6, 0x45, 0x1a, 0x77, 0x2f, 0x5e, 0xa0, - 0x33, 0xdf, 0xcf, 0x77, 0xfa, 0xfb, 0x37, 0x85, 0xb3, 0x20, 0xbe, 0x26, 0x8e, 0xf8, 0xa1, 0x13, - 0x27, 0xa1, 0x53, 0x9b, 0x26, 0x84, 0x13, 0x54, 0xe7, 0x0b, 0x3f, 0x26, 0xcc, 0x16, 0x42, 0xbb, - 0xc5, 0x38, 0x49, 0xb0, 0x13, 0xfa, 0x13, 0x1c, 0xd2, 0x89, 0xc3, 0xd7, 0x14, 0x33, 0xc5, 0xb5, - 0x4f, 0xe7, 0x64, 0x4e, 0xe4, 0xa3, 0x23, 0x9e, 0xd4, 0xae, 0xd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, 0xde, 0x77, 0x59, 0x52, 0x2a, 0x17, 0xc1, 0xd1, 0xfd, - 0x11, 0x14, 0x73, 0x11, 0xf4, 0x2f, 0xa0, 0x24, 0xdf, 0xf6, 0x2a, 0xfd, 0xcf, 0x8f, 0xe4, 0xc1, - 0x8d, 0x6e, 0xb7, 0xee, 0x50, 0xd4, 0xdd, 0x1e, 0x9c, 0x6f, 0x7e, 0x99, 0x85, 0xcd, 0xd6, 0xd4, - 0x6e, 0xb7, 0xa6, 0xf6, 0x73, 0x6b, 0x6a, 0x5f, 0x77, 0x66, 0xe1, 0x76, 0x67, 0x16, 0xbe, 0xef, - 0xcc, 0xc2, 0xe7, 0x8a, 0xfa, 0xd2, 0x4c, 0x2a, 0xf2, 0x43, 0xf1, 0xec, 0x4f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xd4, 0x0a, 0xee, 0xfb, 0x7f, 0x04, 0x00, 0x00, + // 589 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xdf, 0x8a, 0xda, 0x40, + 0x14, 0xc6, 0x8d, 0x7f, 0xe3, 0x71, 0xdd, 0xee, 0x0e, 0xbb, 0x25, 0x4a, 0x89, 0x12, 0xf6, 0x42, + 0x68, 0x31, 0x60, 0xa1, 0x94, 0xf6, 0xaa, 0x6e, 0x85, 0x6e, 0xe9, 0x42, 0x1b, 0x85, 0xc2, 0xde, + 0x84, 0xa8, 0xb3, 0x1a, 0x48, 0x32, 0x63, 0x66, 0xa4, 0xfa, 0x16, 0x7d, 0x95, 0xbe, 0x85, 0x97, + 0x7b, 0xd9, 0xab, 0xd2, 0xea, 0x43, 0xf4, 0xb6, 0xcc, 0x4c, 0x62, 0x0d, 0xdd, 0xbd, 0xe9, 0x8d, + 0x66, 0xe6, 0xfb, 0x9d, 0xc9, 0x39, 0xdf, 0x39, 0x13, 0x38, 0xf7, 0xa3, 0x5b, 0x62, 0x8b, 0x1f, + 0x3a, 0xb6, 0x63, 0x3a, 0xe9, 0xd2, 0x98, 0x70, 0x82, 0x6a, 0x7c, 0xee, 0x45, 0x84, 0x75, 0x85, + 0xd0, 0x6c, 0x30, 0x4e, 0x62, 0x6c, 0x07, 0xde, 0x18, 0x07, 0x74, 0x6c, 0xf3, 0x35, 0xc5, 0x4c, + 0x71, 0xcd, 0xb3, 0x19, 0x99, 0x11, 0xf9, 0x68, 0x8b, 0x27, 0xb5, 0x6b, 0xd5, 0xa1, 0x76, 0x15, + 0xdd, 0x12, 0x07, 0x2f, 0x96, 0x98, 0x71, 0xeb, 0x5b, 0x01, 0x8e, 0xd4, 0x9a, 0x51, 0x12, 0x31, + 0x8c, 0x5e, 0x00, 0xc8, 0xc3, 0x5c, 0x86, 0x39, 0x33, 0xb4, 0x76, 0xa1, 0x53, 0xeb, 0x9d, 0x76, + 0x93, 0x57, 0xde, 0x7c, 0x10, 0xd2, 0x10, 0xf3, 0x7e, 0x71, 0xf3, 0xa3, 0x95, 0x73, 0xaa, 0x41, + 0xb2, 0x66, 0xe8, 0x02, 0xea, 0x97, 0x24, 0xa4, 0x24, 0xc2, 0x11, 0x1f, 0xad, 0x29, 0x36, 0xf2, + 0x6d, 0xad, 0x53, 0x75, 0xb2, 0x9b, 0xe8, 0x19, 0x94, 0x64, 0xc2, 0x46, 0xa1, 0xad, 0x75, 0x6a, + 0xbd, 0xc7, 0xdd, 0x83, 0x5a, 0xba, 0x43, 0xa1, 0xc8, 0x64, 0x14, 0x24, 0xe8, 0x78, 0x19, 0x60, + 0x66, 0x14, 0xef, 0xa1, 0x1d, 0xa1, 0x28, 0x5a, 0x42, 0xe8, 0x1d, 0x3c, 0x0a, 0x31, 0x8f, 0xfd, + 0x89, 0x1b, 0x62, 0xee, 0x4d, 0x3d, 0xee, 0x19, 0x25, 0x19, 0xd7, 0xca, 0xc4, 0x5d, 0x4b, 0xe6, + 0x3a, 0x41, 0xe4, 0x01, 0xc7, 0x61, 0x66, 0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xf7, 0x45, 0xbd, 0x78, + 0x52, 0xb2, 0x6a, 0x50, 0xdd, 0xb7, 0xdd, 0x3a, 0x03, 0xf4, 0x6f, 0x2f, 0xc5, 0x7c, 0x1f, 0xf4, + 0xc7, 0x1a, 0x40, 0x3d, 0x63, 0xfc, 0xff, 0xd9, 0x65, 0x1d, 0xc3, 0xd1, 0x61, 0x27, 0xac, 0x05, + 0xe8, 0x69, 0xae, 0xc8, 0x86, 0x72, 0x62, 0x82, 0x26, 0x1b, 0xf8, 0xe0, 0x6d, 0x49, 0xb0, 0x4c, + 0x0a, 0xf9, 0x87, 0x53, 0x28, 0x64, 0x52, 0xe8, 0x5d, 0x42, 0x51, 0xbe, 0xee, 0x75, 0xf2, 0x9f, + 0x9d, 0xc9, 0x83, 0x3b, 0xdd, 0x6c, 0xdc, 0xa3, 0xa8, 0xdb, 0xdd, 0xbf, 0xd8, 0xfc, 0x32, 0x73, + 0x9b, 0xad, 0xa9, 0xdd, 0x6d, 0x4d, 0xed, 0xe7, 0xd6, 0xd4, 0xbe, 0xee, 0xcc, 0xdc, 0xdd, 0xce, + 0xcc, 0x7d, 0xdf, 0x99, 0xb9, 0x9b, 0xb2, 0xfa, 0xd6, 0x8c, 0xcb, 0xf2, 0x53, 0xf1, 0xfc, 0x4f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x5f, 0x0a, 0x2f, 0x81, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1168,7 +1168,7 @@ func (m *InfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.LabelSets = append(m.LabelSets, labelpb.LabelSet{}) + m.LabelSets = append(m.LabelSets, labelpb.ZLabelSet{}) if err := m.LabelSets[len(m.LabelSets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/pkg/info/infopb/rpc.proto b/pkg/info/infopb/rpc.proto index d41ba12905..9f0db3709d 100644 --- a/pkg/info/infopb/rpc.proto +++ b/pkg/info/infopb/rpc.proto @@ -29,7 +29,7 @@ service Info { message InfoRequest {} message InfoResponse { - repeated LabelSet label_sets = 1 [(gogoproto.nullable) = false]; + repeated ZLabelSet label_sets = 1 [(gogoproto.nullable) = false]; string ComponentType = 2; // StoreInfo holds the metadata related to Store API if exposed by the component otherwise it will be null. @@ -89,7 +89,7 @@ message QueryAPIInfo { } message TSDBInfo { - LabelSet labels = 1 [(gogoproto.nullable) = false]; + ZLabelSet labels = 1 [(gogoproto.nullable) = false]; int64 min_time = 2; int64 max_time = 3; diff --git a/pkg/query/endpointset.go b/pkg/query/endpointset.go index 39c9041e43..226bbb4730 100644 --- a/pkg/query/endpointset.go +++ b/pkg/query/endpointset.go @@ -515,7 +515,7 @@ func (e *EndpointSet) GetExemplarsStores() []*exemplarspb.ExemplarStore { if er.HasExemplarsAPI() { exemplarStores = append(exemplarStores, &exemplarspb.ExemplarStore{ ExemplarsClient: exemplarspb.NewExemplarsClient(er.cc), - LabelSets: labelpb.LabelpbLabelSetsToPromLabels(er.metadata.LabelSets...), + LabelSets: labelpb.ZLabelSetsToPromLabelSets(er.metadata.LabelSets...), }) } } @@ -710,7 +710,7 @@ func (er *endpointRef) labelSets() []labels.Labels { } labelSet := make([]labels.Labels, 0, len(er.metadata.LabelSets)) - for _, ls := range labelpb.LabelpbLabelSetsToPromLabels(er.metadata.LabelSets...) { + for _, ls := range labelpb.ZLabelSetsToPromLabelSets(er.metadata.LabelSets...) { if ls.Len() == 0 { continue } diff --git a/pkg/query/endpointset_test.go b/pkg/query/endpointset_test.go index 431bbeacbb..cc20acf42a 100644 --- a/pkg/query/endpointset_test.go +++ b/pkg/query/endpointset_test.go @@ -117,7 +117,7 @@ type APIs struct { type testEndpointMeta struct { *infopb.InfoResponse - extlsetFn func(addr string) labelpb.LabelSets + extlsetFn func(addr string) []labelpb.ZLabelSet infoDelay time.Duration err error } @@ -257,14 +257,10 @@ func TestEndpointSetUpdate(t *testing.T) { endpoints: []testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }, }, @@ -282,14 +278,10 @@ func TestEndpointSetUpdate(t *testing.T) { { err: fmt.Errorf("endpoint unavailable"), InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }, }, @@ -303,14 +295,10 @@ func TestEndpointSetUpdate(t *testing.T) { { infoDelay: 5 * time.Second, InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }, }, @@ -323,14 +311,10 @@ func TestEndpointSetUpdate(t *testing.T) { endpoints: []testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }, }, @@ -348,19 +332,15 @@ func TestEndpointSetUpdate(t *testing.T) { { InfoResponse: sidecarInfo, // Simulate very long external labels. - extlsetFn: func(addr string) labelpb.LabelSets { + extlsetFn: func(addr string) []labelpb.ZLabelSet { sLabel := []string{} for i := 0; i < 1000; i++ { sLabel = append(sLabel, "lbl") sLabel = append(sLabel, "val") } - return labelpb.LabelSets{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings(sLabel...), - ), - }, - } + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings(sLabel...), + ) }, }, }, @@ -395,14 +375,10 @@ func TestEndpointSetUpdate_DuplicateSpecs(t *testing.T) { endpoints, err := startTestEndpoints([]testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }, }) @@ -423,14 +399,10 @@ func TestEndpointSetUpdate_EndpointGoingAway(t *testing.T) { endpoints, err := startTestEndpoints([]testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }, }) @@ -457,7 +429,7 @@ func TestEndpointSetUpdate_EndpointComingOnline(t *testing.T) { { err: fmt.Errorf("endpoint unavailable"), InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { + extlsetFn: func(addr string) []labelpb.ZLabelSet { return nil }, }, @@ -489,7 +461,7 @@ func TestEndpointSetUpdate_StrictEndpointMetadata(t *testing.T) { { err: fmt.Errorf("endpoint unavailable"), InfoResponse: info, - extlsetFn: func(addr string) labelpb.LabelSets { + extlsetFn: func(addr string) []labelpb.ZLabelSet { return nil }, }, @@ -535,14 +507,10 @@ func TestEndpointSetUpdate_PruneInactiveEndpoints(t *testing.T) { endpoints: []testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }, }, @@ -554,14 +522,10 @@ func TestEndpointSetUpdate_PruneInactiveEndpoints(t *testing.T) { endpoints: []testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }, }, @@ -631,15 +595,15 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { endpoints, err := startTestEndpoints([]testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "addr", Value: addr}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "a", Value: "b"}, }, }, @@ -648,15 +612,15 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { }, { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "addr", Value: addr}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "a", Value: "b"}, }, }, @@ -665,15 +629,15 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { }, { InfoResponse: queryInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "addr", Value: addr}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "a", Value: "b"}, }, }, @@ -763,16 +727,16 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { endpoint2, err := startTestEndpoints([]testEndpointMeta{ { InfoResponse: queryInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l3", Value: "v4"}, }, }, @@ -782,16 +746,16 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { { // Duplicated Querier, in previous versions it would be deduplicated. Now it should be not. InfoResponse: queryInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l3", Value: "v4"}, }, }, @@ -800,10 +764,10 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { }, { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, @@ -814,10 +778,10 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { { // Duplicated Sidecar, in previous versions it would be deduplicated. Now it should be not. InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, @@ -828,10 +792,10 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { { // Querier that duplicates with sidecar, in previous versions it would be deduplicated. Now it should be not. InfoResponse: queryInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, @@ -843,10 +807,10 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { // Ruler that duplicates with sidecar, in previous versions it would be deduplicated. Now it should be not. // Warning should be produced. InfoResponse: ruleInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, @@ -857,10 +821,10 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { { // Duplicated Rule, in previous versions it would be deduplicated. Now it should be not. Warning should be produced. InfoResponse: ruleInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, @@ -871,30 +835,30 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { // Two pre v0.8.0 store gateway nodes, they don't have ext labels set. { InfoResponse: storeGWInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{} + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{} }, }, { InfoResponse: storeGWInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{} + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{} }, }, // Regression tests against https://github.com/thanos-io/thanos/issues/1632: From v0.8.0 stores advertise labels. // If the object storage handled by store gateway has only one sidecar we used to hitting issue. { InfoResponse: storeGWInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l3", Value: "v4"}, }, }, @@ -904,16 +868,16 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { // Stores v0.8.1 has compatibility labels. Check if they are correctly removed. { InfoResponse: storeGWInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l3", Value: "v4"}, }, }, @@ -923,16 +887,16 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { // Duplicated store, in previous versions it would be deduplicated. Now it should be not. { InfoResponse: storeGWInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l3", Value: "v4"}, }, }, @@ -941,16 +905,16 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { }, { InfoResponse: receiveInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l3", Value: "v4"}, }, }, @@ -960,16 +924,16 @@ func TestEndpointSetUpdate_AvailabilityScenarios(t *testing.T) { // Duplicate receiver { InfoResponse: receiveInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l1", Value: "v2"}, {Name: "l2", Value: "v3"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "l3", Value: "v4"}, }, }, @@ -1025,10 +989,10 @@ func TestEndpointSet_Update_NoneAvailable(t *testing.T) { endpoints, err := startTestEndpoints([]testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "addr", Value: addr, @@ -1040,10 +1004,10 @@ func TestEndpointSet_Update_NoneAvailable(t *testing.T) { }, { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "addr", Value: addr, @@ -1097,10 +1061,10 @@ func TestEndpoint_Update_QuerierStrict(t *testing.T) { MetricMetadata: &infopb.MetricMetadataInfo{}, Targets: &infopb.TargetsInfo{}, }, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "addr", Value: addr, @@ -1122,10 +1086,10 @@ func TestEndpoint_Update_QuerierStrict(t *testing.T) { MetricMetadata: &infopb.MetricMetadataInfo{}, Targets: &infopb.TargetsInfo{}, }, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "addr", Value: addr, @@ -1148,10 +1112,10 @@ func TestEndpoint_Update_QuerierStrict(t *testing.T) { MetricMetadata: &infopb.MetricMetadataInfo{}, Targets: &infopb.TargetsInfo{}, }, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "addr", Value: addr, @@ -1226,32 +1190,32 @@ func TestEndpointSet_APIs_Discovery(t *testing.T) { endpoints, err := startTestEndpoints([]testEndpointMeta{ { InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{} + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{} }, }, { InfoResponse: ruleInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{} + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{} }, }, { InfoResponse: receiveInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{} + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{} }, }, { InfoResponse: storeGWInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{} + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{} }, }, { InfoResponse: queryInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{} + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return []labelpb.ZLabelSet{} }, }, }) @@ -1445,14 +1409,10 @@ func makeInfoResponses(n int) []testEndpointMeta { for i := 0; i < n; i++ { responses = append(responses, testEndpointMeta{ InfoResponse: sidecarInfo, - extlsetFn: func(addr string) labelpb.LabelSets { - return []labelpb.LabelSet{ - { - Labels: labelpb.PromLabelsToLabelpbLabels( - labels.FromStrings("addr", addr, "a", "b"), - ), - }, - } + extlsetFn: func(addr string) []labelpb.ZLabelSet { + return labelpb.ZLabelSetsFromPromLabels( + labels.FromStrings("addr", addr, "a", "b"), + ) }, }) } diff --git a/pkg/query/querier_test.go b/pkg/query/querier_test.go index cb67c6dbd4..7ff5ad4954 100644 --- a/pkg/query/querier_test.go +++ b/pkg/query/querier_test.go @@ -1246,7 +1246,7 @@ func storeSeriesResponse(t testing.TB, lset labels.Labels, smplChunks ...[]sampl var s storepb.Series for _, l := range lset { - s.Labels = append(s.Labels, labelpb.Label{Name: l.Name, Value: l.Value}) + s.Labels = append(s.Labels, labelpb.ZLabel{Name: l.Name, Value: l.Value}) } for _, smpls := range smplChunks { diff --git a/pkg/query/query_bench_test.go b/pkg/query/query_bench_test.go index 01e5d35a89..44e4373a26 100644 --- a/pkg/query/query_bench_test.go +++ b/pkg/query/query_bench_test.go @@ -70,7 +70,7 @@ func benchQuerySelect(t testutil.TB, totalSamples, totalSeries int, dedup bool) testutil.Ok(t, head.Close()) for i := 0; i < len(created); i++ { if !dedup || j == 0 { - lset := labelpb.LabelpbLabelsToPromLabels(created[i].Labels).Copy() + lset := labelpb.ZLabelsToPromLabels(created[i].Labels).Copy() if dedup { lset = lset[1:] } diff --git a/pkg/query/remote_engine.go b/pkg/query/remote_engine.go index 3bfc786bcd..c625cab5ba 100644 --- a/pkg/query/remote_engine.go +++ b/pkg/query/remote_engine.go @@ -120,7 +120,7 @@ func (r *remoteEngine) MinT() int64 { highestMintByLabelSet = make(map[uint64]int64) ) for _, lset := range r.adjustedInfos() { - key, _ := labelpb.LabelpbLabelsToPromLabels(lset.Labels.Labels).HashWithoutLabels(hashBuf) + key, _ := labelpb.ZLabelsToPromLabels(lset.Labels.Labels).HashWithoutLabels(hashBuf) lsetMinT, ok := highestMintByLabelSet[key] if !ok { highestMintByLabelSet[key] = lset.MinTime @@ -187,7 +187,7 @@ func (r *remoteEngine) adjustedInfos() infopb.TSDBInfos { infos = append(infos, infopb.NewTSDBInfo( info.MinTime, info.MaxTime, - labelpb.PromLabelsToLabelpbLabels(builder.Labels())), + labelpb.ZLabelsFromPromLabels(builder.Labels())), ) } diff --git a/pkg/query/remote_engine_test.go b/pkg/query/remote_engine_test.go index 4bc05df857..636197b491 100644 --- a/pkg/query/remote_engine_test.go +++ b/pkg/query/remote_engine_test.go @@ -82,14 +82,14 @@ func TestRemoteEngine_LabelSets(t *testing.T) { { name: "non-empty label sets", tsdbInfos: []infopb.TSDBInfo{{ - Labels: labelSetFromStrings("a", "1"), + Labels: zLabelSetFromStrings("a", "1"), }}, expected: []labels.Labels{labels.FromStrings("a", "1")}, }, { name: "non-empty label sets with replica labels", tsdbInfos: []infopb.TSDBInfo{{ - Labels: labelSetFromStrings("a", "1", "b", "2"), + Labels: zLabelSetFromStrings("a", "1", "b", "2"), }}, replicaLabels: []string{"a"}, expected: []labels.Labels{labels.FromStrings("b", "2")}, @@ -98,7 +98,7 @@ func TestRemoteEngine_LabelSets(t *testing.T) { name: "replica labels not in label sets", tsdbInfos: []infopb.TSDBInfo{ { - Labels: labelSetFromStrings("a", "1", "c", "2"), + Labels: zLabelSetFromStrings("a", "1", "c", "2"), }, }, replicaLabels: []string{"a", "b"}, @@ -108,7 +108,7 @@ func TestRemoteEngine_LabelSets(t *testing.T) { name: "non-empty label sets with partition labels", tsdbInfos: []infopb.TSDBInfo{ { - Labels: labelSetFromStrings("a", "1", "c", "2"), + Labels: zLabelSetFromStrings("a", "1", "c", "2"), }, }, partitionLabels: []string{"a"}, @@ -150,7 +150,7 @@ func TestRemoteEngine_MinT(t *testing.T) { { name: "non-empty label sets", tsdbInfos: []infopb.TSDBInfo{{ - Labels: labelSetFromStrings("a", "1"), + Labels: zLabelSetFromStrings("a", "1"), MinTime: 30, }}, expected: 30, @@ -158,7 +158,7 @@ func TestRemoteEngine_MinT(t *testing.T) { { name: "non-empty label sets with replica labels", tsdbInfos: []infopb.TSDBInfo{{ - Labels: labelSetFromStrings("a", "1", "b", "2"), + Labels: zLabelSetFromStrings("a", "1", "b", "2"), MinTime: 30, }}, replicaLabels: []string{"a"}, @@ -168,11 +168,11 @@ func TestRemoteEngine_MinT(t *testing.T) { name: "replicated labelsets with different mint", tsdbInfos: []infopb.TSDBInfo{ { - Labels: labelSetFromStrings("a", "1", "replica", "1"), + Labels: zLabelSetFromStrings("a", "1", "replica", "1"), MinTime: 30, }, { - Labels: labelSetFromStrings("a", "1", "replica", "2"), + Labels: zLabelSetFromStrings("a", "1", "replica", "2"), MinTime: 60, }, }, @@ -183,19 +183,19 @@ func TestRemoteEngine_MinT(t *testing.T) { name: "multiple replicated labelsets with different mint", tsdbInfos: []infopb.TSDBInfo{ { - Labels: labelSetFromStrings("a", "1", "replica", "1"), + Labels: zLabelSetFromStrings("a", "1", "replica", "1"), MinTime: 30, }, { - Labels: labelSetFromStrings("a", "1", "replica", "2"), + Labels: zLabelSetFromStrings("a", "1", "replica", "2"), MinTime: 60, }, { - Labels: labelSetFromStrings("a", "2", "replica", "1"), + Labels: zLabelSetFromStrings("a", "2", "replica", "1"), MinTime: 80, }, { - Labels: labelSetFromStrings("a", "2", "replica", "2"), + Labels: zLabelSetFromStrings("a", "2", "replica", "2"), MinTime: 120, }, }, @@ -216,9 +216,9 @@ func TestRemoteEngine_MinT(t *testing.T) { } } -func labelSetFromStrings(ss ...string) labelpb.LabelSet { - return labelpb.LabelSet{ - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings(ss...)), +func zLabelSetFromStrings(ss ...string) labelpb.ZLabelSet { + return labelpb.ZLabelSet{ + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings(ss...)), } } diff --git a/pkg/queryfrontend/labels_codec.go b/pkg/queryfrontend/labels_codec.go index 4afd751aad..c56d8b52fc 100644 --- a/pkg/queryfrontend/labels_codec.go +++ b/pkg/queryfrontend/labels_codec.go @@ -82,7 +82,7 @@ func (c labelsCodec) MergeResponse(_ queryrange.Request, responses ...queryrange Data: lbls, }, nil case *ThanosSeriesResponse: - seriesData := make(labelpb.LabelSets, 0) + seriesData := make(labelpb.ZLabelSets, 0) uniqueSeries := make(map[string]struct{}) for _, res := range responses { diff --git a/pkg/queryfrontend/labels_codec_test.go b/pkg/queryfrontend/labels_codec_test.go index a592078bac..c7ff233aa5 100644 --- a/pkg/queryfrontend/labels_codec_test.go +++ b/pkg/queryfrontend/labels_codec_test.go @@ -329,14 +329,14 @@ func TestLabelsCodec_DecodeResponse(t *testing.T) { seriesResponse := &ThanosSeriesResponse{ Status: "success", - Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}, + Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}, } seriesData, err := json.Marshal(seriesResponse) testutil.Ok(t, err) seriesResponseWithHeaders := &ThanosSeriesResponse{ Status: "success", - Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}, + Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}, Headers: []*ResponseHeader{{Name: cacheControlHeader, Values: []string{noStoreValue}}}, } seriesDataWithHeaders, err := json.Marshal(seriesResponseWithHeaders) @@ -468,45 +468,45 @@ func TestLabelsCodec_MergeResponse(t *testing.T) { { name: "One series response", responses: []queryrange.Response{ - &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}}, + &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}}, }, - expectedResponse: &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}}, + expectedResponse: &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}}, }, { name: "One series response and two empty responses", responses: []queryrange.Response{ &ThanosSeriesResponse{Status: queryrange.StatusSuccess}, - &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}}, + &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}}, &ThanosSeriesResponse{Status: queryrange.StatusSuccess}, }, - expectedResponse: &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}}, + expectedResponse: &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}}, }, { name: "Multiple duplicate series responses", responses: []queryrange.Response{ - &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}}, - &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}}, - &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}}, + &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}}, + &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}}, + &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}}, }, - expectedResponse: &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}}, + expectedResponse: &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}}, }, { name: "Multiple unordered series responses", responses: []queryrange.Response{ - &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{ - {Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}, - {Labels: []labelpb.Label{{Name: "test", Value: "aaa"}, {Name: "instance", Value: "localhost:9090"}}}, + &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{ + {Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}, + {Labels: []labelpb.ZLabel{{Name: "test", Value: "aaa"}, {Name: "instance", Value: "localhost:9090"}}}, }}, - &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{ - {Labels: []labelpb.Label{{Name: "foo", Value: "aaa"}}}, - {Labels: []labelpb.Label{{Name: "test", Value: "bbb"}, {Name: "instance", Value: "localhost:9091"}}}, + &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{ + {Labels: []labelpb.ZLabel{{Name: "foo", Value: "aaa"}}}, + {Labels: []labelpb.ZLabel{{Name: "test", Value: "bbb"}, {Name: "instance", Value: "localhost:9091"}}}, }}, }, - expectedResponse: &ThanosSeriesResponse{Status: "success", Data: []labelpb.LabelSet{ - {Labels: []labelpb.Label{{Name: "foo", Value: "aaa"}}}, - {Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}, - {Labels: []labelpb.Label{{Name: "test", Value: "aaa"}, {Name: "instance", Value: "localhost:9090"}}}, - {Labels: []labelpb.Label{{Name: "test", Value: "bbb"}, {Name: "instance", Value: "localhost:9091"}}}, + expectedResponse: &ThanosSeriesResponse{Status: "success", Data: []labelpb.ZLabelSet{ + {Labels: []labelpb.ZLabel{{Name: "foo", Value: "aaa"}}}, + {Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}, + {Labels: []labelpb.ZLabel{{Name: "test", Value: "aaa"}, {Name: "instance", Value: "localhost:9090"}}}, + {Labels: []labelpb.ZLabel{{Name: "test", Value: "bbb"}, {Name: "instance", Value: "localhost:9091"}}}, }}, }, } { @@ -576,7 +576,7 @@ func BenchmarkLabelsCodecDecodeResponse(b *testing.B) { b.Run("SeriesResponse", func(b *testing.B) { seriesData, err := json.Marshal(&ThanosSeriesResponse{ Status: "success", - Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}, + Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}, }) testutil.Ok(b, err) @@ -595,7 +595,7 @@ func BenchmarkLabelsCodecDecodeResponse(b *testing.B) { b.Run("SeriesResponseWithHeaders", func(b *testing.B) { seriesDataWithHeaders, err := json.Marshal(&ThanosSeriesResponse{ Status: "success", - Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "foo", Value: "bar"}}}}, + Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "foo", Value: "bar"}}}}, Headers: []*ResponseHeader{{Name: cacheControlHeader, Values: []string{noStoreValue}}}, }) testutil.Ok(b, err) @@ -707,11 +707,11 @@ func makeQueryRangeResponses(size int) ([]queryrange.Response, []queryrange.Resp seriesResp, &ThanosSeriesResponse{ Status: "success", - Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: fmt.Sprintf("foo-%d", i), Value: fmt.Sprintf("bar-%d", i)}}}}, + Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: fmt.Sprintf("foo-%d", i), Value: fmt.Sprintf("bar-%d", i)}}}}, }, &ThanosSeriesResponse{ Status: "success", - Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: fmt.Sprintf("foo-%d", i+1), Value: fmt.Sprintf("bar-%d", i+1)}}}}, + Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: fmt.Sprintf("foo-%d", i+1), Value: fmt.Sprintf("bar-%d", i+1)}}}}, }, ) } diff --git a/pkg/queryfrontend/response.pb.go b/pkg/queryfrontend/response.pb.go index dd0020f591..0aa88fdc62 100644 --- a/pkg/queryfrontend/response.pb.go +++ b/pkg/queryfrontend/response.pb.go @@ -67,11 +67,11 @@ func (m *ThanosLabelsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_ThanosLabelsResponse proto.InternalMessageInfo type ThanosSeriesResponse struct { - Status string `protobuf:"bytes,1,opt,name=Status,proto3" json:"status"` - Data []labelpb.LabelSet `protobuf:"bytes,2,rep,name=Data,proto3" json:"data"` - ErrorType string `protobuf:"bytes,3,opt,name=ErrorType,proto3" json:"errorType,omitempty"` - Error string `protobuf:"bytes,4,opt,name=Error,proto3" json:"error,omitempty"` - Headers []*ResponseHeader `protobuf:"bytes,5,rep,name=Headers,proto3" json:"-"` + Status string `protobuf:"bytes,1,opt,name=Status,proto3" json:"status"` + Data []labelpb.ZLabelSet `protobuf:"bytes,2,rep,name=Data,proto3" json:"data"` + ErrorType string `protobuf:"bytes,3,opt,name=ErrorType,proto3" json:"errorType,omitempty"` + Error string `protobuf:"bytes,4,opt,name=Error,proto3" json:"error,omitempty"` + Headers []*ResponseHeader `protobuf:"bytes,5,rep,name=Headers,proto3" json:"-"` } func (m *ThanosSeriesResponse) Reset() { *m = ThanosSeriesResponse{} } @@ -154,30 +154,30 @@ func init() { func init() { proto.RegisterFile("queryfrontend/response.proto", fileDescriptor_b882fa7024d92f38) } var fileDescriptor_b882fa7024d92f38 = []byte{ - // 362 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x92, 0x3f, 0x4f, 0xc2, 0x40, - 0x18, 0xc6, 0x5b, 0x28, 0x55, 0x0e, 0xff, 0xe5, 0x20, 0xb1, 0x10, 0x68, 0x09, 0x13, 0x26, 0xda, - 0x26, 0x18, 0x57, 0x87, 0x46, 0x13, 0x63, 0x8c, 0x43, 0x21, 0xee, 0x47, 0x78, 0x45, 0x12, 0xe8, - 0xd5, 0xbb, 0x63, 0xe8, 0xb7, 0xe0, 0x63, 0x31, 0x32, 0x3a, 0x35, 0x0a, 0x5b, 0x3f, 0x82, 0x93, - 0xe1, 0x7a, 0x8d, 0x30, 0x3a, 0xba, 0xdd, 0x3d, 0xcf, 0xef, 0x7d, 0x93, 0xe7, 0xc9, 0x8b, 0x9a, - 0xef, 0x73, 0x60, 0xf1, 0x2b, 0xa3, 0xa1, 0x80, 0x70, 0xe4, 0x31, 0xe0, 0x11, 0x0d, 0x39, 0xb8, - 0x11, 0xa3, 0x82, 0xe2, 0xe3, 0x3d, 0xb7, 0x51, 0x1b, 0xd3, 0x31, 0x95, 0x8e, 0xb7, 0x7d, 0x65, - 0x50, 0xa3, 0xce, 0x05, 0x65, 0xe0, 0x4d, 0xc9, 0x10, 0xa6, 0xd1, 0xd0, 0x13, 0x71, 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0x42, 0xe6, 0x0b, 0x99, 0xce, 0x81, 0xab, 0x0b, 0x50, 0xa6, 0x12, 0xfd, - 0xe6, 0xf2, 0xcb, 0xd6, 0x96, 0x6b, 0x5b, 0x5f, 0xad, 0x6d, 0xfd, 0x73, 0x6d, 0xeb, 0x8b, 0x8d, - 0xad, 0xad, 0x36, 0xb6, 0xf6, 0xb1, 0xb1, 0xb5, 0xa1, 0x29, 0x0f, 0xf0, 0xfa, 0x27, 0x00, 0x00, - 0xff, 0xff, 0x68, 0xd1, 0x0b, 0xae, 0xe0, 0x02, 0x00, 0x00, + // 367 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x92, 0x41, 0x4f, 0xea, 0x40, + 0x14, 0x85, 0x5b, 0x28, 0x7d, 0x8f, 0xe1, 0x3d, 0x8d, 0x03, 0x89, 0x85, 0x40, 0x4b, 0x58, 0x61, + 0xa2, 0x6d, 0x02, 0x71, 0xeb, 0xa2, 0xd1, 0xc4, 0x18, 0xe3, 0xa2, 0x10, 0x17, 0xee, 0x86, 0x70, + 0x45, 0x12, 0xe8, 0xd4, 0x99, 0x61, 0xd1, 0x7f, 0xa1, 0xff, 0x8a, 0x25, 0x4b, 0x57, 0x8d, 0xc2, + 0xae, 0x3f, 0xc1, 0x95, 0x61, 0x3a, 0x8d, 0xb0, 0x74, 0xe9, 0x6e, 0xe6, 0x9c, 0xef, 0xde, 0xe4, + 0x9c, 0x5c, 0xd4, 0x7c, 0x5e, 0x00, 0x8b, 0x1f, 0x19, 0x0d, 0x05, 0x84, 0x63, 0x8f, 0x01, 0x8f, + 0x68, 0xc8, 0xc1, 0x8d, 0x18, 0x15, 0x14, 0xff, 0xdf, 0x73, 0x1b, 0xb5, 0x09, 0x9d, 0x50, 0xe9, + 0x78, 0xdb, 0x57, 0x06, 0x35, 0xea, 0x5c, 0x50, 0x06, 0xde, 0x8c, 0x8c, 0x60, 0x16, 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a, 0x14, 0x2f, 0x25, 0xdc, 0x42, 0xe6, 0x3d, 0x99, 0x2d, 0x80, 0xab, + 0x13, 0x50, 0xa6, 0x12, 0xfd, 0xe6, 0xf2, 0xc3, 0xd6, 0x96, 0x6b, 0x5b, 0x5f, 0xad, 0x6d, 0xfd, + 0x7d, 0x6d, 0xeb, 0x2f, 0x1b, 0x5b, 0x5b, 0x6d, 0x6c, 0xed, 0x6d, 0x63, 0x6b, 0x23, 0x53, 0x5e, + 0x60, 0xff, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x6d, 0x4c, 0xcd, 0xdf, 0xe1, 0x02, 0x00, 0x00, } func (m *ThanosLabelsResponse) Marshal() (dAtA []byte, err error) { @@ -762,7 +762,7 @@ func (m *ThanosSeriesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data, labelpb.LabelSet{}) + m.Data = append(m.Data, labelpb.ZLabelSet{}) if err := m.Data[len(m.Data)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/pkg/queryfrontend/response.proto b/pkg/queryfrontend/response.proto index 47985e3848..69bf2c06e5 100644 --- a/pkg/queryfrontend/response.proto +++ b/pkg/queryfrontend/response.proto @@ -30,7 +30,7 @@ message ThanosLabelsResponse { message ThanosSeriesResponse { string Status = 1 [(gogoproto.jsontag) = "status"]; - repeated thanos.LabelSet Data = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "data"]; + repeated thanos.ZLabelSet Data = 2 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "data"]; string ErrorType = 3 [(gogoproto.jsontag) = "errorType,omitempty"]; string Error = 4 [(gogoproto.jsontag) = "error,omitempty"]; repeated ResponseHeader Headers = 5 [(gogoproto.jsontag) = "-"]; diff --git a/pkg/queryfrontend/roundtrip_test.go b/pkg/queryfrontend/roundtrip_test.go index 466e2911ea..7733191e47 100644 --- a/pkg/queryfrontend/roundtrip_test.go +++ b/pkg/queryfrontend/roundtrip_test.go @@ -950,7 +950,7 @@ func seriesResults(fail bool) (*int, http.Handler) { var lock sync.Mutex q := ThanosSeriesResponse{ Status: "success", - Data: []labelpb.LabelSet{{Labels: []labelpb.Label{{Name: "__name__", Value: "up"}, {Name: "foo", Value: "bar"}}}}, + Data: []labelpb.ZLabelSet{{Labels: []labelpb.ZLabel{{Name: "__name__", Value: "up"}, {Name: "foo", Value: "bar"}}}}, } return &count, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/receive/handler.go b/pkg/receive/handler.go index eb419eb752..832d6162f1 100644 --- a/pkg/receive/handler.go +++ b/pkg/receive/handler.go @@ -526,6 +526,9 @@ func (h *Handler) receiveHTTP(w http.ResponseWriter, r *http.Request) { return } + // NOTE: Due to zero copy ZLabels, Labels used from WriteRequests keeps memory + // from the whole request. Ensure that we always copy those when we want to + // store them for longer time. var wreq prompb.WriteRequest if err := proto.Unmarshal(reqBuf, &wreq); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) @@ -827,7 +830,7 @@ func (h *Handler) distributeTimeseriesToReplicas( var tenant = tenantHTTP if h.splitTenantLabelName != "" { - lbls := labelpb.LabelpbLabelsToPromLabels(ts.Labels) + lbls := labelpb.ZLabelsToPromLabels(ts.Labels) tenantLabel := lbls.Get(h.splitTenantLabelName) if tenantLabel != "" { @@ -836,7 +839,7 @@ func (h *Handler) distributeTimeseriesToReplicas( newLabels := labels.NewBuilder(lbls) newLabels.Del(h.splitTenantLabelName) - ts.Labels = labelpb.PromLabelsToLabelpbLabels( + ts.Labels = labelpb.ZLabelsFromPromLabels( newLabels.Labels(), ) } @@ -919,7 +922,7 @@ func (h *Handler) sendLocalWrite( for _, ts := range trackedSeries.timeSeries { var tenant = tenantHTTP if h.splitTenantLabelName != "" { - lbls := labelpb.LabelpbLabelsToPromLabels(ts.Labels) + lbls := labelpb.ZLabelsToPromLabels(ts.Labels) if tnt := lbls.Get(h.splitTenantLabelName); tnt != "" { tenant = tnt } @@ -1047,11 +1050,11 @@ func (h *Handler) relabel(wreq *prompb.WriteRequest) { timeSeries := make([]prompb.TimeSeries, 0, len(wreq.Timeseries)) for _, ts := range wreq.Timeseries { var keep bool - lbls, keep := relabel.Process(labelpb.LabelpbLabelsToPromLabels(ts.Labels), h.options.RelabelConfigs...) + lbls, keep := relabel.Process(labelpb.ZLabelsToPromLabels(ts.Labels), h.options.RelabelConfigs...) if !keep { continue } - ts.Labels = labelpb.PromLabelsToLabelpbLabels(lbls) + ts.Labels = labelpb.ZLabelsFromPromLabels(lbls) timeSeries = append(timeSeries, ts) } wreq.Timeseries = timeSeries diff --git a/pkg/receive/handler_test.go b/pkg/receive/handler_test.go index 997239d3bb..4f81a3d1ca 100644 --- a/pkg/receive/handler_test.go +++ b/pkg/receive/handler_test.go @@ -651,7 +651,7 @@ func testReceiveQuorum(t *testing.T, hashringAlgo HashringAlgorithm, withConsist // Test that each time series is stored // the correct amount of times in each fake DB. for _, ts := range tc.wreq.Timeseries { - lset := labelpb.LabelpbLabelsToPromLabels(ts.Labels) + lset := labelpb.ZLabelsToPromLabels(ts.Labels) for j, a := range tc.appendables { if withConsistencyDelay { var expected int @@ -789,9 +789,9 @@ func TestReceiveWriteRequestLimits(t *testing.T) { } for i := 0; i < tc.amountSeries; i += 1 { - label := labelpb.Label{Name: "foo", Value: "bar"} + label := labelpb.ZLabel{Name: "foo", Value: "bar"} series := prompb.TimeSeries{ - Labels: []labelpb.Label{label}, + Labels: []labelpb.ZLabel{label}, } for j := 0; j < tc.amountSamples; j += 1 { sample := prompb.Sample{Value: float64(j), Timestamp: int64(j)} @@ -938,7 +938,7 @@ func (a *tsOverrideAppender) GetRef(lset labels.Labels, hash uint64) (storage.Se // serializeSeriesWithOneSample returns marshaled and compressed remote write requests like it would // be sent to Thanos receive. // It has one sample and allow passing multiple series, in same manner as typical Prometheus would batch it. -func serializeSeriesWithOneSample(t testing.TB, series [][]labelpb.Label) []byte { +func serializeSeriesWithOneSample(t testing.TB, series [][]labelpb.ZLabel) []byte { r := &prompb.WriteRequest{Timeseries: make([]prompb.TimeSeries, 0, len(series))} for _, s := range series { @@ -957,7 +957,7 @@ func makeSeriesWithValues(numSeries int) []prompb.TimeSeries { series := make([]prompb.TimeSeries, numSeries) for i := 0; i < numSeries; i++ { series[i] = prompb.TimeSeries{ - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: fmt.Sprintf("pod-%d", i), Value: fmt.Sprintf("nginx-%d", i), @@ -1012,13 +1012,13 @@ func benchmarkHandlerMultiTSDBReceiveRemoteWrite(b testutil.TB) { }{ { name: "typical labels under 1KB, 500 of them", - writeRequest: serializeSeriesWithOneSample(b, func() [][]labelpb.Label { - series := make([][]labelpb.Label, 500) + writeRequest: serializeSeriesWithOneSample(b, func() [][]labelpb.ZLabel { + series := make([][]labelpb.ZLabel, 500) for s := 0; s < len(series); s++ { - lbls := make([]labelpb.Label, 10) + lbls := make([]labelpb.ZLabel, 10) for i := 0; i < len(lbls); i++ { // Label ~20B name, 50B value. - lbls[i] = labelpb.Label{Name: fmt.Sprintf("abcdefghijabcdefghijabcdefghij%d", i), Value: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i)} + lbls[i] = labelpb.ZLabel{Name: fmt.Sprintf("abcdefghijabcdefghijabcdefghij%d", i), Value: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i)} } series[s] = lbls } @@ -1027,13 +1027,13 @@ func benchmarkHandlerMultiTSDBReceiveRemoteWrite(b testutil.TB) { }, { name: "typical labels under 1KB, 5000 of them", - writeRequest: serializeSeriesWithOneSample(b, func() [][]labelpb.Label { - series := make([][]labelpb.Label, 5000) + writeRequest: serializeSeriesWithOneSample(b, func() [][]labelpb.ZLabel { + series := make([][]labelpb.ZLabel, 5000) for s := 0; s < len(series); s++ { - lbls := make([]labelpb.Label, 10) + lbls := make([]labelpb.ZLabel, 10) for i := 0; i < len(lbls); i++ { // Label ~20B name, 50B value. - lbls[i] = labelpb.Label{Name: fmt.Sprintf("abcdefghijabcdefghijabcdefghij%d", i), Value: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i)} + lbls[i] = labelpb.ZLabel{Name: fmt.Sprintf("abcdefghijabcdefghijabcdefghij%d", i), Value: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i)} } series[s] = lbls } @@ -1042,13 +1042,13 @@ func benchmarkHandlerMultiTSDBReceiveRemoteWrite(b testutil.TB) { }, { name: "typical labels under 1KB, 20000 of them", - writeRequest: serializeSeriesWithOneSample(b, func() [][]labelpb.Label { - series := make([][]labelpb.Label, 20000) + writeRequest: serializeSeriesWithOneSample(b, func() [][]labelpb.ZLabel { + series := make([][]labelpb.ZLabel, 20000) for s := 0; s < len(series); s++ { - lbls := make([]labelpb.Label, 10) + lbls := make([]labelpb.ZLabel, 10) for i := 0; i < len(lbls); i++ { // Label ~20B name, 50B value. - lbls[i] = labelpb.Label{Name: fmt.Sprintf("abcdefghijabcdefghijabcdefghij%d", i), Value: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i)} + lbls[i] = labelpb.ZLabel{Name: fmt.Sprintf("abcdefghijabcdefghijabcdefghij%d", i), Value: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i)} } series[s] = lbls } @@ -1057,8 +1057,8 @@ func benchmarkHandlerMultiTSDBReceiveRemoteWrite(b testutil.TB) { }, { name: "extremely large label value 10MB, 10 of them", - writeRequest: serializeSeriesWithOneSample(b, func() [][]labelpb.Label { - series := make([][]labelpb.Label, 10) + writeRequest: serializeSeriesWithOneSample(b, func() [][]labelpb.ZLabel { + series := make([][]labelpb.ZLabel, 10) for s := 0; s < len(series); s++ { lbl := &strings.Builder{} lbl.Grow(1024 * 1024 * 10) // 10MB. @@ -1066,7 +1066,7 @@ func benchmarkHandlerMultiTSDBReceiveRemoteWrite(b testutil.TB) { for i := 0; i < lbl.Cap()/len(word); i++ { _, _ = lbl.WriteString(word) } - series[s] = []labelpb.Label{{Name: "__name__", Value: lbl.String()}} + series[s] = []labelpb.ZLabel{{Name: "__name__", Value: lbl.String()}} } return series }()), @@ -1215,7 +1215,7 @@ func TestRelabel(t *testing.T) { writeRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1237,7 +1237,7 @@ func TestRelabel(t *testing.T) { expectedWriteRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1271,7 +1271,7 @@ func TestRelabel(t *testing.T) { writeRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1293,7 +1293,7 @@ func TestRelabel(t *testing.T) { expectedWriteRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1332,7 +1332,7 @@ func TestRelabel(t *testing.T) { writeRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1354,7 +1354,7 @@ func TestRelabel(t *testing.T) { expectedWriteRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "foo", @@ -1385,7 +1385,7 @@ func TestRelabel(t *testing.T) { writeRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1407,7 +1407,7 @@ func TestRelabel(t *testing.T) { expectedWriteRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1435,7 +1435,7 @@ func TestRelabel(t *testing.T) { writeRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1469,7 +1469,7 @@ func TestRelabel(t *testing.T) { writeRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1481,7 +1481,7 @@ func TestRelabel(t *testing.T) { }, Exemplars: []prompb.Exemplar{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "traceID", Value: "foo", @@ -1497,7 +1497,7 @@ func TestRelabel(t *testing.T) { expectedWriteRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1505,7 +1505,7 @@ func TestRelabel(t *testing.T) { }, Exemplars: []prompb.Exemplar{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "traceID", Value: "foo", @@ -1531,7 +1531,7 @@ func TestRelabel(t *testing.T) { writeRequest: prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "__name__", Value: "test_metric", @@ -1543,7 +1543,7 @@ func TestRelabel(t *testing.T) { }, Exemplars: []prompb.Exemplar{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "traceID", Value: "foo", @@ -1694,10 +1694,10 @@ func TestDistributeSeries(t *testing.T) { []uint64{0}, []prompb.TimeSeries{ { - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings("a", "b", tenantIDLabelName, "bar")), + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings("a", "b", tenantIDLabelName, "bar")), }, { - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings("b", "a", tenantIDLabelName, "boo")), + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings("b", "a", tenantIDLabelName, "boo")), }, }, ) @@ -1706,8 +1706,8 @@ func TestDistributeSeries(t *testing.T) { require.Len(t, remote[endpointReplica{endpoint: "http://localhost:9090", replica: 0}]["bar"].timeSeries, 1) require.Len(t, remote[endpointReplica{endpoint: "http://localhost:9090", replica: 0}]["boo"].timeSeries, 1) - require.Equal(t, 1, labelpb.LabelpbLabelsToPromLabels(remote[endpointReplica{endpoint: "http://localhost:9090", replica: 0}]["bar"].timeSeries[0].Labels).Len()) - require.Equal(t, 1, labelpb.LabelpbLabelsToPromLabels(remote[endpointReplica{endpoint: "http://localhost:9090", replica: 0}]["boo"].timeSeries[0].Labels).Len()) + require.Equal(t, 1, labelpb.ZLabelsToPromLabels(remote[endpointReplica{endpoint: "http://localhost:9090", replica: 0}]["bar"].timeSeries[0].Labels).Len()) + require.Equal(t, 1, labelpb.ZLabelsToPromLabels(remote[endpointReplica{endpoint: "http://localhost:9090", replica: 0}]["boo"].timeSeries[0].Labels).Len()) require.Equal(t, map[string]struct{}{"bar": {}, "boo": {}}, hr.seenTenants) } @@ -1749,7 +1749,7 @@ func TestHandlerFlippingHashrings(t *testing.T) { _, err := h.handleRequest(ctx, 0, "test", &prompb.WriteRequest{ Timeseries: []prompb.TimeSeries{ { - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings("foo", "bar")), + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings("foo", "bar")), Samples: []prompb.Sample{ { Timestamp: time.Now().Unix(), diff --git a/pkg/receive/hashring_test.go b/pkg/receive/hashring_test.go index 12404faed6..ad6d4db855 100644 --- a/pkg/receive/hashring_test.go +++ b/pkg/receive/hashring_test.go @@ -20,7 +20,7 @@ import ( func TestHashringGet(t *testing.T) { ts := &prompb.TimeSeries{ - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "foo", Value: "bar", @@ -161,7 +161,7 @@ func TestHashringGet(t *testing.T) { func TestKetamaHashringGet(t *testing.T) { baseTS := &prompb.TimeSeries{ - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "pod", Value: "nginx", @@ -218,7 +218,7 @@ func TestKetamaHashringGet(t *testing.T) { name: "base case with different timeseries", endpoints: []Endpoint{{Address: "node-1"}, {Address: "node-2"}, {Address: "node-3"}}, ts: &prompb.TimeSeries{ - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "pod", Value: "thanos", @@ -381,7 +381,7 @@ func TestKetamaHashringReplicationConsistencyWithAZs(t *testing.T) { func TestKetamaHashringEvenAZSpread(t *testing.T) { tenant := "default-tenant" ts := &prompb.TimeSeries{ - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings("foo", "bar")), + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings("foo", "bar")), Samples: []prompb.Sample{{Value: 1, Timestamp: 0}}, } @@ -554,7 +554,7 @@ func TestKetamaHashringEvenNodeSpread(t *testing.T) { nodeSpread := make(map[string]int) for i := 0; i < int(tt.numSeries); i++ { ts := &prompb.TimeSeries{ - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings("foo", fmt.Sprintf("%d", i))), + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings("foo", fmt.Sprintf("%d", i))), Samples: []prompb.Sample{{Value: 1, Timestamp: 0}}, } for j := 0; j < int(tt.replicas); j++ { @@ -597,7 +597,7 @@ func makeSeries() []prompb.TimeSeries { series := make([]prompb.TimeSeries, numSeries) for i := 0; i < numSeries; i++ { series[i] = prompb.TimeSeries{ - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ { Name: "pod", Value: fmt.Sprintf("nginx-%d", i), @@ -610,8 +610,8 @@ func makeSeries() []prompb.TimeSeries { func findSeries(initialAssignments map[string][]prompb.TimeSeries, node string, newSeries prompb.TimeSeries) bool { for _, oldSeries := range initialAssignments[node] { - l1 := labelpb.LabelpbLabelsToPromLabels(newSeries.Labels) - l2 := labelpb.LabelpbLabelsToPromLabels(oldSeries.Labels) + l1 := labelpb.ZLabelsToPromLabels(newSeries.Labels) + l2 := labelpb.ZLabelsToPromLabels(oldSeries.Labels) if labels.Equal(l1, l2) { return true } diff --git a/pkg/receive/multitsdb.go b/pkg/receive/multitsdb.go index 699533a234..62e39ab500 100644 --- a/pkg/receive/multitsdb.go +++ b/pkg/receive/multitsdb.go @@ -180,7 +180,7 @@ func newLocalClient(store *store.TSDBStore) *localClient { } func (l *localClient) LabelSets() []labels.Labels { - return labelpb.LabelpbLabelSetsToPromLabels(l.store.LabelSet()...) + return labelpb.ZLabelSetsToPromLabelSets(l.store.LabelSet()...) } func (l *localClient) TimeRange() (mint int64, maxt int64) { diff --git a/pkg/receive/multitsdb_test.go b/pkg/receive/multitsdb_test.go index 3308063fb7..eb82c22281 100644 --- a/pkg/receive/multitsdb_test.go +++ b/pkg/receive/multitsdb_test.go @@ -202,11 +202,11 @@ func TestMultiTSDB(t *testing.T) { var ( expectedFooResp = &storepb.Series{ - Labels: []labelpb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "replica", Value: "01"}, {Name: "tenant_id", Value: "foo"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "replica", Value: "01"}, {Name: "tenant_id", Value: "foo"}}, Chunks: []storepb.AggrChunk{{MinTime: 1, MaxTime: 3, Raw: &storepb.Chunk{Data: []byte("\000\003\002@\003L\235\2354X\315\001\330\r\257Mui\251\327:U"), Hash: 9768694233508509040}}}, } expectedBarResp = &storepb.Series{ - Labels: []labelpb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "replica", Value: "01"}, {Name: "tenant_id", Value: "bar"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "replica", Value: "01"}, {Name: "tenant_id", Value: "bar"}}, Chunks: []storepb.AggrChunk{{MinTime: 1, MaxTime: 3, Raw: &storepb.Chunk{Data: []byte("\000\003\002@4i\223\263\246\213\032\001\330\035i\337\322\352\323S\256t\270"), Hash: 2304287992246504442}}}, } ) @@ -287,7 +287,7 @@ func getResponses(storeClient store.Client, respCh chan<- *storepb.Series) error var ( expectedFooRespExemplars = []exemplarspb.ExemplarData{ { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "replica", Value: "01"}, {Name: "tenant_id", Value: "foo"}}}, + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "replica", Value: "01"}, {Name: "tenant_id", Value: "foo"}}}, Exemplars: []*exemplarspb.Exemplar{ {Value: 1, Ts: 1}, {Value: 2.1212, Ts: 2}, @@ -297,11 +297,11 @@ var ( } expectedBarRespExemplars = []exemplarspb.ExemplarData{ { - SeriesLabels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "replica", Value: "01"}, {Name: "tenant_id", Value: "bar"}}}, + SeriesLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "replica", Value: "01"}, {Name: "tenant_id", Value: "bar"}}}, Exemplars: []*exemplarspb.Exemplar{ - {Value: 11, Ts: 1, Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "traceID", Value: "abc"}}}}, - {Value: 22.1212, Ts: 2, Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "traceID", Value: "def"}}}}, - {Value: 33.1313, Ts: 3, Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "traceID", Value: "ghi"}}}}, + {Value: 11, Ts: 1, Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "traceID", Value: "abc"}}}}, + {Value: 22.1212, Ts: 2, Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "traceID", Value: "def"}}}}, + {Value: 33.1313, Ts: 3, Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "traceID", Value: "ghi"}}}}, }, }, } diff --git a/pkg/receive/receive_test.go b/pkg/receive/receive_test.go index 943a51ce7d..ea1b6d81fd 100644 --- a/pkg/receive/receive_test.go +++ b/pkg/receive/receive_test.go @@ -826,7 +826,7 @@ func setupSetsOfExpectedAndActualStoreClientLabelSets( testStore := store.TSDBStore{} testStore.SetExtLset(expectedExternalLabelSets[i]) - expectedClientLabelSets := labelpb.LabelpbLabelSetsToPromLabels(testStore.LabelSet()...) + expectedClientLabelSets := labelpb.ZLabelSetsToPromLabelSets(testStore.LabelSet()...) setOfExpectedClientLabelSets = append(setOfExpectedClientLabelSets, expectedClientLabelSets) actualClientLabelSets := actualStoreClients[i].LabelSets() diff --git a/pkg/receive/writer.go b/pkg/receive/writer.go index cb84f8143b..883db29c56 100644 --- a/pkg/receive/writer.go +++ b/pkg/receive/writer.go @@ -16,7 +16,6 @@ import ( "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb" - "go4.org/intern" "github.com/thanos-io/thanos/pkg/store/labelpb" "github.com/thanos-io/thanos/pkg/store/storepb/prompb" @@ -117,7 +116,7 @@ func (r *Writer) Write(ctx context.Context, tenantID string, wreq *prompb.WriteR // Check if time series labels are valid. If not, skip the time series // and report the error. if err := labelpb.ValidateLabels(t.Labels); err != nil { - lset := &labelpb.LabelSet{Labels: t.Labels} + lset := &labelpb.ZLabelSet{Labels: t.Labels} switch err { case labelpb.ErrOutOfOrderLabels: numLabelsOutOfOrder++ @@ -135,21 +134,15 @@ func (r *Writer) Write(ctx context.Context, tenantID string, wreq *prompb.WriteR continue } - lset := labelpb.LabelpbLabelsToPromLabels(t.Labels) + lset := labelpb.ZLabelsToPromLabels(t.Labels) // Check if the TSDB has cached reference for those labels. ref, lset = getRef.GetRef(lset, lset.Hash()) if ref == 0 { // If not, copy labels, as TSDB will hold those strings long term. Given no // copy unmarshal we don't want to keep memory for whole protobuf, only for labels. - lset = labelpb.LabelpbLabelsToPromLabels(t.Labels) - - if r.opts.Intern { - for i := range t.Labels { - t.Labels[i].Name = intern.GetByString(t.Labels[i].Name).Get().(string) - t.Labels[i].Value = intern.GetByString(t.Labels[i].Value).Get().(string) - } - } + labelpb.ReAllocZLabelsStrings(&t.Labels, r.opts.Intern) + lset = labelpb.ZLabelsToPromLabels(t.Labels) } // Append as many valid samples as possible, but keep track of the errors. @@ -212,7 +205,7 @@ func (r *Writer) Write(ctx context.Context, tenantID string, wreq *prompb.WriteR // We drop the exemplars in case the series doesn't exist. if ref != 0 && len(t.Exemplars) > 0 { for _, ex := range t.Exemplars { - exLset := labelpb.LabelpbLabelsToPromLabels(ex.Labels) + exLset := labelpb.ZLabelsToPromLabels(ex.Labels) exLogger := log.With(tLogger, "exemplarLset", exLset, "exemplar", ex.String()) if _, err = app.AppendExemplar(ref, lset, exemplar.Exemplar{ diff --git a/pkg/receive/writer_test.go b/pkg/receive/writer_test.go index 6e665b97e0..34613794b8 100644 --- a/pkg/receive/writer_test.go +++ b/pkg/receive/writer_test.go @@ -30,7 +30,7 @@ import ( func TestWriter(t *testing.T) { now := model.Now() - lbls := []labelpb.Label{{Name: "__name__", Value: "test"}} + lbls := []labelpb.ZLabel{{Name: "__name__", Value: "test"}} tests := map[string]struct { reqs []*prompb.WriteRequest expectedErr error @@ -46,7 +46,7 @@ func TestWriter(t *testing.T) { Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, { - Labels: []labelpb.Label{{Name: "__name__", Value: ""}}, + Labels: []labelpb.ZLabel{{Name: "__name__", Value: ""}}, Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, }, @@ -59,7 +59,7 @@ func TestWriter(t *testing.T) { { Timeseries: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, }, @@ -68,7 +68,7 @@ func TestWriter(t *testing.T) { expectedErr: nil, expectedIngested: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, }, @@ -78,7 +78,7 @@ func TestWriter(t *testing.T) { { Timeseries: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "1"}, labelpb.Label{Name: "Z", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "1"}, labelpb.ZLabel{Name: "Z", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, }, @@ -91,7 +91,7 @@ func TestWriter(t *testing.T) { { Timeseries: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}, labelpb.Label{Name: "z", Value: "1"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}, labelpb.ZLabel{Name: "z", Value: "1"}), Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, }, @@ -104,15 +104,15 @@ func TestWriter(t *testing.T) { { Timeseries: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "A", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "A", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, { - Labels: append(lbls, labelpb.Label{Name: "c", Value: "1"}, labelpb.Label{Name: "d", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "c", Value: "1"}, labelpb.ZLabel{Name: "d", Value: "2"}), Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, { - Labels: append(lbls, labelpb.Label{Name: "E", Value: "1"}, labelpb.Label{Name: "f", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "E", Value: "1"}, labelpb.ZLabel{Name: "f", Value: "2"}), Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, }, @@ -121,7 +121,7 @@ func TestWriter(t *testing.T) { expectedErr: errors.Wrapf(labelpb.ErrOutOfOrderLabels, "add 2 series"), expectedIngested: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "c", Value: "1"}, labelpb.Label{Name: "d", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "c", Value: "1"}, labelpb.ZLabel{Name: "d", Value: "2"}), Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, }, }, @@ -170,12 +170,12 @@ func TestWriter(t *testing.T) { Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, Exemplars: []prompb.Exemplar{ { - Labels: []labelpb.Label{{Name: "traceID", Value: "123"}}, + Labels: []labelpb.ZLabel{{Name: "traceID", Value: "123"}}, Value: 111, Timestamp: 11, }, { - Labels: []labelpb.Label{{Name: "traceID", Value: "234"}}, + Labels: []labelpb.ZLabel{{Name: "traceID", Value: "234"}}, Value: 112, Timestamp: 12, }, @@ -196,7 +196,7 @@ func TestWriter(t *testing.T) { Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, Exemplars: []prompb.Exemplar{ { - Labels: []labelpb.Label{{Name: "traceID", Value: "123"}}, + Labels: []labelpb.ZLabel{{Name: "traceID", Value: "123"}}, Value: 111, Timestamp: 11, }, @@ -210,7 +210,7 @@ func TestWriter(t *testing.T) { Labels: lbls, Exemplars: []prompb.Exemplar{ { - Labels: []labelpb.Label{{Name: "traceID", Value: "1234"}}, + Labels: []labelpb.ZLabel{{Name: "traceID", Value: "1234"}}, Value: 111, Timestamp: 10, }, @@ -232,7 +232,7 @@ func TestWriter(t *testing.T) { Samples: []prompb.Sample{{Value: 1, Timestamp: 10}}, Exemplars: []prompb.Exemplar{ { - Labels: []labelpb.Label{{Name: strings.Repeat("a", exemplar.ExemplarMaxLabelSetLength), Value: "1"}}, + Labels: []labelpb.ZLabel{{Name: strings.Repeat("a", exemplar.ExemplarMaxLabelSetLength), Value: "1"}}, Value: 111, Timestamp: 11, }, @@ -249,7 +249,7 @@ func TestWriter(t *testing.T) { { Timeseries: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Histograms: []prompb.Histogram{ prompb.HistogramToHistogramProto(10, tsdbutil.GenerateTestHistogram(0)), }, @@ -260,7 +260,7 @@ func TestWriter(t *testing.T) { expectedErr: nil, expectedIngested: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Histograms: []prompb.Histogram{ prompb.HistogramToHistogramProto(10, tsdbutil.GenerateTestHistogram(0)), }, @@ -272,7 +272,7 @@ func TestWriter(t *testing.T) { { Timeseries: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Histograms: []prompb.Histogram{ prompb.FloatHistogramToHistogramProto(10, tsdbutil.GenerateTestFloatHistogram(1)), }, @@ -283,7 +283,7 @@ func TestWriter(t *testing.T) { expectedErr: nil, expectedIngested: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Histograms: []prompb.Histogram{ prompb.FloatHistogramToHistogramProto(10, tsdbutil.GenerateTestFloatHistogram(1)), }, @@ -295,7 +295,7 @@ func TestWriter(t *testing.T) { { Timeseries: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Histograms: []prompb.Histogram{ prompb.HistogramToHistogramProto(10, tsdbutil.GenerateTestHistogram(0)), }, @@ -305,7 +305,7 @@ func TestWriter(t *testing.T) { { Timeseries: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Histograms: []prompb.Histogram{ prompb.HistogramToHistogramProto(9, tsdbutil.GenerateTestHistogram(0)), }, @@ -316,7 +316,7 @@ func TestWriter(t *testing.T) { expectedErr: errors.Wrapf(storage.ErrOutOfOrderSample, "add 1 samples"), expectedIngested: []prompb.TimeSeries{ { - Labels: append(lbls, labelpb.Label{Name: "a", Value: "1"}, labelpb.Label{Name: "b", Value: "2"}), + Labels: append(lbls, labelpb.ZLabel{Name: "a", Value: "1"}, labelpb.ZLabel{Name: "b", Value: "2"}), Histograms: []prompb.Histogram{ prompb.HistogramToHistogramProto(10, tsdbutil.GenerateTestHistogram(0)), }, @@ -382,7 +382,7 @@ func TestWriter(t *testing.T) { gr := a.(storage.GetRef) for _, ts := range testData.expectedIngested { - l := labelpb.LabelpbLabelsToPromLabels(ts.Labels) + l := labelpb.ZLabelsToPromLabels(ts.Labels) ref, _ := gr.GetRef(l, l.Hash()) testutil.Assert(t, ref != 0, fmt.Sprintf("appender should have reference to series %v", ts)) } @@ -490,10 +490,10 @@ func benchmarkWriter(b *testing.B, labelsNum int, seriesNum int, generateHistogr // reflected in the benchmark, but should still capture the performance of receive writer. func generateLabelsAndSeries(numLabels int, numSeries int, generateHistograms bool) []prompb.TimeSeries { // Generate some labels first. - l := make([]labelpb.Label, 0, numLabels) - l = append(l, labelpb.Label{Name: "__name__", Value: "test"}) + l := make([]labelpb.ZLabel, 0, numLabels) + l = append(l, labelpb.ZLabel{Name: "__name__", Value: "test"}) for i := 0; i < numLabels; i++ { - l = append(l, labelpb.Label{Name: fmt.Sprintf("label_%s", string(rune('a'+i))), Value: fmt.Sprintf("%d", i)}) + l = append(l, labelpb.ZLabel{Name: fmt.Sprintf("label_%s", string(rune('a'+i))), Value: fmt.Sprintf("%d", i)}) } ts := make([]prompb.TimeSeries, numSeries) diff --git a/pkg/rules/manager.go b/pkg/rules/manager.go index e93b6f30aa..9a802ce10a 100644 --- a/pkg/rules/manager.go +++ b/pkg/rules/manager.go @@ -65,8 +65,8 @@ func (g Group) toProto() *rulespb.RuleGroup { Query: rule.Query().String(), DurationSeconds: rule.HoldDuration().Seconds(), KeepFiringForSeconds: rule.KeepFiringFor().Seconds(), - Labels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(rule.Labels())}, - Annotations: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(rule.Annotations())}, + Labels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(rule.Labels())}, + Annotations: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(rule.Annotations())}, Alerts: ActiveAlertsToProto(g.PartialResponseStrategy, rule), Health: string(rule.Health()), LastError: lastError, @@ -79,7 +79,7 @@ func (g Group) toProto() *rulespb.RuleGroup { Result: &rulespb.Rule_Recording{Recording: &rulespb.RecordingRule{ Name: rule.Name(), Query: rule.Query().String(), - Labels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(rule.Labels())}, + Labels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(rule.Labels())}, Health: string(rule.Health()), LastError: lastError, EvaluationDurationSeconds: rule.GetEvaluationDuration().Seconds(), @@ -102,8 +102,8 @@ func ActiveAlertsToProto(s storepb.PartialResponseStrategy, a *rules.AlertingRul activeAt := ruleAlert.ActiveAt.UTC() ret[i] = &rulespb.AlertInstance{ PartialResponseStrategy: s, - Labels: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(ruleAlert.Labels)}, - Annotations: labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(ruleAlert.Annotations)}, + Labels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(ruleAlert.Labels)}, + Annotations: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(ruleAlert.Annotations)}, State: rulespb.AlertState(ruleAlert.State), ActiveAt: &activeAt, Value: strconv.FormatFloat(ruleAlert.Value, 'e', -1, 64), diff --git a/pkg/rules/rules_test.go b/pkg/rules/rules_test.go index 04e4abc1bc..e62566a8a7 100644 --- a/pkg/rules/rules_test.go +++ b/pkg/rules/rules_test.go @@ -275,34 +275,34 @@ func TestDedupRules(t *testing.T) { rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, want: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, @@ -313,30 +313,30 @@ func TestDedupRules(t *testing.T) { rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, @@ -344,17 +344,17 @@ func TestDedupRules(t *testing.T) { rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, @@ -365,39 +365,39 @@ func TestDedupRules(t *testing.T) { rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", Query: "up", DurationSeconds: 1.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", Query: "up", DurationSeconds: 1.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", Query: "up", DurationSeconds: 2.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, @@ -406,22 +406,22 @@ func TestDedupRules(t *testing.T) { Name: "a1", Query: "up", DurationSeconds: 1.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", Query: "up", DurationSeconds: 2.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "a1", Query: "up", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "a1", Query: "up", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, @@ -433,7 +433,7 @@ func TestDedupRules(t *testing.T) { Name: "a1", Query: "up", DurationSeconds: 1.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, {Name: "replica", Value: "1"}, }}}), @@ -441,7 +441,7 @@ func TestDedupRules(t *testing.T) { Name: "a1", Query: "up", DurationSeconds: 2.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, @@ -450,14 +450,14 @@ func TestDedupRules(t *testing.T) { Name: "a1", Query: "up", DurationSeconds: 1.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", Query: "up", DurationSeconds: 2.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, @@ -466,21 +466,21 @@ func TestDedupRules(t *testing.T) { { name: "replica labels", rules: []*rulespb.Rule{ - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, {Name: "replica", Value: "3"}, }}}), - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, {Name: "replica", Value: "1"}, }}}), - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, {Name: "replica", Value: "2"}, }}}), }, want: []*rulespb.Rule{ - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), }, @@ -489,28 +489,28 @@ func TestDedupRules(t *testing.T) { { name: "ambiguous replica labels", rules: []*rulespb.Rule{ - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "a", Value: "1"}, }}}), - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, }}}), - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "a", Value: "2"}, }}}), - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "a", Value: "1"}, }}}), }, want: []*rulespb.Rule{ rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1"}), - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), - rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + rulespb.NewRecordingRule(&rulespb.RecordingRule{Name: "a1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "2"}, }}}), }, @@ -522,7 +522,7 @@ func TestDedupRules(t *testing.T) { rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "2"}, }}, LastEvaluation: time.Unix(0, 0), @@ -530,7 +530,7 @@ func TestDedupRules(t *testing.T) { rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, }}, LastEvaluation: time.Unix(1, 0), @@ -538,7 +538,7 @@ func TestDedupRules(t *testing.T) { rulespb.NewRecordingRule(&rulespb.RecordingRule{ Name: "a1", Query: "up", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "3"}, }}, LastEvaluation: time.Unix(3, 0), @@ -563,14 +563,14 @@ func TestDedupRules(t *testing.T) { rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "2"}, }}, LastEvaluation: time.Unix(4, 0), }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "2"}, {Name: "foo", Value: "bar"}, }}, @@ -583,14 +583,14 @@ func TestDedupRules(t *testing.T) { }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, }}, LastEvaluation: time.Unix(3, 0), }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a2", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, }}, LastEvaluation: time.Unix(3, 0), @@ -598,7 +598,7 @@ func TestDedupRules(t *testing.T) { }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "3"}, }}, LastEvaluation: time.Unix(2, 0), @@ -606,7 +606,7 @@ func TestDedupRules(t *testing.T) { }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "foo", Value: "bar"}, }}, State: rulespb.AlertState_FIRING, @@ -622,7 +622,7 @@ func TestDedupRules(t *testing.T) { rulespb.NewAlertingRule(&rulespb.Alert{ State: rulespb.AlertState_FIRING, Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "foo", Value: "bar"}, }}, LastEvaluation: time.Unix(1, 0), @@ -640,7 +640,7 @@ func TestDedupRules(t *testing.T) { rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "severity", Value: "warning"}, }}, @@ -648,7 +648,7 @@ func TestDedupRules(t *testing.T) { }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "severity", Value: "critical"}, }}, @@ -656,7 +656,7 @@ func TestDedupRules(t *testing.T) { }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "2"}, {Name: "severity", Value: "warning"}, }}, @@ -664,7 +664,7 @@ func TestDedupRules(t *testing.T) { }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "2"}, {Name: "severity", Value: "critical"}, }}, @@ -674,14 +674,14 @@ func TestDedupRules(t *testing.T) { want: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "severity", Value: "critical"}, }}, LastEvaluation: time.Unix(1, 0), }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "severity", Value: "warning"}, }}, LastEvaluation: time.Unix(1, 0), @@ -694,7 +694,7 @@ func TestDedupRules(t *testing.T) { rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, @@ -702,7 +702,7 @@ func TestDedupRules(t *testing.T) { }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "2"}, {Name: "label", Value: "foo"}, }}, @@ -710,7 +710,7 @@ func TestDedupRules(t *testing.T) { }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, LastEvaluation: time.Unix(1, 0), @@ -719,7 +719,7 @@ func TestDedupRules(t *testing.T) { want: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, LastEvaluation: time.Unix(1, 0), @@ -998,18 +998,18 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r2", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r2", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1022,18 +1022,18 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r2", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r2", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1050,18 +1050,18 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r2", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r2", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1074,13 +1074,13 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1097,18 +1097,18 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r2", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r2", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1126,14 +1126,14 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, {Name: "templatedlabel", Value: "{{ $externalURL }}"}, }}, }), rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a2", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1151,17 +1151,17 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1a", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1a", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1b", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1b", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1172,12 +1172,12 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1b", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "some", Value: "label"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1b", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1b", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1190,12 +1190,12 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1a", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1a", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1205,7 +1205,7 @@ func TestFilterRules(t *testing.T) { Name: "b", Rules: []*rulespb.Rule{ rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1b", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1b", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1222,17 +1222,17 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1a", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1a", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1b", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1b", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1243,12 +1243,12 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1b", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "some", Value: "label"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1b", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1b", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1266,7 +1266,7 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "templatedlabel", Value: "{{ $externalURL }}"}, }}, }), @@ -1277,7 +1277,7 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1b", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "templated", Value: "{{ $externalURL }}"}, }}, }), @@ -1295,7 +1295,7 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "templatedlabel", Value: "{{ $externalURL }}"}, }}, }), @@ -1306,7 +1306,7 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1b", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "templated", Value: "{{ $externalURL }}"}, }}, }), @@ -1324,17 +1324,17 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1a", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1a", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1b", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1b", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1345,12 +1345,12 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1b", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "some", Value: "label"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1b", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1b", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1363,12 +1363,12 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1a", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1a", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1378,7 +1378,7 @@ func TestFilterRules(t *testing.T) { Name: "b", Rules: []*rulespb.Rule{ rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1b", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1b", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), @@ -1395,18 +1395,18 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r2", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r2", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1419,7 +1419,7 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, @@ -1650,18 +1650,18 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r1", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r1", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "label", Value: "foo"}, }}, }), rulespb.NewRecordingRule(&rulespb.RecordingRule{ - Name: "r2", Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Name: "r2", Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "otherlabel", Value: "bar"}, }}, }), @@ -1674,7 +1674,7 @@ func TestFilterRules(t *testing.T) { Rules: []*rulespb.Rule{ rulespb.NewAlertingRule(&rulespb.Alert{ Name: "a1", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "replica", Value: "1"}, {Name: "label", Value: "foo"}, }}, diff --git a/pkg/rules/rulespb/custom.go b/pkg/rules/rulespb/custom.go index bb1ee31996..5e405b2e86 100644 --- a/pkg/rules/rulespb/custom.go +++ b/pkg/rules/rulespb/custom.go @@ -84,10 +84,10 @@ func (r *Rule) GetLabels() labels.Labels { } func (r *Rule) SetLabels(ls labels.Labels) { - var result labelpb.LabelSet + var result labelpb.ZLabelSet if !ls.IsEmpty() { - result = labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(ls)} + result = labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(ls)} } switch { diff --git a/pkg/rules/rulespb/custom_test.go b/pkg/rules/rulespb/custom_test.go index 358258b469..81880213ec 100644 --- a/pkg/rules/rulespb/custom_test.go +++ b/pkg/rules/rulespb/custom_test.go @@ -200,14 +200,14 @@ func TestJSONUnmarshalMarshal(t *testing.T) { NewAlertingRule(&Alert{ Name: "alert1", Query: "up == 0", - Labels: labelpb.LabelSet{ - Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{ + Labels: []labelpb.ZLabel{ {Name: "a2", Value: "b2"}, {Name: "c2", Value: "d2"}, }, }, - Annotations: labelpb.LabelSet{ - Labels: []labelpb.Label{ + Annotations: labelpb.ZLabelSet{ + Labels: []labelpb.ZLabel{ {Name: "ann1", Value: "ann44"}, {Name: "ann2", Value: "ann33"}, }, @@ -313,8 +313,8 @@ func TestJSONUnmarshalMarshal(t *testing.T) { NewRecordingRule(&RecordingRule{ Query: "up", Name: "recording1", - Labels: labelpb.LabelSet{ - Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{ + Labels: []labelpb.ZLabel{ {Name: "a", Value: "b"}, {Name: "c", Value: "d"}, }, @@ -327,27 +327,27 @@ func TestJSONUnmarshalMarshal(t *testing.T) { NewAlertingRule(&Alert{ Name: "alert1", Query: "up == 0", - Labels: labelpb.LabelSet{ - Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{ + Labels: []labelpb.ZLabel{ {Name: "a2", Value: "b2"}, {Name: "c2", Value: "d2"}, }, }, - Annotations: labelpb.LabelSet{ - Labels: []labelpb.Label{ + Annotations: labelpb.ZLabelSet{ + Labels: []labelpb.ZLabel{ {Name: "ann1", Value: "ann44"}, {Name: "ann2", Value: "ann33"}, }, }, Alerts: []*AlertInstance{ { - Labels: labelpb.LabelSet{ - Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{ + Labels: []labelpb.ZLabel{ {Name: "instance1", Value: "1"}, }, }, - Annotations: labelpb.LabelSet{ - Labels: []labelpb.Label{ + Annotations: labelpb.ZLabelSet{ + Labels: []labelpb.ZLabel{ {Name: "annotation1", Value: "2"}, }, }, @@ -451,7 +451,7 @@ func TestRulesComparator(t *testing.T) { r1: NewAlertingRule(&Alert{Name: "a"}), r2: NewAlertingRule(&Alert{ Name: "a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), want: -1, @@ -460,12 +460,12 @@ func TestRulesComparator(t *testing.T) { name: "label ordering", r1: NewAlertingRule(&Alert{ Name: "a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), r2: NewAlertingRule(&Alert{ Name: "a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "2"}, }}}), want: -1, @@ -474,12 +474,12 @@ func TestRulesComparator(t *testing.T) { name: "multiple label ordering", r1: NewAlertingRule(&Alert{ Name: "a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), r2: NewAlertingRule(&Alert{ Name: "a", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, {Name: "b", Value: "1"}, }}}), @@ -490,13 +490,13 @@ func TestRulesComparator(t *testing.T) { r1: NewAlertingRule(&Alert{ Name: "a", DurationSeconds: 0.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), r2: NewAlertingRule(&Alert{ Name: "a", DurationSeconds: 1.0, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "a", Value: "1"}, }}}), want: -1, diff --git a/pkg/rules/rulespb/rpc.pb.go b/pkg/rules/rulespb/rpc.pb.go index bb5ba32189..298ce03063 100644 --- a/pkg/rules/rulespb/rpc.pb.go +++ b/pkg/rules/rulespb/rpc.pb.go @@ -407,11 +407,11 @@ func (*Rule) XXX_OneofWrappers() []interface{} { } type AlertInstance struct { - Labels labelpb.LabelSet `protobuf:"bytes,1,opt,name=labels,proto3" json:"labels"` - Annotations labelpb.LabelSet `protobuf:"bytes,2,opt,name=annotations,proto3" json:"annotations"` - State AlertState `protobuf:"varint,3,opt,name=state,proto3,enum=thanos.AlertState" json:"state"` - ActiveAt *time.Time `protobuf:"bytes,4,opt,name=active_at,json=activeAt,proto3,stdtime" json:"activeAt,omitempty"` - Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value"` + Labels labelpb.ZLabelSet `protobuf:"bytes,1,opt,name=labels,proto3" json:"labels"` + Annotations labelpb.ZLabelSet `protobuf:"bytes,2,opt,name=annotations,proto3" json:"annotations"` + State AlertState `protobuf:"varint,3,opt,name=state,proto3,enum=thanos.AlertState" json:"state"` + ActiveAt *time.Time `protobuf:"bytes,4,opt,name=active_at,json=activeAt,proto3,stdtime" json:"activeAt,omitempty"` + Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value"` // Thanos specific. Used mainly for alert API purposes. PartialResponseStrategy storepb.PartialResponseStrategy `protobuf:"varint,6,opt,name=PartialResponseStrategy,proto3,enum=thanos.PartialResponseStrategy" json:"partialResponseStrategy"` } @@ -451,18 +451,18 @@ var xxx_messageInfo_AlertInstance proto.InternalMessageInfo type Alert struct { /// state returns the maximum state of alert instances for this rule. - State AlertState `protobuf:"varint,1,opt,name=state,proto3,enum=thanos.AlertState" json:"state"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name"` - Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query"` - DurationSeconds float64 `protobuf:"fixed64,4,opt,name=duration_seconds,json=durationSeconds,proto3" json:"duration"` - Labels labelpb.LabelSet `protobuf:"bytes,5,opt,name=labels,proto3" json:"labels"` - Annotations labelpb.LabelSet `protobuf:"bytes,6,opt,name=annotations,proto3" json:"annotations"` - Alerts []*AlertInstance `protobuf:"bytes,7,rep,name=alerts,proto3" json:"alerts"` - Health string `protobuf:"bytes,8,opt,name=health,proto3" json:"health"` - LastError string `protobuf:"bytes,9,opt,name=last_error,json=lastError,proto3" json:"lastError,omitempty"` - EvaluationDurationSeconds float64 `protobuf:"fixed64,10,opt,name=evaluation_duration_seconds,json=evaluationDurationSeconds,proto3" json:"evaluationTime"` - LastEvaluation time.Time `protobuf:"bytes,11,opt,name=last_evaluation,json=lastEvaluation,proto3,stdtime" json:"lastEvaluation"` - KeepFiringForSeconds float64 `protobuf:"fixed64,12,opt,name=keep_firing_for_seconds,json=keepFiringForSeconds,proto3" json:"keepFiringFor"` + State AlertState `protobuf:"varint,1,opt,name=state,proto3,enum=thanos.AlertState" json:"state"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name"` + Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query"` + DurationSeconds float64 `protobuf:"fixed64,4,opt,name=duration_seconds,json=durationSeconds,proto3" json:"duration"` + Labels labelpb.ZLabelSet `protobuf:"bytes,5,opt,name=labels,proto3" json:"labels"` + Annotations labelpb.ZLabelSet `protobuf:"bytes,6,opt,name=annotations,proto3" json:"annotations"` + Alerts []*AlertInstance `protobuf:"bytes,7,rep,name=alerts,proto3" json:"alerts"` + Health string `protobuf:"bytes,8,opt,name=health,proto3" json:"health"` + LastError string `protobuf:"bytes,9,opt,name=last_error,json=lastError,proto3" json:"lastError,omitempty"` + EvaluationDurationSeconds float64 `protobuf:"fixed64,10,opt,name=evaluation_duration_seconds,json=evaluationDurationSeconds,proto3" json:"evaluationTime"` + LastEvaluation time.Time `protobuf:"bytes,11,opt,name=last_evaluation,json=lastEvaluation,proto3,stdtime" json:"lastEvaluation"` + KeepFiringForSeconds float64 `protobuf:"fixed64,12,opt,name=keep_firing_for_seconds,json=keepFiringForSeconds,proto3" json:"keepFiringFor"` } func (m *Alert) Reset() { *m = Alert{} } @@ -499,13 +499,13 @@ func (m *Alert) XXX_DiscardUnknown() { var xxx_messageInfo_Alert proto.InternalMessageInfo type RecordingRule struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name"` - Query string `protobuf:"bytes,2,opt,name=query,proto3" json:"query"` - Labels labelpb.LabelSet `protobuf:"bytes,3,opt,name=labels,proto3" json:"labels"` - Health string `protobuf:"bytes,4,opt,name=health,proto3" json:"health"` - LastError string `protobuf:"bytes,5,opt,name=last_error,json=lastError,proto3" json:"lastError,omitempty"` - EvaluationDurationSeconds float64 `protobuf:"fixed64,6,opt,name=evaluation_duration_seconds,json=evaluationDurationSeconds,proto3" json:"evaluationTime"` - LastEvaluation time.Time `protobuf:"bytes,7,opt,name=last_evaluation,json=lastEvaluation,proto3,stdtime" json:"lastEvaluation"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name"` + Query string `protobuf:"bytes,2,opt,name=query,proto3" json:"query"` + Labels labelpb.ZLabelSet `protobuf:"bytes,3,opt,name=labels,proto3" json:"labels"` + Health string `protobuf:"bytes,4,opt,name=health,proto3" json:"health"` + LastError string `protobuf:"bytes,5,opt,name=last_error,json=lastError,proto3" json:"lastError,omitempty"` + EvaluationDurationSeconds float64 `protobuf:"fixed64,6,opt,name=evaluation_duration_seconds,json=evaluationDurationSeconds,proto3" json:"evaluationTime"` + LastEvaluation time.Time `protobuf:"bytes,7,opt,name=last_evaluation,json=lastEvaluation,proto3,stdtime" json:"lastEvaluation"` } func (m *RecordingRule) Reset() { *m = RecordingRule{} } @@ -557,76 +557,76 @@ func init() { func init() { proto.RegisterFile("rules/rulespb/rpc.proto", fileDescriptor_91b1d28f30eb5efb) } var fileDescriptor_91b1d28f30eb5efb = []byte{ - // 1098 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcd, 0x6e, 0x23, 0x45, - 0x10, 0xf6, 0xd8, 0x9e, 0xb1, 0xa7, 0x1c, 0x67, 0xbd, 0xbd, 0xbb, 0xca, 0x24, 0x0b, 0x9e, 0xc8, - 0x52, 0x50, 0x40, 0xac, 0x8d, 0x12, 0xed, 0x02, 0x27, 0x14, 0xe7, 0x5f, 0x8a, 0xc2, 0xaa, 0x1d, - 0x71, 0x80, 0x83, 0xe9, 0x38, 0x1d, 0x67, 0xc4, 0x78, 0x66, 0xb6, 0xa7, 0x1d, 0x94, 0xb7, 0xd8, - 0x2b, 0x0f, 0xc2, 0x81, 0x37, 0xc8, 0x05, 0x69, 0x8f, 0x9c, 0x0c, 0x24, 0x37, 0x1f, 0x78, 0x06, - 0xd4, 0xd5, 0x33, 0x1e, 0x27, 0x9b, 0x90, 0x5d, 0x08, 0x17, 0x77, 0xf7, 0x57, 0x5f, 0xf5, 0x4f, - 0xd5, 0x57, 0xe5, 0x81, 0x39, 0x31, 0xf4, 0x79, 0xdc, 0xc2, 0xdf, 0xe8, 0xb0, 0x25, 0xa2, 0x5e, - 0x33, 0x12, 0xa1, 0x0c, 0x89, 0x25, 0x4f, 0x58, 0x10, 0xc6, 0x0b, 0xf3, 0xb1, 0x0c, 0x05, 0x6f, - 0xe1, 0x6f, 0x74, 0xd8, 0x92, 0x67, 0x11, 0x8f, 0x35, 0x25, 0x35, 0xf9, 0xec, 0x90, 0xfb, 0xd7, - 0x4c, 0x8f, 0xfb, 0x61, 0x3f, 0xc4, 0x69, 0x4b, 0xcd, 0x12, 0xd4, 0xed, 0x87, 0x61, 0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73, 0xfd, 0x6b, 0xba, 0x51, 0xcb, 0x37, 0xbe, 0x87, 0x6a, 0x12, 0x16, - 0x7d, 0x6f, 0xf2, 0x31, 0x98, 0xfa, 0x18, 0x15, 0xbc, 0xca, 0xca, 0xc3, 0xe9, 0xe0, 0xe1, 0x71, - 0x3b, 0x39, 0xaa, 0x19, 0x64, 0x01, 0x4a, 0x3f, 0x32, 0x11, 0xa8, 0x37, 0xa9, 0x28, 0xd9, 0x3b, - 0x39, 0x9a, 0x02, 0xed, 0x32, 0x58, 0x82, 0xc7, 0x43, 0x5f, 0x36, 0xd6, 0x01, 0x26, 0xbe, 0x31, - 0x79, 0x0e, 0x16, 0x3a, 0xc7, 0x8e, 0xb1, 0x58, 0xb8, 0x71, 0xff, 0x36, 0x8c, 0x47, 0x6e, 0x42, - 0xa2, 0xc9, 0xd8, 0xf8, 0xab, 0x00, 0xf6, 0x84, 0x41, 0x3e, 0x80, 0x22, 0xc6, 0x49, 0x5d, 0xd1, - 0x6e, 0x97, 0xc7, 0x23, 0x17, 0xd7, 0x14, 0x7f, 0x95, 0x15, 0xc3, 0x91, 0xcf, 0xac, 0x6a, 0xad, - 0x03, 0x43, 0x9e, 0x81, 0x89, 0xb2, 0xc5, 0x34, 0x54, 0x56, 0x66, 0xa6, 0xcf, 0x6f, 0xdb, 0xe3, - 0x91, 0xab, 0xcd, 0x54, 0x0f, 0x64, 0x19, 0xca, 0x5e, 0x20, 0xb9, 0x38, 0x65, 0xbe, 0x53, 0x5c, - 0x34, 0x96, 0x8d, 0xf6, 0xcc, 0x78, 0xe4, 0x4e, 0x30, 0x3a, 0x99, 0x11, 0x0a, 0x4f, 0xf9, 0x29, - 0xf3, 0x87, 0x4c, 0x7a, 0x61, 0xd0, 0x3d, 0x1a, 0x0a, 0x3d, 0x89, 0x79, 0x2f, 0x0c, 0x8e, 0x62, - 0xc7, 0x44, 0x67, 0x32, 0x1e, 0xb9, 0xb3, 0x19, 0xed, 0xc0, 0x1b, 0x70, 0x3a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 0x7a, 0xee, 0xb7, - 0xcb, 0x7a, 0xee, 0xdb, 0x52, 0xf2, 0x0d, 0x7e, 0x68, 0xe1, 0xe3, 0x56, 0xff, 0x0e, 0x00, 0x00, - 0xff, 0xff, 0xdc, 0x00, 0x20, 0x9a, 0x9b, 0x0b, 0x00, 0x00, + // 1096 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcd, 0x4e, 0x23, 0x47, + 0x10, 0xf6, 0xd8, 0x9e, 0xb1, 0xa7, 0x8c, 0x59, 0xb6, 0x17, 0xc4, 0x00, 0x89, 0x07, 0x59, 0x22, + 0x22, 0x51, 0xd6, 0x8e, 0x40, 0xbb, 0xd1, 0x9e, 0x22, 0xcc, 0xcf, 0x82, 0x84, 0xc8, 0xaa, 0x8d, + 0x72, 0xd8, 0x1c, 0x9c, 0xc6, 0x34, 0x66, 0x94, 0xf1, 0xcc, 0x6c, 0x4f, 0x9b, 0x88, 0xb7, 0xd8, + 0x73, 0x5e, 0x24, 0xca, 0x1b, 0x70, 0xcb, 0x1e, 0x73, 0x72, 0x12, 0xb8, 0xf9, 0x90, 0x67, 0x88, + 0xba, 0x7a, 0xc6, 0x63, 0x08, 0x84, 0xdd, 0x84, 0x5c, 0xdc, 0xdd, 0x5f, 0x7d, 0xd5, 0x3f, 0x55, + 0x5f, 0x95, 0x07, 0xe6, 0xc5, 0xc0, 0xe7, 0x71, 0x13, 0x7f, 0xa3, 0xa3, 0xa6, 0x88, 0xba, 0x8d, + 0x48, 0x84, 0x32, 0x24, 0x96, 0x3c, 0x65, 0x41, 0x18, 0x2f, 0x2e, 0xc4, 0x32, 0x14, 0xbc, 0x89, + 0xbf, 0xd1, 0x51, 0x53, 0x9e, 0x47, 0x3c, 0xd6, 0x94, 0xd4, 0xe4, 0xb3, 0x23, 0xee, 0xdf, 0x30, + 0xcd, 0xf6, 0xc2, 0x5e, 0x88, 0xd3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xd0, 0x9d, 0xce, 0x68, 0x87, 0x5e, 0x9f, 0xd3, 0x85, 0x6c, 0xbd, 0x95, + 0x78, 0xb5, 0xb5, 0x13, 0xe9, 0xc0, 0x23, 0x9f, 0xc5, 0xb2, 0x93, 0x31, 0x1c, 0x0b, 0xd3, 0xb2, + 0xd8, 0xd0, 0x45, 0xd1, 0x48, 0x8b, 0xa2, 0x71, 0x98, 0x16, 0x45, 0x6b, 0xf1, 0x62, 0xe8, 0xe6, + 0xd4, 0x39, 0xca, 0x75, 0x7b, 0xec, 0xf9, 0xf6, 0x37, 0xd7, 0xa0, 0x37, 0x30, 0xe2, 0x82, 0xe9, + 0x7b, 0x7d, 0x4f, 0x3a, 0xf6, 0xb2, 0xb1, 0x5a, 0xd0, 0xef, 0x47, 0x80, 0xea, 0x81, 0x9c, 0xc1, + 0xfc, 0x1d, 0x92, 0x77, 0xca, 0xef, 0x55, 0x19, 0xad, 0xa5, 0xd1, 0xd0, 0xbd, 0xab, 0x3a, 0xe8, + 0x5d, 0x9b, 0xd7, 0x03, 0x28, 0xaa, 0x8c, 0x90, 0x67, 0x60, 0x0b, 0xde, 0x0d, 0xc5, 0xb1, 0x52, + 0x99, 0x96, 0xe4, 0xdc, 0x38, 0x65, 0xa9, 0x41, 0x31, 0x77, 0x73, 0x34, 0x63, 0x92, 0x15, 0x30, + 0x99, 0xcf, 0x85, 0x44, 0x11, 0x54, 0xd6, 0xaa, 0xa9, 0xcb, 0x86, 0x02, 0x95, 0x82, 0xd1, 0x3a, + 0xa1, 0xd2, 0x9f, 0x0a, 0x50, 0x45, 0xe3, 0x5e, 0x10, 0x4b, 0x16, 0x74, 0x39, 0x79, 0x01, 0x16, + 0xf6, 0xa8, 0xf8, 0x66, 0x25, 0xbc, 0xde, 0x57, 0x70, 0x9b, 0xcb, 0xd6, 0x74, 0x12, 0xe9, 0x84, + 0x48, 0x93, 0x91, 0xec, 0x42, 0x85, 0x05, 0x41, 0x28, 0x31, 0xc6, 0x71, 0x72, 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0xaa, 0x96, 0xfb, 0xf5, 0xaa, 0x96, + 0x7b, 0x5d, 0x4a, 0x3e, 0xc4, 0x8f, 0x2c, 0x7c, 0xdc, 0xfa, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xa0, 0xc1, 0xf7, 0x10, 0xa0, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/pkg/rules/rulespb/rpc.proto b/pkg/rules/rulespb/rpc.proto index be154201d1..f5fc8a038b 100644 --- a/pkg/rules/rulespb/rpc.proto +++ b/pkg/rules/rulespb/rpc.proto @@ -106,8 +106,8 @@ enum AlertState { } message AlertInstance { - LabelSet labels = 1 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false ]; - LabelSet annotations = 2 [(gogoproto.jsontag) = "annotations", (gogoproto.nullable) = false ]; + ZLabelSet labels = 1 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false ]; + ZLabelSet annotations = 2 [(gogoproto.jsontag) = "annotations", (gogoproto.nullable) = false ]; AlertState state = 3 [(gogoproto.jsontag) = "state" ]; google.protobuf.Timestamp active_at = 4 [(gogoproto.jsontag) = "activeAt,omitempty", (gogoproto.stdtime) = true]; string value = 5 [(gogoproto.jsontag) = "value" ]; @@ -122,8 +122,8 @@ message Alert { string name = 2 [(gogoproto.jsontag) = "name" ]; string query = 3 [(gogoproto.jsontag) = "query" ]; double duration_seconds = 4 [(gogoproto.jsontag) = "duration" ]; - LabelSet labels = 5 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false ]; - LabelSet annotations = 6 [(gogoproto.jsontag) = "annotations", (gogoproto.nullable) = false ]; + ZLabelSet labels = 5 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false ]; + ZLabelSet annotations = 6 [(gogoproto.jsontag) = "annotations", (gogoproto.nullable) = false ]; repeated AlertInstance alerts = 7 [(gogoproto.jsontag) = "alerts" ]; string health = 8 [(gogoproto.jsontag) = "health" ]; string last_error = 9 [(gogoproto.jsontag) = "lastError,omitempty" ]; @@ -135,7 +135,7 @@ message Alert { message RecordingRule { string name = 1 [(gogoproto.jsontag) = "name" ]; string query = 2 [(gogoproto.jsontag) = "query" ]; - LabelSet labels = 3 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false ]; + ZLabelSet labels = 3 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false ]; string health = 4 [(gogoproto.jsontag) = "health" ]; string last_error = 5 [(gogoproto.jsontag) = "lastError,omitempty" ]; double evaluation_duration_seconds = 6 [(gogoproto.jsontag) = "evaluationTime" ]; diff --git a/pkg/store/acceptance_test.go b/pkg/store/acceptance_test.go index 274f32386c..793f16eb60 100644 --- a/pkg/store/acceptance_test.go +++ b/pkg/store/acceptance_test.go @@ -864,7 +864,7 @@ func testStoreAPIsSeriesSplitSamplesIntoChunksWithMaxSizeOf120(t *testing.T, sta firstSeries := srv.SeriesSet[0] - testutil.Equals(t, []labelpb.Label{ + testutil.Equals(t, []labelpb.ZLabel{ {Name: "a", Value: "b"}, {Name: "region", Value: "eu-west"}, }, firstSeries.Labels) diff --git a/pkg/store/bucket.go b/pkg/store/bucket.go index 644cea2db8..865ea3878d 100644 --- a/pkg/store/bucket.go +++ b/pkg/store/bucket.go @@ -408,7 +408,7 @@ type BucketStore struct { partitioner Partitioner filterConfig *FilterConfig - advLabelSets []labelpb.LabelSet + advLabelSets []labelpb.ZLabelSet enableCompatibilityLabel bool // Every how many posting offset entry we pool in heap memory. Default in Prometheus is 32. @@ -709,9 +709,9 @@ func (s *BucketStore) SyncBlocks(ctx context.Context) error { // Sync advertise labels. s.mtx.Lock() - s.advLabelSets = make([]labelpb.LabelSet, 0, len(s.advLabelSets)) + s.advLabelSets = make([]labelpb.ZLabelSet, 0, len(s.advLabelSets)) for _, bs := range s.blockSets { - s.advLabelSets = append(s.advLabelSets, labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(bs.labels.Copy())}) + s.advLabelSets = append(s.advLabelSets, labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(bs.labels.Copy())}) } sort.Slice(s.advLabelSets, func(i, j int) bool { return strings.Compare(s.advLabelSets[i].String(), s.advLabelSets[j].String()) < 0 @@ -908,8 +908,8 @@ func (s *BucketStore) TSDBInfos() []infopb.TSDBInfo { lbls := labels.FromMap(b.meta.Thanos.Labels) hash := lbls.Hash() infoMap[hash] = append(infoMap[hash], infopb.TSDBInfo{ - Labels: labelpb.LabelSet{ - Labels: labelpb.PromLabelsToLabelpbLabels(lbls), + Labels: labelpb.ZLabelSet{ + Labels: labelpb.ZLabelsFromPromLabels(lbls), }, MinTime: b.meta.MinTime, MaxTime: b.meta.MaxTime, @@ -938,13 +938,13 @@ func (s *BucketStore) TSDBInfos() []infopb.TSDBInfo { return res } -func (s *BucketStore) LabelSet() []labelpb.LabelSet { +func (s *BucketStore) LabelSet() []labelpb.ZLabelSet { s.mtx.RLock() labelSets := s.advLabelSets s.mtx.RUnlock() if s.enableCompatibilityLabel && len(labelSets) > 0 { - labelSets = append(labelSets, labelpb.LabelSet{Labels: []labelpb.Label{{Name: CompatibilityTypeLabelName, Value: "store"}}}) + labelSets = append(labelSets, labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: CompatibilityTypeLabelName, Value: "store"}}}) } return labelSets @@ -1191,7 +1191,7 @@ func (b *blockSeriesClient) Recv() (*storepb.SeriesResponse, error) { b.entries = b.entries[1:] return storepb.NewSeriesResponse(&storepb.Series{ - Labels: labelpb.PromLabelsToLabelpbLabels(next.lset), + Labels: labelpb.ZLabelsFromPromLabels(next.lset), Chunks: next.chks, }), nil } @@ -1281,7 +1281,7 @@ OUTER: completeLabelset = rmLabels(completeLabelset, b.extLsetToRemove) } - if !b.shardMatcher.MatchesLabels(labelpb.PromLabelsToLabelpbLabels(completeLabelset)) { + if !b.shardMatcher.MatchesLabels(completeLabelset) { continue } @@ -2129,7 +2129,7 @@ func (s *BucketStore) LabelValues(ctx context.Context, req *storepb.LabelValuesR continue } - val := labelpb.LabelpbLabelsToPromLabels(ls.GetSeries().Labels).Get(req.Label) + val := labelpb.ZLabelsToPromLabels(ls.GetSeries().Labels).Get(req.Label) if val != "" { // Should never be empty since we added labelName!="" matcher to the list of matchers. values[val] = struct{}{} } diff --git a/pkg/store/bucket_e2e_test.go b/pkg/store/bucket_e2e_test.go index 051328f12c..cec72b374b 100644 --- a/pkg/store/bucket_e2e_test.go +++ b/pkg/store/bucket_e2e_test.go @@ -242,7 +242,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { // TODO(bwplotka): Add those test cases to TSDB querier_test.go as well, there are no tests for matching. for i, tcase := range []struct { req *storepb.SeriesRequest - expected [][]labelpb.Label + expected [][]labelpb.ZLabel expectedChunkLen int }{ { @@ -254,7 +254,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, @@ -275,7 +275,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { WithoutReplicaLabels: []string{"ext1", "ext2"}, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}}, @@ -295,7 +295,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, @@ -311,7 +311,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, @@ -327,7 +327,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, @@ -347,7 +347,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, @@ -367,7 +367,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "2"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, }, @@ -383,7 +383,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "2"}, {Name: "ext2", Value: "value2"}}, }, @@ -407,7 +407,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, @@ -423,7 +423,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { MaxTime: maxt, }, expectedChunkLen: 3, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, @@ -457,7 +457,7 @@ func testBucketStore_e2e(t *testing.T, ctx context.Context, s *storeSuite) { SkipChunks: true, }, expectedChunkLen: 0, - expected: [][]labelpb.Label{ + expected: [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, @@ -585,7 +585,7 @@ func TestBucketStore_TimePartitioning_e2e(t *testing.T) { MaxTime: timestamp.FromTime(time.Now().AddDate(0, 0, 1)), } - expectedLabels := [][]labelpb.Label{ + expectedLabels := [][]labelpb.ZLabel{ {{Name: "a", Value: "1"}, {Name: "b", Value: "1"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "b", Value: "2"}, {Name: "ext1", Value: "value1"}}, {{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext2", Value: "value2"}}, diff --git a/pkg/store/bucket_test.go b/pkg/store/bucket_test.go index e7247851bc..8c5b5c61ee 100644 --- a/pkg/store/bucket_test.go +++ b/pkg/store/bucket_test.go @@ -719,17 +719,17 @@ func TestBucketStore_TSDBInfo(t *testing.T) { }) testutil.Equals(t, infos, []infopb.TSDBInfo{ { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "a", Value: "b"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "a", Value: "b"}}}, MinTime: 0, MaxTime: 2000, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "a", Value: "b"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "a", Value: "b"}}}, MinTime: 3000, MaxTime: 5000, }, { - Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "a", Value: "c"}}}, + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "a", Value: "c"}}}, MinTime: 0, MaxTime: 2000, }, @@ -806,32 +806,32 @@ func testSharding(t *testing.T, reuseDisk string, bkt objstore.Bucket, all ...ul name string relabel string expectedIDs []ulid.ULID - expectedAdvLabels []labelpb.LabelSet + expectedAdvLabels []labelpb.ZLabelSet }{ { name: "no sharding", expectedIDs: all, - expectedAdvLabels: []labelpb.LabelSet{ + expectedAdvLabels: []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "cluster", Value: "a"}, {Name: "region", Value: "r1"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "cluster", Value: "a"}, {Name: "region", Value: "r2"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "cluster", Value: "b"}, {Name: "region", Value: "r1"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: CompatibilityTypeLabelName, Value: "store"}, }, }, @@ -846,15 +846,15 @@ func testSharding(t *testing.T, reuseDisk string, bkt objstore.Bucket, all ...ul - cluster `, expectedIDs: []ulid.ULID{all[2]}, - expectedAdvLabels: []labelpb.LabelSet{ + expectedAdvLabels: []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "cluster", Value: "b"}, {Name: "region", Value: "r1"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: CompatibilityTypeLabelName, Value: "store"}, }, }, @@ -869,21 +869,21 @@ func testSharding(t *testing.T, reuseDisk string, bkt objstore.Bucket, all ...ul - cluster `, expectedIDs: []ulid.ULID{all[0], all[1], all[3]}, - expectedAdvLabels: []labelpb.LabelSet{ + expectedAdvLabels: []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "cluster", Value: "a"}, {Name: "region", Value: "r1"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "cluster", Value: "a"}, {Name: "region", Value: "r2"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: CompatibilityTypeLabelName, Value: "store"}, }, }, @@ -902,15 +902,15 @@ func testSharding(t *testing.T, reuseDisk string, bkt objstore.Bucket, all ...ul - region `, expectedIDs: []ulid.ULID{all[0], all[1]}, - expectedAdvLabels: []labelpb.LabelSet{ + expectedAdvLabels: []labelpb.ZLabelSet{ { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: "cluster", Value: "a"}, {Name: "region", Value: "r1"}, }, }, { - Labels: []labelpb.Label{ + Labels: []labelpb.ZLabel{ {Name: CompatibilityTypeLabelName, Value: "store"}, }, }, @@ -929,7 +929,7 @@ func testSharding(t *testing.T, reuseDisk string, bkt objstore.Bucket, all ...ul - region `, expectedIDs: []ulid.ULID{}, - expectedAdvLabels: []labelpb.LabelSet{}, + expectedAdvLabels: []labelpb.ZLabelSet{}, }, } { t.Run(sc.name, func(t *testing.T) { @@ -2225,7 +2225,7 @@ func TestSeries_SeriesSortedWithoutReplicaLabels(t *testing.T) { var response []labels.Labels for _, respSeries := range srv.SeriesSet { - promLabels := labelpb.LabelpbLabelsToPromLabels(respSeries.Labels) + promLabels := labelpb.ZLabelsToPromLabels(respSeries.Labels) response = append(response, promLabels) } diff --git a/pkg/store/flushable.go b/pkg/store/flushable.go index 2b1f22590a..33680c3c89 100644 --- a/pkg/store/flushable.go +++ b/pkg/store/flushable.go @@ -69,6 +69,7 @@ func (r *resortingServer) Send(response *storepb.SeriesResponse) error { } series := response.GetSeries() + labelpb.ReAllocZLabelsStrings(&series.Labels, false) r.series = append(r.series, series) return nil } @@ -76,8 +77,8 @@ func (r *resortingServer) Send(response *storepb.SeriesResponse) error { func (r *resortingServer) Flush() error { slices.SortFunc(r.series, func(a, b *storepb.Series) int { return labels.Compare( - labelpb.LabelpbLabelsToPromLabels(a.Labels), - labelpb.LabelpbLabelsToPromLabels(b.Labels), + labelpb.ZLabelsToPromLabels(a.Labels), + labelpb.ZLabelsToPromLabels(b.Labels), ) }) if r.notSend { diff --git a/pkg/store/labelpb/label.go b/pkg/store/labelpb/label.go index 14e8d2fbe3..2829bec439 100644 --- a/pkg/store/labelpb/label.go +++ b/pkg/store/labelpb/label.go @@ -1,16 +1,23 @@ // Copyright (c) The Thanos Authors. // Licensed under the Apache License 2.0. +// Package containing proto and JSON serializable Labels and ZLabels (no copy) structs used to +// identify series. This package expose no-copy converters to Prometheus labels.Labels. + package labelpb import ( "encoding/json" + "fmt" + "io" "sort" "strings" + "unsafe" - "github.com/cespare/xxhash" + "github.com/cespare/xxhash/v2" "github.com/pkg/errors" "github.com/prometheus/prometheus/model/labels" + "go4.org/intern" ) var ( @@ -21,109 +28,319 @@ var ( sep = []byte{'\xff'} ) -// ExtendSortedLabels extend given labels by extend in labels format. -// The type conversion is done safely, which means we don't modify extend labels underlying array. +func noAllocString(buf []byte) string { + return *(*string)(unsafe.Pointer(&buf)) +} + +func noAllocBytes(buf string) []byte { + return *(*[]byte)(unsafe.Pointer(&buf)) +} + +// ZLabelsFromPromLabels converts Prometheus labels to slice of labelpb.ZLabel in type unsafe manner. +// It reuses the same memory. Caller should abort using passed labels.Labels. +func ZLabelsFromPromLabels(lset labels.Labels) []ZLabel { + return *(*[]ZLabel)(unsafe.Pointer(&lset)) +} + +// ZLabelsToPromLabels convert slice of labelpb.ZLabel to Prometheus labels in type unsafe manner. +// It reuses the same memory. Caller should abort using passed []ZLabel. +// NOTE: Use with care. ZLabels holds memory from the whole protobuf unmarshal, so the returned +// Prometheus Labels will hold this memory as well. +func ZLabelsToPromLabels(lset []ZLabel) labels.Labels { + return *(*labels.Labels)(unsafe.Pointer(&lset)) +} + +// ReAllocAndInternZLabelsStrings re-allocates all underlying bytes for string, detaching it from bigger memory pool. +// If `intern` is set to true, the method will use interning, i.e. reuse already allocated strings, to make the reallocation +// method more efficient. // -// In case of existing labels already present in given label set, it will be overwritten by external one. -func ExtendSortedLabels(lset, extend labels.Labels) labels.Labels { - if extend.IsEmpty() { - return lset.Copy() +// This is primarily intended to be used before labels are written into TSDB which can hold label strings in the memory long term. +func ReAllocZLabelsStrings(lset *[]ZLabel, intern bool) { + if intern { + for j, l := range *lset { + (*lset)[j].Name = detachAndInternLabelString(l.Name) + (*lset)[j].Value = detachAndInternLabelString(l.Value) + } + return } - b := labels.NewBuilder(lset) - extend.Range(func(l labels.Label) { - b.Set(l.Name, l.Value) - }) - return b.Labels() -} -func PromLabelSetsToString(lsets []labels.Labels) string { - s := []string{} - for _, ls := range lsets { - s = append(s, ls.String()) + for j, l := range *lset { + (*lset)[j].Name = string(noAllocBytes(l.Name)) + (*lset)[j].Value = string(noAllocBytes(l.Value)) } - sort.Strings(s) - return strings.Join(s, ",") } -// ValidateLabels validates label names and values (checks for empty -// names and values, out of order labels and duplicate label names) -// Returns appropriate error if validation fails on a label. -func ValidateLabels(lbls []Label) error { - if len(lbls) == 0 { - return ErrEmptyLabels - } +// internLabelString is a helper method to intern a label string or, +// if the string was previously interned, it returns the existing +// reference and asserts it to a string. +func internLabelString(s string) string { + return intern.GetByString(s).Get().(string) +} - // Check first label. - l0 := lbls[0] - if l0.Name == "" || l0.Value == "" { - return ErrEmptyLabels +// detachAndInternLabelString reallocates the label string to detach it +// from a bigger memory pool and interns the string. +func detachAndInternLabelString(s string) string { + return internLabelString(string(noAllocBytes(s))) +} + +// ZLabelSetsToPromLabelSets converts slice of labelpb.ZLabelSet to slice of Prometheus labels. +func ZLabelSetsToPromLabelSets(lss ...ZLabelSet) []labels.Labels { + res := make([]labels.Labels, 0, len(lss)) + for _, ls := range lss { + res = append(res, ls.PromLabels()) } + return res +} - // Iterate over the rest, check each for empty / duplicates and - // check lexicographical (alphabetically) ordering. - for _, l := range lbls[1:] { - if l.Name == "" || l.Value == "" { - return ErrEmptyLabels +// ZLabelSetsFromPromLabels converts []labels.labels to []labelpb.ZLabelSet. +func ZLabelSetsFromPromLabels(lss ...labels.Labels) []ZLabelSet { + sets := make([]ZLabelSet, 0, len(lss)) + for _, ls := range lss { + set := ZLabelSet{ + Labels: make([]ZLabel, 0, ls.Len()), } + ls.Range(func(lbl labels.Label) { + set.Labels = append(set.Labels, ZLabel{ + Name: lbl.Name, + Value: lbl.Value, + }) + }) + sets = append(sets, set) + } - if l.Name == l0.Name { - return ErrDuplicateLabels - } + return sets +} - if l.Name < l0.Name { - return ErrOutOfOrderLabels +// ZLabel is a Label (also easily transformable to Prometheus labels.Labels) that can be unmarshalled from protobuf +// reusing the same memory address for string bytes. +// NOTE: While unmarshalling it uses exactly same bytes that were allocated for protobuf. This mean that *whole* protobuf +// bytes will be not GC-ed as long as ZLabels are referenced somewhere. Use it carefully, only for short living +// protobuf message processing. +type ZLabel Label + +func (m *ZLabel) MarshalTo(data []byte) (int, error) { + f := Label(*m) + return f.MarshalTo(data) +} + +func (m *ZLabel) MarshalToSizedBuffer(data []byte) (int, error) { + f := Label(*m) + return f.MarshalToSizedBuffer(data) +} + +// Unmarshal unmarshalls gRPC protobuf into ZLabel struct. ZLabel string is directly using bytes passed in `data`. +// To use it add (gogoproto.customtype) = "github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel" to proto field tag. +// NOTE: This exists in internal Google protobuf implementation, but not in open source one: https://news.ycombinator.com/item?id=23588882 +func (m *ZLabel) 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 ErrIntOverflowTypes + } + 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: ZLabel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ZLabel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = noAllocString(data[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := data[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = noAllocString(data[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(data[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } - l0 = l } + if iNdEx > l { + return io.ErrUnexpectedEOF + } return nil } -func PromLabelsToLabelpbLabels(lbls labels.Labels) []Label { - if lbls.Len() == 0 { - return []Label(nil) +func (m *ZLabel) UnmarshalJSON(entry []byte) error { + f := Label(*m) + if err := json.Unmarshal(entry, &f); err != nil { + return errors.Wrapf(err, "labels: label field unmarshal: %v", string(entry)) } - lset := make([]Label, 0, lbls.Len()) - lbls.Range(func(l labels.Label) { - lset = append(lset, Label{Name: l.Name, Value: l.Value}) - }) + *m = ZLabel(f) + return nil +} - return lset +func (m *ZLabel) Marshal() ([]byte, error) { + f := Label(*m) + return f.Marshal() } -func LabelpbLabelsToPromLabels(lbls []Label) labels.Labels { - lblSlice := make([]string, 0, len(lbls)*2) - for _, l := range lbls { - lblSlice = append(lblSlice, l.Name, l.Value) - } - return labels.FromStrings(lblSlice...) +func (m *ZLabel) MarshalJSON() ([]byte, error) { + return json.Marshal(Label(*m)) +} + +// Size implements proto.Sizer. +func (m *ZLabel) Size() (n int) { + f := Label(*m) + return f.Size() } -func (l *Label) Equal(other Label) bool { - return l.Name == other.Name && l.Value == other.Value +// Equal implements proto.Equaler. +func (m *ZLabel) Equal(other ZLabel) bool { + return m.Name == other.Name && m.Value == other.Value } -func (m *Label) Compare(other Label) int { +// Compare implements proto.Comparer. +func (m *ZLabel) Compare(other ZLabel) int { if c := strings.Compare(m.Name, other.Name); c != 0 { return c } return strings.Compare(m.Value, other.Value) } -func (m *LabelSet) PromLabels() labels.Labels { - return LabelpbLabelsToPromLabels(m.Labels) +// ExtendSortedLabels extend given labels by extend in labels format. +// The type conversion is done safely, which means we don't modify extend labels underlying array. +// +// In case of existing labels already present in given label set, it will be overwritten by external one. +func ExtendSortedLabels(lset, extend labels.Labels) labels.Labels { + if extend.IsEmpty() { + return lset.Copy() + } + b := labels.NewBuilder(lset) + extend.Range(func(l labels.Label) { + b.Set(l.Name, l.Value) + }) + return b.Labels() } -func LabelpbLabelSetsToPromLabels(lss ...LabelSet) []labels.Labels { - res := make([]labels.Labels, 0, len(lss)) - for _, ls := range lss { - res = append(res, ls.PromLabels()) +func PromLabelSetsToString(lsets []labels.Labels) string { + s := []string{} + for _, ls := range lsets { + s = append(s, ls.String()) } - return res + sort.Strings(s) + return strings.Join(s, ",") +} + +func (m *ZLabelSet) UnmarshalJSON(entry []byte) error { + lbls := labels.Labels{} + if err := lbls.UnmarshalJSON(entry); err != nil { + return errors.Wrapf(err, "labels: labels field unmarshal: %v", string(entry)) + } + m.Labels = ZLabelsFromPromLabels(lbls) + return nil +} + +func (m *ZLabelSet) MarshalJSON() ([]byte, error) { + return m.PromLabels().MarshalJSON() +} + +// PromLabels return Prometheus labels.Labels without extra allocation. +func (m *ZLabelSet) PromLabels() labels.Labels { + return ZLabelsToPromLabels(m.Labels) +} + +// DeepCopy copies labels and each label's string to separate bytes. +func DeepCopy(lbls []ZLabel) []ZLabel { + ret := make([]ZLabel, len(lbls)) + for i := range lbls { + ret[i].Name = string(noAllocBytes(lbls[i].Name)) + ret[i].Value = string(noAllocBytes(lbls[i].Value)) + } + return ret } // HashWithPrefix returns a hash for the given prefix and labels. -func HashWithPrefix(prefix string, lbls []Label) uint64 { +func HashWithPrefix(prefix string, lbls []ZLabel) uint64 { // Use xxhash.Sum64(b) for fast path as it's faster. b := make([]byte, 0, 1024) b = append(b, prefix...) @@ -135,9 +352,9 @@ func HashWithPrefix(prefix string, lbls []Label) uint64 { h := xxhash.New() _, _ = h.Write(b) for _, v := range lbls[i:] { - _, _ = h.Write([]byte(v.Name)) + _, _ = h.WriteString(v.Name) _, _ = h.Write(sep) - _, _ = h.Write([]byte(v.Value)) + _, _ = h.WriteString(v.Value) _, _ = h.Write(sep) } return h.Sum64() @@ -150,13 +367,48 @@ func HashWithPrefix(prefix string, lbls []Label) uint64 { return xxhash.Sum64(b) } -type LabelSets []LabelSet +// ValidateLabels validates label names and values (checks for empty +// names and values, out of order labels and duplicate label names) +// Returns appropriate error if validation fails on a label. +func ValidateLabels(lbls []ZLabel) error { + if len(lbls) == 0 { + return ErrEmptyLabels + } + + // Check first label. + l0 := lbls[0] + if l0.Name == "" || l0.Value == "" { + return ErrEmptyLabels + } + + // Iterate over the rest, check each for empty / duplicates and + // check lexicographical (alphabetically) ordering. + for _, l := range lbls[1:] { + if l.Name == "" || l.Value == "" { + return ErrEmptyLabels + } + + if l.Name == l0.Name { + return ErrDuplicateLabels + } + + if l.Name < l0.Name { + return ErrOutOfOrderLabels + } + l0 = l + } + + return nil +} + +// ZLabelSets is a sortable list of ZLabelSet. It assumes the label pairs in each ZLabelSet element are already sorted. +type ZLabelSets []ZLabelSet -func (z LabelSets) Len() int { return len(z) } +func (z ZLabelSets) Len() int { return len(z) } -func (z LabelSets) Swap(i, j int) { z[i], z[j] = z[j], z[i] } +func (z ZLabelSets) Swap(i, j int) { z[i], z[j] = z[j], z[i] } -func (z LabelSets) Less(i, j int) bool { +func (z ZLabelSets) Less(i, j int) bool { l := 0 r := 0 var result int @@ -170,27 +422,6 @@ func (z LabelSets) Less(i, j int) bool { } return result < 0 } - return l == lenI -} -func (m *Label) UnmarshalJSON(entry []byte) error { - f := Label(*m) - if err := json.Unmarshal(entry, &f); err != nil { - return errors.Wrapf(err, "labels: label field unmarshal: %v", string(entry)) - } - *m = Label(f) - return nil -} - -func (m *LabelSet) UnmarshalJSON(entry []byte) error { - lbls := labels.Labels{} - if err := lbls.UnmarshalJSON(entry); err != nil { - return errors.Wrapf(err, "labels: labels field unmarshal: %v", string(entry)) - } - m.Labels = PromLabelsToLabelpbLabels(lbls) - return nil -} - -func (m *LabelSet) MarshalJSON() ([]byte, error) { - return m.PromLabels().MarshalJSON() + return l == lenI } diff --git a/pkg/store/labelpb/label_zlabel_test.go b/pkg/store/labelpb/label_zlabel_test.go new file mode 100644 index 0000000000..fbe5122e31 --- /dev/null +++ b/pkg/store/labelpb/label_zlabel_test.go @@ -0,0 +1,533 @@ +// Copyright (c) The Thanos Authors. +// Licensed under the Apache License 2.0. + +//go:build !stringlabels + +package labelpb + +import ( + "fmt" + "reflect" + "sort" + "strings" + "testing" + + "github.com/prometheus/prometheus/model/labels" + + "github.com/efficientgo/core/testutil" +) + +var testLsetMap = map[string]string{ + "a": "1", + "c": "2", + "d": "dsfsdfsdfsdf123414234", + "124134235423534534ffdasdfsf": "1", + "": "", + "b": "", +} + +func TestLabelsToPromLabels_LabelsToPromLabels(t *testing.T) { + testutil.Equals(t, labels.FromMap(testLsetMap), ZLabelsToPromLabels(ZLabelsFromPromLabels(labels.FromMap(testLsetMap)))) + + lset := labels.FromMap(testLsetMap) + zlset := ZLabelsFromPromLabels(lset) + for i := range zlset { + if zlset[i].Name != "a" { + continue + } + zlset[i].Value += "yolo" + } + + m := lset.Map() + testutil.Equals(t, "1yolo", m["a"]) + + m["a"] = "1" + testutil.Equals(t, testLsetMap, m) +} + +func TestLabelMarshal_Unmarshal(t *testing.T) { + l := ZLabelsFromPromLabels(labels.FromStrings("aaaaaaa", "bbbbb"))[0] + b, err := (&l).Marshal() + testutil.Ok(t, err) + + l2 := &ZLabel{} + testutil.Ok(t, l2.Unmarshal(b)) + testutil.Equals(t, labels.FromStrings("aaaaaaa", "bbbbb"), ZLabelsToPromLabels([]ZLabel{*l2})) +} + +func TestValidateLabels(t *testing.T) { + testCases := []struct { + labelSet []ZLabel + expectedErr error + }{ + { + // No labels at all. + labelSet: []ZLabel{}, + expectedErr: ErrEmptyLabels, + }, + { + // Empty label. + labelSet: []ZLabel{ + { + Name: "foo", + Value: "bar", + }, + { + Name: "", + Value: "baz", + }, + }, + expectedErr: ErrEmptyLabels, + }, + { + // Empty label (first label). + labelSet: []ZLabel{ + { + Name: "", + Value: "bar", + }, + { + Name: "foo", + Value: "baz", + }, + }, + expectedErr: ErrEmptyLabels, + }, + { + // Empty label (empty value). + labelSet: []ZLabel{ + { + Name: "foo", + Value: "bar", + }, + { + Name: "baz", + Value: "", + }, + }, + expectedErr: ErrEmptyLabels, + }, + { + // Out-of-order and duplicate label (out-of-order comes first). + labelSet: []ZLabel{ + { + Name: "foo", + Value: "bar", + }, + { + Name: "test", + Value: "baz", + }, + { + Name: "foo", + Value: "bar", + }, + }, + expectedErr: ErrOutOfOrderLabels, + }, + { + // Out-of-order and duplicate label (out-of-order comes first). + labelSet: []ZLabel{ + { + Name: "__test__", + Value: "baz", + }, + { + Name: "foo", + Value: "bar", + }, + { + Name: "foo", + Value: "bar", + }, + { + Name: "test", + Value: "baz", + }, + }, + expectedErr: ErrDuplicateLabels, + }, + { + // Empty and duplicate label (empty comes first). + labelSet: []ZLabel{ + { + Name: "foo", + Value: "bar", + }, + { + Name: "", + Value: "baz", + }, + { + Name: "foo", + Value: "bar", + }, + }, + expectedErr: ErrEmptyLabels, + }, + { + // Wrong order. + labelSet: []ZLabel{ + { + Name: "a", + Value: "bar", + }, + { + Name: "b", + Value: "baz", + }, + { + Name: "__name__", + Value: "test", + }, + }, + expectedErr: ErrOutOfOrderLabels, + }, + { + // Wrong order and duplicate (wrong order comes first). + labelSet: []ZLabel{ + { + Name: "a", + Value: "bar", + }, + { + Name: "__name__", + Value: "test", + }, + { + Name: "a", + Value: "bar", + }, + }, + expectedErr: ErrOutOfOrderLabels, + }, + { + // All good. + labelSet: []ZLabel{ + { + Name: "__name__", + Value: "test", + }, + { + Name: "a1", + Value: "bar", + }, + { + Name: "a2", + Value: "baz", + }, + }, + expectedErr: nil, + }, + } + + for i, tc := range testCases { + t.Run(fmt.Sprintf("case %d", i+1), func(t *testing.T) { + err := ValidateLabels(tc.labelSet) + testutil.Equals(t, tc.expectedErr, err) + }) + } + +} + +var ( + zdest ZLabel + dest Label +) + +func BenchmarkZLabelsMarshalUnmarshal(b *testing.B) { + const ( + fmtLbl = "%07daaaaaaaaaabbbbbbbbbbccccccccccdddddddddd" + num = 1000000 + ) + + b.Run("Label", func(b *testing.B) { + b.ReportAllocs() + lbls := LabelSet{Labels: make([]Label, 0, num)} + for i := 0; i < num; i++ { + lbls.Labels = append(lbls.Labels, Label{Name: fmt.Sprintf(fmtLbl, i), Value: fmt.Sprintf(fmtLbl, i)}) + } + b.ResetTimer() + + for i := 0; i < b.N; i++ { + data, err := lbls.Marshal() + testutil.Ok(b, err) + + dest = Label{} + testutil.Ok(b, (&dest).Unmarshal(data)) + } + }) + + b.Run("ZLabel", func(b *testing.B) { + b.ReportAllocs() + lbls := ZLabelSet{Labels: make([]ZLabel, 0, num)} + for i := 0; i < num; i++ { + lbls.Labels = append(lbls.Labels, ZLabel{Name: fmt.Sprintf(fmtLbl, i), Value: fmt.Sprintf(fmtLbl, i)}) + } + b.ResetTimer() + + for i := 0; i < b.N; i++ { + data, err := lbls.Marshal() + testutil.Ok(b, err) + + zdest = ZLabel{} + testutil.Ok(b, (&zdest).Unmarshal(data)) + } + }) +} + +func BenchmarkTransformWithAndWithoutCopyWithSingleLabel(b *testing.B) { + benchmarkTransformWithAndWithoutCopy(b, 1) +} + +func BenchmarkTransformWithAndWithoutCopyWith1000Labels(b *testing.B) { + benchmarkTransformWithAndWithoutCopy(b, 1000) +} + +func BenchmarkTransformWithAndWithoutCopyWith100000Labels(b *testing.B) { + benchmarkTransformWithAndWithoutCopy(b, 100000) +} + +var ret labels.Labels + +func benchmarkTransformWithAndWithoutCopy(b *testing.B, num int) { + const fmtLbl = "%07daaaaaaaaaabbbbbbbbbbccccccccccdddddddddd" + + b.Run("ZLabelsToPromLabels", func(b *testing.B) { + b.ReportAllocs() + lbls := make([]ZLabel, num) + for i := 0; i < num; i++ { + lbls[i] = ZLabel{Name: fmt.Sprintf(fmtLbl, i), Value: fmt.Sprintf(fmtLbl, i)} + } + b.ResetTimer() + + for i := 0; i < b.N; i++ { + ret = ZLabelsToPromLabels(lbls) + } + }) + b.Run("ZLabelsToPromLabelsWithRealloc", func(b *testing.B) { + b.ReportAllocs() + lbls := make([]ZLabel, num) + for i := 0; i < num; i++ { + lbls[i] = ZLabel{Name: fmt.Sprintf(fmtLbl, i), Value: fmt.Sprintf(fmtLbl, i)} + } + b.ResetTimer() + + for i := 0; i < b.N; i++ { + ReAllocZLabelsStrings(&lbls, true) + ret = ZLabelsToPromLabels(lbls) + } + }) +} + +func TestSortZLabelSets(t *testing.T) { + expectedResult := ZLabelSets{ + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_client_handled_total", + "cluster": "test", + "grpc_code": "OK", + "grpc_method": "Info", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_client_handled_total", + "cluster": "test", + "grpc_code": "OK", + "grpc_method": "LabelNames", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_client_handled_total", + "cluster": "test", + "grpc_code": "OK", + "aa": "1", + "bb": "2", + "cc": "3", + "dd": "4", + "ee": "5", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_client_handled_total", + "cluster": "test", + "grpc_code": "OK", + "aa": "1", + "bb": "2", + "cc": "3", + "dd": "4", + "ee": "5", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_server_handled_total", + "cluster": "test", + "grpc_code": "OK", + "grpc_method": "Info", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "up", + "instance": "localhost:10908", + }), + ), + }, + } + + list := ZLabelSets{ + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "up", + "instance": "localhost:10908", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_server_handled_total", + "cluster": "test", + "grpc_code": "OK", + "grpc_method": "Info", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_client_handled_total", + "cluster": "test", + "grpc_code": "OK", + "grpc_method": "LabelNames", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_client_handled_total", + "cluster": "test", + "grpc_code": "OK", + "grpc_method": "Info", + }), + ), + }, + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "__name__": "grpc_client_handled_total", + "cluster": "test", + "grpc_code": "OK", + "aa": "1", + "bb": "2", + "cc": "3", + "dd": "4", + "ee": "5", + }), + ), + }, + // This label set is the same as the previous one, which should correctly return 0 in Less() function. + { + Labels: ZLabelsFromPromLabels( + labels.FromMap(map[string]string{ + "cluster": "test", + "__name__": "grpc_client_handled_total", + "grpc_code": "OK", + "aa": "1", + "bb": "2", + "cc": "3", + "dd": "4", + "ee": "5", + }), + ), + }, + } + + sort.Sort(list) + reflect.DeepEqual(expectedResult, list) +} + +func TestHashWithPrefix(t *testing.T) { + lbls := []ZLabel{ + {Name: "foo", Value: "bar"}, + {Name: "baz", Value: "qux"}, + } + testutil.Equals(t, HashWithPrefix("a", lbls), HashWithPrefix("a", lbls)) + testutil.Assert(t, HashWithPrefix("a", lbls) != HashWithPrefix("a", []ZLabel{lbls[0]})) + testutil.Assert(t, HashWithPrefix("a", lbls) != HashWithPrefix("a", []ZLabel{lbls[1], lbls[0]})) + testutil.Assert(t, HashWithPrefix("a", lbls) != HashWithPrefix("b", lbls)) +} + +var benchmarkLabelsResult uint64 + +func BenchmarkHasWithPrefix(b *testing.B) { + for _, tcase := range []struct { + name string + lbls []ZLabel + }{ + { + name: "typical labels under 1KB", + lbls: func() []ZLabel { + lbls := make([]ZLabel, 10) + for i := 0; i < len(lbls); i++ { + // ZLabel ~20B name, 50B value. + lbls[i] = ZLabel{Name: fmt.Sprintf("abcdefghijabcdefghijabcdefghij%d", i), Value: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i)} + } + return lbls + }(), + }, + { + name: "bigger labels over 1KB", + lbls: func() []ZLabel { + lbls := make([]ZLabel, 10) + for i := 0; i < len(lbls); i++ { + //ZLabel ~50B name, 50B value. + lbls[i] = ZLabel{Name: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i), Value: fmt.Sprintf("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij%d", i)} + } + return lbls + }(), + }, + { + name: "extremely large label value 10MB", + lbls: func() []ZLabel { + lbl := &strings.Builder{} + lbl.Grow(1024 * 1024 * 10) // 10MB. + word := "abcdefghij" + for i := 0; i < lbl.Cap()/len(word); i++ { + _, _ = lbl.WriteString(word) + } + return []ZLabel{{Name: "__name__", Value: lbl.String()}} + }(), + }, + } { + b.Run(tcase.name, func(b *testing.B) { + var h uint64 + + const prefix = "test-" + + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + h = HashWithPrefix(prefix, tcase.lbls) + } + benchmarkLabelsResult = h + }) + } +} diff --git a/pkg/store/labelpb/types.pb.go b/pkg/store/labelpb/types.pb.go index 8173df058c..3dd6d97299 100644 --- a/pkg/store/labelpb/types.pb.go +++ b/pkg/store/labelpb/types.pb.go @@ -99,15 +99,53 @@ func (m *LabelSet) XXX_DiscardUnknown() { var xxx_messageInfo_LabelSet proto.InternalMessageInfo +type ZLabelSet struct { + Labels []ZLabel `protobuf:"bytes,1,rep,name=labels,proto3,customtype=ZLabel" json:"labels"` +} + +func (m *ZLabelSet) Reset() { *m = ZLabelSet{} } +func (m *ZLabelSet) String() string { return proto.CompactTextString(m) } +func (*ZLabelSet) ProtoMessage() {} +func (*ZLabelSet) Descriptor() ([]byte, []int) { + return fileDescriptor_cdcc9e7dae4870e8, []int{2} +} +func (m *ZLabelSet) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ZLabelSet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ZLabelSet.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ZLabelSet) XXX_Merge(src proto.Message) { + xxx_messageInfo_ZLabelSet.Merge(m, src) +} +func (m *ZLabelSet) XXX_Size() int { + return m.Size() +} +func (m *ZLabelSet) XXX_DiscardUnknown() { + xxx_messageInfo_ZLabelSet.DiscardUnknown(m) +} + +var xxx_messageInfo_ZLabelSet proto.InternalMessageInfo + func init() { proto.RegisterType((*Label)(nil), "thanos.Label") proto.RegisterType((*LabelSet)(nil), "thanos.LabelSet") + proto.RegisterType((*ZLabelSet)(nil), "thanos.ZLabelSet") } func init() { proto.RegisterFile("store/labelpb/types.proto", fileDescriptor_cdcc9e7dae4870e8) } var fileDescriptor_cdcc9e7dae4870e8 = []byte{ - // 191 bytes of a gzipped FileDescriptorProto + // 212 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x2e, 0xc9, 0x2f, 0x4a, 0xd5, 0xcf, 0x49, 0x4c, 0x4a, 0xcd, 0x29, 0x48, 0xd2, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2b, 0xc9, 0x48, 0xcc, 0xcb, 0x2f, 0x96, 0x12, 0x49, @@ -116,10 +154,12 @@ var fileDescriptor_cdcc9e7dae4870e8 = []byte{ 0x30, 0x5b, 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x82, 0x09, 0x2c, 0x08, 0xe1, 0x28, 0x99, 0x73, 0x71, 0x80, 0xb5, 0x04, 0xa7, 0x96, 0x08, 0x69, 0x73, 0xb1, 0x81, 0xed, 0x2c, 0x96, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0xe2, 0xd5, 0x83, 0xd8, 0xa6, 0x07, 0x56, 0xe1, 0xc4, - 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x54, 0x89, 0x93, 0xea, 0x89, 0x87, 0x72, 0x0c, 0x27, 0x1e, - 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, - 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xc5, 0x0e, 0x75, 0x7c, 0x12, 0x1b, 0xd8, 0x65, - 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x44, 0x87, 0xd3, 0x2f, 0xd4, 0x00, 0x00, 0x00, + 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x54, 0x89, 0x92, 0x13, 0x17, 0x67, 0x14, 0x5c, 0xa7, 0x29, + 0x7e, 0x9d, 0x7c, 0x20, 0x9d, 0xb7, 0xee, 0xc9, 0xb3, 0x41, 0x74, 0xc0, 0xcc, 0x70, 0x52, 0x3d, + 0xf1, 0x50, 0x8e, 0xe1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, + 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xd8, 0xa1, + 0x01, 0x90, 0xc4, 0x06, 0xf6, 0x9d, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd0, 0x80, 0xe8, 0x16, + 0x18, 0x01, 0x00, 0x00, } func (m *Label) Marshal() (dAtA []byte, err error) { @@ -196,6 +236,43 @@ func (m *LabelSet) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ZLabelSet) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ZLabelSet) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ZLabelSet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Labels) > 0 { + for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.Labels[iNdEx].Size() + i -= size + if _, err := m.Labels[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -239,6 +316,21 @@ func (m *LabelSet) Size() (n int) { return n } +func (m *ZLabelSet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Labels) > 0 { + for _, e := range m.Labels { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -443,6 +535,90 @@ func (m *LabelSet) Unmarshal(dAtA []byte) error { } return nil } +func (m *ZLabelSet) 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 ErrIntOverflowTypes + } + 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: ZLabelSet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ZLabelSet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Labels", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Labels = append(m.Labels, ZLabel{}) + if err := m.Labels[len(m.Labels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/pkg/store/labelpb/types.proto b/pkg/store/labelpb/types.proto index fc732dd6df..65aa195ec1 100644 --- a/pkg/store/labelpb/types.proto +++ b/pkg/store/labelpb/types.proto @@ -26,4 +26,8 @@ message Label { message LabelSet { repeated Label labels = 1 [(gogoproto.nullable) = false]; -} \ No newline at end of file +} + +message ZLabelSet { + repeated Label labels = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "ZLabel"]; +} diff --git a/pkg/store/local.go b/pkg/store/local.go index 30a39c21a1..cb80f8f8cb 100644 --- a/pkg/store/local.go +++ b/pkg/store/local.go @@ -143,7 +143,7 @@ func (s *LocalStore) Series(r *storepb.SeriesRequest, srv storepb.Store_SeriesSe var chosen []int for si, series := range s.series { - lbls := labelpb.LabelpbLabelsToPromLabels(series.Labels) + lbls := labelpb.ZLabelsToPromLabels(series.Labels) var noMatch bool for _, m := range matchers { extValue := lbls.Get(m.Name) @@ -162,7 +162,7 @@ func (s *LocalStore) Series(r *storepb.SeriesRequest, srv storepb.Store_SeriesSe chosen = chosen[:0] resp := &storepb.Series{ // Copy labels as in-process clients like proxy tend to work on same memory for labels. - Labels: series.Labels, + Labels: labelpb.DeepCopy(series.Labels), Chunks: make([]storepb.AggrChunk, 0, len(s.sortedChunks[si])), } @@ -212,7 +212,7 @@ func (s *LocalStore) LabelValues(_ context.Context, r *storepb.LabelValuesReques ) { vals := map[string]struct{}{} for _, series := range s.series { - lbls := labelpb.LabelpbLabelsToPromLabels(series.Labels) + lbls := labelpb.ZLabelsToPromLabels(series.Labels) val := lbls.Get(r.Label) if val == "" { continue diff --git a/pkg/store/prometheus.go b/pkg/store/prometheus.go index 3148738b12..cf0082a5f0 100644 --- a/pkg/store/prometheus.go +++ b/pkg/store/prometheus.go @@ -162,7 +162,7 @@ func (p *PrometheusStore) Series(r *storepb.SeriesRequest, seriesSrv storepb.Sto finalExtLset.Range(func(l labels.Label) { b.Set(l.Name, l.Value) }) - lset := labelpb.PromLabelsToLabelpbLabels(b.Labels()) + lset := labelpb.ZLabelsFromPromLabels(b.Labels()) if err = s.Send(storepb.NewSeriesResponse(&storepb.Series{Labels: lset})); err != nil { return err } @@ -238,7 +238,7 @@ func (p *PrometheusStore) handleSampledPrometheusResponse( // https://github.com/prometheus/prometheus/blob/3f6f5d3357e232abe53f1775f893fdf8f842712c/storage/remote/read_handler.go#L166 // MergeLabels() prefers local labels over external labels but we prefer // external labels hence we need to do this: - lset := rmLabels(labelpb.ExtendSortedLabels(labelpb.LabelpbLabelsToPromLabels(e.Labels), extLset), extLsetToRemove) + lset := rmLabels(labelpb.ExtendSortedLabels(labelpb.ZLabelsToPromLabels(e.Labels), extLset), extLsetToRemove) if len(e.Samples) == 0 { // As found in https://github.com/thanos-io/thanos/issues/381 // Prometheus can give us completely empty time series. Ignore these with log until we figure out that @@ -258,7 +258,7 @@ func (p *PrometheusStore) handleSampledPrometheusResponse( } if err := s.Send(storepb.NewSeriesResponse(&storepb.Series{ - Labels: labelpb.PromLabelsToLabelpbLabels(lset), + Labels: labelpb.ZLabelsFromPromLabels(lset), Chunks: aggregatedChunks, })); err != nil { return err @@ -317,8 +317,8 @@ func (p *PrometheusStore) handleStreamedPrometheusResponse( // MergeLabels() prefers local labels over external labels but we prefer // external labels hence we need to do this: // https://github.com/prometheus/prometheus/blob/3f6f5d3357e232abe53f1775f893fdf8f842712c/storage/remote/codec.go#L210. - completeLabelset := rmLabels(labelpb.ExtendSortedLabels(labelpb.LabelpbLabelsToPromLabels(series.Labels), extLset), extLsetToRemove) - if !shardMatcher.MatchesLabels(labelpb.PromLabelsToLabelpbLabels(completeLabelset)) { + completeLabelset := rmLabels(labelpb.ExtendSortedLabels(labelpb.ZLabelsToPromLabels(series.Labels), extLset), extLsetToRemove) + if !shardMatcher.MatchesLabels(completeLabelset) { continue } @@ -347,7 +347,7 @@ func (p *PrometheusStore) handleStreamedPrometheusResponse( } r := storepb.NewSeriesResponse(&storepb.Series{ - Labels: labelpb.PromLabelsToLabelpbLabels(completeLabelset), + Labels: labelpb.ZLabelsFromPromLabels(completeLabelset), Chunks: thanosChks, }) if err := s.Send(r); err != nil { @@ -654,12 +654,12 @@ func (p *PrometheusStore) LabelValues(ctx context.Context, r *storepb.LabelValue return &storepb.LabelValuesResponse{Values: vals}, nil } -func (p *PrometheusStore) LabelSet() []labelpb.LabelSet { - labels := labelpb.PromLabelsToLabelpbLabels(p.externalLabelsFn()) +func (p *PrometheusStore) LabelSet() []labelpb.ZLabelSet { + labels := labelpb.ZLabelsFromPromLabels(p.externalLabelsFn()) - labelset := []labelpb.LabelSet{} + labelset := []labelpb.ZLabelSet{} if len(labels) > 0 { - labelset = append(labelset, labelpb.LabelSet{ + labelset = append(labelset, labelpb.ZLabelSet{ Labels: labels, }) } @@ -676,7 +676,7 @@ func (p *PrometheusStore) TSDBInfos() []infopb.TSDBInfo { mint, maxt := p.Timestamps() return []infopb.TSDBInfo{ { - Labels: labelpb.LabelSet{ + Labels: labelpb.ZLabelSet{ Labels: labels[0].Labels, }, MinTime: mint, diff --git a/pkg/store/prometheus_test.go b/pkg/store/prometheus_test.go index 5a31ccbf17..e754ef4a15 100644 --- a/pkg/store/prometheus_test.go +++ b/pkg/store/prometheus_test.go @@ -89,7 +89,7 @@ func testPrometheusStoreSeriesE2e(t *testing.T, prefix string) { testutil.Equals(t, 1, len(srv.SeriesSet)) - testutil.Equals(t, []labelpb.Label{ + testutil.Equals(t, []labelpb.ZLabel{ {Name: "a", Value: "b"}, {Name: "region", Value: "eu-west"}, }, srv.SeriesSet[0].Labels) @@ -122,7 +122,7 @@ func testPrometheusStoreSeriesE2e(t *testing.T, prefix string) { testutil.Equals(t, 1, len(srv.SeriesSet)) - testutil.Equals(t, []labelpb.Label{ + testutil.Equals(t, []labelpb.ZLabel{ {Name: "a", Value: "b"}, {Name: "region", Value: "eu-west"}, }, srv.SeriesSet[0].Labels) @@ -239,7 +239,7 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) { }, expected: []storepb.Series{ { - Labels: []labelpb.Label{{Name: "a", Value: "b"}, {Name: "b", Value: "d"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "b"}, {Name: "b", Value: "d"}, {Name: "region", Value: "eu-west"}}, }, }, }, @@ -265,10 +265,10 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) { }, expected: []storepb.Series{ { - Labels: []labelpb.Label{{Name: "a", Value: "c"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "c"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, }, { - Labels: []labelpb.Label{{Name: "a", Value: "d"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "d"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, }, }, }, @@ -283,10 +283,10 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) { }, expected: []storepb.Series{ { - Labels: []labelpb.Label{{Name: "a", Value: "c"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "c"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, }, { - Labels: []labelpb.Label{{Name: "a", Value: "d"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "d"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, }, }, }, @@ -301,7 +301,7 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) { }, expected: []storepb.Series{ { - Labels: []labelpb.Label{{Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, }, }, }, @@ -316,13 +316,13 @@ func TestPrometheusStore_SeriesLabels_e2e(t *testing.T) { }, expected: []storepb.Series{ { - Labels: []labelpb.Label{{Name: "a", Value: "c"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "c"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, }, { - Labels: []labelpb.Label{{Name: "a", Value: "d"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "d"}, {Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, }, { - Labels: []labelpb.Label{{Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, + Labels: []labelpb.ZLabel{{Name: "b", Value: "d"}, {Name: "job", Value: "test"}, {Name: "region", Value: "eu-west"}}, }, }, }, @@ -385,7 +385,7 @@ func TestPrometheusStore_Series_MatchExternalLabel(t *testing.T) { }, srv)) testutil.Equals(t, 1, len(srv.SeriesSet)) - testutil.Equals(t, []labelpb.Label{ + testutil.Equals(t, []labelpb.ZLabel{ {Name: "a", Value: "b"}, {Name: "region", Value: "eu-west"}, }, srv.SeriesSet[0].Labels) diff --git a/pkg/store/proxy.go b/pkg/store/proxy.go index e3a22183bc..08cd36e485 100644 --- a/pkg/store/proxy.go +++ b/pkg/store/proxy.go @@ -165,21 +165,21 @@ func NewProxyStore( return s } -func (s *ProxyStore) LabelSet() []labelpb.LabelSet { +func (s *ProxyStore) LabelSet() []labelpb.ZLabelSet { stores := s.stores() if len(stores) == 0 { - return []labelpb.LabelSet{} + return []labelpb.ZLabelSet{} } - mergedLabelSets := make(map[uint64]labelpb.LabelSet, len(stores)) + mergedLabelSets := make(map[uint64]labelpb.ZLabelSet, len(stores)) for _, st := range stores { for _, lset := range st.LabelSets() { mergedLabelSet := labelpb.ExtendSortedLabels(lset, s.selectorLabels) - mergedLabelSets[mergedLabelSet.Hash()] = labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(mergedLabelSet)} + mergedLabelSets[mergedLabelSet.Hash()] = labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(mergedLabelSet)} } } - labelSets := make([]labelpb.LabelSet, 0, len(mergedLabelSets)) + labelSets := make([]labelpb.ZLabelSet, 0, len(mergedLabelSets)) for _, v := range mergedLabelSets { labelSets = append(labelSets, v) } @@ -188,9 +188,9 @@ func (s *ProxyStore) LabelSet() []labelpb.LabelSet { // selector-labels represents. If no label-sets are announced by the // store-proxy's discovered stores, then we still want to enforce // announcing this subset by announcing the selector as the label-set. - selectorLabels := labelpb.PromLabelsToLabelpbLabels(s.selectorLabels) + selectorLabels := labelpb.ZLabelsFromPromLabels(s.selectorLabels) if len(labelSets) == 0 && len(selectorLabels) > 0 { - labelSets = append(labelSets, labelpb.LabelSet{Labels: selectorLabels}) + labelSets = append(labelSets, labelpb.ZLabelSet{Labels: selectorLabels}) } return labelSets diff --git a/pkg/store/proxy_merge.go b/pkg/store/proxy_merge.go index aaf94efbb3..eaf4ce1839 100644 --- a/pkg/store/proxy_merge.go +++ b/pkg/store/proxy_merge.go @@ -99,7 +99,7 @@ func (d *responseDeduplicator) Next() bool { lbls := d.bufferedSameSeries[0].GetSeries().Labels atLbls := s.GetSeries().Labels - if labels.Compare(labelpb.LabelpbLabelsToPromLabels(lbls), labelpb.LabelpbLabelsToPromLabels(atLbls)) == 0 { + if labels.Compare(labelpb.ZLabelsToPromLabels(lbls), labelpb.ZLabelsToPromLabels(atLbls)) == 0 { d.bufferedSameSeries = append(d.bufferedSameSeries, s) continue } @@ -183,8 +183,8 @@ func NewProxyResponseLoserTree(seriesSets ...respSet) *losertree.Tree[*storepb.S return true } if a.GetSeries() != nil && b.GetSeries() != nil { - iLbls := labelpb.LabelpbLabelsToPromLabels(a.GetSeries().Labels) - jLbls := labelpb.LabelpbLabelsToPromLabels(b.GetSeries().Labels) + iLbls := labelpb.ZLabelsToPromLabels(a.GetSeries().Labels) + jLbls := labelpb.ZLabelsToPromLabels(b.GetSeries().Labels) return labels.Compare(iLbls, jLbls) < 0 } else if a.GetSeries() == nil && b.GetSeries() != nil { @@ -392,7 +392,7 @@ func newLazyRespSet( numResponses++ bytesProcessed += resp.Size() - if resp.GetSeries() != nil && applySharding && !shardMatcher.MatchesLabels(resp.GetSeries().Labels) { + if resp.GetSeries() != nil && applySharding && !shardMatcher.MatchesZLabels(resp.GetSeries().Labels) { return true } @@ -642,7 +642,7 @@ func newEagerRespSet( numResponses++ bytesProcessed += resp.Size() - if resp.GetSeries() != nil && applySharding && !shardMatcher.MatchesLabels(resp.GetSeries().Labels) { + if resp.GetSeries() != nil && applySharding && !shardMatcher.MatchesZLabels(resp.GetSeries().Labels) { return true } @@ -695,7 +695,7 @@ func sortWithoutLabels(set []*storepb.SeriesResponse, labelsToRemove map[string] } if len(labelsToRemove) > 0 { - ser.Labels = labelpb.PromLabelsToLabelpbLabels(rmLabels(labelpb.LabelpbLabelsToPromLabels(ser.Labels), labelsToRemove)) + ser.Labels = labelpb.ZLabelsFromPromLabels(rmLabels(labelpb.ZLabelsToPromLabels(ser.Labels), labelsToRemove)) } } @@ -710,7 +710,7 @@ func sortWithoutLabels(set []*storepb.SeriesResponse, labelsToRemove map[string] if sj == nil { return false } - return labels.Compare(labelpb.LabelpbLabelsToPromLabels(si.Labels), labelpb.LabelpbLabelsToPromLabels(sj.Labels)) < 0 + return labels.Compare(labelpb.ZLabelsToPromLabels(si.Labels), labelpb.ZLabelsToPromLabels(sj.Labels)) < 0 }) } diff --git a/pkg/store/proxy_test.go b/pkg/store/proxy_test.go index aaf1869f4d..1ac6346acd 100644 --- a/pkg/store/proxy_test.go +++ b/pkg/store/proxy_test.go @@ -64,12 +64,12 @@ func TestProxyStore_TSDBInfos(t *testing.T) { }, &storetestutil.TestClient{ StoreTSDBInfos: []infopb.TSDBInfo{ - infopb.NewTSDBInfo(0, 10, []labelpb.Label{{Name: "lbl", Value: "val1"}}), + infopb.NewTSDBInfo(0, 10, []labelpb.ZLabel{{Name: "lbl", Value: "val1"}}), }, }, &storetestutil.TestClient{ StoreTSDBInfos: []infopb.TSDBInfo{ - infopb.NewTSDBInfo(0, 20, []labelpb.Label{{Name: "lbl", Value: "val2"}}), + infopb.NewTSDBInfo(0, 20, []labelpb.ZLabel{{Name: "lbl", Value: "val2"}}), }, }, } @@ -79,8 +79,8 @@ func TestProxyStore_TSDBInfos(t *testing.T) { ) expected := []infopb.TSDBInfo{ - infopb.NewTSDBInfo(0, 10, []labelpb.Label{{Name: "lbl", Value: "val1"}}), - infopb.NewTSDBInfo(0, 20, []labelpb.Label{{Name: "lbl", Value: "val2"}}), + infopb.NewTSDBInfo(0, 10, []labelpb.ZLabel{{Name: "lbl", Value: "val1"}}), + infopb.NewTSDBInfo(0, 20, []labelpb.ZLabel{{Name: "lbl", Value: "val2"}}), } testutil.Equals(t, expected, q.TSDBInfos()) } @@ -1778,7 +1778,7 @@ func seriesEquals(t *testing.T, expected []rawSeries, got []storepb.Series) { ret := make([]rawSeries, len(got)) for i, s := range got { r := rawSeries{ - lset: labelpb.LabelpbLabelsToPromLabels(s.Labels), + lset: labelpb.ZLabelsToPromLabels(s.Labels), } for _, chk := range s.Chunks { var samples []sample @@ -2019,7 +2019,7 @@ func (s *mockedStoreAPI) LabelValues(_ context.Context, req *storepb.LabelValues func storeSeriesResponse(t testing.TB, lset labels.Labels, smplChunks ...[]sample) *storepb.SeriesResponse { var s storepb.Series - s.Labels = append(s.Labels, labelpb.PromLabelsToLabelpbLabels(lset)...) + s.Labels = append(s.Labels, labelpb.ZLabelsFromPromLabels(lset)...) for _, smpls := range smplChunks { c := chunkenc.NewXORChunk() @@ -2303,7 +2303,7 @@ func TestDedupRespHeap_Deduplication(t *testing.T) { { Result: &storepb.SeriesResponse_Series{ Series: &storepb.Series{ - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings("foo", "bar")), + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings("foo", "bar")), Chunks: []storepb.AggrChunk{ { Raw: &storepb.Chunk{ @@ -2329,7 +2329,7 @@ func TestDedupRespHeap_Deduplication(t *testing.T) { { Result: &storepb.SeriesResponse_Series{ Series: &storepb.Series{ - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings("foo", "bar")), + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings("foo", "bar")), Chunks: []storepb.AggrChunk{ { Raw: &storepb.Chunk{ @@ -2344,7 +2344,7 @@ func TestDedupRespHeap_Deduplication(t *testing.T) { { Result: &storepb.SeriesResponse_Series{ Series: &storepb.Series{ - Labels: labelpb.PromLabelsToLabelpbLabels(labels.FromStrings("foo", "bar")), + Labels: labelpb.ZLabelsFromPromLabels(labels.FromStrings("foo", "bar")), Chunks: []storepb.AggrChunk{ { Raw: &storepb.Chunk{ diff --git a/pkg/store/storepb/custom.go b/pkg/store/storepb/custom.go index 499538271f..faed79bc7b 100644 --- a/pkg/store/storepb/custom.go +++ b/pkg/store/storepb/custom.go @@ -244,13 +244,13 @@ func (s *uniqueSeriesSet) Next() bool { } lset, chks := s.SeriesSet.At() if s.peek == nil { - s.peek = &Series{Labels: labelpb.PromLabelsToLabelpbLabels(lset), Chunks: chks} + s.peek = &Series{Labels: labelpb.ZLabelsFromPromLabels(lset), Chunks: chks} continue } if labels.Compare(lset, s.peek.PromLabels()) != 0 { s.lset, s.chunks = s.peek.PromLabels(), s.peek.Chunks - s.peek = &Series{Labels: labelpb.PromLabelsToLabelpbLabels(lset), Chunks: chks} + s.peek = &Series{Labels: labelpb.ZLabelsFromPromLabels(lset), Chunks: chks} return true } @@ -447,27 +447,27 @@ func (x LabelMatcher_Type) PromString() string { // PromLabels return Prometheus labels.Labels without extra allocation. func (m *Series) PromLabels() labels.Labels { - return labelpb.LabelpbLabelsToPromLabels(m.Labels) + return labelpb.ZLabelsToPromLabels(m.Labels) } // Deprecated. // TODO(bwplotka): Remove this once Cortex dep will stop using it. -type Label = labelpb.Label +type Label = labelpb.ZLabel // Deprecated. // TODO(bwplotka): Remove this in next PR. Done to reduce diff only. -type LabelSet = labelpb.LabelSet +type LabelSet = labelpb.ZLabelSet // Deprecated. // TODO(bwplotka): Remove this once Cortex dep will stop using it. func CompareLabels(a, b []Label) int { - return labels.Compare(labelpb.LabelpbLabelsToPromLabels(a), labelpb.LabelpbLabelsToPromLabels(b)) + return labels.Compare(labelpb.ZLabelsToPromLabels(a), labelpb.ZLabelsToPromLabels(b)) } // Deprecated. // TODO(bwplotka): Remove this once Cortex dep will stop using it. func LabelsToPromLabelsUnsafe(lset []Label) labels.Labels { - return labelpb.LabelpbLabelsToPromLabels(lset) + return labelpb.ZLabelsToPromLabels(lset) } // XORNumSamples return number of samples. Returns 0 if it's not XOR chunk. @@ -486,7 +486,7 @@ type SeriesStatsCounter struct { Samples int } -func (c *SeriesStatsCounter) CountSeries(seriesLabels []labelpb.Label) { +func (c *SeriesStatsCounter) CountSeries(seriesLabels []labelpb.ZLabel) { seriesHash := labelpb.HashWithPrefix("", seriesLabels) if c.lastSeriesHash != 0 || seriesHash != c.lastSeriesHash { c.lastSeriesHash = seriesHash diff --git a/pkg/store/storepb/custom_test.go b/pkg/store/storepb/custom_test.go index f31c8d6670..4a1c6d83c2 100644 --- a/pkg/store/storepb/custom_test.go +++ b/pkg/store/storepb/custom_test.go @@ -32,7 +32,7 @@ type listSeriesSet struct { func newSeries(tb testing.TB, lset labels.Labels, smplChunks [][]sample) Series { s := Series{ - Labels: labelpb.PromLabelsToLabelpbLabels(lset), + Labels: labelpb.ZLabelsFromPromLabels(lset), } for _, smpls := range smplChunks { diff --git a/pkg/store/storepb/inprocess_test.go b/pkg/store/storepb/inprocess_test.go index dab3f5548c..d37a36d48e 100644 --- a/pkg/store/storepb/inprocess_test.go +++ b/pkg/store/storepb/inprocess_test.go @@ -58,16 +58,16 @@ func TestServerAsClient(t *testing.T) { s := &testStoreServer{ series: []*SeriesResponse{ NewSeriesResponse(&Series{ - Labels: []labelpb.Label{{Name: "a", Value: "b"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "b"}}, Chunks: []AggrChunk{{MinTime: 123, MaxTime: 124}, {MinTime: 12455, MaxTime: 14124}}, }), NewSeriesResponse(&Series{ - Labels: []labelpb.Label{{Name: "a", Value: "b1"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "b1"}}, Chunks: []AggrChunk{{MinTime: 1231, MaxTime: 124}, {MinTime: 12455, MaxTime: 14124}}, }), NewWarnSeriesResponse(errors.New("yolo")), NewSeriesResponse(&Series{ - Labels: []labelpb.Label{{Name: "a", Value: "b3"}}, + Labels: []labelpb.ZLabel{{Name: "a", Value: "b3"}}, Chunks: []AggrChunk{{MinTime: 123, MaxTime: 124}, {MinTime: 124554, MaxTime: 14124}}, }), }} diff --git a/pkg/store/storepb/prompb/types.pb.go b/pkg/store/storepb/prompb/types.pb.go index 00e8b97e21..46aca14f64 100644 --- a/pkg/store/storepb/prompb/types.pb.go +++ b/pkg/store/storepb/prompb/types.pb.go @@ -12,7 +12,8 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - labelpb "github.com/thanos-io/thanos/pkg/store/labelpb" + _ "github.com/thanos-io/thanos/pkg/store/labelpb" + github_com_thanos_io_thanos_pkg_store_labelpb "github.com/thanos-io/thanos/pkg/store/labelpb" ) // Reference imports to suppress errors if they are not otherwise used. @@ -287,8 +288,8 @@ func (m *Sample) GetTimestamp() int64 { type Exemplar struct { // Optional, can be empty. - Labels []labelpb.Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"` - Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` + Labels []github_com_thanos_io_thanos_pkg_store_labelpb.ZLabel `protobuf:"bytes,1,rep,name=labels,proto3,customtype=github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel" json:"labels"` + Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` // timestamp is in ms format, see pkg/timestamp/timestamp.go for // conversion from time.Time to Prometheus timestamp. Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` @@ -327,13 +328,6 @@ func (m *Exemplar) XXX_DiscardUnknown() { var xxx_messageInfo_Exemplar proto.InternalMessageInfo -func (m *Exemplar) GetLabels() []labelpb.Label { - if m != nil { - return m.Labels - } - return nil -} - func (m *Exemplar) GetValue() float64 { if m != nil { return m.Value @@ -645,10 +639,11 @@ func (m *BucketSpan) GetLength() uint32 { // TimeSeries represents samples and labels for a single time series. type TimeSeries struct { // Labels have to be sorted by label names and without duplicated label names. - Labels []labelpb.Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"` - Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"` - Exemplars []Exemplar `protobuf:"bytes,3,rep,name=exemplars,proto3" json:"exemplars"` - Histograms []Histogram `protobuf:"bytes,4,rep,name=histograms,proto3" json:"histograms"` + // TODO(bwplotka): Don't use zero copy ZLabels, see https://github.com/thanos-io/thanos/pull/3279 for details. + Labels []github_com_thanos_io_thanos_pkg_store_labelpb.ZLabel `protobuf:"bytes,1,rep,name=labels,proto3,customtype=github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel" json:"labels"` + Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"` + Exemplars []Exemplar `protobuf:"bytes,3,rep,name=exemplars,proto3" json:"exemplars"` + Histograms []Histogram `protobuf:"bytes,4,rep,name=histograms,proto3" json:"histograms"` } func (m *TimeSeries) Reset() { *m = TimeSeries{} } @@ -684,13 +679,6 @@ func (m *TimeSeries) XXX_DiscardUnknown() { var xxx_messageInfo_TimeSeries proto.InternalMessageInfo -func (m *TimeSeries) GetLabels() []labelpb.Label { - if m != nil { - return m.Labels - } - return nil -} - func (m *TimeSeries) GetSamples() []Sample { if m != nil { return m.Samples @@ -938,7 +926,7 @@ func (m *Chunk) GetData() []byte { // ChunkedSeries represents single, encoded time series. type ChunkedSeries struct { // Labels should be sorted. - Labels []labelpb.Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"` + Labels []github_com_thanos_io_thanos_pkg_store_labelpb.ZLabel `protobuf:"bytes,1,rep,name=labels,proto3,customtype=github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel" json:"labels"` // Chunks will be in start time order and may overlap. Chunks []Chunk `protobuf:"bytes,2,rep,name=chunks,proto3" json:"chunks"` } @@ -976,13 +964,6 @@ func (m *ChunkedSeries) XXX_DiscardUnknown() { var xxx_messageInfo_ChunkedSeries proto.InternalMessageInfo -func (m *ChunkedSeries) GetLabels() []labelpb.Label { - if m != nil { - return m.Labels - } - return nil -} - func (m *ChunkedSeries) GetChunks() []Chunk { if m != nil { return m.Chunks @@ -1010,77 +991,79 @@ func init() { func init() { proto.RegisterFile("store/storepb/prompb/types.proto", fileDescriptor_166e07899dab7c14) } var fileDescriptor_166e07899dab7c14 = []byte{ - // 1115 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcf, 0x8e, 0x1a, 0xc7, - 0x13, 0x66, 0x18, 0x18, 0x98, 0x5a, 0x60, 0xc7, 0xfd, 0xf3, 0xcf, 0x1e, 0x6f, 0x12, 0x4c, 0x46, - 0xf9, 0x83, 0x9c, 0x88, 0x95, 0x6c, 0x2b, 0xb9, 0x38, 0x51, 0x76, 0xd7, 0xac, 0xb1, 0x62, 0x40, - 0x6e, 0x58, 0x25, 0xce, 0x05, 0x35, 0xd0, 0x0b, 0x23, 0x33, 0x7f, 0x34, 0xdd, 0x58, 0x4b, 0x9e, - 0x22, 0xe7, 0xdc, 0xf2, 0x08, 0x79, 0x0b, 0x1f, 0x7d, 0x8a, 0xa2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 0x17, 0xbb, 0xcf, 0x17, 0x01, 0x93, 0x71, 0x9a, 0x4e, 0x8e, - 0x02, 0x82, 0xa7, 0x0a, 0x23, 0x16, 0xe8, 0x62, 0xe9, 0x61, 0x1e, 0x8d, 0xaa, 0x25, 0xb9, 0x05, - 0x86, 0x98, 0xcc, 0xb9, 0xc7, 0xb0, 0x62, 0x37, 0x68, 0x62, 0x91, 0x0f, 0xa1, 0xf6, 0x3d, 0x8f, - 0x82, 0x91, 0x9c, 0x47, 0x5c, 0xcc, 0x83, 0xc5, 0x14, 0xab, 0xa7, 0xd1, 0xaa, 0x42, 0x87, 0x29, - 0x48, 0x3e, 0x4a, 0x68, 0x99, 0x2e, 0x03, 0x75, 0x69, 0xb4, 0xa2, 0xf0, 0x93, 0x54, 0xdb, 0x3d, - 0xb0, 0x36, 0x78, 0xb1, 0xc0, 0x12, 0x0a, 0xd4, 0x68, 0x6d, 0xcd, 0x8c, 0x45, 0x76, 0xa0, 0xe6, - 0xf3, 0x19, 0x93, 0xee, 0x2b, 0x3e, 0x12, 0x21, 0xf3, 0x85, 0x5d, 0xc6, 0xd3, 0x7d, 0x67, 0xa7, - 0x75, 0x8f, 0x97, 0x93, 0x97, 0x5c, 0x0e, 0x42, 0xe6, 0x27, 0x67, 0x5d, 0x4d, 0x03, 0x15, 0x26, - 0xc8, 0xc7, 0xb0, 0xbf, 0xde, 0x69, 0xca, 0x17, 0x92, 0x09, 0xdb, 0x6c, 0xe8, 0x4d, 0x42, 0xd7, - 0x09, 0x1e, 0x23, 0xba, 0x45, 0x44, 0x89, 0xc2, 0x86, 0x86, 0xde, 0xd4, 0x32, 0x22, 0xea, 0x13, - 0x4a, 0x5b, 0x18, 0x08, 0x77, 0x43, 0xdb, 0xde, 0x3f, 0xd6, 0x96, 0x06, 0xae, 0xb5, 0xad, 0x77, - 0x4a, 0xb4, 0x55, 0x62, 0x6d, 0x29, 0x9c, 0x69, 0x5b, 0x13, 0x13, 0x6d, 0xd5, 0x58, 0x5b,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0x89, 0xff, 0x41, 0x52, 0x09, 0x1d, 0x2b, - 0x71, 0x77, 0xa7, 0x12, 0x98, 0xa5, 0xd5, 0xf6, 0x27, 0xc1, 0xd4, 0xf5, 0x67, 0x59, 0x19, 0xd4, - 0xab, 0x8b, 0x9f, 0x56, 0xa1, 0xb8, 0x76, 0x1e, 0x43, 0x39, 0x65, 0xed, 0xdc, 0xb1, 0x6f, 0xfb, - 0xea, 0x51, 0xdc, 0x7a, 0x09, 0xf3, 0xe4, 0x7f, 0xb0, 0x7f, 0xfa, 0xac, 0x7f, 0x34, 0x1c, 0x6d, - 0x3c, 0x8f, 0x4e, 0x04, 0x55, 0xcc, 0xc8, 0xa7, 0xff, 0xe5, 0x86, 0x3c, 0x04, 0x63, 0xa2, 0xa2, - 0xd3, 0x0b, 0x72, 0xeb, 0xef, 0x3f, 0x27, 0x8d, 0x8a, 0xb9, 0xc7, 0x8d, 0xd7, 0x97, 0x75, 0xed, - 0xcd, 0x65, 0x5d, 0xfb, 0xe3, 0xb2, 0xae, 0xfd, 0x70, 0x55, 0xcf, 0xbd, 0xb9, 0xaa, 0xe7, 0x7e, - 0xbd, 0xaa, 0xe7, 0xbe, 0x33, 0xe2, 0x7f, 0x3b, 0x63, 0x03, 0xff, 0xa6, 0x3c, 0xf8, 0x2b, 0x00, - 0x00, 0xff, 0xff, 0x73, 0xfe, 0x08, 0x7f, 0x0c, 0x09, 0x00, 0x00, + // 1150 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x8f, 0xda, 0x46, + 0x14, 0xc7, 0x36, 0x18, 0xfc, 0x16, 0x58, 0x67, 0x9a, 0x26, 0xce, 0xb6, 0x25, 0xd4, 0xea, 0x1f, + 0x14, 0xb5, 0x20, 0x25, 0x51, 0x7b, 0x49, 0xab, 0x2e, 0x1b, 0x36, 0x44, 0x0d, 0xa0, 0x0c, 0xac, + 0xda,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xcf, 0xe6, + 0xad, 0xad, 0x86, 0x36, 0x9f, 0xcb, 0x68, 0x9c, 0xa4, 0xce, 0x58, 0xaa, 0x6f, 0x65, 0xa9, 0x5d, + 0x65, 0xf9, 0xba, 0x00, 0x46, 0xd7, 0x65, 0x3c, 0x98, 0x47, 0xc4, 0x43, 0x1f, 0x81, 0x31, 0x0d, + 0x96, 0x3e, 0x1f, 0xbb, 0x3e, 0x97, 0xdf, 0x9a, 0xef, 0xe6, 0x70, 0x49, 0x42, 0x8f, 0x7d, 0x8e, + 0x3e, 0x86, 0xbd, 0xd8, 0x7c, 0xba, 0x08, 0x08, 0x8f, 0xcb, 0x74, 0x73, 0x18, 0x24, 0x78, 0x2c, + 0x30, 0x64, 0x82, 0xc6, 0x96, 0x9e, 0xac, 0xa3, 0x60, 0x21, 0xa2, 0x1b, 0xa0, 0xb3, 0xa9, 0x43, + 0x3d, 0x22, 0x5b, 0x7d, 0x0d, 0x27, 0x1a, 0xfa, 0x14, 0xaa, 0x3f, 0xd1, 0x28, 0x18, 0x73, 0x27, + 0xa2, 0xcc, 0x09, 0x16, 0x33, 0xd9, 0x76, 0x05, 0x57, 0x04, 0x3a, 0x4a, 0x41, 0xf4, 0x59, 0xe2, + 0x96, 0xf1, 0xd2, 0x25, 0x2f, 0x05, 0x97, 0x05, 0x7e, 0x94, 0x72, 0xbb, 0x03, 0xe6, 0x86, 0x5f, + 0x4c, 0xb0, 0x28, 0x09, 0x2a, 0xb8, 0xba, 0xf6, 0x8c, 0x49, 0x76, 0xa1, 0xea, 0xd3, 0x39, 0xe1, + 0xee, 0x0b, 0x3a, 0x66, 0x21, 0xf1, 0x99, 0x55, 0x92, 0x5d, 0xf9, 0x60, 0x67, 0xe6, 0xdb, 0xcb, + 0xe9, 0x19, 0xe5, 0xc3, 0x90, 0xf8, 0xed, 0xbc, 0xe8, 0x11, 0xae, 0xa4, 0x81, 0x02, 0x63, 0xe8, + 0x73, 0xd8, 0x5f, 0x67, 0x9a, 0xd1, 0x05, 0x27, 0xcc, 0x32, 0xea, 0x5a, 0x03, 0xe1, 0x75, 0x81, + 0x87, 0x12, 0xdd, 0x72, 0x94, 0x14, 0x99, 0x05, 0x75, 0xad, 0xa1, 0x64, 0x8e, 0x92, 0x1f, 0x13, + 0xdc, 0xc2, 0x80, 0xb9, 0x1b, 0xdc, 0xf6, 0xfe, 0x37, 0xb7, 0x34, 0x70, 0xcd, 0x6d, 0x9d, 0x29, + 0xe1, 0x56, 0x8e, 0xb9, 0xa5, 0x70, 0xc6, 0x6d, 0xed, 0x98, 0x70, 0xab, 0xc4, 0xdc, 0x52, 0x38, + 0xe1, 0x76, 0x04, 0x10, 0x51, 0x46, 0xf9, 0xd8, 0x11, 0x7d, 0xa8, 0xca, 0x77, 0xe2, 0x93, 0x1d, + 0x5e, 0xeb, 0x71, 0x6a, 0x62, 0xe1, 0xdc, 0x75, 0x7d, 0x8e, 0x8d, 0x28, 0x15, 0xb7, 0xe7, 0x71, + 0xff, 0xea, 0x3c, 0xde, 0x07, 0x63, 0x1d, 0xb5, 0x7d, 0xdb, 0x8b, 0xa0, 0x3d, 0xeb, 0x0c, 0x4d, + 0x05, 0xe9, 0xa0, 0xf6, 0x07, 0xa6, 0x9a, 0xdd, 0x78, 0xad, 0x5d, 0x84, 0x82, 0x24, 0xde, 0x2e, + 0x03, 0x64, 0x53, 0x60, 0x3f, 0x00, 0xc8, 0x0e, 0x49, 0x0c, 0x62, 0x70, 0x7a, 0xca, 0x68, 0x3c, + 0xd9, 0xd7, 0x70, 0xa2, 0x09, 0x7c, 0x41, 0xfd, 0x39, 0x77, 0xe4, 0x40, 0x57, 0x70, 0xa2, 0xd9, + 0x7f, 0xa8, 0x00, 0x23, 0xd7, 0xa3, 0x43, 0x1a, 0xb9, 0x94, 0xbd, 0x9b, 0x2b, 0xfc, 0x35, 0x14, + 0x99, 0x7c, 0x72, 0x98, 0xa5, 0xca, 0x2a, 0x37, 0x77, 0x8e, 0x37, 0x7e, 0x92, 0x92, 0x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0x22, 0x7f, 0xb6, 0x09, 0x00, 0x00, } func (m *MetricMetadata) Marshal() (dAtA []byte, err error) { @@ -1200,11 +1183,11 @@ func (m *Exemplar) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Labels) > 0 { for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Labels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.Labels[iNdEx].Size() + i -= size + if _, err := m.Labels[iNdEx].MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- @@ -1516,11 +1499,11 @@ func (m *TimeSeries) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Labels) > 0 { for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Labels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.Labels[iNdEx].Size() + i -= size + if _, err := m.Labels[iNdEx].MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- @@ -1723,11 +1706,11 @@ func (m *ChunkedSeries) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Labels) > 0 { for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Labels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.Labels[iNdEx].Size() + i -= size + if _, err := m.Labels[iNdEx].MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- @@ -2360,7 +2343,7 @@ func (m *Exemplar) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Labels = append(m.Labels, labelpb.Label{}) + m.Labels = append(m.Labels, github_com_thanos_io_thanos_pkg_store_labelpb.ZLabel{}) if err := m.Labels[len(m.Labels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3089,7 +3072,7 @@ func (m *TimeSeries) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Labels = append(m.Labels, labelpb.Label{}) + m.Labels = append(m.Labels, github_com_thanos_io_thanos_pkg_store_labelpb.ZLabel{}) if err := m.Labels[len(m.Labels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3759,7 +3742,7 @@ func (m *ChunkedSeries) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Labels = append(m.Labels, labelpb.Label{}) + m.Labels = append(m.Labels, github_com_thanos_io_thanos_pkg_store_labelpb.ZLabel{}) if err := m.Labels[len(m.Labels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/pkg/store/storepb/prompb/types.proto b/pkg/store/storepb/prompb/types.proto index e508acfd09..c2d089b06b 100644 --- a/pkg/store/storepb/prompb/types.proto +++ b/pkg/store/storepb/prompb/types.proto @@ -55,7 +55,7 @@ message Sample { message Exemplar { // Optional, can be empty. - repeated thanos.Label labels = 1 [(gogoproto.nullable) = false]; + repeated thanos.Label labels = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel"]; double value = 2; // timestamp is in ms format, see pkg/timestamp/timestamp.go for // conversion from time.Time to Prometheus timestamp. @@ -131,7 +131,8 @@ message BucketSpan { // TimeSeries represents samples and labels for a single time series. message TimeSeries { // Labels have to be sorted by label names and without duplicated label names. - repeated thanos.Label labels = 1 [(gogoproto.nullable) = false]; + // TODO(bwplotka): Don't use zero copy ZLabels, see https://github.com/thanos-io/thanos/pull/3279 for details. + repeated thanos.Label labels = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel"]; repeated Sample samples = 2 [(gogoproto.nullable) = false]; repeated Exemplar exemplars = 3 [(gogoproto.nullable) = false]; repeated Histogram histograms = 4 [(gogoproto.nullable) = false]; @@ -180,7 +181,7 @@ message Chunk { // ChunkedSeries represents single, encoded time series. message ChunkedSeries { // Labels should be sorted. - repeated thanos.Label labels = 1 [(gogoproto.nullable) = false]; + repeated thanos.Label labels = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel"]; // Chunks will be in start time order and may overlap. repeated Chunk chunks = 2 [(gogoproto.nullable) = false]; } diff --git a/pkg/store/storepb/shard_info.go b/pkg/store/storepb/shard_info.go index 51ea4469f0..28d559b49a 100644 --- a/pkg/store/storepb/shard_info.go +++ b/pkg/store/storepb/shard_info.go @@ -7,6 +7,7 @@ import ( "sync" "github.com/cespare/xxhash/v2" + "github.com/prometheus/prometheus/model/labels" "github.com/thanos-io/thanos/pkg/store/labelpb" ) @@ -36,14 +37,14 @@ func (s *ShardMatcher) Close() { } } -func (s *ShardMatcher) MatchesLabels(lbls []labelpb.Label) bool { +func (s *ShardMatcher) MatchesZLabels(zLabels []labelpb.ZLabel) bool { // Match all series when query is not sharded if s == nil || !s.isSharded { return true } *s.buf = (*s.buf)[:0] - for _, lbl := range lbls { + for _, lbl := range zLabels { if shardByLabel(s.shardingLabelset, lbl, s.by) { *s.buf = append(*s.buf, lbl.Name...) *s.buf = append(*s.buf, sep[0]) @@ -56,8 +57,12 @@ func (s *ShardMatcher) MatchesLabels(lbls []labelpb.Label) bool { return hash%uint64(s.totalShards) == uint64(s.shardIndex) } -func shardByLabel(labelSet map[string]struct{}, lbl labelpb.Label, groupingBy bool) bool { - _, shardHasLabel := labelSet[lbl.Name] +func (s *ShardMatcher) MatchesLabels(lbls labels.Labels) bool { + return s.MatchesZLabels(labelpb.ZLabelsFromPromLabels(lbls)) +} + +func shardByLabel(labelSet map[string]struct{}, zlabel labelpb.ZLabel, groupingBy bool) bool { + _, shardHasLabel := labelSet[zlabel.Name] if groupingBy && shardHasLabel { return true } diff --git a/pkg/store/storepb/shard_info_test.go b/pkg/store/storepb/shard_info_test.go index 7ff659a8ef..ff1ef0972a 100644 --- a/pkg/store/storepb/shard_info_test.go +++ b/pkg/store/storepb/shard_info_test.go @@ -14,7 +14,7 @@ import ( ) func TestShardInfo_MatchesSeries(t *testing.T) { - series := labelpb.PromLabelsToLabelpbLabels(labels.FromStrings( + series := labelpb.ZLabelsFromPromLabels(labels.FromStrings( "pod", "nginx", "node", "node-1", "container", "nginx", @@ -23,7 +23,7 @@ func TestShardInfo_MatchesSeries(t *testing.T) { tests := []struct { name string shardInfo *ShardInfo - series []labelpb.Label + series []labelpb.ZLabel matches bool }{ { @@ -118,7 +118,7 @@ func TestShardInfo_MatchesSeries(t *testing.T) { t.Run(test.name, func(t *testing.T) { matcher := test.shardInfo.Matcher(&buffers) defer matcher.Close() - isMatch := matcher.MatchesLabels(test.series) + isMatch := matcher.MatchesZLabels(test.series) if isMatch != test.matches { t.Fatalf("invalid result, got %t, want %t", isMatch, test.matches) } diff --git a/pkg/store/storepb/testutil/series.go b/pkg/store/storepb/testutil/series.go index b743e9b50b..f563d5f2a5 100644 --- a/pkg/store/storepb/testutil/series.go +++ b/pkg/store/storepb/testutil/series.go @@ -151,7 +151,7 @@ func ReadSeriesFromBlock(t testing.TB, h tsdb.BlockReader, extLabels labels.Labe for all.Next() { testutil.Ok(t, ir.Series(all.At(), &builder, &chunkMetas)) lset := labelpb.ExtendSortedLabels(builder.Labels(), extLabels) - expected = append(expected, &storepb.Series{Labels: labelpb.PromLabelsToLabelpbLabels(lset)}) + expected = append(expected, &storepb.Series{Labels: labelpb.ZLabelsFromPromLabels(lset)}) if skipChunks { continue diff --git a/pkg/store/storepb/types.pb.go b/pkg/store/storepb/types.pb.go index 194f800906..401dcad2dc 100644 --- a/pkg/store/storepb/types.pb.go +++ b/pkg/store/storepb/types.pb.go @@ -11,7 +11,8 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - labelpb "github.com/thanos-io/thanos/pkg/store/labelpb" + _ "github.com/thanos-io/thanos/pkg/store/labelpb" + github_com_thanos_io_thanos_pkg_store_labelpb "github.com/thanos-io/thanos/pkg/store/labelpb" ) // Reference imports to suppress errors if they are not otherwise used. @@ -158,8 +159,8 @@ func (m *Chunk) XXX_DiscardUnknown() { var xxx_messageInfo_Chunk proto.InternalMessageInfo type Series struct { - Labels []labelpb.Label `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels"` - Chunks []AggrChunk `protobuf:"bytes,2,rep,name=chunks,proto3" json:"chunks"` + Labels []github_com_thanos_io_thanos_pkg_store_labelpb.ZLabel `protobuf:"bytes,1,rep,name=labels,proto3,customtype=github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel" json:"labels"` + Chunks []AggrChunk `protobuf:"bytes,2,rep,name=chunks,proto3" json:"chunks"` } func (m *Series) Reset() { *m = Series{} } @@ -292,40 +293,43 @@ func init() { func init() { proto.RegisterFile("store/storepb/types.proto", fileDescriptor_121fba57de02d8e0) } var fileDescriptor_121fba57de02d8e0 = []byte{ - // 528 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xbd, 0xb6, 0xe3, 0x24, 0x43, 0x0b, 0x66, 0xa9, 0x60, 0xd3, 0x83, 0x1b, 0x19, 0x21, - 0xa2, 0x22, 0x1c, 0xa9, 0x1c, 0x38, 0x27, 0x28, 0xfc, 0x91, 0xda, 0x86, 0x6e, 0x22, 0x81, 0xb8, - 0x54, 0x9b, 0x74, 0x71, 0x2c, 0xe2, 0x75, 0xe4, 0xdd, 0x40, 0xf2, 0x16, 0x20, 0x6e, 0x3c, 0x51, - 0x8e, 0x3d, 0x72, 0x42, 0x90, 0xbc, 0x08, 0xf2, 0xda, 0xa1, 0x44, 0xf2, 0x25, 0x9a, 0x7c, 0xdf, - 0x6f, 0x66, 0x67, 0xc7, 0xb3, 0xd0, 0x90, 0x2a, 0x49, 0x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, 0x48, 0x3e, 0x50, 0x29, 0x53, 0x3c, 0x5c, 0xe2, - 0x1a, 0xd8, 0xef, 0x3a, 0xf4, 0xdc, 0x35, 0x70, 0x1d, 0x2a, 0x9d, 0x6e, 0x9f, 0x0e, 0x5d, 0xd4, - 0x7d, 0xb4, 0xfa, 0xe3, 0x19, 0xab, 0xb5, 0x87, 0xae, 0xd7, 0x1e, 0xfa, 0xbd, 0xf6, 0xd0, 0xd7, - 0x8d, 0x67, 0x5c, 0x6f, 0x3c, 0xe3, 0xe7, 0xc6, 0x33, 0x3e, 0x54, 0x8b, 0xa7, 0x34, 0x72, 0xf4, - 0x63, 0x78, 0xf6, 0x37, 0x00, 0x00, 0xff, 0xff, 0x20, 0x34, 0x7d, 0xbe, 0x62, 0x03, 0x00, 0x00, + // 565 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0xf5, 0xda, 0x8e, 0x93, 0x0c, 0x2d, 0x98, 0xa5, 0x02, 0xb7, 0x07, 0x27, 0x32, 0x42, 0x44, + 0x95, 0x6a, 0x4b, 0x05, 0x89, 0x0b, 0x97, 0x04, 0x85, 0x0f, 0xa9, 0x6d, 0xe8, 0x26, 0x12, 0xa8, + 0x97, 0x6a, 0xe3, 0xae, 0x6c, 0xab, 0xf1, 0x87, 0xec, 0x35, 0x24, 0xff, 0x02, 0xc4, 0x8d, 0x03, + 0xbf, 0x27, 0xc7, 0x1e, 0x11, 0x87, 0x08, 0x92, 0x3f, 0x82, 0xbc, 0x76, 0x28, 0x91, 0x72, 0xb1, + 0xc6, 0xef, 0xbd, 0x99, 0xd9, 0x79, 0x3b, 0x0b, 0xfb, 0x19, 0x8f, 0x53, 0xe6, 0x88, 0x6f, 0x32, + 0x76, 0xf8, 0x2c, 0x61, 0x99, 0x9d, 0xa4, 0x31, 0x8f, 0xb1, 0xc6, 0x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a, 0x2a, 0x00, 0xd2, 0xd7, 0x65, 0x01, 0x90, 0xbe, 0xae, + 0x1c, 0xda, 0xf0, 0xe8, 0x3d, 0x4d, 0x79, 0x40, 0x27, 0x84, 0x65, 0x49, 0x1c, 0x65, 0x6c, 0xc8, + 0x53, 0xca, 0x99, 0x37, 0xc3, 0x0d, 0x50, 0x3f, 0x74, 0xc9, 0x99, 0x2e, 0xe1, 0x26, 0xd4, 0xba, + 0xbd, 0x01, 0x19, 0xe9, 0xa8, 0xf7, 0x64, 0xfe, 0xc7, 0x94, 0xe6, 0x4b, 0x13, 0xdd, 0x2c, 0x4d, + 0xf4, 0x7b, 0x69, 0xa2, 0x2f, 0x2b, 0x53, 0xba, 0x59, 0x99, 0xd2, 0xcf, 0x95, 0x29, 0x5d, 0xd4, + 0xab, 0x37, 0x38, 0xd6, 0xc4, 0x2b, 0x7a, 0xf6, 0x37, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x6d, 0x25, + 0xf3, 0x9b, 0x03, 0x00, 0x00, } func (m *Chunk) Marshal() (dAtA []byte, err error) { @@ -405,11 +409,11 @@ func (m *Series) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Labels) > 0 { for iNdEx := len(m.Labels) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Labels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.Labels[iNdEx].Size() + i -= size + if _, err := m.Labels[iNdEx].MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- @@ -862,7 +866,7 @@ func (m *Series) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Labels = append(m.Labels, labelpb.Label{}) + m.Labels = append(m.Labels, github_com_thanos_io_thanos_pkg_store_labelpb.ZLabel{}) if err := m.Labels[len(m.Labels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/pkg/store/storepb/types.proto b/pkg/store/storepb/types.proto index 2435b16f15..840d3c5188 100644 --- a/pkg/store/storepb/types.proto +++ b/pkg/store/storepb/types.proto @@ -32,7 +32,7 @@ message Chunk { } message Series { - repeated Label labels = 1 [(gogoproto.nullable) = false]; + repeated Label labels = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/thanos-io/thanos/pkg/store/labelpb.ZLabel"]; repeated AggrChunk chunks = 2 [(gogoproto.nullable) = false]; } diff --git a/pkg/store/tsdb.go b/pkg/store/tsdb.go index 589c05fc5c..b4cea0022b 100644 --- a/pkg/store/tsdb.go +++ b/pkg/store/tsdb.go @@ -93,13 +93,11 @@ func (s *TSDBStore) getExtLset() labels.Labels { return s.extLset } -func (s *TSDBStore) LabelSet() []labelpb.LabelSet { - labels := labelpb.PromLabelsToLabelpbLabels(s.getExtLset()) - labelSets := []labelpb.LabelSet{} +func (s *TSDBStore) LabelSet() []labelpb.ZLabelSet { + labels := labelpb.ZLabelSetsFromPromLabels(s.getExtLset()) + labelSets := []labelpb.ZLabelSet{} if len(labels) > 0 { - labelSets = append(labelSets, labelpb.LabelSet{ - Labels: labels, - }) + labelSets = append(labelSets, labels...) } return labelSets @@ -114,7 +112,7 @@ func (p *TSDBStore) TSDBInfos() []infopb.TSDBInfo { mint, maxt := p.TimeRange() return []infopb.TSDBInfo{ { - Labels: labelpb.LabelSet{ + Labels: labelpb.ZLabelSet{ Labels: labels[0].Labels, }, MinTime: mint, @@ -218,11 +216,11 @@ func (s *TSDBStore) Series(r *storepb.SeriesRequest, seriesSrv storepb.Store_Ser series := set.At() completeLabelset := labelpb.ExtendSortedLabels(rmLabels(series.Labels(), extLsetToRemove), finalExtLset) - if !shardMatcher.MatchesLabels(labelpb.PromLabelsToLabelpbLabels(completeLabelset)) { + if !shardMatcher.MatchesLabels(completeLabelset) { continue } - storeSeries := storepb.Series{Labels: labelpb.PromLabelsToLabelpbLabels(completeLabelset)} + storeSeries := storepb.Series{Labels: labelpb.ZLabelsFromPromLabels(completeLabelset)} if r.SkipChunks { if err := srv.Send(storepb.NewSeriesResponse(&storeSeries)); err != nil { return status.Error(codes.Aborted, err.Error()) diff --git a/pkg/store/tsdb_test.go b/pkg/store/tsdb_test.go index 784e4cf04a..5a6457a6fe 100644 --- a/pkg/store/tsdb_test.go +++ b/pkg/store/tsdb_test.go @@ -563,16 +563,16 @@ func benchTSDBStoreSeries(t testutil.TB, totalSamples, totalSeries int) { // Add external labels & frame it. s := r.GetSeries() bytesLeftForChunks := store.maxBytesPerFrame - lbls := make([]labelpb.Label, 0, len(s.Labels)+extLabels.Len()) + lbls := make([]labelpb.ZLabel, 0, len(s.Labels)+extLabels.Len()) for _, l := range s.Labels { - lbls = append(lbls, labelpb.Label{ + lbls = append(lbls, labelpb.ZLabel{ Name: l.Name, Value: l.Value, }) bytesLeftForChunks -= lbls[len(lbls)-1].Size() } extLabels.Range(func(l labels.Label) { - lbls = append(lbls, labelpb.Label{ + lbls = append(lbls, labelpb.ZLabel{ Name: l.Name, Value: l.Value, }) diff --git a/pkg/targets/prometheus_test.go b/pkg/targets/prometheus_test.go index b6324948dd..6121ecc791 100644 --- a/pkg/targets/prometheus_test.go +++ b/pkg/targets/prometheus_test.go @@ -73,7 +73,7 @@ scrape_configs: expected := &targetspb.TargetDiscovery{ ActiveTargets: []*targetspb.ActiveTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: p.Addr()}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -82,7 +82,7 @@ scrape_configs: {Name: "job", Value: "myself"}, {Name: "replica", Value: "test1"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: p.Addr()}, {Name: "job", Value: "myself"}, {Name: "replica", Value: "test1"}, @@ -97,7 +97,7 @@ scrape_configs: }, DroppedTargets: []*targetspb.DroppedTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:80"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, diff --git a/pkg/targets/targets_test.go b/pkg/targets/targets_test.go index b4b9d926df..c98d38a416 100644 --- a/pkg/targets/targets_test.go +++ b/pkg/targets/targets_test.go @@ -29,7 +29,7 @@ func TestDedupTargets(t *testing.T) { targets: &targetspb.TargetDiscovery{ DroppedTargets: []*targetspb.DroppedTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:80"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -39,7 +39,7 @@ func TestDedupTargets(t *testing.T) { }}, }, { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:80"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -53,7 +53,7 @@ func TestDedupTargets(t *testing.T) { want: &targetspb.TargetDiscovery{ DroppedTargets: []*targetspb.DroppedTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:80"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -70,7 +70,7 @@ func TestDedupTargets(t *testing.T) { targets: &targetspb.TargetDiscovery{ ActiveTargets: []*targetspb.ActiveTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -78,7 +78,7 @@ func TestDedupTargets(t *testing.T) { {Name: "prometheus", Value: "ha"}, {Name: "replica", Value: "0"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -89,7 +89,7 @@ func TestDedupTargets(t *testing.T) { Health: targetspb.TargetHealth_UP, }, { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -97,7 +97,7 @@ func TestDedupTargets(t *testing.T) { {Name: "prometheus", Value: "ha"}, {Name: "replica", Value: "1"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -112,14 +112,14 @@ func TestDedupTargets(t *testing.T) { want: &targetspb.TargetDiscovery{ ActiveTargets: []*targetspb.ActiveTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -137,7 +137,7 @@ func TestDedupTargets(t *testing.T) { targets: &targetspb.TargetDiscovery{ ActiveTargets: []*targetspb.ActiveTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -145,7 +145,7 @@ func TestDedupTargets(t *testing.T) { {Name: "prometheus", Value: "ha"}, {Name: "replica", Value: "0"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -156,7 +156,7 @@ func TestDedupTargets(t *testing.T) { Health: targetspb.TargetHealth_UP, }, { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -164,7 +164,7 @@ func TestDedupTargets(t *testing.T) { {Name: "prometheus", Value: "ha"}, {Name: "replica", Value: "1"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -179,14 +179,14 @@ func TestDedupTargets(t *testing.T) { want: &targetspb.TargetDiscovery{ ActiveTargets: []*targetspb.ActiveTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -204,7 +204,7 @@ func TestDedupTargets(t *testing.T) { targets: &targetspb.TargetDiscovery{ ActiveTargets: []*targetspb.ActiveTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -212,7 +212,7 @@ func TestDedupTargets(t *testing.T) { {Name: "prometheus", Value: "ha"}, {Name: "replica", Value: "0"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -224,7 +224,7 @@ func TestDedupTargets(t *testing.T) { LastScrape: time.Unix(1, 0), }, { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -232,7 +232,7 @@ func TestDedupTargets(t *testing.T) { {Name: "prometheus", Value: "ha"}, {Name: "replica", Value: "1"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -248,14 +248,14 @@ func TestDedupTargets(t *testing.T) { want: &targetspb.TargetDiscovery{ ActiveTargets: []*targetspb.ActiveTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, diff --git a/pkg/targets/targetspb/custom.go b/pkg/targets/targetspb/custom.go index 188ddf65cd..9fb1d93620 100644 --- a/pkg/targets/targetspb/custom.go +++ b/pkg/targets/targetspb/custom.go @@ -100,30 +100,30 @@ func (t1 *DroppedTarget) Compare(t2 *DroppedTarget) int { } func (t *ActiveTarget) SetLabels(ls labels.Labels) { - var result labelpb.LabelSet + var result labelpb.ZLabelSet if !ls.IsEmpty() { - result = labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(ls)} + result = labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(ls)} } t.Labels = result } func (t *ActiveTarget) SetDiscoveredLabels(ls labels.Labels) { - var result labelpb.LabelSet + var result labelpb.ZLabelSet if !ls.IsEmpty() { - result = labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(ls)} + result = labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(ls)} } t.DiscoveredLabels = result } func (t *DroppedTarget) SetDiscoveredLabels(ls labels.Labels) { - var result labelpb.LabelSet + var result labelpb.ZLabelSet if !ls.IsEmpty() { - result = labelpb.LabelSet{Labels: labelpb.PromLabelsToLabelpbLabels(ls)} + result = labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(ls)} } t.DiscoveredLabels = result diff --git a/pkg/targets/targetspb/rpc.pb.go b/pkg/targets/targetspb/rpc.pb.go index 8083c215ec..5344c1905e 100644 --- a/pkg/targets/targetspb/rpc.pb.go +++ b/pkg/targets/targetspb/rpc.pb.go @@ -256,15 +256,15 @@ func (m *TargetDiscovery) XXX_DiscardUnknown() { var xxx_messageInfo_TargetDiscovery proto.InternalMessageInfo type ActiveTarget struct { - DiscoveredLabels labelpb.LabelSet `protobuf:"bytes,1,opt,name=discoveredLabels,proto3" json:"discoveredLabels"` - Labels labelpb.LabelSet `protobuf:"bytes,2,opt,name=labels,proto3" json:"labels"` - ScrapePool string `protobuf:"bytes,3,opt,name=scrapePool,proto3" json:"scrapePool"` - ScrapeUrl string `protobuf:"bytes,4,opt,name=scrapeUrl,proto3" json:"scrapeUrl"` - GlobalUrl string `protobuf:"bytes,5,opt,name=globalUrl,proto3" json:"globalUrl"` - LastError string `protobuf:"bytes,6,opt,name=lastError,proto3" json:"lastError"` - LastScrape time.Time `protobuf:"bytes,7,opt,name=lastScrape,proto3,stdtime" json:"lastScrape"` - LastScrapeDuration float64 `protobuf:"fixed64,8,opt,name=lastScrapeDuration,proto3" json:"lastScrapeDuration"` - Health TargetHealth `protobuf:"varint,9,opt,name=health,proto3,enum=thanos.TargetHealth" json:"health"` + DiscoveredLabels labelpb.ZLabelSet `protobuf:"bytes,1,opt,name=discoveredLabels,proto3" json:"discoveredLabels"` + Labels labelpb.ZLabelSet `protobuf:"bytes,2,opt,name=labels,proto3" json:"labels"` + ScrapePool string `protobuf:"bytes,3,opt,name=scrapePool,proto3" json:"scrapePool"` + ScrapeUrl string `protobuf:"bytes,4,opt,name=scrapeUrl,proto3" json:"scrapeUrl"` + GlobalUrl string `protobuf:"bytes,5,opt,name=globalUrl,proto3" json:"globalUrl"` + LastError string `protobuf:"bytes,6,opt,name=lastError,proto3" json:"lastError"` + LastScrape time.Time `protobuf:"bytes,7,opt,name=lastScrape,proto3,stdtime" json:"lastScrape"` + LastScrapeDuration float64 `protobuf:"fixed64,8,opt,name=lastScrapeDuration,proto3" json:"lastScrapeDuration"` + Health TargetHealth `protobuf:"varint,9,opt,name=health,proto3,enum=thanos.TargetHealth" json:"health"` } func (m *ActiveTarget) Reset() { *m = ActiveTarget{} } @@ -301,7 +301,7 @@ func (m *ActiveTarget) XXX_DiscardUnknown() { var xxx_messageInfo_ActiveTarget proto.InternalMessageInfo type DroppedTarget struct { - DiscoveredLabels labelpb.LabelSet `protobuf:"bytes,1,opt,name=discoveredLabels,proto3" json:"discoveredLabels"` + DiscoveredLabels labelpb.ZLabelSet `protobuf:"bytes,1,opt,name=discoveredLabels,proto3" json:"discoveredLabels"` } func (m *DroppedTarget) Reset() { *m = DroppedTarget{} } @@ -350,51 +350,51 @@ func init() { func init() { proto.RegisterFile("targets/targetspb/rpc.proto", fileDescriptor_b5cdaee03579e907) } var fileDescriptor_b5cdaee03579e907 = []byte{ - // 699 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xc1, 0x72, 0xd3, 0x3c, - 0x10, 0xb6, 0xd3, 0x36, 0x69, 0xb6, 0x6d, 0xfe, 0xfc, 0x9a, 0xfe, 0xad, 0x9b, 0x9f, 0x89, 0x3b, - 0xb9, 0x50, 0x60, 0xb0, 0x99, 0xf4, 0xc2, 0x81, 0x4b, 0x4d, 0x0a, 0x65, 0x80, 0x34, 0x28, 0x69, - 0x19, 0xe0, 0xd0, 0x51, 0x12, 0xe1, 0x66, 0xc6, 0x8d, 0x8c, 0xa4, 0x94, 0xe9, 0x5b, 0xf4, 0x45, - 0x38, 0xf1, 0x12, 0x3d, 0x70, 0xe8, 0x91, 0x93, 0x81, 0xf6, 0x96, 0xa7, 0x60, 0x2c, 0xdb, 0xb1, - 0xd3, 0x86, 0x23, 0x17, 0x6b, 0xf7, 0xdb, 0x6f, 0xbf, 0x5d, 0x59, 0x5a, 0xc1, 0xff, 0x92, 0x70, - 0x97, 0x4a, 0x61, 0xc7, 0xab, 0xdf, 0xb5, 0xb9, 0xdf, 0xb3, 0x7c, 0xce, 0x24, 0x43, 0x79, 0x79, - 0x4c, 0x86, 0x4c, 0x54, 0x36, 0x84, 0x64, 0x9c, 0xda, 0xea, 0xeb, 0x77, 0x6d, 0x79, 0xe6, 0x53, - 0x11, 0x51, 0x2a, 0xab, 0x2e, 0x73, 0x99, 0x32, 0xed, 0xd0, 0x8a, 0xd1, 0x38, 0xc1, 0x23, 0x5d, - 0xea, 0xdd, 0x48, 0x30, 0x5d, 0xc6, 0x5c, 0x8f, 0xda, 0xca, 0xeb, 0x8e, 0x3e, 0xda, 0x72, 0x70, - 0x42, 0x85, 0x24, 0x27, 0x7e, 0x44, 0xa8, 0x7d, 0xd3, 0xa1, 0xd4, 0x89, 0x9a, 0xc1, 0xf4, 0xd3, - 0x88, 0x0a, 0x89, 0xea, 0xb0, 0x20, 0x24, 0x91, 0xd4, 0xd0, 0x37, 0xf5, 0xad, 0x52, 0xfd, 0x8e, - 0x15, 0xf5, 0x65, 0x4d, 0xd3, 0xac, 0x76, 0xc8, 0xc1, 0x11, 0x15, 0x7d, 0x80, 0x0d, 0x9f, 0x70, - 0x39, 0x20, 0xde, 0x11, 0xa7, 0xc2, 0x67, 0x43, 0x41, 0x8f, 0x84, 0xe4, 0x44, 0x52, 0xf7, 0xcc, - 0xc8, 0x29, 0x1d, 0x33, 0xd1, 0x69, 0x45, 0x44, 0x1c, 0xf3, 0xda, 0x31, 0x0d, 0xaf, 0xfb, 0xb3, - 0x03, 0xb5, 0x7b, 0xb0, 0xa0, 0x8a, 0xa1, 0x02, 0xcc, 0xed, 0x34, 0xdf, 0x95, 0x35, 0x04, 0x90, - 0xdf, 0x79, 0xda, 0x79, 0x71, 0xb8, 0x5b, 0xd6, 0xd1, 0x12, 0x14, 0x1a, 0x78, 0xbf, 0xd5, 0xda, - 0x6d, 0x94, 0x73, 0x35, 0x0f, 0xfe, 0x99, 0xb4, 0x19, 0xa9, 0xa0, 0x6d, 0x28, 0xc4, 0x7f, 0x5b, - 0x6d, 0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2e, 0xae, 0xaa, - 0xfa, 0xe5, 0x55, 0x55, 0xff, 0x79, 0x55, 0xd5, 0xcf, 0xaf, 0xab, 0xda, 0xe5, 0x75, 0x55, 0xfb, - 0x7e, 0x5d, 0xd5, 0xde, 0x17, 0x27, 0x6f, 0x75, 0x37, 0xaf, 0xce, 0x70, 0xfb, 0x77, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x81, 0x5b, 0x5e, 0xa6, 0xc7, 0x05, 0x00, 0x00, + // 702 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x41, 0x53, 0xdb, 0x3a, + 0x10, 0xb6, 0x03, 0x38, 0x64, 0x81, 0xbc, 0xa0, 0xe1, 0x81, 0xc9, 0x7b, 0x13, 0x33, 0xb9, 0x3c, + 0x5e, 0x3b, 0x75, 0x3a, 0xe1, 0xd2, 0xce, 0xf4, 0x82, 0x1b, 0x5a, 0x3a, 0x6d, 0x43, 0xaa, 0x84, + 0x32, 0xa5, 0x07, 0x46, 0x49, 0x54, 0x27, 0x33, 0x26, 0x72, 0x25, 0x85, 0x0e, 0xff, 0x82, 0x7f, + 0xd2, 0x43, 0xff, 0x04, 0x87, 0x1e, 0x38, 0xf6, 0x94, 0xb6, 0x70, 0xcb, 0xaf, 0xe8, 0x58, 0xb6, + 0x63, 0x07, 0xd2, 0x63, 0x2f, 0xd6, 0xee, 0xb7, 0xdf, 0x7e, 0xbb, 0xb2, 0xb4, 0x82, 0x7f, 0x24, + 0xe1, 0x2e, 0x95, 0xa2, 0x12, 0xad, 0x7e, 0xbb, 0xc2, 0xfd, 0x8e, 0xed, 0x73, 0x26, 0x19, 0x32, + 0x64, 0x8f, 0x0c, 0x98, 0x28, 0x6e, 0x0a, 0xc9, 0x38, 0xad, 0xa8, 0xaf, 0xdf, 0xae, 0xc8, 0x73, + 0x9f, 0x8a, 0x90, 0x52, 0x5c, 0x73, 0x99, 0x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xdd, 0x36, 0xd4, 0x21, 0xee, + 0xfc, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x5c, 0x84, 0x60, 0xca, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/pkg/targets/targetspb/rpc.proto b/pkg/targets/targetspb/rpc.proto index e60ef7416a..6515dc0070 100644 --- a/pkg/targets/targetspb/rpc.proto +++ b/pkg/targets/targetspb/rpc.proto @@ -64,8 +64,8 @@ enum TargetHealth { } message ActiveTarget { - LabelSet discoveredLabels = 1 [(gogoproto.jsontag) = "discoveredLabels", (gogoproto.nullable) = false]; - LabelSet labels = 2 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false]; + ZLabelSet discoveredLabels = 1 [(gogoproto.jsontag) = "discoveredLabels", (gogoproto.nullable) = false]; + ZLabelSet labels = 2 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false]; string scrapePool = 3 [(gogoproto.jsontag) = "scrapePool"]; string scrapeUrl = 4 [(gogoproto.jsontag) = "scrapeUrl"]; string globalUrl = 5 [(gogoproto.jsontag) = "globalUrl"]; @@ -76,5 +76,5 @@ message ActiveTarget { } message DroppedTarget { - LabelSet discoveredLabels = 1 [(gogoproto.jsontag) = "discoveredLabels", (gogoproto.nullable) = false]; + ZLabelSet discoveredLabels = 1 [(gogoproto.jsontag) = "discoveredLabels", (gogoproto.nullable) = false]; } diff --git a/test/e2e/exemplars_api_test.go b/test/e2e/exemplars_api_test.go index 29625ddaa2..60c423f667 100644 --- a/test/e2e/exemplars_api_test.go +++ b/test/e2e/exemplars_api_test.go @@ -131,7 +131,7 @@ func exemplarsOnExpectedSeries(requiredSeriesLabels map[string]string) func(data } // Compare series labels. - seriesLabels := labelpb.LabelpbLabelSetsToPromLabels(data[0].SeriesLabels) + seriesLabels := labelpb.ZLabelSetsToPromLabelSets(data[0].SeriesLabels) for _, lbls := range seriesLabels { for k, v := range requiredSeriesLabels { if lbls.Get(k) != v { @@ -142,7 +142,7 @@ func exemplarsOnExpectedSeries(requiredSeriesLabels map[string]string) func(data // Make sure the exemplar contains the correct traceID label. for _, exemplar := range data[0].Exemplars { - for _, lbls := range labelpb.LabelpbLabelSetsToPromLabels(exemplar.Labels) { + for _, lbls := range labelpb.ZLabelSetsToPromLabelSets(exemplar.Labels) { if !lbls.Has(traceIDLabel) { return errors.Errorf("unexpected labels in exemplar, expected %v, got: %v", traceIDLabel, exemplar.Labels) } diff --git a/test/e2e/rules_api_test.go b/test/e2e/rules_api_test.go index fe1d7ee5a0..2b5670a598 100644 --- a/test/e2e/rules_api_test.go +++ b/test/e2e/rules_api_test.go @@ -104,7 +104,7 @@ func TestRulesAPI_Fanout(t *testing.T) { Name: "TestAlert_AbortOnPartialResponse", State: rulespb.AlertState_FIRING, Query: "absent(some_metric)", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "prometheus", Value: "ha"}, {Name: "severity", Value: "page"}, }}, @@ -120,7 +120,7 @@ func TestRulesAPI_Fanout(t *testing.T) { Name: "TestAlert_AbortOnPartialResponse", State: rulespb.AlertState_FIRING, Query: "absent(some_metric)", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "severity", Value: "page"}, }}, Health: string(rules.HealthGood), @@ -135,7 +135,7 @@ func TestRulesAPI_Fanout(t *testing.T) { Name: "TestAlert_WarnOnPartialResponse", State: rulespb.AlertState_FIRING, Query: "absent(some_metric)", - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "severity", Value: "page"}, }}, Health: string(rules.HealthGood), @@ -151,7 +151,7 @@ func TestRulesAPI_Fanout(t *testing.T) { Name: "TestAlert_WithLimit", State: rulespb.AlertState_INACTIVE, Query: `promhttp_metric_handler_requests_total`, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "severity", Value: "page"}, }}, Health: string(rules.HealthBad), diff --git a/test/e2e/targets_api_test.go b/test/e2e/targets_api_test.go index 6a446cc1e4..803f7f1d0d 100644 --- a/test/e2e/targets_api_test.go +++ b/test/e2e/targets_api_test.go @@ -64,7 +64,7 @@ func TestTargetsAPI_Fanout(t *testing.T) { targetAndAssert(t, ctx, q.Endpoint("http"), "", &targetspb.TargetDiscovery{ ActiveTargets: []*targetspb.ActiveTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:9090"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"}, @@ -73,7 +73,7 @@ func TestTargetsAPI_Fanout(t *testing.T) { {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, }}, - Labels: labelpb.LabelSet{Labels: []labelpb.Label{ + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "ha"}, @@ -85,7 +85,7 @@ func TestTargetsAPI_Fanout(t *testing.T) { }, DroppedTargets: []*targetspb.DroppedTarget{ { - DiscoveredLabels: labelpb.LabelSet{Labels: []labelpb.Label{ + DiscoveredLabels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ {Name: "__address__", Value: "localhost:80"}, {Name: "__metrics_path__", Value: "/metrics"}, {Name: "__scheme__", Value: "http"},