MCPcopy
hub / github.com/prometheus/prometheus / floatHistogramSamplesV2

Method floatHistogramSamplesV2

tsdb/record/record.go:1271–1300  ·  view source on GitHub ↗

floatHistogramSamplesV2 encodes exponential float histogram samples and splits off custom-bucket float histogram samples to be encoded later.

(histograms []RefFloatHistogramSample, b []byte)

Source from the content-addressed store, hash-verified

1269// floatHistogramSamplesV2 encodes exponential float histogram samples and
1270// splits off custom-bucket float histogram samples to be encoded later.
1271func (*Encoder) floatHistogramSamplesV2(histograms []RefFloatHistogramSample, b []byte) []byte {
1272 buf := encoding.Encbuf{B: b}
1273 buf.PutByte(byte(FloatHistogramSamplesV2))
1274
1275 if len(histograms) == 0 {
1276 return buf.Get()
1277 }
1278
1279 var first, prev *RefFloatHistogramSample
1280 for _, fh := range histograms {
1281 if first == nil {
1282 first = &fh
1283 buf.PutVarint64(int64(first.Ref))
1284 buf.PutVarint64(first.T)
1285 buf.PutVarint64(first.ST)
1286 prev = first
1287 EncodeFloatHistogram(&buf, fh.FH)
1288 continue
1289 }
1290
1291 buf.PutVarint64(int64(fh.Ref) - int64(prev.Ref))
1292 buf.PutVarint64(fh.T - first.T)
1293
1294 writeSTMarker(&buf, fh.ST, first.ST, prev.ST)
1295 EncodeFloatHistogram(&buf, fh.FH)
1296 prev = &fh
1297 }
1298
1299 return buf.Get()
1300}
1301
1302// CustomBucketsFloatHistogramSamples appends the encoded custom-bucket float
1303// histogram samples to b and returns the resulting slice.

Callers 2

FloatHistogramSamplesMethod · 0.95

Calls 5

PutByteMethod · 0.95
GetMethod · 0.95
PutVarint64Method · 0.95
EncodeFloatHistogramFunction · 0.85
writeSTMarkerFunction · 0.85

Tested by

no test coverage detected