Skip to content

Commit

Permalink
*: rm ZLabels and friends
Browse files Browse the repository at this point in the history
Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
  • Loading branch information
GiedriusS committed Aug 30, 2024
1 parent 5d4c3e1 commit e11fd06
Show file tree
Hide file tree
Showing 85 changed files with 1,335 additions and 2,268 deletions.
2 changes: 1 addition & 1 deletion cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ func runQuery(

infoSrv := info.NewInfoServer(
component.Query.String(),
info.WithLabelSetFunc(func() []labelpb.ZLabelSet { return proxy.LabelSet() }),
info.WithLabelSetFunc(func() []labelpb.LabelSet { return proxy.LabelSet() }),
info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) {
if httpProbe.IsReady() {
mint, maxt := proxy.TimeRange()
Expand Down
2 changes: 1 addition & 1 deletion cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func runReceive(

infoSrv := info.NewInfoServer(
component.Receive.String(),
info.WithLabelSetFunc(func() []labelpb.ZLabelSet { return proxy.LabelSet() }),
info.WithLabelSetFunc(func() []labelpb.LabelSet { return proxy.LabelSet() }),
info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) {
if httpProbe.IsReady() {
minTime, maxTime := proxy.TimeRange()
Expand Down
2 changes: 1 addition & 1 deletion cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ func runRule(
tsdbStore := store.NewTSDBStore(logger, tsdbDB, component.Rule, conf.lset)
infoOptions = append(
infoOptions,
info.WithLabelSetFunc(func() []labelpb.ZLabelSet {
info.WithLabelSetFunc(func() []labelpb.LabelSet {
return tsdbStore.LabelSet()
}),
info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/thanos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func runSidecar(

infoSrv := info.NewInfoServer(
component.Sidecar.String(),
info.WithLabelSetFunc(func() []labelpb.ZLabelSet {
info.WithLabelSetFunc(func() []labelpb.LabelSet {
return promStore.LabelSet()
}),
info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/thanos/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func runStore(

infoSrv := info.NewInfoServer(
component.Store.String(),
info.WithLabelSetFunc(func() []labelpb.ZLabelSet {
info.WithLabelSetFunc(func() []labelpb.LabelSet {
return bs.LabelSet()
}),
info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) {
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ require (
github.com/onsi/gomega v1.33.1
github.com/prometheus-community/prom-label-proxy v0.8.1-0.20240127162815-c1195f9aabc0
go.opentelemetry.io/contrib/propagators/autoprop v0.53.0
go4.org/intern v0.0.0-20230525184215-6c62f75575cb
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
)

Expand Down Expand Up @@ -152,7 +151,6 @@ require (
go.opentelemetry.io/collector/semconv v0.104.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/propagators/ot v1.28.0 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1478,10 +1478,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go4.org/intern v0.0.0-20230525184215-6c62f75575cb h1:ae7kzL5Cfdmcecbh22ll7lYP3iuUdnfnhiPcSaDgH/8=
go4.org/intern v0.0.0-20230525184215-6c62f75575cb/go.mod h1:Ycrt6raEcnF5FTsLiLKkhBTO6DPX3RCUCUVnks3gFJU=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 h1:WJhcL4p+YeDxmZWg141nRm7XC8IDmhz7lk5GpadO1Sg=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/query/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.ZLabelsFromPromLabels(sample.Metric),
Labels: labelpb.PromLabelsToLabelpbLabels(sample.Metric),
Samples: floats,
Histograms: histograms,
}
Expand Down Expand Up @@ -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.ZLabelsFromPromLabels(series.Metric),
Labels: labelpb.PromLabelsToLabelpbLabels(series.Metric),
Samples: floats,
Histograms: histograms,
}
Expand All @@ -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.ZLabelsFromPromLabels(sample.Metric),
Labels: labelpb.PromLabelsToLabelpbLabels(sample.Metric),
Samples: floats,
Histograms: histograms,
}
Expand Down
40 changes: 20 additions & 20 deletions pkg/api/query/v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ func TestRulesHandler(t *testing.T) {
EvaluationDurationSeconds: 12,
Health: "x",
Query: "sum(up)",
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label"}}},
Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label"}}},
LastError: "err1",
}),
rulespb.NewRecordingRule(&rulespb.RecordingRule{
Expand All @@ -1799,7 +1799,7 @@ func TestRulesHandler(t *testing.T) {
EvaluationDurationSeconds: 12,
Health: "x",
Query: "sum(up1)",
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label2"}}},
Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label2"}}},
}),
rulespb.NewAlertingRule(&rulespb.Alert{
Name: "3",
Expand All @@ -1809,21 +1809,21 @@ func TestRulesHandler(t *testing.T) {
Query: "sum(up2) == 2",
DurationSeconds: 101,
KeepFiringForSeconds: 102,
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label3"}}},
Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "ann", Value: "a1"}}},
Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label3"}}},
Annotations: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "ann", Value: "a1"}}},
Alerts: []*rulespb.AlertInstance{
{
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "inside", Value: "1"}}},
Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "insideann", Value: "2"}}},
Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "inside", Value: "1"}}},
Annotations: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "insideann", Value: "2"}}},
State: rulespb.AlertState_FIRING,
ActiveAt: &twoHAgo,
Value: "1",
// This is unlikely if groups is warn, but test nevertheless.
PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT,
},
{
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "inside", Value: "3"}}},
Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "insideann", Value: "4"}}},
Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "inside", Value: "3"}}},
Annotations: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "insideann", Value: "4"}}},
State: rulespb.AlertState_PENDING,
ActiveAt: nil,
Value: "2",
Expand All @@ -1841,7 +1841,7 @@ func TestRulesHandler(t *testing.T) {
DurationSeconds: 102,
KeepFiringForSeconds: 103,
Query: "sum(up3) == 3",
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label4"}}},
Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label4"}}},
State: rulespb.AlertState_INACTIVE,
}),
rulespb.NewAlertingRule(&rulespb.Alert{
Expand All @@ -1852,7 +1852,7 @@ func TestRulesHandler(t *testing.T) {
DurationSeconds: 61,
KeepFiringForSeconds: 62,
Query: "sum(up4) == 4",
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label5"}}},
Labels: labelpb.LabelSet{Labels: []labelpb.Label{{Name: "some", Value: "label5"}}},
State: rulespb.AlertState_INACTIVE,
}),
}
Expand Down Expand Up @@ -1913,7 +1913,7 @@ func TestRulesHandler(t *testing.T) {
testpromcompatibility.RecordingRule{
Name: all[0].GetRecording().Name,
Query: all[0].GetRecording().Query,
Labels: labelpb.ZLabelsToPromLabels(all[0].GetRecording().Labels.Labels),
Labels: labelpb.LabelpbLabelsToPromLabels(all[0].GetRecording().Labels.Labels),
Health: rules.RuleHealth(all[0].GetRecording().Health),
LastError: all[0].GetRecording().LastError,
LastEvaluation: all[0].GetRecording().LastEvaluation,
Expand All @@ -1923,7 +1923,7 @@ func TestRulesHandler(t *testing.T) {
testpromcompatibility.RecordingRule{
Name: all[1].GetRecording().Name,
Query: all[1].GetRecording().Query,
Labels: labelpb.ZLabelsToPromLabels(all[1].GetRecording().Labels.Labels),
Labels: labelpb.LabelpbLabelsToPromLabels(all[1].GetRecording().Labels.Labels),
Health: rules.RuleHealth(all[1].GetRecording().Health),
LastError: all[1].GetRecording().LastError,
LastEvaluation: all[1].GetRecording().LastEvaluation,
Expand All @@ -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.ZLabelsToPromLabels(all[2].GetAlert().Labels.Labels),
Labels: labelpb.LabelpbLabelsToPromLabels(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.ZLabelsToPromLabels(all[2].GetAlert().Annotations.Labels),
Annotations: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Annotations.Labels),
Alerts: []*testpromcompatibility.Alert{
{
Labels: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[0].Labels.Labels),
Annotations: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[0].Annotations.Labels),
Labels: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Alerts[0].Labels.Labels),
Annotations: labelpb.LabelpbLabelsToPromLabels(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.ZLabelsToPromLabels(all[2].GetAlert().Alerts[1].Labels.Labels),
Annotations: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[1].Annotations.Labels),
Labels: labelpb.LabelpbLabelsToPromLabels(all[2].GetAlert().Alerts[1].Labels.Labels),
Annotations: labelpb.LabelpbLabelsToPromLabels(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,
Expand All @@ -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.ZLabelsToPromLabels(all[3].GetAlert().Labels.Labels),
Labels: labelpb.LabelpbLabelsToPromLabels(all[3].GetAlert().Labels.Labels),
Health: rules.RuleHealth(all[2].GetAlert().Health),
LastError: all[3].GetAlert().LastError,
LastEvaluation: all[3].GetAlert().LastEvaluation,
Expand All @@ -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.ZLabelsToPromLabels(all[4].GetAlert().Labels.Labels),
Labels: labelpb.LabelpbLabelsToPromLabels(all[4].GetAlert().Labels.Labels),
Health: rules.RuleHealth(all[2].GetAlert().Health),
LastError: all[4].GetAlert().LastError,
LastEvaluation: all[4].GetAlert().LastEvaluation,
Expand Down
6 changes: 3 additions & 3 deletions pkg/exemplars/exemplars.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func dedupExemplarsResponse(exemplarsData []*exemplarspb.ExemplarData, replicaLa
continue
}
e.SeriesLabels.Labels = removeReplicaLabels(e.SeriesLabels.Labels, replicaLabels)
h := labelpb.ZLabelsToPromLabels(e.SeriesLabels.Labels).Hash()
h := labelpb.LabelpbLabelsToPromLabels(e.SeriesLabels.Labels).Hash()
if ref, ok := hashToExemplar[h]; ok {
ref.Exemplars = append(ref.Exemplars, e.Exemplars...)
} else {
Expand Down Expand Up @@ -155,11 +155,11 @@ func dedupExemplars(exemplars []*exemplarspb.Exemplar) []*exemplarspb.Exemplar {
return exemplars[:i+1]
}

func removeReplicaLabels(labels []labelpb.ZLabel, replicaLabels map[string]struct{}) []labelpb.ZLabel {
func removeReplicaLabels(labels []labelpb.Label, replicaLabels map[string]struct{}) []labelpb.Label {
if len(replicaLabels) == 0 {
return labels
}
newLabels := make([]labelpb.ZLabel, 0, len(labels))
newLabels := make([]labelpb.Label, 0, len(labels))
for _, l := range labels {
if _, ok := replicaLabels[l.Name]; !ok {
newLabels = append(newLabels, l)
Expand Down
Loading

0 comments on commit e11fd06

Please sign in to comment.