mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
add doc comments
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
This commit is contained in:
parent
cbd5488cd3
commit
57bde06d2c
|
@ -29,23 +29,31 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type NhcbParser struct {
|
type NhcbParser struct {
|
||||||
parser Parser
|
// The parser we're wrapping.
|
||||||
|
parser Parser
|
||||||
|
// Option to keep classic histograms along with converted histograms.
|
||||||
keepClassicHistograms bool
|
keepClassicHistograms bool
|
||||||
|
|
||||||
|
// Caches the values from the underlying parser.
|
||||||
|
// For Series and Histogram.
|
||||||
bytes []byte
|
bytes []byte
|
||||||
ts *int64
|
ts *int64
|
||||||
value float64
|
value float64
|
||||||
h *histogram.Histogram
|
h *histogram.Histogram
|
||||||
fh *histogram.FloatHistogram
|
fh *histogram.FloatHistogram
|
||||||
|
// For Metric.
|
||||||
lset labels.Labels
|
lset labels.Labels
|
||||||
metricString string
|
metricString string
|
||||||
|
|
||||||
buf []byte
|
buf []byte
|
||||||
|
|
||||||
|
// Collates values from the classic histogram series to build
|
||||||
|
// the converted histogram later.
|
||||||
lsetNhcb labels.Labels
|
lsetNhcb labels.Labels
|
||||||
tempNhcb convertnhcb.TempHistogram
|
tempNhcb convertnhcb.TempHistogram
|
||||||
|
|
||||||
|
// Remembers the last native histogram name so we can ignore
|
||||||
|
// conversions to NHCB when the name is the same.
|
||||||
lastNativeHistName string
|
lastNativeHistName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +126,10 @@ func (p *NhcbParser) Next() (Entry, error) {
|
||||||
return et, err
|
return et, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleClassicHistogramSeries collates the classic histogram series to be converted to NHCB
|
||||||
|
// if it is actually a classic histogram series (and not a normal float series) and if there
|
||||||
|
// isn't already a native histogram with the same name (assuming it is always processed
|
||||||
|
// right before the classic histograms) and returns true if the collation was done.
|
||||||
func (p *NhcbParser) handleClassicHistogramSeries(lset labels.Labels) bool {
|
func (p *NhcbParser) handleClassicHistogramSeries(lset labels.Labels) bool {
|
||||||
mName := lset.Get(labels.MetricName)
|
mName := lset.Get(labels.MetricName)
|
||||||
if convertnhcb.GetHistogramMetricBaseName(mName) == p.lastNativeHistName {
|
if convertnhcb.GetHistogramMetricBaseName(mName) == p.lastNativeHistName {
|
||||||
|
@ -151,6 +163,8 @@ func (p *NhcbParser) processClassicHistogramSeries(lset labels.Labels, suffix st
|
||||||
updateHist(&p.tempNhcb)
|
updateHist(&p.tempNhcb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// processNhcb converts the collated classic histogram series to NHCB and caches the info
|
||||||
|
// to be returned to callers.
|
||||||
func (p *NhcbParser) processNhcb(th convertnhcb.TempHistogram) bool {
|
func (p *NhcbParser) processNhcb(th convertnhcb.TempHistogram) bool {
|
||||||
if len(th.BucketCounts) == 0 {
|
if len(th.BucketCounts) == 0 {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in a new issue