@@ -25,7 +25,7 @@ import (
25
25
"github.com/prometheus/prometheus/util/jsonutil"
26
26
"github.com/weaveworks/common/httpgrpc"
27
27
28
- _ "github.com/cortexproject/cortex/pkg/chunk" // Register jsoniter type: labels.Labels.
28
+ "github.com/cortexproject/cortex/pkg/chunk"
29
29
"github.com/cortexproject/cortex/pkg/cortexpb"
30
30
"github.com/cortexproject/cortex/pkg/util/limiter"
31
31
"github.com/cortexproject/cortex/pkg/util/runutil"
@@ -115,7 +115,7 @@ func decodeSampleStream(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
115
115
switch field {
116
116
case "metric" :
117
117
lbls := labels.Labels {}
118
- iter . ReadVal ( & lbls )
118
+ chunk . DecodeLabels ( unsafe . Pointer ( & lbls ), iter )
119
119
ss .Labels = cortexpb .FromLabelsToLabelAdapters (lbls )
120
120
case "values" :
121
121
for iter .ReadArray () {
@@ -299,7 +299,8 @@ func encodeSampleStream(ptr unsafe.Pointer, stream *jsoniter.Stream) {
299
299
stream .WriteObjectStart ()
300
300
301
301
stream .WriteObjectField (`metric` )
302
- stream .WriteVal (cortexpb .FromLabelAdaptersToLabels (ss .Labels ))
302
+ metric := cortexpb .FromLabelAdaptersToLabels (ss .Labels )
303
+ chunk .EncodeLabels (unsafe .Pointer (& metric ), stream )
303
304
304
305
if len (ss .Samples ) > 0 {
305
306
stream .WriteMore ()
@@ -336,7 +337,7 @@ func decodeSample(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
336
337
switch field {
337
338
case "metric" :
338
339
lbls := labels.Labels {}
339
- iter . ReadVal ( & lbls )
340
+ chunk . DecodeLabels ( unsafe . Pointer ( & lbls ), iter )
340
341
ss .Labels = cortexpb .FromLabelsToLabelAdapters (lbls )
341
342
case "value" :
342
343
ss .Sample = & cortexpb.Sample {}
@@ -356,7 +357,8 @@ func encodeSample(ptr unsafe.Pointer, stream *jsoniter.Stream) {
356
357
stream .WriteObjectStart ()
357
358
358
359
stream .WriteObjectField (`metric` )
359
- stream .WriteVal (cortexpb .FromLabelAdaptersToLabels (ss .Labels ))
360
+ metric := cortexpb .FromLabelAdaptersToLabels (ss .Labels )
361
+ chunk .EncodeLabels (unsafe .Pointer (& metric ), stream )
360
362
361
363
if ss .Sample != nil {
362
364
stream .WriteMore ()
0 commit comments