@@ -35,30 +35,34 @@ var (
3535 }
3636)
3737
38- func makeV2ReqWithSeries (num int ) * writev2. Request {
39- ts := make ([]writev2. TimeSeries , 0 , num )
38+ func makeV2ReqWithSeries (num int ) * cortexpb. PreallocWriteRequestV2 {
39+ ts := make ([]cortexpb. PreallocTimeseriesV2 , 0 , num )
4040 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" }
4141 for range num {
42- ts = append (ts , writev2.TimeSeries {
43- LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
44- Metadata : writev2.Metadata {
45- Type : writev2 .Metadata_METRIC_TYPE_GAUGE ,
46-
47- HelpRef : 15 ,
48- UnitRef : 16 ,
49- },
50- Samples : []writev2.Sample {{Value : 1 , Timestamp : 10 }},
51- Exemplars : []writev2.Exemplar {{LabelsRefs : []uint32 {11 , 12 }, Value : 1 , Timestamp : 10 }},
52- Histograms : []writev2.Histogram {
53- writev2 .FromIntHistogram (10 , & testHistogram ),
54- writev2 .FromFloatHistogram (20 , testHistogram .ToFloat (nil )),
42+ ts = append (ts , cortexpb.PreallocTimeseriesV2 {
43+ TimeSeriesV2 : & cortexpb.TimeSeriesV2 {
44+ LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
45+ Metadata : cortexpb.MetadataV2 {
46+ Type : cortexpb .METRIC_TYPE_GAUGE ,
47+
48+ HelpRef : 15 ,
49+ UnitRef : 16 ,
50+ },
51+ Samples : []cortexpb.Sample {{Value : 1 , TimestampMs : 10 }},
52+ Exemplars : []cortexpb.ExemplarV2 {{LabelsRefs : []uint32 {11 , 12 }, Value : 1 , Timestamp : 10 }},
53+ Histograms : []cortexpb.Histogram {
54+ cortexpb .HistogramToHistogramProto (10 , & testHistogram ),
55+ cortexpb .FloatHistogramToHistogramProto (20 , testHistogram .ToFloat (nil )),
56+ },
5557 },
5658 })
5759 }
5860
59- return & writev2.Request {
60- Symbols : symbols ,
61- Timeseries : ts ,
61+ return & cortexpb.PreallocWriteRequestV2 {
62+ WriteRequestV2 : cortexpb.WriteRequestV2 {
63+ Symbols : symbols ,
64+ Timeseries : ts ,
65+ },
6266 }
6367}
6468
@@ -161,36 +165,44 @@ func Benchmark_convertV2RequestToV1(b *testing.B) {
161165}
162166
163167func Test_convertV2RequestToV1 (t * testing.T ) {
164- var v2Req writev2. Request
168+ var v2Req cortexpb. PreallocWriteRequestV2
165169
166170 fh := tsdbutil .GenerateTestFloatHistogram (1 )
167- ph := writev2 . FromFloatHistogram (4 , fh )
171+ ph := cortexpb . FloatHistogramToHistogramProto (4 , fh )
168172
169173 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" }
170- timeseries := []writev2. TimeSeries {
174+ timeseries := []cortexpb. PreallocTimeseriesV2 {
171175 {
172- LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
173- Metadata : writev2.Metadata {
174- Type : writev2 .Metadata_METRIC_TYPE_COUNTER ,
176+ TimeSeriesV2 : & cortexpb.TimeSeriesV2 {
177+ LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
178+ Metadata : cortexpb.MetadataV2 {
179+ Type : cortexpb .METRIC_TYPE_COUNTER ,
175180
176- HelpRef : 15 ,
177- UnitRef : 16 ,
181+ HelpRef : 15 ,
182+ UnitRef : 16 ,
183+ },
184+ Samples : []cortexpb.Sample {{Value : 1 , TimestampMs : 1 }},
185+ Exemplars : []cortexpb.ExemplarV2 {{LabelsRefs : []uint32 {11 , 12 }, Value : 1 , Timestamp : 1 }},
178186 },
179- Samples : []writev2.Sample {{Value : 1 , Timestamp : 1 }},
180- Exemplars : []writev2.Exemplar {{LabelsRefs : []uint32 {11 , 12 }, Value : 1 , Timestamp : 1 }},
181187 },
182188 {
183- LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
184- Samples : []writev2.Sample {{Value : 2 , Timestamp : 2 }},
189+ TimeSeriesV2 : & cortexpb.TimeSeriesV2 {
190+ LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
191+ Samples : []cortexpb.Sample {{Value : 2 , TimestampMs : 2 }},
192+ },
185193 },
186194 {
187- LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
188- Samples : []writev2.Sample {{Value : 3 , Timestamp : 3 }},
195+ TimeSeriesV2 : & cortexpb.TimeSeriesV2 {
196+ LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
197+ Samples : []cortexpb.Sample {{Value : 3 , TimestampMs : 3 }},
198+ },
189199 },
190200 {
191- LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
192- Histograms : []writev2.Histogram {ph , ph },
193- Exemplars : []writev2.Exemplar {{LabelsRefs : []uint32 {11 , 12 }, Value : 1 , Timestamp : 1 }},
201+ TimeSeriesV2 : & cortexpb.TimeSeriesV2 {
202+ LabelsRefs : []uint32 {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
203+ Histograms : []cortexpb.Histogram {ph , ph },
204+ Exemplars : []cortexpb.ExemplarV2 {{LabelsRefs : []uint32 {11 , 12 }, Value : 1 , Timestamp : 1 }},
205+ },
194206 },
195207 }
196208
@@ -391,7 +403,7 @@ func TestHandler_ignoresSkipLabelNameValidationIfSet(t *testing.T) {
391403 }
392404}
393405
394- func verifyWriteRequestHandler (t * testing.T , expectSource cortexpb.WriteRequest_SourceEnum ) func (ctx context.Context , request * cortexpb.WriteRequest ) (response * cortexpb.WriteResponse , err error ) {
406+ func verifyWriteRequestHandler (t * testing.T , expectSource cortexpb.SourceEnum ) func (ctx context.Context , request * cortexpb.WriteRequest ) (response * cortexpb.WriteResponse , err error ) {
395407 t .Helper ()
396408 return func (ctx context.Context , request * cortexpb.WriteRequest ) (response * cortexpb.WriteResponse , err error ) {
397409 assert .Len (t , request .Timeseries , 1 )
@@ -441,7 +453,7 @@ func createRequest(t *testing.T, protobuf []byte, isV2 bool) *http.Request {
441453 return req
442454}
443455
444- func createCortexRemoteWriteV2Protobuf (t * testing.T , skipLabelNameValidation bool , source cortexpb.WriteRequest_SourceEnum ) []byte {
456+ func createCortexRemoteWriteV2Protobuf (t * testing.T , skipLabelNameValidation bool , source cortexpb.SourceEnum ) []byte {
445457 t .Helper ()
446458 input := writev2.Request {
447459 Symbols : []string {"" , "__name__" , "foo" },
@@ -497,7 +509,7 @@ func createPrometheusRemoteWriteProtobuf(t *testing.T) []byte {
497509 require .NoError (t , err )
498510 return inoutBytes
499511}
500- func createCortexWriteRequestProtobuf (t * testing.T , skipLabelNameValidation bool , source cortexpb.WriteRequest_SourceEnum ) []byte {
512+ func createCortexWriteRequestProtobuf (t * testing.T , skipLabelNameValidation bool , source cortexpb.SourceEnum ) []byte {
501513 t .Helper ()
502514 ts := cortexpb.PreallocTimeseries {
503515 TimeSeries : & cortexpb.TimeSeries {
0 commit comments