Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: rm ZLabels #7675

Merged
merged 7 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bingo/minio.sum
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ 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=
Expand Down
2 changes: 1 addition & 1 deletion cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ func runQuery(

infoSrv := info.NewInfoServer(
component.Query.String(),
info.WithLabelSetFunc(func() []labelpb.ZLabelSet { return proxyStore.LabelSet() }),
info.WithLabelSetFunc(func() []labelpb.LabelSet { return proxyStore.LabelSet() }),
info.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) {
if httpProbe.IsReady() {
mint, maxt := proxyStore.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
3 changes: 2 additions & 1 deletion docs/components/receive.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 '999,1008p' pkg/receive/handler.go"
```go mdox-exec="sed -n '996,1006p' 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
Expand All @@ -322,6 +322,7 @@ 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.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ 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
)

Expand Down Expand Up @@ -264,6 +263,7 @@ 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.24.0 // indirect
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
Loading