Skip to content

Commit

Permalink
move one mimirpb custom type to separate package
Browse files Browse the repository at this point in the history
  • Loading branch information
francoposa committed Dec 29, 2024
1 parent f8e07d0 commit 823590d
Show file tree
Hide file tree
Showing 71 changed files with 1,990 additions and 1,810 deletions.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,19 @@ GENERATE_FILES ?= true

%.pb.go: %.proto
ifeq ($(GENERATE_FILES),true)
protoc -I $(GOPATH)/src:./vendor/github.com/gogo/protobuf:./vendor:./$(@D):./pkg/storegateway/storepb --gogoslick_out=plugins=grpc,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,:./$(@D) ./$(patsubst %.pb.go,%.proto,$@)
if case "$@" in *_custom_types.pb.go) false ;; *) true ;; esac; then \
protoc \
-I $(GOPATH)/src \
-I ./vendor/github.com/gogo/protobuf \
-I ./vendor \
-I ./$(@D) \
-I ./pkg/storegateway/storepb \
-I ./pkg/mimirpb \
--gogoslick_out=plugins=grpc,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,:./$(@D) \
./$(patsubst %.pb.go,%.proto,$@); \
else \
echo "Skipping $@"; \
fi
else
@echo "Warning: generating files has been disabled, but the following file needs to be regenerated: $@"
@echo "If this is unexpected, check if the last modified timestamps on $@ and $(patsubst %.pb.go,%.proto,$@) are correct."
Expand Down
11 changes: 6 additions & 5 deletions pkg/blockbuilder/tsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"golang.org/x/sync/errgroup"

"github.com/grafana/mimir/pkg/mimirpb"
"github.com/grafana/mimir/pkg/mimirpb_custom"
mimir_storage "github.com/grafana/mimir/pkg/storage"
mimir_tsdb "github.com/grafana/mimir/pkg/storage/tsdb"
util_log "github.com/grafana/mimir/pkg/util/log"
Expand All @@ -48,11 +49,11 @@ type TSDBBuilder struct {

// We use this only to identify the soft errors.
var softErrProcessor = mimir_storage.NewSoftAppendErrorProcessor(
func() {}, func(int64, []mimirpb.LabelAdapter) {}, func(int64, []mimirpb.LabelAdapter) {},
func(int64, []mimirpb.LabelAdapter) {}, func(int64, []mimirpb.LabelAdapter) {}, func(int64, []mimirpb.LabelAdapter) {},
func() {}, func([]mimirpb.LabelAdapter) {}, func(error, int64, []mimirpb.LabelAdapter) {},
func(error, int64, []mimirpb.LabelAdapter) {}, func(error, int64, []mimirpb.LabelAdapter) {}, func(error, int64, []mimirpb.LabelAdapter) {},
func(error, int64, []mimirpb.LabelAdapter) {}, func(error, int64, []mimirpb.LabelAdapter) {},
func() {}, func(int64, []mimirpb_custom.LabelAdapter) {}, func(int64, []mimirpb_custom.LabelAdapter) {},
func(int64, []mimirpb_custom.LabelAdapter) {}, func(int64, []mimirpb_custom.LabelAdapter) {}, func(int64, []mimirpb_custom.LabelAdapter) {},
func() {}, func([]mimirpb_custom.LabelAdapter) {}, func(error, int64, []mimirpb_custom.LabelAdapter) {},
func(error, int64, []mimirpb_custom.LabelAdapter) {}, func(error, int64, []mimirpb_custom.LabelAdapter) {}, func(error, int64, []mimirpb_custom.LabelAdapter) {},
func(error, int64, []mimirpb_custom.LabelAdapter) {}, func(error, int64, []mimirpb_custom.LabelAdapter) {},
)

type tsdbTenant struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/blockbuilder/tsdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/twmb/franz-go/pkg/kgo"

"github.com/grafana/mimir/pkg/mimirpb"
"github.com/grafana/mimir/pkg/mimirpb_custom"
mimir_tsdb "github.com/grafana/mimir/pkg/storage/tsdb"
"github.com/grafana/mimir/pkg/util/test"
"github.com/grafana/mimir/pkg/util/validation"
Expand All @@ -43,7 +44,7 @@ func createWriteRequest(t *testing.T, suffix string, samples []mimirpb.Sample, h
}
req.Timeseries = append(req.Timeseries, mimirpb.PreallocTimeseries{
TimeSeries: &mimirpb.TimeSeries{
Labels: []mimirpb.LabelAdapter{
Labels: []mimirpb_custom.LabelAdapter{
{Name: "foo", Value: fmt.Sprintf("%s%s", seriesValue, suffix)},
},
Samples: samples,
Expand Down Expand Up @@ -358,7 +359,7 @@ func TestProcessingEmptyRequest(t *testing.T) {
req := mimirpb.WriteRequest{}
req.Timeseries = append(req.Timeseries, mimirpb.PreallocTimeseries{
TimeSeries: &mimirpb.TimeSeries{
Labels: []mimirpb.LabelAdapter{{Name: "foo", Value: "bar"}},
Labels: []mimirpb_custom.LabelAdapter{{Name: "foo", Value: "bar"}},
Samples: []mimirpb.Sample{},
},
})
Expand Down
5 changes: 3 additions & 2 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
"github.com/grafana/mimir/pkg/cardinality"
ingester_client "github.com/grafana/mimir/pkg/ingester/client"
"github.com/grafana/mimir/pkg/mimirpb"
"github.com/grafana/mimir/pkg/mimirpb_custom"
"github.com/grafana/mimir/pkg/querier/stats"
"github.com/grafana/mimir/pkg/storage/ingest"
"github.com/grafana/mimir/pkg/util"
Expand Down Expand Up @@ -900,7 +901,7 @@ func (d *Distributor) validateSeries(nowt time.Time, ts *mimirpb.PreallocTimeser

return false, nil
}
func (d *Distributor) labelValuesWithNewlines(labels []mimirpb.LabelAdapter) int {
func (d *Distributor) labelValuesWithNewlines(labels []mimirpb_custom.LabelAdapter) int {
count := 0
for _, l := range labels {
if strings.IndexByte(l.Value, '\n') >= 0 {
Expand Down Expand Up @@ -1807,7 +1808,7 @@ func getTokensForMetadata(userID string, metadata []*mimirpb.MetricMetadata) []u
return metadataKeys
}

func tokenForLabels(userID string, labels []mimirpb.LabelAdapter) uint32 {
func tokenForLabels(userID string, labels []mimirpb_custom.LabelAdapter) uint32 {
return mimirpb.ShardByAllLabelAdapters(userID, labels)
}

Expand Down
Loading

0 comments on commit 823590d

Please sign in to comment.