From 865cbadeb3fcd7162768763e98001b61fe62c6fc Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Mon, 10 Mar 2025 11:02:12 +0900 Subject: [PATCH 01/11] Support remote write v2 by converting request Signed-off-by: SungJin1212 --- docs/configuration/config-file-reference.md | 5 ++ integration/remote_write_v2_test.go | 4 +- pkg/cortexpb/cortex.proto | 8 ++ pkg/distributor/write_stats.go | 62 ++++++++++++++ pkg/distributor/write_stats_test.go | 41 ++++++++++ pkg/ingester/ingester.go | 8 +- pkg/util/push/push.go | 2 + pkg/util/push/push_test.go | 90 ++++++++++++--------- 8 files changed, 178 insertions(+), 42 deletions(-) create mode 100644 pkg/distributor/write_stats.go create mode 100644 pkg/distributor/write_stats_test.go diff --git a/docs/configuration/config-file-reference.md b/docs/configuration/config-file-reference.md index c4ef8305ed6..7e1e3b512d6 100644 --- a/docs/configuration/config-file-reference.md +++ b/docs/configuration/config-file-reference.md @@ -3135,6 +3135,11 @@ ha_tracker: # CLI flag: -distributor.sign-write-requests [sign_write_requests: | default = false] +# EXPERIMENTAL: If true, accept prometheus remote write v2 protocol push +# request. +# CLI flag: -distributor.remote-write2-enabled +[remote_write2_enabled: | default = false] + # EXPERIMENTAL: If enabled, distributor would use stream connection to send # requests to ingesters. # CLI flag: -distributor.use-stream-push diff --git a/integration/remote_write_v2_test.go b/integration/remote_write_v2_test.go index 8ba26447f68..e189e1df0ff 100644 --- a/integration/remote_write_v2_test.go +++ b/integration/remote_write_v2_test.go @@ -25,8 +25,8 @@ import ( ) func TestIngesterRollingUpdate(t *testing.T) { - // Test ingester rolling update situation: when -distributor.remote-writev2-enabled is true, and ingester uses the v1.19.0 image. - // Expected: remote write 2.0 push success + // Test ingester rolling update situation: when -distributor.remote-write2-enabled is true, and ingester uses the v1.19.0 image. + // Expected: remote write 2.0 push success, but response header values are set to "0". const blockRangePeriod = 5 * time.Second ingesterImage := "quay.io/cortexproject/cortex:v1.19.0" diff --git a/pkg/cortexpb/cortex.proto b/pkg/cortexpb/cortex.proto index fa2caf287c2..e6fbbf51bf9 100644 --- a/pkg/cortexpb/cortex.proto +++ b/pkg/cortexpb/cortex.proto @@ -43,6 +43,14 @@ message WriteResponse { // Exemplars represents X-Prometheus-Remote-Write-Written-Exemplars int64 Exemplars = 5; } +message WriteResponse { + // Samples represents X-Prometheus-Remote-Write-Written-Samples + int64 Samples = 1; + // Histograms represents X-Prometheus-Remote-Write-Written-Histograms + int64 Histograms = 2; + // Exemplars represents X-Prometheus-Remote-Write-Written-Exemplars + int64 Exemplars = 3; +} message TimeSeries { repeated LabelPair labels = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "LabelAdapter"]; diff --git a/pkg/distributor/write_stats.go b/pkg/distributor/write_stats.go new file mode 100644 index 00000000000..0f7fbc332d0 --- /dev/null +++ b/pkg/distributor/write_stats.go @@ -0,0 +1,62 @@ +package distributor + +import ( + "go.uber.org/atomic" +) + +type WriteStats struct { + // Samples represents X-Prometheus-Remote-Write-Written-Samples + Samples atomic.Int64 + // Histograms represents X-Prometheus-Remote-Write-Written-Histograms + Histograms atomic.Int64 + // Exemplars represents X-Prometheus-Remote-Write-Written-Exemplars + Exemplars atomic.Int64 +} + +func (w *WriteStats) SetSamples(samples int64) { + if w == nil { + return + } + + w.Samples.Store(samples) +} + +func (w *WriteStats) SetHistograms(histograms int64) { + if w == nil { + return + } + + w.Histograms.Store(histograms) +} + +func (w *WriteStats) SetExemplars(exemplars int64) { + if w == nil { + return + } + + w.Exemplars.Store(exemplars) +} + +func (w *WriteStats) LoadSamples() int64 { + if w == nil { + return 0 + } + + return w.Samples.Load() +} + +func (w *WriteStats) LoadHistogram() int64 { + if w == nil { + return 0 + } + + return w.Histograms.Load() +} + +func (w *WriteStats) LoadExemplars() int64 { + if w == nil { + return 0 + } + + return w.Exemplars.Load() +} diff --git a/pkg/distributor/write_stats_test.go b/pkg/distributor/write_stats_test.go new file mode 100644 index 00000000000..523f16788fe --- /dev/null +++ b/pkg/distributor/write_stats_test.go @@ -0,0 +1,41 @@ +package distributor + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_SetAndLoad(t *testing.T) { + ws := &WriteStats{} + + t.Run("Samples", func(t *testing.T) { + ws.SetSamples(3) + assert.Equal(t, int64(3), ws.LoadSamples()) + }) + t.Run("Histograms", func(t *testing.T) { + ws.SetHistograms(10) + assert.Equal(t, int64(10), ws.LoadHistogram()) + }) + t.Run("Exemplars", func(t *testing.T) { + ws.SetExemplars(2) + assert.Equal(t, int64(2), ws.LoadExemplars()) + }) +} + +func Test_NilReceiver(t *testing.T) { + var ws *WriteStats + + t.Run("Samples", func(t *testing.T) { + ws.SetSamples(3) + assert.Equal(t, int64(0), ws.LoadSamples()) + }) + t.Run("Histograms", func(t *testing.T) { + ws.SetHistograms(10) + assert.Equal(t, int64(0), ws.LoadHistogram()) + }) + t.Run("Exemplars", func(t *testing.T) { + ws.SetExemplars(2) + assert.Equal(t, int64(0), ws.LoadExemplars()) + }) +} diff --git a/pkg/ingester/ingester.go b/pkg/ingester/ingester.go index c2dab4a54ec..2ca25e9b6d3 100644 --- a/pkg/ingester/ingester.go +++ b/pkg/ingester/ingester.go @@ -1569,7 +1569,13 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte return &cortexpb.WriteResponse{}, httpgrpc.Errorf(code, "%s", wrapWithUser(firstPartialErr, userID).Error()) } - return &cortexpb.WriteResponse{}, nil + writeResponse := &cortexpb.WriteResponse{ + Samples: int64(succeededSamplesCount), + Histograms: int64(succeededHistogramsCount), + Exemplars: int64(succeededExemplarsCount), + } + + return writeResponse, nil } func (i *Ingester) PushStream(srv client.Ingester_PushStreamServer) error { diff --git a/pkg/util/push/push.go b/pkg/util/push/push.go index 17413f0e4dd..2f14c44f0af 100644 --- a/pkg/util/push/push.go +++ b/pkg/util/push/push.go @@ -32,6 +32,8 @@ const ( rw20WrittenSamplesHeader = "X-Prometheus-Remote-Write-Samples-Written" rw20WrittenHistogramsHeader = "X-Prometheus-Remote-Write-Histograms-Written" rw20WrittenExemplarsHeader = "X-Prometheus-Remote-Write-Exemplars-Written" + + errMsgNotEnabledPRW2 = "Not enabled prometheus remote write v2 push request" ) // Func defines the type of the push. It is similar to http.HandlerFunc. diff --git a/pkg/util/push/push_test.go b/pkg/util/push/push_test.go index 46cb0770f75..e61952bbb1a 100644 --- a/pkg/util/push/push_test.go +++ b/pkg/util/push/push_test.go @@ -35,30 +35,34 @@ var ( } ) -func makeV2ReqWithSeries(num int) *writev2.Request { - ts := make([]writev2.TimeSeries, 0, num) +func makeV2ReqWithSeries(num int) *cortexpb.PreallocWriteRequestV2 { + ts := make([]cortexpb.PreallocTimeseriesV2, 0, num) symbols := []string{"", "__name__", "test_metric1", "b", "c", "baz", "qux", "d", "e", "foo", "bar", "f", "g", "h", "i", "Test gauge for test purposes", "Maybe op/sec who knows (:", "Test counter for test purposes"} for i := 0; i < num; i++ { - ts = append(ts, writev2.TimeSeries{ - LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, - Metadata: writev2.Metadata{ - Type: writev2.Metadata_METRIC_TYPE_GAUGE, - - HelpRef: 15, - UnitRef: 16, - }, - Samples: []writev2.Sample{{Value: 1, Timestamp: 10}}, - Exemplars: []writev2.Exemplar{{LabelsRefs: []uint32{11, 12}, Value: 1, Timestamp: 10}}, - Histograms: []writev2.Histogram{ - writev2.FromIntHistogram(10, &testHistogram), - writev2.FromFloatHistogram(20, testHistogram.ToFloat(nil)), + ts = append(ts, cortexpb.PreallocTimeseriesV2{ + TimeSeriesV2: &cortexpb.TimeSeriesV2{ + LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + Metadata: cortexpb.MetadataV2{ + Type: cortexpb.METRIC_TYPE_GAUGE, + + HelpRef: 15, + UnitRef: 16, + }, + Samples: []cortexpb.Sample{{Value: 1, TimestampMs: 10}}, + Exemplars: []cortexpb.ExemplarV2{{LabelsRefs: []uint32{11, 12}, Value: 1, Timestamp: 10}}, + Histograms: []cortexpb.Histogram{ + cortexpb.HistogramToHistogramProto(10, &testHistogram), + cortexpb.FloatHistogramToHistogramProto(20, testHistogram.ToFloat(nil)), + }, }, }) } - return &writev2.Request{ - Symbols: symbols, - Timeseries: ts, + return &cortexpb.PreallocWriteRequestV2{ + WriteRequestV2: cortexpb.WriteRequestV2{ + Symbols: symbols, + Timeseries: ts, + }, } } @@ -164,36 +168,44 @@ func Benchmark_convertV2RequestToV1(b *testing.B) { } func Test_convertV2RequestToV1(t *testing.T) { - var v2Req writev2.Request + var v2Req cortexpb.PreallocWriteRequestV2 fh := tsdbutil.GenerateTestFloatHistogram(1) - ph := writev2.FromFloatHistogram(4, fh) + ph := cortexpb.FloatHistogramToHistogramProto(4, fh) symbols := []string{"", "__name__", "test_metric", "b", "c", "baz", "qux", "d", "e", "foo", "bar", "f", "g", "h", "i", "Test gauge for test purposes", "Maybe op/sec who knows (:", "Test counter for test purposes"} - timeseries := []writev2.TimeSeries{ + timeseries := []cortexpb.PreallocTimeseriesV2{ { - LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, - Metadata: writev2.Metadata{ - Type: writev2.Metadata_METRIC_TYPE_COUNTER, + TimeSeriesV2: &cortexpb.TimeSeriesV2{ + LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + Metadata: cortexpb.MetadataV2{ + Type: cortexpb.METRIC_TYPE_COUNTER, - HelpRef: 15, - UnitRef: 16, + HelpRef: 15, + UnitRef: 16, + }, + Samples: []cortexpb.Sample{{Value: 1, TimestampMs: 1}}, + Exemplars: []cortexpb.ExemplarV2{{LabelsRefs: []uint32{11, 12}, Value: 1, Timestamp: 1}}, }, - Samples: []writev2.Sample{{Value: 1, Timestamp: 1}}, - Exemplars: []writev2.Exemplar{{LabelsRefs: []uint32{11, 12}, Value: 1, Timestamp: 1}}, }, { - LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, - Samples: []writev2.Sample{{Value: 2, Timestamp: 2}}, + TimeSeriesV2: &cortexpb.TimeSeriesV2{ + LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + Samples: []cortexpb.Sample{{Value: 2, TimestampMs: 2}}, + }, }, { - LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, - Samples: []writev2.Sample{{Value: 3, Timestamp: 3}}, + TimeSeriesV2: &cortexpb.TimeSeriesV2{ + LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + Samples: []cortexpb.Sample{{Value: 3, TimestampMs: 3}}, + }, }, { - LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, - Histograms: []writev2.Histogram{ph, ph}, - Exemplars: []writev2.Exemplar{{LabelsRefs: []uint32{11, 12}, Value: 1, Timestamp: 1}}, + TimeSeriesV2: &cortexpb.TimeSeriesV2{ + LabelsRefs: []uint32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + Histograms: []cortexpb.Histogram{ph, ph}, + Exemplars: []cortexpb.ExemplarV2{{LabelsRefs: []uint32{11, 12}, Value: 1, Timestamp: 1}}, + }, }, } @@ -394,7 +406,7 @@ func TestHandler_ignoresSkipLabelNameValidationIfSet(t *testing.T) { } } -func verifyWriteRequestHandler(t *testing.T, expectSource cortexpb.WriteRequest_SourceEnum) func(ctx context.Context, request *cortexpb.WriteRequest) (response *cortexpb.WriteResponse, err error) { +func verifyWriteRequestHandler(t *testing.T, expectSource cortexpb.SourceEnum) func(ctx context.Context, request *cortexpb.WriteRequest) (response *cortexpb.WriteResponse, err error) { t.Helper() return func(ctx context.Context, request *cortexpb.WriteRequest) (response *cortexpb.WriteResponse, err error) { assert.Len(t, request.Timeseries, 1) @@ -444,7 +456,7 @@ func createRequest(t *testing.T, protobuf []byte, isV2 bool) *http.Request { return req } -func createCortexRemoteWriteV2Protobuf(t *testing.T, skipLabelNameValidation bool, source cortexpb.WriteRequest_SourceEnum) []byte { +func createCortexRemoteWriteV2Protobuf(t *testing.T, skipLabelNameValidation bool, source cortexpb.SourceEnum) []byte { t.Helper() input := writev2.Request{ Symbols: []string{"", "__name__", "foo"}, @@ -500,7 +512,7 @@ func createPrometheusRemoteWriteProtobuf(t *testing.T) []byte { require.NoError(t, err) return inoutBytes } -func createCortexWriteRequestProtobuf(t *testing.T, skipLabelNameValidation bool, source cortexpb.WriteRequest_SourceEnum) []byte { +func createCortexWriteRequestProtobuf(t *testing.T, skipLabelNameValidation bool, source cortexpb.SourceEnum) []byte { t.Helper() ts := cortexpb.PreallocTimeseries{ TimeSeries: &cortexpb.TimeSeries{ @@ -520,4 +532,4 @@ func createCortexWriteRequestProtobuf(t *testing.T, skipLabelNameValidation bool inoutBytes, err := input.Marshal() require.NoError(t, err) return inoutBytes -} +} \ No newline at end of file From 09198025da255f9fafc1806c92969eebd6fe77f5 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Mon, 14 Apr 2025 10:53:24 +0900 Subject: [PATCH 02/11] Change to not break exist behavior Signed-off-by: SungJin1212 --- pkg/util/push/push.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/util/push/push.go b/pkg/util/push/push.go index 2f14c44f0af..17413f0e4dd 100644 --- a/pkg/util/push/push.go +++ b/pkg/util/push/push.go @@ -32,8 +32,6 @@ const ( rw20WrittenSamplesHeader = "X-Prometheus-Remote-Write-Samples-Written" rw20WrittenHistogramsHeader = "X-Prometheus-Remote-Write-Histograms-Written" rw20WrittenExemplarsHeader = "X-Prometheus-Remote-Write-Exemplars-Written" - - errMsgNotEnabledPRW2 = "Not enabled prometheus remote write v2 push request" ) // Func defines the type of the push. It is similar to http.HandlerFunc. From 9ce52d22472128aa63de2be4e464711623e6a1e9 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Tue, 15 Apr 2025 13:36:07 +0900 Subject: [PATCH 03/11] Add benchmarks Signed-off-by: SungJin1212 --- pkg/util/push/push_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/util/push/push_test.go b/pkg/util/push/push_test.go index e61952bbb1a..a1a7f0c9562 100644 --- a/pkg/util/push/push_test.go +++ b/pkg/util/push/push_test.go @@ -532,4 +532,4 @@ func createCortexWriteRequestProtobuf(t *testing.T, skipLabelNameValidation bool inoutBytes, err := input.Marshal() require.NoError(t, err) return inoutBytes -} \ No newline at end of file +} From 59cee4b1dac7af6dfbb1efe3db50ec290977dc35 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Mon, 14 Jul 2025 21:46:06 +0900 Subject: [PATCH 04/11] rebase from stream connection Signed-off-by: SungJin1212 --- pkg/cortexpb/cortex.proto | 8 -------- pkg/distributor/distributor.go | 3 ++- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pkg/cortexpb/cortex.proto b/pkg/cortexpb/cortex.proto index e6fbbf51bf9..fa2caf287c2 100644 --- a/pkg/cortexpb/cortex.proto +++ b/pkg/cortexpb/cortex.proto @@ -43,14 +43,6 @@ message WriteResponse { // Exemplars represents X-Prometheus-Remote-Write-Written-Exemplars int64 Exemplars = 5; } -message WriteResponse { - // Samples represents X-Prometheus-Remote-Write-Written-Samples - int64 Samples = 1; - // Histograms represents X-Prometheus-Remote-Write-Written-Histograms - int64 Histograms = 2; - // Exemplars represents X-Prometheus-Remote-Write-Written-Exemplars - int64 Exemplars = 3; -} message TimeSeries { repeated LabelPair labels = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "LabelAdapter"]; diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index beaa738e751..17250f6ccc1 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -1182,13 +1182,14 @@ func (d *Distributor) send(ctx context.Context, ingester ring.InstanceDesc, time d.inflightClientRequests.Inc() defer d.inflightClientRequests.Dec() + var resp *cortexpb.WriteResponse if d.cfg.UseStreamPush { req := &cortexpb.WriteRequest{ Timeseries: timeseries, Metadata: metadata, Source: source, } - _, err = c.PushStreamConnection(ctx, req) + resp, err = c.PushStreamConnection(ctx, req) } else { req := cortexpb.PreallocWriteRequestFromPool() req.Timeseries = timeseries From 4eca425146210d31a98b746312958b62b3d41701 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Wed, 23 Jul 2025 14:00:30 +0900 Subject: [PATCH 05/11] Change to expose header at Distributor side Signed-off-by: SungJin1212 --- integration/remote_write_v2_test.go | 2 +- pkg/distributor/distributor.go | 3 +- pkg/distributor/write_stats.go | 62 ----------------------------- pkg/distributor/write_stats_test.go | 41 ------------------- pkg/ingester/ingester.go | 8 +--- 5 files changed, 3 insertions(+), 113 deletions(-) delete mode 100644 pkg/distributor/write_stats.go delete mode 100644 pkg/distributor/write_stats_test.go diff --git a/integration/remote_write_v2_test.go b/integration/remote_write_v2_test.go index e189e1df0ff..67593df424a 100644 --- a/integration/remote_write_v2_test.go +++ b/integration/remote_write_v2_test.go @@ -26,7 +26,7 @@ import ( func TestIngesterRollingUpdate(t *testing.T) { // Test ingester rolling update situation: when -distributor.remote-write2-enabled is true, and ingester uses the v1.19.0 image. - // Expected: remote write 2.0 push success, but response header values are set to "0". + // Expected: remote write 2.0 push success const blockRangePeriod = 5 * time.Second ingesterImage := "quay.io/cortexproject/cortex:v1.19.0" diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index 17250f6ccc1..beaa738e751 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -1182,14 +1182,13 @@ func (d *Distributor) send(ctx context.Context, ingester ring.InstanceDesc, time d.inflightClientRequests.Inc() defer d.inflightClientRequests.Dec() - var resp *cortexpb.WriteResponse if d.cfg.UseStreamPush { req := &cortexpb.WriteRequest{ Timeseries: timeseries, Metadata: metadata, Source: source, } - resp, err = c.PushStreamConnection(ctx, req) + _, err = c.PushStreamConnection(ctx, req) } else { req := cortexpb.PreallocWriteRequestFromPool() req.Timeseries = timeseries diff --git a/pkg/distributor/write_stats.go b/pkg/distributor/write_stats.go deleted file mode 100644 index 0f7fbc332d0..00000000000 --- a/pkg/distributor/write_stats.go +++ /dev/null @@ -1,62 +0,0 @@ -package distributor - -import ( - "go.uber.org/atomic" -) - -type WriteStats struct { - // Samples represents X-Prometheus-Remote-Write-Written-Samples - Samples atomic.Int64 - // Histograms represents X-Prometheus-Remote-Write-Written-Histograms - Histograms atomic.Int64 - // Exemplars represents X-Prometheus-Remote-Write-Written-Exemplars - Exemplars atomic.Int64 -} - -func (w *WriteStats) SetSamples(samples int64) { - if w == nil { - return - } - - w.Samples.Store(samples) -} - -func (w *WriteStats) SetHistograms(histograms int64) { - if w == nil { - return - } - - w.Histograms.Store(histograms) -} - -func (w *WriteStats) SetExemplars(exemplars int64) { - if w == nil { - return - } - - w.Exemplars.Store(exemplars) -} - -func (w *WriteStats) LoadSamples() int64 { - if w == nil { - return 0 - } - - return w.Samples.Load() -} - -func (w *WriteStats) LoadHistogram() int64 { - if w == nil { - return 0 - } - - return w.Histograms.Load() -} - -func (w *WriteStats) LoadExemplars() int64 { - if w == nil { - return 0 - } - - return w.Exemplars.Load() -} diff --git a/pkg/distributor/write_stats_test.go b/pkg/distributor/write_stats_test.go deleted file mode 100644 index 523f16788fe..00000000000 --- a/pkg/distributor/write_stats_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package distributor - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func Test_SetAndLoad(t *testing.T) { - ws := &WriteStats{} - - t.Run("Samples", func(t *testing.T) { - ws.SetSamples(3) - assert.Equal(t, int64(3), ws.LoadSamples()) - }) - t.Run("Histograms", func(t *testing.T) { - ws.SetHistograms(10) - assert.Equal(t, int64(10), ws.LoadHistogram()) - }) - t.Run("Exemplars", func(t *testing.T) { - ws.SetExemplars(2) - assert.Equal(t, int64(2), ws.LoadExemplars()) - }) -} - -func Test_NilReceiver(t *testing.T) { - var ws *WriteStats - - t.Run("Samples", func(t *testing.T) { - ws.SetSamples(3) - assert.Equal(t, int64(0), ws.LoadSamples()) - }) - t.Run("Histograms", func(t *testing.T) { - ws.SetHistograms(10) - assert.Equal(t, int64(0), ws.LoadHistogram()) - }) - t.Run("Exemplars", func(t *testing.T) { - ws.SetExemplars(2) - assert.Equal(t, int64(0), ws.LoadExemplars()) - }) -} diff --git a/pkg/ingester/ingester.go b/pkg/ingester/ingester.go index 2ca25e9b6d3..c2dab4a54ec 100644 --- a/pkg/ingester/ingester.go +++ b/pkg/ingester/ingester.go @@ -1569,13 +1569,7 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte return &cortexpb.WriteResponse{}, httpgrpc.Errorf(code, "%s", wrapWithUser(firstPartialErr, userID).Error()) } - writeResponse := &cortexpb.WriteResponse{ - Samples: int64(succeededSamplesCount), - Histograms: int64(succeededHistogramsCount), - Exemplars: int64(succeededExemplarsCount), - } - - return writeResponse, nil + return &cortexpb.WriteResponse{}, nil } func (i *Ingester) PushStream(srv client.Ingester_PushStreamServer) error { From 5bb3531d9eef1841546b8bc47bf5a26c30f36960 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Mon, 28 Jul 2025 13:57:17 +0900 Subject: [PATCH 06/11] Add prw2 pool Signed-off-by: SungJin1212 --- pkg/cortexpb/compat.go | 2 +- pkg/cortexpb/compatv2.go | 22 + pkg/cortexpb/cortex.pb.go | 2229 ++++++++++++++++++++++++++--- pkg/cortexpb/cortex.proto | 97 +- pkg/cortexpb/histograms.go | 34 - pkg/cortexpb/timeseriesv2.go | 131 ++ pkg/cortexpb/timeseriesv2_test.go | 118 ++ pkg/distributor/distributor.go | 2 +- pkg/util/push/otlp_test.go | 2 +- pkg/util/push/push.go | 64 +- 10 files changed, 2403 insertions(+), 298 deletions(-) create mode 100644 pkg/cortexpb/compatv2.go create mode 100644 pkg/cortexpb/timeseriesv2.go create mode 100644 pkg/cortexpb/timeseriesv2_test.go diff --git a/pkg/cortexpb/compat.go b/pkg/cortexpb/compat.go index 83bdbff33d1..f67204cf7c8 100644 --- a/pkg/cortexpb/compat.go +++ b/pkg/cortexpb/compat.go @@ -20,7 +20,7 @@ import ( // ToWriteRequest converts matched slices of Labels, Samples, Metadata and Histograms into a WriteRequest proto. // It gets timeseries from the pool, so ReuseSlice() should be called when done. -func ToWriteRequest(lbls []labels.Labels, samples []Sample, metadata []*MetricMetadata, histograms []Histogram, source WriteRequest_SourceEnum) *WriteRequest { +func ToWriteRequest(lbls []labels.Labels, samples []Sample, metadata []*MetricMetadata, histograms []Histogram, source SourceEnum) *WriteRequest { req := &WriteRequest{ Timeseries: PreallocTimeseriesSliceFromPool(), Metadata: metadata, diff --git a/pkg/cortexpb/compatv2.go b/pkg/cortexpb/compatv2.go new file mode 100644 index 00000000000..c1cbda9009c --- /dev/null +++ b/pkg/cortexpb/compatv2.go @@ -0,0 +1,22 @@ +package cortexpb + +import "github.com/prometheus/prometheus/model/labels" + +func (e *ExemplarV2) ToLabels(b *labels.ScratchBuilder, symbols []string) labels.Labels { + return desymbolizeLabels(b, e.GetLabelsRefs(), symbols) +} + +func (t *TimeSeriesV2) ToLabels(b *labels.ScratchBuilder, symbols []string) labels.Labels { + return desymbolizeLabels(b, t.GetLabelsRefs(), symbols) +} + +// desymbolizeLabels decodes label references, with given symbols to labels. +// Copied from the Prometheus: https://github.com/prometheus/prometheus/blob/v3.5.0/prompb/io/prometheus/write/v2/symbols.go#L76 +func desymbolizeLabels(b *labels.ScratchBuilder, labelRefs []uint32, symbols []string) labels.Labels { + b.Reset() + for i := 0; i < len(labelRefs); i += 2 { + b.Add(symbols[labelRefs[i]], symbols[labelRefs[i+1]]) + } + b.Sort() + return b.Labels() +} diff --git a/pkg/cortexpb/cortex.pb.go b/pkg/cortexpb/cortex.pb.go index e0dac736baf..03028c30981 100644 --- a/pkg/cortexpb/cortex.pb.go +++ b/pkg/cortexpb/cortex.pb.go @@ -28,25 +28,64 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type WriteRequest_SourceEnum int32 +type SourceEnum int32 const ( - API WriteRequest_SourceEnum = 0 - RULE WriteRequest_SourceEnum = 1 + API SourceEnum = 0 + RULE SourceEnum = 1 ) -var WriteRequest_SourceEnum_name = map[int32]string{ +var SourceEnum_name = map[int32]string{ 0: "API", 1: "RULE", } -var WriteRequest_SourceEnum_value = map[string]int32{ +var SourceEnum_value = map[string]int32{ "API": 0, "RULE": 1, } -func (WriteRequest_SourceEnum) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{1, 0} +func (SourceEnum) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_893a47d0a749d749, []int{0} +} + +type MetadataV2_MetricType int32 + +const ( + METRIC_TYPE_UNSPECIFIED MetadataV2_MetricType = 0 + METRIC_TYPE_COUNTER MetadataV2_MetricType = 1 + METRIC_TYPE_GAUGE MetadataV2_MetricType = 2 + METRIC_TYPE_HISTOGRAM MetadataV2_MetricType = 3 + METRIC_TYPE_GAUGEHISTOGRAM MetadataV2_MetricType = 4 + METRIC_TYPE_SUMMARY MetadataV2_MetricType = 5 + METRIC_TYPE_INFO MetadataV2_MetricType = 6 + METRIC_TYPE_STATESET MetadataV2_MetricType = 7 +) + +var MetadataV2_MetricType_name = map[int32]string{ + 0: "METRIC_TYPE_UNSPECIFIED", + 1: "METRIC_TYPE_COUNTER", + 2: "METRIC_TYPE_GAUGE", + 3: "METRIC_TYPE_HISTOGRAM", + 4: "METRIC_TYPE_GAUGEHISTOGRAM", + 5: "METRIC_TYPE_SUMMARY", + 6: "METRIC_TYPE_INFO", + 7: "METRIC_TYPE_STATESET", +} + +var MetadataV2_MetricType_value = map[string]int32{ + "METRIC_TYPE_UNSPECIFIED": 0, + "METRIC_TYPE_COUNTER": 1, + "METRIC_TYPE_GAUGE": 2, + "METRIC_TYPE_HISTOGRAM": 3, + "METRIC_TYPE_GAUGEHISTOGRAM": 4, + "METRIC_TYPE_SUMMARY": 5, + "METRIC_TYPE_INFO": 6, + "METRIC_TYPE_STATESET": 7, +} + +func (MetadataV2_MetricType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_893a47d0a749d749, []int{5, 0} } type MetricMetadata_MetricType int32 @@ -85,7 +124,7 @@ var MetricMetadata_MetricType_value = map[string]int32{ } func (MetricMetadata_MetricType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{7, 0} + return fileDescriptor_893a47d0a749d749, []int{11, 0} } type Histogram_ResetHint int32 @@ -112,7 +151,7 @@ var Histogram_ResetHint_value = map[string]int32{ } func (Histogram_ResetHint) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{10, 0} + return fileDescriptor_893a47d0a749d749, []int{14, 0} } func (m *MessageWithBufRef) Reset() { *m = MessageWithBufRef{} } @@ -148,10 +187,10 @@ func (m *MessageWithBufRef) XXX_DiscardUnknown() { var xxx_messageInfo_MessageWithBufRef proto.InternalMessageInfo type WriteRequest struct { - Timeseries []PreallocTimeseries `protobuf:"bytes,1,rep,name=timeseries,proto3,customtype=PreallocTimeseries" json:"timeseries"` - Source WriteRequest_SourceEnum `protobuf:"varint,2,opt,name=Source,proto3,enum=cortexpb.WriteRequest_SourceEnum" json:"Source,omitempty"` - Metadata []*MetricMetadata `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty"` - SkipLabelNameValidation bool `protobuf:"varint,1000,opt,name=skip_label_name_validation,json=skipLabelNameValidation,proto3" json:"skip_label_name_validation,omitempty"` + Timeseries []PreallocTimeseries `protobuf:"bytes,1,rep,name=timeseries,proto3,customtype=PreallocTimeseries" json:"timeseries"` + Source SourceEnum `protobuf:"varint,2,opt,name=Source,proto3,enum=cortexpb.SourceEnum" json:"Source,omitempty"` + Metadata []*MetricMetadata `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty"` + SkipLabelNameValidation bool `protobuf:"varint,1000,opt,name=skip_label_name_validation,json=skipLabelNameValidation,proto3" json:"skip_label_name_validation,omitempty"` MessageWithBufRef `protobuf:"bytes,1001,opt,name=Ref,proto3,embedded=Ref,customtype=MessageWithBufRef" json:"Ref"` } @@ -187,7 +226,7 @@ func (m *WriteRequest) XXX_DiscardUnknown() { var xxx_messageInfo_WriteRequest proto.InternalMessageInfo -func (m *WriteRequest) GetSource() WriteRequest_SourceEnum { +func (m *WriteRequest) GetSource() SourceEnum { if m != nil { return m.Source } @@ -208,6 +247,313 @@ func (m *WriteRequest) GetSkipLabelNameValidation() bool { return false } +// refer to https://github.com/prometheus/prometheus/blob/v3.5.0/prompb/io/prometheus/write/v2/types.proto +// The histogram and Sample are shared with PRW1. +type WriteRequestV2 struct { + Symbols []string `protobuf:"bytes,4,rep,name=symbols,proto3" json:"symbols,omitempty"` + Timeseries []PreallocTimeseriesV2 `protobuf:"bytes,5,rep,name=timeseries,proto3,customtype=PreallocTimeseriesV2" json:"timeseries"` + Source SourceEnum `protobuf:"varint,6,opt,name=Source,proto3,enum=cortexpb.SourceEnum" json:"Source,omitempty"` + SkipLabelNameValidation bool `protobuf:"varint,1000,opt,name=skip_label_name_validation,json=skipLabelNameValidation,proto3" json:"skip_label_name_validation,omitempty"` + MessageWithBufRef `protobuf:"bytes,1001,opt,name=Ref,proto3,embedded=Ref,customtype=MessageWithBufRef" json:"Ref"` +} + +func (m *WriteRequestV2) Reset() { *m = WriteRequestV2{} } +func (*WriteRequestV2) ProtoMessage() {} +func (*WriteRequestV2) Descriptor() ([]byte, []int) { + return fileDescriptor_893a47d0a749d749, []int{2} +} +func (m *WriteRequestV2) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WriteRequestV2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WriteRequestV2.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 *WriteRequestV2) XXX_Merge(src proto.Message) { + xxx_messageInfo_WriteRequestV2.Merge(m, src) +} +func (m *WriteRequestV2) XXX_Size() int { + return m.Size() +} +func (m *WriteRequestV2) XXX_DiscardUnknown() { + xxx_messageInfo_WriteRequestV2.DiscardUnknown(m) +} + +var xxx_messageInfo_WriteRequestV2 proto.InternalMessageInfo + +func (m *WriteRequestV2) GetSymbols() []string { + if m != nil { + return m.Symbols + } + return nil +} + +func (m *WriteRequestV2) GetSource() SourceEnum { + if m != nil { + return m.Source + } + return API +} + +func (m *WriteRequestV2) GetSkipLabelNameValidation() bool { + if m != nil { + return m.SkipLabelNameValidation + } + return false +} + +type TimeSeriesV2 struct { + LabelsRefs []uint32 `protobuf:"varint,1,rep,packed,name=labels_refs,json=labelsRefs,proto3" json:"labels_refs,omitempty"` + // Timeseries messages can either specify samples or (native) histogram samples + // (histogram field), but not both. For a typical sender (real-time metric + // streaming), in healthy cases, there will be only one sample or histogram. + // + // Samples and histograms are sorted by timestamp (older first). + Samples []Sample `protobuf:"bytes,2,rep,name=samples,proto3" json:"samples"` + Histograms []Histogram `protobuf:"bytes,3,rep,name=histograms,proto3" json:"histograms"` + // exemplars represents an optional set of exemplars attached to this series' samples. + Exemplars []ExemplarV2 `protobuf:"bytes,4,rep,name=exemplars,proto3" json:"exemplars"` + // metadata represents the metadata associated with the given series' samples. + Metadata MetadataV2 `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata"` + // created_timestamp represents an optional created timestamp associated with + // this series' samples in ms format, typically for counter or histogram type + // metrics. Created timestamp represents the time when the counter started + // counting (sometimes referred to as start timestamp), which can increase + // the accuracy of query results. + // + // Note that some receivers might require this and in return fail to + // ingest such samples within the Request. + // + // For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go + // for conversion from/to time.Time to Prometheus timestamp. + // + // Note that the "optional" keyword is omitted due to + // https://cloud.google.com/apis/design/design_patterns.md#optional_primitive_fields + // Zero value means value not set. If you need to use exactly zero value for + // the timestamp, use 1 millisecond before or after. + CreatedTimestamp int64 `protobuf:"varint,6,opt,name=created_timestamp,json=createdTimestamp,proto3" json:"created_timestamp,omitempty"` +} + +func (m *TimeSeriesV2) Reset() { *m = TimeSeriesV2{} } +func (*TimeSeriesV2) ProtoMessage() {} +func (*TimeSeriesV2) Descriptor() ([]byte, []int) { + return fileDescriptor_893a47d0a749d749, []int{3} +} +func (m *TimeSeriesV2) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TimeSeriesV2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TimeSeriesV2.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 *TimeSeriesV2) XXX_Merge(src proto.Message) { + xxx_messageInfo_TimeSeriesV2.Merge(m, src) +} +func (m *TimeSeriesV2) XXX_Size() int { + return m.Size() +} +func (m *TimeSeriesV2) XXX_DiscardUnknown() { + xxx_messageInfo_TimeSeriesV2.DiscardUnknown(m) +} + +var xxx_messageInfo_TimeSeriesV2 proto.InternalMessageInfo + +func (m *TimeSeriesV2) GetLabelsRefs() []uint32 { + if m != nil { + return m.LabelsRefs + } + return nil +} + +func (m *TimeSeriesV2) GetSamples() []Sample { + if m != nil { + return m.Samples + } + return nil +} + +func (m *TimeSeriesV2) GetHistograms() []Histogram { + if m != nil { + return m.Histograms + } + return nil +} + +func (m *TimeSeriesV2) GetExemplars() []ExemplarV2 { + if m != nil { + return m.Exemplars + } + return nil +} + +func (m *TimeSeriesV2) GetMetadata() MetadataV2 { + if m != nil { + return m.Metadata + } + return MetadataV2{} +} + +func (m *TimeSeriesV2) GetCreatedTimestamp() int64 { + if m != nil { + return m.CreatedTimestamp + } + return 0 +} + +// Exemplar is an additional information attached to some series' samples. +// It is typically used to attach an example trace or request ID associated with +// the metric changes. +type ExemplarV2 struct { + // labels_refs is an optional list of label name-value pair references, encoded + // as indices to the Request.symbols array. This list's len is always + // a multiple of 2, and the underlying labels should be sorted lexicographically. + // If the exemplar references a trace it should use the `trace_id` label name, as a best practice. + LabelsRefs []uint32 `protobuf:"varint,1,rep,packed,name=labels_refs,json=labelsRefs,proto3" json:"labels_refs,omitempty"` + // value represents an exact example value. This can be useful when the exemplar + // is attached to a histogram, which only gives an estimated value through buckets. + Value float64 `protobuf:"fixed64,2,opt,name=value,proto3" json:"value,omitempty"` + // timestamp represents the timestamp of the exemplar in ms. + // + // For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go + // for conversion from/to time.Time to Prometheus timestamp. + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *ExemplarV2) Reset() { *m = ExemplarV2{} } +func (*ExemplarV2) ProtoMessage() {} +func (*ExemplarV2) Descriptor() ([]byte, []int) { + return fileDescriptor_893a47d0a749d749, []int{4} +} +func (m *ExemplarV2) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExemplarV2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExemplarV2.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 *ExemplarV2) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExemplarV2.Merge(m, src) +} +func (m *ExemplarV2) XXX_Size() int { + return m.Size() +} +func (m *ExemplarV2) XXX_DiscardUnknown() { + xxx_messageInfo_ExemplarV2.DiscardUnknown(m) +} + +var xxx_messageInfo_ExemplarV2 proto.InternalMessageInfo + +func (m *ExemplarV2) GetLabelsRefs() []uint32 { + if m != nil { + return m.LabelsRefs + } + return nil +} + +func (m *ExemplarV2) GetValue() float64 { + if m != nil { + return m.Value + } + return 0 +} + +func (m *ExemplarV2) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +// Metadata represents the metadata associated with the given series' samples. +type MetadataV2 struct { + Type MetadataV2_MetricType `protobuf:"varint,1,opt,name=type,proto3,enum=cortexpb.MetadataV2_MetricType" json:"type,omitempty"` + // help_ref is a reference to the Request.symbols array representing help + // text for the metric. Help is optional, reference should point to an empty string in + // such a case. + HelpRef uint32 `protobuf:"varint,3,opt,name=help_ref,json=helpRef,proto3" json:"help_ref,omitempty"` + // unit_ref is a reference to the Request.symbols array representing a unit + // for the metric. Unit is optional, reference should point to an empty string in + // such a case. + UnitRef uint32 `protobuf:"varint,4,opt,name=unit_ref,json=unitRef,proto3" json:"unit_ref,omitempty"` +} + +func (m *MetadataV2) Reset() { *m = MetadataV2{} } +func (*MetadataV2) ProtoMessage() {} +func (*MetadataV2) Descriptor() ([]byte, []int) { + return fileDescriptor_893a47d0a749d749, []int{5} +} +func (m *MetadataV2) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MetadataV2) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MetadataV2.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 *MetadataV2) XXX_Merge(src proto.Message) { + xxx_messageInfo_MetadataV2.Merge(m, src) +} +func (m *MetadataV2) XXX_Size() int { + return m.Size() +} +func (m *MetadataV2) XXX_DiscardUnknown() { + xxx_messageInfo_MetadataV2.DiscardUnknown(m) +} + +var xxx_messageInfo_MetadataV2 proto.InternalMessageInfo + +func (m *MetadataV2) GetType() MetadataV2_MetricType { + if m != nil { + return m.Type + } + return METRIC_TYPE_UNSPECIFIED +} + +func (m *MetadataV2) GetHelpRef() uint32 { + if m != nil { + return m.HelpRef + } + return 0 +} + +func (m *MetadataV2) GetUnitRef() uint32 { + if m != nil { + return m.UnitRef + } + return 0 +} + type StreamWriteRequest struct { TenantID string `protobuf:"bytes,1,opt,name=TenantID,proto3" json:"TenantID,omitempty"` Request *WriteRequest `protobuf:"bytes,2,opt,name=Request,proto3" json:"Request,omitempty"` @@ -217,7 +563,7 @@ type StreamWriteRequest struct { func (m *StreamWriteRequest) Reset() { *m = StreamWriteRequest{} } func (*StreamWriteRequest) ProtoMessage() {} func (*StreamWriteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{2} + return fileDescriptor_893a47d0a749d749, []int{6} } func (m *StreamWriteRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -274,7 +620,7 @@ type WriteResponse struct { func (m *WriteResponse) Reset() { *m = WriteResponse{} } func (*WriteResponse) ProtoMessage() {} func (*WriteResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{3} + return fileDescriptor_893a47d0a749d749, []int{7} } func (m *WriteResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -349,7 +695,7 @@ type TimeSeries struct { func (m *TimeSeries) Reset() { *m = TimeSeries{} } func (*TimeSeries) ProtoMessage() {} func (*TimeSeries) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{4} + return fileDescriptor_893a47d0a749d749, []int{8} } func (m *TimeSeries) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -407,7 +753,7 @@ type LabelPair struct { func (m *LabelPair) Reset() { *m = LabelPair{} } func (*LabelPair) ProtoMessage() {} func (*LabelPair) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{5} + return fileDescriptor_893a47d0a749d749, []int{9} } func (m *LabelPair) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -458,7 +804,7 @@ type Sample struct { func (m *Sample) Reset() { *m = Sample{} } func (*Sample) ProtoMessage() {} func (*Sample) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{6} + return fileDescriptor_893a47d0a749d749, []int{10} } func (m *Sample) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -511,7 +857,7 @@ type MetricMetadata struct { func (m *MetricMetadata) Reset() { *m = MetricMetadata{} } func (*MetricMetadata) ProtoMessage() {} func (*MetricMetadata) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{7} + return fileDescriptor_893a47d0a749d749, []int{11} } func (m *MetricMetadata) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -575,7 +921,7 @@ type Metric struct { func (m *Metric) Reset() { *m = Metric{} } func (*Metric) ProtoMessage() {} func (*Metric) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{8} + return fileDescriptor_893a47d0a749d749, []int{12} } func (m *Metric) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -614,7 +960,7 @@ type Exemplar struct { func (m *Exemplar) Reset() { *m = Exemplar{} } func (*Exemplar) ProtoMessage() {} func (*Exemplar) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{9} + return fileDescriptor_893a47d0a749d749, []int{13} } func (m *Exemplar) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -707,7 +1053,7 @@ type Histogram struct { func (m *Histogram) Reset() { *m = Histogram{} } func (*Histogram) ProtoMessage() {} func (*Histogram) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{10} + return fileDescriptor_893a47d0a749d749, []int{14} } func (m *Histogram) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -908,7 +1254,7 @@ type BucketSpan struct { func (m *BucketSpan) Reset() { *m = BucketSpan{} } func (*BucketSpan) ProtoMessage() {} func (*BucketSpan) Descriptor() ([]byte, []int) { - return fileDescriptor_893a47d0a749d749, []int{11} + return fileDescriptor_893a47d0a749d749, []int{15} } func (m *BucketSpan) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -952,11 +1298,16 @@ func (m *BucketSpan) GetLength() uint32 { } func init() { - proto.RegisterEnum("cortexpb.WriteRequest_SourceEnum", WriteRequest_SourceEnum_name, WriteRequest_SourceEnum_value) + proto.RegisterEnum("cortexpb.SourceEnum", SourceEnum_name, SourceEnum_value) + proto.RegisterEnum("cortexpb.MetadataV2_MetricType", MetadataV2_MetricType_name, MetadataV2_MetricType_value) proto.RegisterEnum("cortexpb.MetricMetadata_MetricType", MetricMetadata_MetricType_name, MetricMetadata_MetricType_value) proto.RegisterEnum("cortexpb.Histogram_ResetHint", Histogram_ResetHint_name, Histogram_ResetHint_value) proto.RegisterType((*MessageWithBufRef)(nil), "cortexpb.MessageWithBufRef") proto.RegisterType((*WriteRequest)(nil), "cortexpb.WriteRequest") + proto.RegisterType((*WriteRequestV2)(nil), "cortexpb.WriteRequestV2") + proto.RegisterType((*TimeSeriesV2)(nil), "cortexpb.TimeSeriesV2") + proto.RegisterType((*ExemplarV2)(nil), "cortexpb.ExemplarV2") + proto.RegisterType((*MetadataV2)(nil), "cortexpb.MetadataV2") proto.RegisterType((*StreamWriteRequest)(nil), "cortexpb.StreamWriteRequest") proto.RegisterType((*WriteResponse)(nil), "cortexpb.WriteResponse") proto.RegisterType((*TimeSeries)(nil), "cortexpb.TimeSeries") @@ -972,85 +1323,110 @@ func init() { func init() { proto.RegisterFile("cortex.proto", fileDescriptor_893a47d0a749d749) } var fileDescriptor_893a47d0a749d749 = []byte{ - // 1183 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xbd, 0x8f, 0x1b, 0x45, - 0x14, 0xdf, 0xb9, 0xf5, 0xd7, 0x3e, 0xfb, 0x9c, 0xcd, 0x70, 0x0a, 0xcb, 0x41, 0xd6, 0x8e, 0x11, - 0x60, 0x21, 0x74, 0xa0, 0x43, 0x80, 0x12, 0x45, 0x48, 0x76, 0xe2, 0xe4, 0x4e, 0x89, 0x7d, 0xa7, - 0xb1, 0x8f, 0x28, 0x34, 0xd6, 0xc4, 0x37, 0xb6, 0x57, 0xd9, 0x2f, 0x76, 0xc6, 0x51, 0x8e, 0x8a, - 0x06, 0x44, 0x49, 0x43, 0x43, 0x87, 0x68, 0x68, 0xf9, 0x2f, 0x52, 0x5e, 0x19, 0xa5, 0x38, 0x11, - 0xa7, 0x09, 0x5d, 0x0a, 0xfe, 0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, 0x61, 0x47, 0x23, - 0x15, 0x05, 0xed, 0xfa, 0x02, 0x5f, 0x82, 0x6a, 0xec, 0x9e, 0xba, 0x01, 0x8d, 0xbf, 0x56, 0x68, - 0x47, 0x23, 0xa0, 0xc0, 0x1b, 0x12, 0xc3, 0x26, 0xe8, 0x7c, 0xe1, 0xa9, 0x9b, 0x10, 0x91, 0x47, - 0x7c, 0x01, 0x4a, 0x7c, 0x32, 0x67, 0x1e, 0x55, 0xc3, 0x3d, 0x4f, 0x12, 0x0b, 0x7f, 0x00, 0xf5, - 0xef, 0x59, 0x14, 0x8c, 0xc5, 0x3c, 0x62, 0x7c, 0x1e, 0xb8, 0x87, 0x6a, 0xd0, 0x88, 0xac, 0x4b, - 0x74, 0x94, 0x82, 0xf8, 0xc3, 0x24, 0x2c, 0xe7, 0x55, 0x52, 0xbc, 0x10, 0xa9, 0x49, 0xfc, 0x5a, - 0xca, 0xed, 0x63, 0x30, 0x57, 0xe2, 0x62, 0x82, 0x65, 0x45, 0x10, 0x91, 0x7a, 0x16, 0x19, 0x93, - 0xec, 0x40, 0xdd, 0x67, 0x33, 0x2a, 0x9c, 0x07, 0x6c, 0xcc, 0x43, 0xea, 0x73, 0xab, 0xf2, 0xf2, - 0xef, 0x63, 0x77, 0x31, 0xb9, 0xcf, 0xc4, 0x30, 0xa4, 0x7e, 0xb2, 0xa1, 0xeb, 0x69, 0x86, 0xc4, - 0x38, 0xfe, 0x08, 0xce, 0x65, 0x25, 0x0e, 0x99, 0x2b, 0x28, 0xb7, 0x8c, 0xa6, 0xde, 0xc6, 0x24, - 0xab, 0x7c, 0x5d, 0xa1, 0xa7, 0x02, 0x15, 0x37, 0x6e, 0x41, 0x53, 0x6f, 0xa3, 0x3c, 0x50, 0x11, - 0x93, 0x9f, 0xb7, 0x7a, 0x18, 0x70, 0x67, 0x85, 0x54, 0xf5, 0xff, 0x49, 0xa5, 0x19, 0x19, 0xa9, - 0xac, 0x44, 0x42, 0xaa, 0x16, 0x93, 0x4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da, 0x09, 0x00, 0x00, -} - -func (x WriteRequest_SourceEnum) String() string { - s, ok := WriteRequest_SourceEnum_name[int32(x)] + // 1458 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0xcb, 0x6f, 0x53, 0x47, + 0x17, 0xf7, 0xf8, 0x7d, 0x8f, 0x1f, 0xdc, 0x0c, 0x06, 0x4c, 0x80, 0xeb, 0xe0, 0x4f, 0xdf, 0xf7, + 0x45, 0x14, 0xa5, 0x55, 0x50, 0x69, 0x8b, 0x50, 0x25, 0x3b, 0x38, 0xc4, 0x02, 0x3b, 0xd1, 0xd8, + 0x09, 0xa2, 0x1b, 0xeb, 0xc6, 0x19, 0xc7, 0x57, 0xdc, 0x87, 0x7b, 0x67, 0x8c, 0x48, 0x57, 0x5d, + 0x55, 0x5d, 0x76, 0xd3, 0x4d, 0x77, 0x55, 0x37, 0xdd, 0x76, 0xdd, 0x7f, 0x80, 0x65, 0x76, 0x45, + 0x48, 0x8d, 0x4a, 0xd8, 0xd0, 0x1d, 0x8b, 0xfe, 0x01, 0xd5, 0xcc, 0x7d, 0x3a, 0x0e, 0xa2, 0xad, + 0x58, 0x74, 0x37, 0x73, 0x1e, 0x33, 0xbf, 0x39, 0xe7, 0x77, 0x7e, 0xd7, 0x86, 0xe2, 0xd0, 0x71, + 0x39, 0x7d, 0xb2, 0x32, 0x71, 0x1d, 0xee, 0xe0, 0xbc, 0xb7, 0x9b, 0xec, 0x2e, 0x56, 0xf6, 0x9d, + 0x7d, 0x47, 0x1a, 0xdf, 0x17, 0x2b, 0xcf, 0x5f, 0xbf, 0x08, 0x0b, 0x1d, 0xca, 0x98, 0xbe, 0x4f, + 0x1f, 0x18, 0x7c, 0xdc, 0x9c, 0x8e, 0x08, 0x1d, 0xdd, 0x4a, 0xbf, 0xfe, 0xbe, 0x96, 0xa8, 0xff, + 0x92, 0x84, 0xe2, 0x03, 0xd7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, 0x76, 0xb3, + 0xf2, 0x6f, 0xdd, 0x8d, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x33, 0xce, 0xcd, 0x06, 0x0e, + 0x00, 0x00, +} + +func (x SourceEnum) String() string { + s, ok := SourceEnum_name[int32(x)] + if ok { + return s + } + return strconv.Itoa(int(x)) +} +func (x MetadataV2_MetricType) String() string { + s, ok := MetadataV2_MetricType_name[int32(x)] if ok { return s } @@ -1137,14 +1513,14 @@ func (this *WriteRequest) Equal(that interface{}) bool { } return true } -func (this *StreamWriteRequest) Equal(that interface{}) bool { +func (this *WriteRequestV2) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*StreamWriteRequest) + that1, ok := that.(*WriteRequestV2) if !ok { - that2, ok := that.(StreamWriteRequest) + that2, ok := that.(WriteRequestV2) if ok { that1 = &that2 } else { @@ -1156,61 +1532,41 @@ func (this *StreamWriteRequest) Equal(that interface{}) bool { } else if this == nil { return false } - if this.TenantID != that1.TenantID { - return false - } - if !this.Request.Equal(that1.Request) { - return false - } - if !this.MessageWithBufRef.Equal(that1.MessageWithBufRef) { + if len(this.Symbols) != len(that1.Symbols) { return false } - return true -} -func (this *WriteResponse) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*WriteResponse) - if !ok { - that2, ok := that.(WriteResponse) - if ok { - that1 = &that2 - } else { + for i := range this.Symbols { + if this.Symbols[i] != that1.Symbols[i] { return false } } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Code != that1.Code { + if len(this.Timeseries) != len(that1.Timeseries) { return false } - if this.Message != that1.Message { - return false + for i := range this.Timeseries { + if !this.Timeseries[i].Equal(that1.Timeseries[i]) { + return false + } } - if this.Samples != that1.Samples { + if this.Source != that1.Source { return false } - if this.Histograms != that1.Histograms { + if this.SkipLabelNameValidation != that1.SkipLabelNameValidation { return false } - if this.Exemplars != that1.Exemplars { + if !this.MessageWithBufRef.Equal(that1.MessageWithBufRef) { return false } return true } -func (this *TimeSeries) Equal(that interface{}) bool { +func (this *TimeSeriesV2) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*TimeSeries) + that1, ok := that.(*TimeSeriesV2) if !ok { - that2, ok := that.(TimeSeries) + that2, ok := that.(TimeSeriesV2) if ok { that1 = &that2 } else { @@ -1222,11 +1578,201 @@ func (this *TimeSeries) Equal(that interface{}) bool { } else if this == nil { return false } - if len(this.Labels) != len(that1.Labels) { + if len(this.LabelsRefs) != len(that1.LabelsRefs) { return false } - for i := range this.Labels { - if !this.Labels[i].Equal(that1.Labels[i]) { + for i := range this.LabelsRefs { + if this.LabelsRefs[i] != that1.LabelsRefs[i] { + return false + } + } + if len(this.Samples) != len(that1.Samples) { + return false + } + for i := range this.Samples { + if !this.Samples[i].Equal(&that1.Samples[i]) { + return false + } + } + if len(this.Histograms) != len(that1.Histograms) { + return false + } + for i := range this.Histograms { + if !this.Histograms[i].Equal(&that1.Histograms[i]) { + return false + } + } + if len(this.Exemplars) != len(that1.Exemplars) { + return false + } + for i := range this.Exemplars { + if !this.Exemplars[i].Equal(&that1.Exemplars[i]) { + return false + } + } + if !this.Metadata.Equal(&that1.Metadata) { + return false + } + if this.CreatedTimestamp != that1.CreatedTimestamp { + return false + } + return true +} +func (this *ExemplarV2) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ExemplarV2) + if !ok { + that2, ok := that.(ExemplarV2) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.LabelsRefs) != len(that1.LabelsRefs) { + return false + } + for i := range this.LabelsRefs { + if this.LabelsRefs[i] != that1.LabelsRefs[i] { + return false + } + } + if this.Value != that1.Value { + return false + } + if this.Timestamp != that1.Timestamp { + return false + } + return true +} +func (this *MetadataV2) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MetadataV2) + if !ok { + that2, ok := that.(MetadataV2) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Type != that1.Type { + return false + } + if this.HelpRef != that1.HelpRef { + return false + } + if this.UnitRef != that1.UnitRef { + return false + } + return true +} +func (this *StreamWriteRequest) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*StreamWriteRequest) + if !ok { + that2, ok := that.(StreamWriteRequest) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.TenantID != that1.TenantID { + return false + } + if !this.Request.Equal(that1.Request) { + return false + } + if !this.MessageWithBufRef.Equal(that1.MessageWithBufRef) { + return false + } + return true +} +func (this *WriteResponse) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*WriteResponse) + if !ok { + that2, ok := that.(WriteResponse) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Code != that1.Code { + return false + } + if this.Message != that1.Message { + return false + } + if this.Samples != that1.Samples { + return false + } + if this.Histograms != that1.Histograms { + return false + } + if this.Exemplars != that1.Exemplars { + return false + } + return true +} +func (this *TimeSeries) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*TimeSeries) + if !ok { + that2, ok := that.(TimeSeries) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Labels) != len(that1.Labels) { + return false + } + for i := range this.Labels { + if !this.Labels[i].Equal(that1.Labels[i]) { return false } } @@ -1657,6 +2203,77 @@ func (this *WriteRequest) GoString() string { s = append(s, "}") return strings.Join(s, "") } +func (this *WriteRequestV2) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 9) + s = append(s, "&cortexpb.WriteRequestV2{") + s = append(s, "Symbols: "+fmt.Sprintf("%#v", this.Symbols)+",\n") + s = append(s, "Timeseries: "+fmt.Sprintf("%#v", this.Timeseries)+",\n") + s = append(s, "Source: "+fmt.Sprintf("%#v", this.Source)+",\n") + s = append(s, "SkipLabelNameValidation: "+fmt.Sprintf("%#v", this.SkipLabelNameValidation)+",\n") + s = append(s, "MessageWithBufRef: "+fmt.Sprintf("%#v", this.MessageWithBufRef)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *TimeSeriesV2) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 10) + s = append(s, "&cortexpb.TimeSeriesV2{") + s = append(s, "LabelsRefs: "+fmt.Sprintf("%#v", this.LabelsRefs)+",\n") + if this.Samples != nil { + vs := make([]*Sample, len(this.Samples)) + for i := range vs { + vs[i] = &this.Samples[i] + } + s = append(s, "Samples: "+fmt.Sprintf("%#v", vs)+",\n") + } + if this.Histograms != nil { + vs := make([]*Histogram, len(this.Histograms)) + for i := range vs { + vs[i] = &this.Histograms[i] + } + s = append(s, "Histograms: "+fmt.Sprintf("%#v", vs)+",\n") + } + if this.Exemplars != nil { + vs := make([]*ExemplarV2, len(this.Exemplars)) + for i := range vs { + vs[i] = &this.Exemplars[i] + } + s = append(s, "Exemplars: "+fmt.Sprintf("%#v", vs)+",\n") + } + s = append(s, "Metadata: "+strings.Replace(this.Metadata.GoString(), `&`, ``, 1)+",\n") + s = append(s, "CreatedTimestamp: "+fmt.Sprintf("%#v", this.CreatedTimestamp)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *ExemplarV2) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&cortexpb.ExemplarV2{") + s = append(s, "LabelsRefs: "+fmt.Sprintf("%#v", this.LabelsRefs)+",\n") + s = append(s, "Value: "+fmt.Sprintf("%#v", this.Value)+",\n") + s = append(s, "Timestamp: "+fmt.Sprintf("%#v", this.Timestamp)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *MetadataV2) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&cortexpb.MetadataV2{") + s = append(s, "Type: "+fmt.Sprintf("%#v", this.Type)+",\n") + s = append(s, "HelpRef: "+fmt.Sprintf("%#v", this.HelpRef)+",\n") + s = append(s, "UnitRef: "+fmt.Sprintf("%#v", this.UnitRef)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} func (this *StreamWriteRequest) GoString() string { if this == nil { return "nil" @@ -1965,7 +2582,7 @@ func (m *WriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *StreamWriteRequest) Marshal() (dAtA []byte, err error) { +func (m *WriteRequestV2) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1975,12 +2592,12 @@ func (m *StreamWriteRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *StreamWriteRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *WriteRequestV2) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *StreamWriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *WriteRequestV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1996,25 +2613,288 @@ func (m *StreamWriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3e i-- - dAtA[i] = 0xc2 - if m.Request != nil { - { - size, err := m.Request.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCortex(dAtA, i, uint64(size)) + dAtA[i] = 0xca + if m.SkipLabelNameValidation { + i-- + if m.SkipLabelNameValidation { + dAtA[i] = 1 + } else { + dAtA[i] = 0 } i-- - dAtA[i] = 0x12 - } - if len(m.TenantID) > 0 { - i -= len(m.TenantID) - copy(dAtA[i:], m.TenantID) - i = encodeVarintCortex(dAtA, i, uint64(len(m.TenantID))) + dAtA[i] = 0x3e i-- - dAtA[i] = 0xa + dAtA[i] = 0xc0 + } + if m.Source != 0 { + i = encodeVarintCortex(dAtA, i, uint64(m.Source)) + i-- + dAtA[i] = 0x30 + } + if len(m.Timeseries) > 0 { + for iNdEx := len(m.Timeseries) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.Timeseries[iNdEx].Size() + i -= size + if _, err := m.Timeseries[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintCortex(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.Symbols) > 0 { + for iNdEx := len(m.Symbols) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Symbols[iNdEx]) + copy(dAtA[i:], m.Symbols[iNdEx]) + i = encodeVarintCortex(dAtA, i, uint64(len(m.Symbols[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + return len(dAtA) - i, nil +} + +func (m *TimeSeriesV2) 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 *TimeSeriesV2) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TimeSeriesV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CreatedTimestamp != 0 { + i = encodeVarintCortex(dAtA, i, uint64(m.CreatedTimestamp)) + i-- + dAtA[i] = 0x30 + } + { + size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCortex(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.Exemplars) > 0 { + for iNdEx := len(m.Exemplars) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Exemplars[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCortex(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Histograms) > 0 { + for iNdEx := len(m.Histograms) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Histograms[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCortex(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Samples) > 0 { + for iNdEx := len(m.Samples) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Samples[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCortex(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.LabelsRefs) > 0 { + dAtA5 := make([]byte, len(m.LabelsRefs)*10) + var j4 int + for _, num := range m.LabelsRefs { + for num >= 1<<7 { + dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j4++ + } + dAtA5[j4] = uint8(num) + j4++ + } + i -= j4 + copy(dAtA[i:], dAtA5[:j4]) + i = encodeVarintCortex(dAtA, i, uint64(j4)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ExemplarV2) 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 *ExemplarV2) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExemplarV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintCortex(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x18 + } + if m.Value != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Value)))) + i-- + dAtA[i] = 0x11 + } + if len(m.LabelsRefs) > 0 { + dAtA7 := make([]byte, len(m.LabelsRefs)*10) + var j6 int + for _, num := range m.LabelsRefs { + for num >= 1<<7 { + dAtA7[j6] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j6++ + } + dAtA7[j6] = uint8(num) + j6++ + } + i -= j6 + copy(dAtA[i:], dAtA7[:j6]) + i = encodeVarintCortex(dAtA, i, uint64(j6)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MetadataV2) 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 *MetadataV2) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MetadataV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.UnitRef != 0 { + i = encodeVarintCortex(dAtA, i, uint64(m.UnitRef)) + i-- + dAtA[i] = 0x20 + } + if m.HelpRef != 0 { + i = encodeVarintCortex(dAtA, i, uint64(m.HelpRef)) + i-- + dAtA[i] = 0x18 + } + if m.Type != 0 { + i = encodeVarintCortex(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *StreamWriteRequest) 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 *StreamWriteRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StreamWriteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MessageWithBufRef.Size() + i -= size + if _, err := m.MessageWithBufRef.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintCortex(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3e + i-- + dAtA[i] = 0xc2 + if m.Request != nil { + { + size, err := m.Request.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintCortex(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.TenantID) > 0 { + i -= len(m.TenantID) + copy(dAtA[i:], m.TenantID) + i = encodeVarintCortex(dAtA, i, uint64(len(m.TenantID))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -2385,30 +3265,30 @@ func (m *Histogram) MarshalToSizedBuffer(dAtA []byte) (int, error) { } if len(m.PositiveCounts) > 0 { for iNdEx := len(m.PositiveCounts) - 1; iNdEx >= 0; iNdEx-- { - f4 := math.Float64bits(float64(m.PositiveCounts[iNdEx])) + f10 := math.Float64bits(float64(m.PositiveCounts[iNdEx])) i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f4)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f10)) } i = encodeVarintCortex(dAtA, i, uint64(len(m.PositiveCounts)*8)) i-- dAtA[i] = 0x6a } if len(m.PositiveDeltas) > 0 { - var j5 int - dAtA7 := make([]byte, len(m.PositiveDeltas)*10) + var j11 int + dAtA13 := make([]byte, len(m.PositiveDeltas)*10) for _, num := range m.PositiveDeltas { - x6 := (uint64(num) << 1) ^ uint64((num >> 63)) - for x6 >= 1<<7 { - dAtA7[j5] = uint8(uint64(x6)&0x7f | 0x80) - j5++ - x6 >>= 7 - } - dAtA7[j5] = uint8(x6) - j5++ - } - i -= j5 - copy(dAtA[i:], dAtA7[:j5]) - i = encodeVarintCortex(dAtA, i, uint64(j5)) + x12 := (uint64(num) << 1) ^ uint64((num >> 63)) + for x12 >= 1<<7 { + dAtA13[j11] = uint8(uint64(x12)&0x7f | 0x80) + j11++ + x12 >>= 7 + } + dAtA13[j11] = uint8(x12) + j11++ + } + i -= j11 + copy(dAtA[i:], dAtA13[:j11]) + i = encodeVarintCortex(dAtA, i, uint64(j11)) i-- dAtA[i] = 0x62 } @@ -2428,30 +3308,30 @@ func (m *Histogram) MarshalToSizedBuffer(dAtA []byte) (int, error) { } if len(m.NegativeCounts) > 0 { for iNdEx := len(m.NegativeCounts) - 1; iNdEx >= 0; iNdEx-- { - f8 := math.Float64bits(float64(m.NegativeCounts[iNdEx])) + f14 := math.Float64bits(float64(m.NegativeCounts[iNdEx])) i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f8)) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f14)) } i = encodeVarintCortex(dAtA, i, uint64(len(m.NegativeCounts)*8)) i-- dAtA[i] = 0x52 } if len(m.NegativeDeltas) > 0 { - var j9 int - dAtA11 := make([]byte, len(m.NegativeDeltas)*10) + var j15 int + dAtA17 := make([]byte, len(m.NegativeDeltas)*10) for _, num := range m.NegativeDeltas { - x10 := (uint64(num) << 1) ^ uint64((num >> 63)) - for x10 >= 1<<7 { - dAtA11[j9] = uint8(uint64(x10)&0x7f | 0x80) - j9++ - x10 >>= 7 - } - dAtA11[j9] = uint8(x10) - j9++ - } - i -= j9 - copy(dAtA[i:], dAtA11[:j9]) - i = encodeVarintCortex(dAtA, i, uint64(j9)) + x16 := (uint64(num) << 1) ^ uint64((num >> 63)) + for x16 >= 1<<7 { + dAtA17[j15] = uint8(uint64(x16)&0x7f | 0x80) + j15++ + x16 >>= 7 + } + dAtA17[j15] = uint8(x16) + j15++ + } + i -= j15 + copy(dAtA[i:], dAtA17[:j15]) + i = encodeVarintCortex(dAtA, i, uint64(j15)) i-- dAtA[i] = 0x4a } @@ -2635,43 +3515,151 @@ func (m *WriteRequest) Size() (n int) { return n } -func (m *StreamWriteRequest) Size() (n int) { +func (m *WriteRequestV2) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.TenantID) - if l > 0 { - n += 1 + l + sovCortex(uint64(l)) + if len(m.Symbols) > 0 { + for _, s := range m.Symbols { + l = len(s) + n += 1 + l + sovCortex(uint64(l)) + } } - if m.Request != nil { - l = m.Request.Size() - n += 1 + l + sovCortex(uint64(l)) + if len(m.Timeseries) > 0 { + for _, e := range m.Timeseries { + l = e.Size() + n += 1 + l + sovCortex(uint64(l)) + } + } + if m.Source != 0 { + n += 1 + sovCortex(uint64(m.Source)) + } + if m.SkipLabelNameValidation { + n += 3 } l = m.MessageWithBufRef.Size() n += 2 + l + sovCortex(uint64(l)) return n } -func (m *WriteResponse) Size() (n int) { +func (m *TimeSeriesV2) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Code != 0 { - n += 1 + sovCortex(uint64(m.Code)) - } - l = len(m.Message) - if l > 0 { - n += 1 + l + sovCortex(uint64(l)) - } - if m.Samples != 0 { - n += 1 + sovCortex(uint64(m.Samples)) + if len(m.LabelsRefs) > 0 { + l = 0 + for _, e := range m.LabelsRefs { + l += sovCortex(uint64(e)) + } + n += 1 + sovCortex(uint64(l)) + l } - if m.Histograms != 0 { - n += 1 + sovCortex(uint64(m.Histograms)) + if len(m.Samples) > 0 { + for _, e := range m.Samples { + l = e.Size() + n += 1 + l + sovCortex(uint64(l)) + } + } + if len(m.Histograms) > 0 { + for _, e := range m.Histograms { + l = e.Size() + n += 1 + l + sovCortex(uint64(l)) + } + } + if len(m.Exemplars) > 0 { + for _, e := range m.Exemplars { + l = e.Size() + n += 1 + l + sovCortex(uint64(l)) + } + } + l = m.Metadata.Size() + n += 1 + l + sovCortex(uint64(l)) + if m.CreatedTimestamp != 0 { + n += 1 + sovCortex(uint64(m.CreatedTimestamp)) + } + return n +} + +func (m *ExemplarV2) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.LabelsRefs) > 0 { + l = 0 + for _, e := range m.LabelsRefs { + l += sovCortex(uint64(e)) + } + n += 1 + sovCortex(uint64(l)) + l + } + if m.Value != 0 { + n += 9 + } + if m.Timestamp != 0 { + n += 1 + sovCortex(uint64(m.Timestamp)) + } + return n +} + +func (m *MetadataV2) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Type != 0 { + n += 1 + sovCortex(uint64(m.Type)) + } + if m.HelpRef != 0 { + n += 1 + sovCortex(uint64(m.HelpRef)) + } + if m.UnitRef != 0 { + n += 1 + sovCortex(uint64(m.UnitRef)) + } + return n +} + +func (m *StreamWriteRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TenantID) + if l > 0 { + n += 1 + l + sovCortex(uint64(l)) + } + if m.Request != nil { + l = m.Request.Size() + n += 1 + l + sovCortex(uint64(l)) + } + l = m.MessageWithBufRef.Size() + n += 2 + l + sovCortex(uint64(l)) + return n +} + +func (m *WriteResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Code != 0 { + n += 1 + sovCortex(uint64(m.Code)) + } + l = len(m.Message) + if l > 0 { + n += 1 + l + sovCortex(uint64(l)) + } + if m.Samples != 0 { + n += 1 + sovCortex(uint64(m.Samples)) + } + if m.Histograms != 0 { + n += 1 + sovCortex(uint64(m.Histograms)) } if m.Exemplars != 0 { n += 1 + sovCortex(uint64(m.Exemplars)) @@ -2951,6 +3939,74 @@ func (this *WriteRequest) String() string { }, "") return s } +func (this *WriteRequestV2) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&WriteRequestV2{`, + `Symbols:` + fmt.Sprintf("%v", this.Symbols) + `,`, + `Timeseries:` + fmt.Sprintf("%v", this.Timeseries) + `,`, + `Source:` + fmt.Sprintf("%v", this.Source) + `,`, + `SkipLabelNameValidation:` + fmt.Sprintf("%v", this.SkipLabelNameValidation) + `,`, + `MessageWithBufRef:` + fmt.Sprintf("%v", this.MessageWithBufRef) + `,`, + `}`, + }, "") + return s +} +func (this *TimeSeriesV2) String() string { + if this == nil { + return "nil" + } + repeatedStringForSamples := "[]Sample{" + for _, f := range this.Samples { + repeatedStringForSamples += strings.Replace(strings.Replace(f.String(), "Sample", "Sample", 1), `&`, ``, 1) + "," + } + repeatedStringForSamples += "}" + repeatedStringForHistograms := "[]Histogram{" + for _, f := range this.Histograms { + repeatedStringForHistograms += strings.Replace(strings.Replace(f.String(), "Histogram", "Histogram", 1), `&`, ``, 1) + "," + } + repeatedStringForHistograms += "}" + repeatedStringForExemplars := "[]ExemplarV2{" + for _, f := range this.Exemplars { + repeatedStringForExemplars += strings.Replace(strings.Replace(f.String(), "ExemplarV2", "ExemplarV2", 1), `&`, ``, 1) + "," + } + repeatedStringForExemplars += "}" + s := strings.Join([]string{`&TimeSeriesV2{`, + `LabelsRefs:` + fmt.Sprintf("%v", this.LabelsRefs) + `,`, + `Samples:` + repeatedStringForSamples + `,`, + `Histograms:` + repeatedStringForHistograms + `,`, + `Exemplars:` + repeatedStringForExemplars + `,`, + `Metadata:` + strings.Replace(strings.Replace(this.Metadata.String(), "MetadataV2", "MetadataV2", 1), `&`, ``, 1) + `,`, + `CreatedTimestamp:` + fmt.Sprintf("%v", this.CreatedTimestamp) + `,`, + `}`, + }, "") + return s +} +func (this *ExemplarV2) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ExemplarV2{`, + `LabelsRefs:` + fmt.Sprintf("%v", this.LabelsRefs) + `,`, + `Value:` + fmt.Sprintf("%v", this.Value) + `,`, + `Timestamp:` + fmt.Sprintf("%v", this.Timestamp) + `,`, + `}`, + }, "") + return s +} +func (this *MetadataV2) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&MetadataV2{`, + `Type:` + fmt.Sprintf("%v", this.Type) + `,`, + `HelpRef:` + fmt.Sprintf("%v", this.HelpRef) + `,`, + `UnitRef:` + fmt.Sprintf("%v", this.UnitRef) + `,`, + `}`, + }, "") + return s +} func (this *StreamWriteRequest) String() string { if this == nil { return "nil" @@ -3283,7 +4339,7 @@ func (m *WriteRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Source |= WriteRequest_SourceEnum(b&0x7F) << shift + m.Source |= SourceEnum(b&0x7F) << shift if b < 0x80 { break } @@ -3399,6 +4455,749 @@ func (m *WriteRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *WriteRequestV2) 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 ErrIntOverflowCortex + } + 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: WriteRequestV2: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WriteRequestV2: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbols", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + 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 ErrInvalidLengthCortex + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Symbols = append(m.Symbols, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Timeseries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCortex + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Timeseries = append(m.Timeseries, PreallocTimeseriesV2{}) + if err := m.Timeseries[len(m.Timeseries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) + } + m.Source = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Source |= SourceEnum(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 1000: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SkipLabelNameValidation", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SkipLabelNameValidation = bool(v != 0) + case 1001: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MessageWithBufRef", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCortex + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MessageWithBufRef.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCortex(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCortex + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCortex + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TimeSeriesV2) 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 ErrIntOverflowCortex + } + 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: TimeSeriesV2: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TimeSeriesV2: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LabelsRefs = append(m.LabelsRefs, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthCortex + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.LabelsRefs) == 0 { + m.LabelsRefs = make([]uint32, 0, elementCount) + } + for iNdEx < postIndex { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LabelsRefs = append(m.LabelsRefs, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field LabelsRefs", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Samples", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCortex + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Samples = append(m.Samples, Sample{}) + if err := m.Samples[len(m.Samples)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Histograms", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCortex + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Histograms = append(m.Histograms, Histogram{}) + if err := m.Histograms[len(m.Histograms)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Exemplars", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCortex + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Exemplars = append(m.Exemplars, ExemplarV2{}) + if err := m.Exemplars[len(m.Exemplars)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthCortex + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedTimestamp", wireType) + } + m.CreatedTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedTimestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCortex(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCortex + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCortex + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExemplarV2) 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 ErrIntOverflowCortex + } + 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: ExemplarV2: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExemplarV2: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LabelsRefs = append(m.LabelsRefs, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthCortex + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthCortex + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.LabelsRefs) == 0 { + m.LabelsRefs = make([]uint32, 0, elementCount) + } + for iNdEx < postIndex { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.LabelsRefs = append(m.LabelsRefs, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field LabelsRefs", wireType) + } + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Value = float64(math.Float64frombits(v)) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCortex(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCortex + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCortex + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MetadataV2) 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 ErrIntOverflowCortex + } + 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: MetadataV2: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MetadataV2: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= MetadataV2_MetricType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HelpRef", wireType) + } + m.HelpRef = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HelpRef |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UnitRef", wireType) + } + m.UnitRef = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCortex + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UnitRef |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipCortex(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCortex + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCortex + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *StreamWriteRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/pkg/cortexpb/cortex.proto b/pkg/cortexpb/cortex.proto index fa2caf287c2..7a2ae97544e 100644 --- a/pkg/cortexpb/cortex.proto +++ b/pkg/cortexpb/cortex.proto @@ -8,6 +8,10 @@ import "gogoproto/gogo.proto"; option (gogoproto.marshaler_all) = true; option (gogoproto.unmarshaler_all) = true; +enum SourceEnum { + API = 0; + RULE = 1; +} message MessageWithBufRef { option (gogoproto.typedecl) = false; @@ -15,10 +19,6 @@ message MessageWithBufRef { message WriteRequest { repeated TimeSeries timeseries = 1 [(gogoproto.nullable) = false, (gogoproto.customtype) = "PreallocTimeseries"]; - enum SourceEnum { - API = 0; - RULE = 1; - } SourceEnum Source = 2; repeated MetricMetadata metadata = 3 [(gogoproto.nullable) = true]; @@ -26,6 +26,95 @@ message WriteRequest { MessageWithBufRef Ref = 1001 [(gogoproto.embed) = true, (gogoproto.customtype) = "MessageWithBufRef", (gogoproto.nullable) = false]; } +// refer to https://github.com/prometheus/prometheus/blob/v3.5.0/prompb/io/prometheus/write/v2/types.proto +// The histogram and Sample are shared with PRW1. +message WriteRequestV2 { + repeated string symbols = 4; + repeated TimeSeriesV2 timeseries = 5 [(gogoproto.nullable) = false, (gogoproto.customtype) = "PreallocTimeseriesV2"]; + SourceEnum Source = 6; + + bool skip_label_name_validation = 1000; // set intentionally high to keep WriteRequest compatible with upstream Prometheus + MessageWithBufRef Ref = 1001 [(gogoproto.embed) = true, (gogoproto.customtype) = "MessageWithBufRef", (gogoproto.nullable) = false]; +} + +message TimeSeriesV2 { + repeated uint32 labels_refs = 1; + // Timeseries messages can either specify samples or (native) histogram samples + // (histogram field), but not both. For a typical sender (real-time metric + // streaming), in healthy cases, there will be only one sample or histogram. + // + // Samples and histograms are sorted by timestamp (older first). + repeated Sample samples = 2 [(gogoproto.nullable) = false]; + repeated Histogram histograms = 3 [(gogoproto.nullable) = false]; + + // exemplars represents an optional set of exemplars attached to this series' samples. + repeated ExemplarV2 exemplars = 4 [(gogoproto.nullable) = false]; + + // metadata represents the metadata associated with the given series' samples. + MetadataV2 metadata = 5 [(gogoproto.nullable) = false]; + + // created_timestamp represents an optional created timestamp associated with + // this series' samples in ms format, typically for counter or histogram type + // metrics. Created timestamp represents the time when the counter started + // counting (sometimes referred to as start timestamp), which can increase + // the accuracy of query results. + // + // Note that some receivers might require this and in return fail to + // ingest such samples within the Request. + // + // For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go + // for conversion from/to time.Time to Prometheus timestamp. + // + // Note that the "optional" keyword is omitted due to + // https://cloud.google.com/apis/design/design_patterns.md#optional_primitive_fields + // Zero value means value not set. If you need to use exactly zero value for + // the timestamp, use 1 millisecond before or after. + int64 created_timestamp = 6; +} + +// Exemplar is an additional information attached to some series' samples. +// It is typically used to attach an example trace or request ID associated with +// the metric changes. +message ExemplarV2 { + // labels_refs is an optional list of label name-value pair references, encoded + // as indices to the Request.symbols array. This list's len is always + // a multiple of 2, and the underlying labels should be sorted lexicographically. + // If the exemplar references a trace it should use the `trace_id` label name, as a best practice. + repeated uint32 labels_refs = 1; + // value represents an exact example value. This can be useful when the exemplar + // is attached to a histogram, which only gives an estimated value through buckets. + double value = 2; + // timestamp represents the timestamp of the exemplar in ms. + // + // For Go, see github.com/prometheus/prometheus/model/timestamp/timestamp.go + // for conversion from/to time.Time to Prometheus timestamp. + int64 timestamp = 3; +} + +// Metadata represents the metadata associated with the given series' samples. +message MetadataV2 { + enum MetricType { + METRIC_TYPE_UNSPECIFIED = 0; + METRIC_TYPE_COUNTER = 1; + METRIC_TYPE_GAUGE = 2; + METRIC_TYPE_HISTOGRAM = 3; + METRIC_TYPE_GAUGEHISTOGRAM = 4; + METRIC_TYPE_SUMMARY = 5; + METRIC_TYPE_INFO = 6; + METRIC_TYPE_STATESET = 7; + } + + MetricType type = 1; + // help_ref is a reference to the Request.symbols array representing help + // text for the metric. Help is optional, reference should point to an empty string in + // such a case. + uint32 help_ref = 3; + // unit_ref is a reference to the Request.symbols array representing a unit + // for the metric. Unit is optional, reference should point to an empty string in + // such a case. + uint32 unit_ref = 4; +} + message StreamWriteRequest { string TenantID = 1; WriteRequest Request = 2; diff --git a/pkg/cortexpb/histograms.go b/pkg/cortexpb/histograms.go index d05dbaa7727..60e7207a19a 100644 --- a/pkg/cortexpb/histograms.go +++ b/pkg/cortexpb/histograms.go @@ -16,7 +16,6 @@ package cortexpb import ( "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/prompb" - writev2 "github.com/prometheus/prometheus/prompb/io/prometheus/write/v2" ) func (h Histogram) IsFloatHistogram() bool { @@ -24,30 +23,6 @@ func (h Histogram) IsFloatHistogram() bool { return ok } -func HistogramWriteV2ProtoToHistogramProto(h writev2.Histogram) Histogram { - ph := Histogram{ - Sum: h.Sum, - Schema: h.Schema, - ZeroThreshold: h.ZeroThreshold, - NegativeSpans: spansWriteV2ProtoToSpansProto(h.NegativeSpans), - NegativeDeltas: h.NegativeDeltas, - NegativeCounts: h.NegativeCounts, - PositiveSpans: spansWriteV2ProtoToSpansProto(h.PositiveSpans), - PositiveDeltas: h.PositiveDeltas, - PositiveCounts: h.PositiveCounts, - ResetHint: Histogram_ResetHint(h.ResetHint), - TimestampMs: h.Timestamp, - } - if h.IsFloatHistogram() { - ph.Count = &Histogram_CountFloat{CountFloat: h.GetCountFloat()} - ph.ZeroCount = &Histogram_ZeroCountFloat{ZeroCountFloat: h.GetZeroCountFloat()} - } else { - ph.Count = &Histogram_CountInt{CountInt: h.GetCountInt()} - ph.ZeroCount = &Histogram_ZeroCountInt{ZeroCountInt: h.GetZeroCountInt()} - } - return ph -} - // HistogramPromProtoToHistogramProto converts a prometheus protobuf Histogram to cortex protobuf Histogram. func HistogramPromProtoToHistogramProto(h prompb.Histogram) Histogram { ph := Histogram{ @@ -180,12 +155,3 @@ func spansPromProtoToSpansProto(s []prompb.BucketSpan) []BucketSpan { return spans } - -func spansWriteV2ProtoToSpansProto(s []writev2.BucketSpan) []BucketSpan { - spans := make([]BucketSpan, len(s)) - for i := 0; i < len(s); i++ { - spans[i] = BucketSpan{Offset: s[i].Offset, Length: s[i].Length} - } - - return spans -} diff --git a/pkg/cortexpb/timeseriesv2.go b/pkg/cortexpb/timeseriesv2.go new file mode 100644 index 00000000000..126c059d1f3 --- /dev/null +++ b/pkg/cortexpb/timeseriesv2.go @@ -0,0 +1,131 @@ +package cortexpb + +import ( + "sync" +) + +var ( + expectedSymbols = 20 + + slicePoolV2 = sync.Pool{ + New: func() interface{} { + return make([]PreallocTimeseriesV2, 0, expectedTimeseries) + }, + } + + timeSeriesPoolV2 = sync.Pool{ + New: func() interface{} { + return &TimeSeriesV2{ + LabelsRefs: make([]uint32, 0, expectedLabels), + Samples: make([]Sample, 0, expectedSamplesPerSeries), + Histograms: make([]Histogram, 0, expectedHistogramsPerSeries), + Exemplars: make([]ExemplarV2, 0, expectedExemplarsPerSeries), + Metadata: MetadataV2{}, + } + }, + } + + writeRequestPoolV2 = sync.Pool{ + New: func() interface{} { + return &PreallocWriteRequestV2{ + WriteRequestV2: WriteRequestV2{ + Symbols: make([]string, 0, expectedSymbols), + }, + } + }, + } + bytePoolV2 = newSlicePool(20) +) + +// PreallocWriteRequestV2 is a WriteRequestV2 which preallocs slices on Unmarshal. +type PreallocWriteRequestV2 struct { + WriteRequestV2 + data *[]byte +} + +// Unmarshal implements proto.Message. +func (p *PreallocWriteRequestV2) Unmarshal(dAtA []byte) error { + p.Timeseries = PreallocTimeseriesV2SliceFromPool() + return p.WriteRequestV2.Unmarshal(dAtA) +} + +func (p *PreallocWriteRequestV2) Marshal() (dAtA []byte, err error) { + size := p.Size() + p.data = bytePoolV2.getSlice(size) + dAtA = *p.data + n, err := p.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +// PreallocTimeseriesV2 is a TimeSeries which preallocs slices on Unmarshal. +type PreallocTimeseriesV2 struct { + *TimeSeriesV2 +} + +// Unmarshal implements proto.Message. +func (p *PreallocTimeseriesV2) Unmarshal(dAtA []byte) error { + p.TimeSeriesV2 = TimeseriesV2FromPool() + return p.TimeSeriesV2.Unmarshal(dAtA) +} + +func ReuseWriteRequestV2(req *PreallocWriteRequestV2) { + if req.data != nil { + bytePoolV2.reuseSlice(req.data) + req.data = nil + } + req.Source = 0 + req.Symbols = req.Symbols[:0] + if req.Timeseries != nil { + ReuseSliceV2(req.Timeseries) + req.Timeseries = nil + } + writeRequestPoolV2.Put(req) +} + +func PreallocWriteRequestV2FromPool() *PreallocWriteRequestV2 { + return writeRequestPoolV2.Get().(*PreallocWriteRequestV2) +} + +// PreallocTimeseriesV2SliceFromPool retrieves a slice of PreallocTimeseriesV2 from a sync.Pool. +// ReuseSliceV2 should be called once done. +func PreallocTimeseriesV2SliceFromPool() []PreallocTimeseriesV2 { + return slicePoolV2.Get().([]PreallocTimeseriesV2) +} + +// ReuseSliceV2 puts the slice back into a sync.Pool for reuse. +func ReuseSliceV2(ts []PreallocTimeseriesV2) { + for i := range ts { + ReuseTimeseriesV2(ts[i].TimeSeriesV2) + } + + slicePoolV2.Put(ts[:0]) //nolint:staticcheck //see comment on slicePool for more details +} + +// TimeseriesV2FromPool retrieves a pointer to a TimeSeriesV2 from a sync.Pool. +// ReuseTimeseriesV2 should be called once done, unless ReuseSliceV2 was called on the slice that contains this TimeSeriesV2 . +func TimeseriesV2FromPool() *TimeSeriesV2 { + return timeSeriesPoolV2.Get().(*TimeSeriesV2) +} + +// ReuseTimeseriesV2 puts the timeseriesV2 back into a sync.Pool for reuse. +func ReuseTimeseriesV2(ts *TimeSeriesV2) { + // clear ts labelRef and samples + ts.LabelsRefs = ts.LabelsRefs[:0] + ts.Samples = ts.Samples[:0] + + // clear exemplar label refs + for i := range ts.Exemplars { + ts.Exemplars[i].LabelsRefs = ts.Exemplars[i].LabelsRefs[:0] + } + + for i := range ts.Histograms { + ts.Histograms[i].Reset() + } + + ts.Exemplars = ts.Exemplars[:0] + ts.Histograms = ts.Histograms[:0] + timeSeriesPoolV2.Put(ts) +} diff --git a/pkg/cortexpb/timeseriesv2_test.go b/pkg/cortexpb/timeseriesv2_test.go new file mode 100644 index 00000000000..de953b87fe7 --- /dev/null +++ b/pkg/cortexpb/timeseriesv2_test.go @@ -0,0 +1,118 @@ +package cortexpb + +import ( + "testing" + + "github.com/gogo/protobuf/proto" + "github.com/prometheus/prometheus/model/labels" + writev2 "github.com/prometheus/prometheus/prompb/io/prometheus/write/v2" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestPreallocTimeseriesV2SliceFromPool(t *testing.T) { + t.Run("new instance is provided when not available to reuse", func(t *testing.T) { + first := PreallocTimeseriesV2SliceFromPool() + second := PreallocTimeseriesV2SliceFromPool() + + assert.NotSame(t, first, second) + }) + + t.Run("instance is cleaned before reusing", func(t *testing.T) { + slice := PreallocTimeseriesV2SliceFromPool() + slice = append(slice, PreallocTimeseriesV2{TimeSeriesV2: &TimeSeriesV2{}}) + ReuseSliceV2(slice) + + reused := PreallocTimeseriesV2SliceFromPool() + assert.Len(t, reused, 0) + }) +} + +func TestTimeseriesV2FromPool(t *testing.T) { + t.Run("new instance is provided when not available to reuse", func(t *testing.T) { + first := TimeseriesV2FromPool() + second := TimeseriesV2FromPool() + + assert.NotSame(t, first, second) + }) + + t.Run("instance is cleaned before reusing", func(t *testing.T) { + ts := TimeseriesV2FromPool() + ts.LabelsRefs = []uint32{1, 2} + ts.Samples = []Sample{{Value: 1, TimestampMs: 2}} + ts.Exemplars = []ExemplarV2{{LabelsRefs: []uint32{1, 2}, Value: 1, Timestamp: 2}} + ts.Histograms = []Histogram{{}} + ReuseTimeseriesV2(ts) + + reused := TimeseriesV2FromPool() + assert.Len(t, reused.LabelsRefs, 0) + assert.Len(t, reused.Samples, 0) + assert.Len(t, reused.Exemplars, 0) + assert.Len(t, reused.Histograms, 0) + }) +} + +func BenchmarkMarshallWriteRequestV2(b *testing.B) { + ts := PreallocTimeseriesV2SliceFromPool() + + numOfSeries := 100 + st := writev2.NewSymbolTable() + lbs := labels.FromStrings(labels.MetricName, "foo", "labelName1", "labelValue1", "labelName2", "labelValue2", "labelName3", "labelValue3") + st.SymbolizeLabels(lbs, nil) + symbols := st.Symbols() + for i := 0; i < numOfSeries; i++ { + ts = append(ts, PreallocTimeseriesV2{TimeSeriesV2: TimeseriesV2FromPool()}) + ts[i].LabelsRefs = []uint32{1, 2, 3, 4, 5, 6, 7, 8} + ts[i].Samples = []Sample{{Value: 1, TimestampMs: 2}} + } + + tests := []struct { + name string + writeRequestFactory func() proto.Marshaler + clean func(in interface{}) + }{ + { + name: "no-pool", + writeRequestFactory: func() proto.Marshaler { + return &WriteRequestV2{Symbols: symbols, Timeseries: ts} + }, + clean: func(in interface{}) {}, + }, + { + name: "byte pool", + writeRequestFactory: func() proto.Marshaler { + w := &PreallocWriteRequestV2{} + w.Timeseries = ts + w.Symbols = symbols + return w + }, + clean: func(in interface{}) { + ReuseWriteRequestV2(in.(*PreallocWriteRequestV2)) + }, + }, + { + name: "byte and write pool", + writeRequestFactory: func() proto.Marshaler { + w := PreallocWriteRequestV2FromPool() + w.Timeseries = ts + w.Symbols = symbols + return w + }, + clean: func(in interface{}) { + ReuseWriteRequestV2(in.(*PreallocWriteRequestV2)) + }, + }, + } + + for _, tc := range tests { + b.Run(tc.name, func(b *testing.B) { + for i := 0; i < b.N; i++ { + w := tc.writeRequestFactory() + _, err := w.Marshal() + require.NoError(b, err) + tc.clean(w) + } + b.ReportAllocs() + }) + } +} diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index beaa738e751..d1eff0d7c14 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -1166,7 +1166,7 @@ func sortLabelsIfNeeded(labels []cortexpb.LabelAdapter) { }) } -func (d *Distributor) send(ctx context.Context, ingester ring.InstanceDesc, timeseries []cortexpb.PreallocTimeseries, metadata []*cortexpb.MetricMetadata, source cortexpb.WriteRequest_SourceEnum) error { +func (d *Distributor) send(ctx context.Context, ingester ring.InstanceDesc, timeseries []cortexpb.PreallocTimeseries, metadata []*cortexpb.MetricMetadata, source cortexpb.SourceEnum) error { h, err := d.ingesterPool.GetClientFor(ingester.Addr) if err != nil { return err diff --git a/pkg/util/push/otlp_test.go b/pkg/util/push/otlp_test.go index 99932188fcd..a685bf18aed 100644 --- a/pkg/util/push/otlp_test.go +++ b/pkg/util/push/otlp_test.go @@ -803,7 +803,7 @@ func generateOTLPWriteRequest() pmetricotlp.ExportRequest { return pmetricotlp.NewExportRequestFromMetrics(d) } -func verifyOTLPWriteRequestHandler(t *testing.T, expectSource cortexpb.WriteRequest_SourceEnum) func(ctx context.Context, request *cortexpb.WriteRequest) (response *cortexpb.WriteResponse, err error) { +func verifyOTLPWriteRequestHandler(t *testing.T, expectSource cortexpb.SourceEnum) func(ctx context.Context, request *cortexpb.WriteRequest) (response *cortexpb.WriteResponse, err error) { t.Helper() return func(ctx context.Context, request *cortexpb.WriteRequest) (response *cortexpb.WriteResponse, err error) { assert.Len(t, request.Timeseries, 13) // 1 (target_info) + 1 (counter) + 1 (gauge) + 7 (hist_bucket) + 2 (hist_sum, hist_count) + 1 (exponential histogram) diff --git a/pkg/util/push/push.go b/pkg/util/push/push.go index 17413f0e4dd..cc04517cfb3 100644 --- a/pkg/util/push/push.go +++ b/pkg/util/push/push.go @@ -10,7 +10,6 @@ import ( "github.com/go-kit/log/level" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/labels" - writev2 "github.com/prometheus/prometheus/prompb/io/prometheus/write/v2" "github.com/prometheus/prometheus/util/compression" "github.com/weaveworks/common/httpgrpc" "github.com/weaveworks/common/middleware" @@ -80,7 +79,7 @@ func Handler(remoteWrite2Enabled bool, maxRecvMsgSize int, sourceIPs *middleware } handlePRW2 := func() { - var req writev2.Request + var req cortexpb.PreallocWriteRequestV2 err := util.ParseProtoReader(ctx, r.Body, int(r.ContentLength), maxRecvMsgSize, &req, util.RawSnappy) if err != nil { level.Error(logger).Log("err", err.Error()) @@ -88,6 +87,11 @@ func Handler(remoteWrite2Enabled bool, maxRecvMsgSize int, sourceIPs *middleware return } + req.SkipLabelNameValidation = false + if req.Source == 0 { + req.Source = cortexpb.API + } + v1Req, err := convertV2RequestToV1(&req) if err != nil { level.Error(logger).Log("err", err.Error()) @@ -191,7 +195,7 @@ func parseProtoMsg(contentType string) (config.RemoteWriteProtoMsg, error) { return config.RemoteWriteProtoMsgV1, nil } -func convertV2RequestToV1(req *writev2.Request) (cortexpb.PreallocWriteRequest, error) { +func convertV2RequestToV1(req *cortexpb.PreallocWriteRequestV2) (cortexpb.PreallocWriteRequest, error) { var v1Req cortexpb.PreallocWriteRequest v1Timeseries := make([]cortexpb.PreallocTimeseries, 0, len(req.Timeseries)) var v1Metadata []*cortexpb.MetricMetadata @@ -203,9 +207,9 @@ func convertV2RequestToV1(req *writev2.Request) (cortexpb.PreallocWriteRequest, v1Timeseries = append(v1Timeseries, cortexpb.PreallocTimeseries{ TimeSeries: &cortexpb.TimeSeries{ Labels: cortexpb.FromLabelsToLabelAdapters(lbs), - Samples: convertV2ToV1Samples(v2Ts.Samples), - Exemplars: convertV2ToV1Exemplars(b, symbols, v2Ts.Exemplars), - Histograms: convertV2ToV1Histograms(v2Ts.Histograms), + Samples: v2Ts.Samples, + Exemplars: convertV2ToV1Exemplars(&b, symbols, v2Ts.Exemplars), + Histograms: v2Ts.Histograms, }, }) @@ -224,50 +228,27 @@ func convertV2RequestToV1(req *writev2.Request) (cortexpb.PreallocWriteRequest, return v1Req, nil } -func shouldConvertV2Metadata(metadata writev2.Metadata) bool { - return !(metadata.HelpRef == 0 && metadata.UnitRef == 0 && metadata.Type == writev2.Metadata_METRIC_TYPE_UNSPECIFIED) //nolint:staticcheck -} - -func convertV2ToV1Histograms(histograms []writev2.Histogram) []cortexpb.Histogram { - v1Histograms := make([]cortexpb.Histogram, 0, len(histograms)) - - for _, h := range histograms { - v1Histograms = append(v1Histograms, cortexpb.HistogramWriteV2ProtoToHistogramProto(h)) - } - - return v1Histograms -} - -func convertV2ToV1Samples(samples []writev2.Sample) []cortexpb.Sample { - v1Samples := make([]cortexpb.Sample, 0, len(samples)) - - for _, s := range samples { - v1Samples = append(v1Samples, cortexpb.Sample{ - Value: s.Value, - TimestampMs: s.Timestamp, - }) - } - - return v1Samples +func shouldConvertV2Metadata(metadata cortexpb.MetadataV2) bool { + return !(metadata.HelpRef == 0 && metadata.UnitRef == 0 && metadata.Type == cortexpb.METRIC_TYPE_UNSPECIFIED) //nolint:staticcheck } -func convertV2ToV1Metadata(name string, symbols []string, metadata writev2.Metadata) *cortexpb.MetricMetadata { +func convertV2ToV1Metadata(name string, symbols []string, metadata cortexpb.MetadataV2) *cortexpb.MetricMetadata { t := cortexpb.UNKNOWN switch metadata.Type { - case writev2.Metadata_METRIC_TYPE_COUNTER: + case cortexpb.METRIC_TYPE_COUNTER: t = cortexpb.COUNTER - case writev2.Metadata_METRIC_TYPE_GAUGE: + case cortexpb.METRIC_TYPE_GAUGE: t = cortexpb.GAUGE - case writev2.Metadata_METRIC_TYPE_HISTOGRAM: + case cortexpb.METRIC_TYPE_HISTOGRAM: t = cortexpb.HISTOGRAM - case writev2.Metadata_METRIC_TYPE_GAUGEHISTOGRAM: + case cortexpb.METRIC_TYPE_GAUGEHISTOGRAM: t = cortexpb.GAUGEHISTOGRAM - case writev2.Metadata_METRIC_TYPE_SUMMARY: + case cortexpb.METRIC_TYPE_SUMMARY: t = cortexpb.SUMMARY - case writev2.Metadata_METRIC_TYPE_INFO: + case cortexpb.METRIC_TYPE_INFO: t = cortexpb.INFO - case writev2.Metadata_METRIC_TYPE_STATESET: + case cortexpb.METRIC_TYPE_STATESET: t = cortexpb.STATESET } @@ -279,12 +260,11 @@ func convertV2ToV1Metadata(name string, symbols []string, metadata writev2.Metad } } -func convertV2ToV1Exemplars(b labels.ScratchBuilder, symbols []string, v2Exemplars []writev2.Exemplar) []cortexpb.Exemplar { +func convertV2ToV1Exemplars(b *labels.ScratchBuilder, symbols []string, v2Exemplars []cortexpb.ExemplarV2) []cortexpb.Exemplar { v1Exemplars := make([]cortexpb.Exemplar, 0, len(v2Exemplars)) for _, e := range v2Exemplars { - promExemplar := e.ToExemplar(&b, symbols) v1Exemplars = append(v1Exemplars, cortexpb.Exemplar{ - Labels: cortexpb.FromLabelsToLabelAdapters(promExemplar.Labels), + Labels: cortexpb.FromLabelsToLabelAdapters(e.ToLabels(b, symbols)), Value: e.Value, TimestampMs: e.Timestamp, }) From cde1f700c7a7928105f71777724881937bbec75a Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Mon, 28 Jul 2025 14:43:58 +0900 Subject: [PATCH 07/11] Fix test Signed-off-by: SungJin1212 --- pkg/cortexpb/timeseriesv2_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cortexpb/timeseriesv2_test.go b/pkg/cortexpb/timeseriesv2_test.go index de953b87fe7..06be1a85784 100644 --- a/pkg/cortexpb/timeseriesv2_test.go +++ b/pkg/cortexpb/timeseriesv2_test.go @@ -15,7 +15,7 @@ func TestPreallocTimeseriesV2SliceFromPool(t *testing.T) { first := PreallocTimeseriesV2SliceFromPool() second := PreallocTimeseriesV2SliceFromPool() - assert.NotSame(t, first, second) + assert.NotSame(t, &first, &second) }) t.Run("instance is cleaned before reusing", func(t *testing.T) { From 40bba5407be6bfd2221eb40894992b387d0e0c75 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Mon, 28 Jul 2025 15:17:03 +0900 Subject: [PATCH 08/11] Fix lint Signed-off-by: SungJin1212 --- pkg/querier/tripperware/query.pb.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/querier/tripperware/query.pb.go b/pkg/querier/tripperware/query.pb.go index 5b493380f8a..893290303c5 100644 --- a/pkg/querier/tripperware/query.pb.go +++ b/pkg/querier/tripperware/query.pb.go @@ -737,7 +737,6 @@ func (m *PrometheusResponseHeader) GetValues() []string { type PrometheusQueryResult struct { // Types that are valid to be assigned to Result: - // // *PrometheusQueryResult_Vector // *PrometheusQueryResult_RawBytes // *PrometheusQueryResult_Matrix From 11cffdb9f9c07b0bcec1d9dbb677d0c705e1bc0b Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Thu, 7 Aug 2025 14:02:43 +0900 Subject: [PATCH 09/11] get rebase Signed-off-by: SungJin1212 --- docs/configuration/config-file-reference.md | 5 ----- integration/remote_write_v2_test.go | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/configuration/config-file-reference.md b/docs/configuration/config-file-reference.md index 7e1e3b512d6..c4ef8305ed6 100644 --- a/docs/configuration/config-file-reference.md +++ b/docs/configuration/config-file-reference.md @@ -3135,11 +3135,6 @@ ha_tracker: # CLI flag: -distributor.sign-write-requests [sign_write_requests: | default = false] -# EXPERIMENTAL: If true, accept prometheus remote write v2 protocol push -# request. -# CLI flag: -distributor.remote-write2-enabled -[remote_write2_enabled: | default = false] - # EXPERIMENTAL: If enabled, distributor would use stream connection to send # requests to ingesters. # CLI flag: -distributor.use-stream-push diff --git a/integration/remote_write_v2_test.go b/integration/remote_write_v2_test.go index 67593df424a..8ba26447f68 100644 --- a/integration/remote_write_v2_test.go +++ b/integration/remote_write_v2_test.go @@ -25,7 +25,7 @@ import ( ) func TestIngesterRollingUpdate(t *testing.T) { - // Test ingester rolling update situation: when -distributor.remote-write2-enabled is true, and ingester uses the v1.19.0 image. + // Test ingester rolling update situation: when -distributor.remote-writev2-enabled is true, and ingester uses the v1.19.0 image. // Expected: remote write 2.0 push success const blockRangePeriod = 5 * time.Second ingesterImage := "quay.io/cortexproject/cortex:v1.19.0" From 18b528ea39e302b8843f692592ba4a7f90482a24 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Thu, 7 Aug 2025 16:05:26 +0900 Subject: [PATCH 10/11] Update test Signed-off-by: SungJin1212 --- pkg/util/push/push_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/util/push/push_test.go b/pkg/util/push/push_test.go index a1a7f0c9562..67ffbb7487f 100644 --- a/pkg/util/push/push_test.go +++ b/pkg/util/push/push_test.go @@ -458,16 +458,21 @@ func createRequest(t *testing.T, protobuf []byte, isV2 bool) *http.Request { func createCortexRemoteWriteV2Protobuf(t *testing.T, skipLabelNameValidation bool, source cortexpb.SourceEnum) []byte { t.Helper() - input := writev2.Request{ + + input := cortexpb.WriteRequestV2{ Symbols: []string{"", "__name__", "foo"}, - Timeseries: []writev2.TimeSeries{ + Timeseries: []cortexpb.PreallocTimeseriesV2{ { - LabelsRefs: []uint32{1, 2}, - Samples: []writev2.Sample{ - {Value: 1, Timestamp: time.Date(2020, 4, 1, 0, 0, 0, 0, time.UTC).UnixNano()}, + TimeSeriesV2: &cortexpb.TimeSeriesV2{ + LabelsRefs: []uint32{1, 2}, + Samples: []cortexpb.Sample{ + {Value: 1, TimestampMs: time.Date(2020, 4, 1, 0, 0, 0, 0, time.UTC).UnixNano()}, + }, }, }, }, + Source: source, + SkipLabelNameValidation: skipLabelNameValidation, } inoutBytes, err := input.Marshal() From 85a2506955a3b601fc3ae77a4f06ce97465d735d Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Thu, 7 Aug 2025 20:23:00 +0900 Subject: [PATCH 11/11] Add a changelog Signed-off-by: SungJin1212 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f05aaf715f2..3c44b83c410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * [FEATURE] Querier: Support for configuring query optimizers and enabling XFunctions in the Thanos engine. #6873 * [FEATURE] Query Frontend: Add support /api/v1/format_query API for formatting queries. #6893 * [ENHANCEMENT] Ingester: Add `cortex_ingester_tsdb_wal_replay_unknown_refs_total` and `cortex_ingester_tsdb_wbl_replay_unknown_refs_total` metrics to track unknown series references during wal/wbl replaying. #6945 +* [ENHANCEMENT] Distributor: Introduce a Protobuf model for Prometheus Remote Write 2.0 and a pool to improve performance. #6917 * [ENHANCEMENT] Ruler: Emit an error message when the rule synchronization fails. #6902 * [ENHANCEMENT] Querier: Support snappy and zstd response compression for `-querier.response-compression` flag. #6848 * [ENHANCEMENT] Tenant Federation: Add a # of query result limit logic when the `-tenant-federation.regex-matcher-enabled` is enabled. #6845