MCPcopy Index your code
hub / github.com/cortexproject/cortex / EncodeLabels

Function EncodeLabels

pkg/chunk/json_helpers.go:32–50  ·  view source on GitHub ↗

Override Prometheus' labels.Labels encoder which goes via a map

(ptr unsafe.Pointer, stream *jsoniter.Stream)

Source from the content-addressed store, hash-verified

30
31// Override Prometheus' labels.Labels encoder which goes via a map
32func EncodeLabels(ptr unsafe.Pointer, stream *jsoniter.Stream) {
33 lbls := *(*labels.Labels)(ptr)
34
35 stream.WriteObjectStart()
36 first := true
37
38 lbls.Range(func(l labels.Label) {
39 if !first {
40 stream.WriteMore()
41 }
42 first = false
43
44 stream.WriteString(l.Name)
45 stream.WriteRaw(`:`)
46 stream.WriteString(l.Value)
47 })
48
49 stream.WriteObjectEnd()
50}
51
52func labelsIsEmpty(ptr unsafe.Pointer) bool {
53 labelsPtr := *(*labels.Labels)(ptr)

Callers 2

encodeSampleStreamFunction · 0.92
encodeSampleFunction · 0.92

Calls 1

WriteStringMethod · 0.80

Tested by

no test coverage detected