@@ -21,7 +21,6 @@ import (
21
21
22
22
"github.com/cortexproject/cortex/pkg/chunk"
23
23
"github.com/cortexproject/cortex/pkg/ingester/client"
24
- "github.com/cortexproject/cortex/pkg/util"
25
24
"github.com/cortexproject/cortex/pkg/util/chunkcompat"
26
25
"github.com/cortexproject/cortex/pkg/util/validation"
27
26
"github.com/weaveworks/common/httpgrpc"
@@ -499,7 +498,7 @@ func benchmarkIngesterSeriesCreationLocking(b *testing.B, parallelism int) {
499
498
_ , err := ing .Push (ctx , & client.WriteRequest {
500
499
Timeseries : []client.PreallocTimeseries {
501
500
{
502
- TimeSeries : client.TimeSeries {
501
+ TimeSeries : & client.TimeSeries {
503
502
Labels : []client.LabelAdapter {
504
503
{Name : model .MetricNameLabel , Value : fmt .Sprintf ("metric_%d" , j )},
505
504
},
@@ -530,31 +529,28 @@ func BenchmarkIngesterPush(b *testing.B) {
530
529
)
531
530
532
531
// Construct a set of realistic-looking samples, all with slightly different label sets
533
- labels := util . LabelsToMetric ( chunk . BenchmarkLabels ). Clone ()
534
- ts := make ( []client.PreallocTimeseries , 0 , series )
532
+ var allLabels []labels. Labels
533
+ var allSamples []client.Sample
535
534
for j := 0 ; j < series ; j ++ {
536
- labels ["cpu" ] = model .LabelValue (fmt .Sprintf ("cpu%02d" , j ))
537
- ts = append (ts , client.PreallocTimeseries {
538
- TimeSeries : client.TimeSeries {
539
- Labels : client .FromMetricsToLabelAdapters (labels ),
540
- Samples : []client.Sample {
541
- {TimestampMs : 0 , Value : float64 (j )},
542
- },
543
- },
544
- })
535
+ labels := chunk .BenchmarkLabels .Copy ()
536
+ for i := range labels {
537
+ if labels [i ].Name == "cpu" {
538
+ labels [i ].Value = fmt .Sprintf ("cpu%02d" , j )
539
+ }
540
+ }
541
+ allLabels = append (allLabels , labels )
542
+ allSamples = append (allSamples , client.Sample {TimestampMs : 0 , Value : float64 (j )})
545
543
}
546
544
ctx := user .InjectOrgID (context .Background (), "1" )
547
545
b .ResetTimer ()
548
546
for iter := 0 ; iter < b .N ; iter ++ {
549
547
_ , ing := newTestStore (b , cfg , clientCfg , limits )
550
548
// Bump the timestamp on each of our test samples each time round the loop
551
549
for j := 0 ; j < samples ; j ++ {
552
- for i := range ts {
553
- ts [i ].TimeSeries . Samples [ 0 ]. TimestampMs = int64 (i )
550
+ for i := range allSamples {
551
+ allSamples [i ].TimestampMs = int64 (j + 1 )
554
552
}
555
- _ , err := ing .Push (ctx , & client.WriteRequest {
556
- Timeseries : ts ,
557
- })
553
+ _ , err := ing .Push (ctx , client .ToWriteRequest (allLabels , allSamples , client .API ))
558
554
require .NoError (b , err )
559
555
}
560
556
ing .Shutdown ()
0 commit comments