MCPcopy
hub / github.com/prometheus/prometheus / floatHistogramSamplesV1

Method floatHistogramSamplesV1

tsdb/record/record.go:1234–1267  ·  view source on GitHub ↗
(histograms []RefFloatHistogramSample, b []byte)

Source from the content-addressed store, hash-verified

1232}
1233
1234func (*Encoder) floatHistogramSamplesV1(histograms []RefFloatHistogramSample, b []byte) ([]byte, []RefFloatHistogramSample) {
1235 buf := encoding.Encbuf{B: b}
1236 buf.PutByte(byte(FloatHistogramSamples))
1237
1238 if len(histograms) == 0 {
1239 return buf.Get(), nil
1240 }
1241
1242 var customBucketsFloatHistograms []RefFloatHistogramSample
1243
1244 // Store base timestamp and base reference number of first histogram.
1245 // All histograms encode their timestamp and ref as delta to those.
1246 first := histograms[0]
1247 buf.PutBE64(uint64(first.Ref))
1248 buf.PutBE64int64(first.T)
1249
1250 for _, h := range histograms {
1251 if h.FH.UsesCustomBuckets() {
1252 customBucketsFloatHistograms = append(customBucketsFloatHistograms, h)
1253 continue
1254 }
1255 buf.PutVarint64(int64(h.Ref) - int64(first.Ref))
1256 buf.PutVarint64(h.T - first.T)
1257
1258 EncodeFloatHistogram(&buf, h.FH)
1259 }
1260
1261 // Reset buffer if only custom bucket histograms existed in list of histogram samples
1262 if len(histograms) == len(customBucketsFloatHistograms) {
1263 buf.Reset()
1264 }
1265
1266 return buf.Get(), customBucketsFloatHistograms
1267}
1268
1269// floatHistogramSamplesV2 encodes exponential float histogram samples and
1270// splits off custom-bucket float histogram samples to be encoded later.

Callers 1

FloatHistogramSamplesMethod · 0.95

Calls 8

PutByteMethod · 0.95
GetMethod · 0.95
PutBE64Method · 0.95
PutBE64int64Method · 0.95
PutVarint64Method · 0.95
ResetMethod · 0.95
EncodeFloatHistogramFunction · 0.85
UsesCustomBucketsMethod · 0.45

Tested by

no test coverage detected