mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 06:29:42 -08:00
Use labels hash to determine change in metric like CT
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (0) (push) Has been cancelled
CI / Build Prometheus for common architectures (1) (push) Has been cancelled
CI / Build Prometheus for common architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (0) (push) Has been cancelled
CI / Build Prometheus for all architectures (1) (push) Has been cancelled
CI / Build Prometheus for all architectures (10) (push) Has been cancelled
CI / Build Prometheus for all architectures (11) (push) Has been cancelled
CI / Build Prometheus for all architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (3) (push) Has been cancelled
CI / Build Prometheus for all architectures (4) (push) Has been cancelled
CI / Build Prometheus for all architectures (5) (push) Has been cancelled
CI / Build Prometheus for all architectures (6) (push) Has been cancelled
CI / Build Prometheus for all architectures (7) (push) Has been cancelled
CI / Build Prometheus for all architectures (8) (push) Has been cancelled
CI / Build Prometheus for all architectures (9) (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (0) (push) Has been cancelled
CI / Build Prometheus for common architectures (1) (push) Has been cancelled
CI / Build Prometheus for common architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (0) (push) Has been cancelled
CI / Build Prometheus for all architectures (1) (push) Has been cancelled
CI / Build Prometheus for all architectures (10) (push) Has been cancelled
CI / Build Prometheus for all architectures (11) (push) Has been cancelled
CI / Build Prometheus for all architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (3) (push) Has been cancelled
CI / Build Prometheus for all architectures (4) (push) Has been cancelled
CI / Build Prometheus for all architectures (5) (push) Has been cancelled
CI / Build Prometheus for all architectures (6) (push) Has been cancelled
CI / Build Prometheus for all architectures (7) (push) Has been cancelled
CI / Build Prometheus for all architectures (8) (push) Has been cancelled
CI / Build Prometheus for all architectures (9) (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
This commit is contained in:
parent
14f92319d9
commit
9b5d7287bb
|
@ -75,7 +75,9 @@ type NHCBParser struct {
|
||||||
// Remembers the last base histogram metric name (assuming it's
|
// Remembers the last base histogram metric name (assuming it's
|
||||||
// a classic histogram) so we can tell if the next float series
|
// a classic histogram) so we can tell if the next float series
|
||||||
// is part of the same classic histogram.
|
// is part of the same classic histogram.
|
||||||
lastBaseHistLabels labels.Labels
|
lastHistogramName string
|
||||||
|
lastHistogramLabelsHash uint64
|
||||||
|
hBuffer []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNHCBParser(p Parser, st *labels.SymbolTable, keepClassicHistograms bool) Parser {
|
func NewNHCBParser(p Parser, st *labels.SymbolTable, keepClassicHistograms bool) Parser {
|
||||||
|
@ -192,7 +194,7 @@ func (p *NHCBParser) Next() (Entry, error) {
|
||||||
// Update the stored labels if the labels have changed.
|
// Update the stored labels if the labels have changed.
|
||||||
func (p *NHCBParser) compareLabels() bool {
|
func (p *NHCBParser) compareLabels() bool {
|
||||||
// Collection not in progress.
|
// Collection not in progress.
|
||||||
if p.lastBaseHistLabels.IsEmpty() {
|
if p.lastHistogramName == "" {
|
||||||
if p.typ == model.MetricTypeHistogram {
|
if p.typ == model.MetricTypeHistogram {
|
||||||
p.storeBaseLabels()
|
p.storeBaseLabels()
|
||||||
}
|
}
|
||||||
|
@ -200,19 +202,17 @@ func (p *NHCBParser) compareLabels() bool {
|
||||||
}
|
}
|
||||||
if p.typ != model.MetricTypeHistogram {
|
if p.typ != model.MetricTypeHistogram {
|
||||||
// Different metric type, emit the NHCB.
|
// Different metric type, emit the NHCB.
|
||||||
p.lastBaseHistLabels = labels.EmptyLabels()
|
p.lastHistogramName = ""
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.lastBaseHistLabels.Get(labels.MetricName) != convertnhcb.GetHistogramMetricBaseName(p.lset.Get(labels.MetricName)) {
|
if p.lastHistogramName != convertnhcb.GetHistogramMetricBaseName(p.lset.Get(labels.MetricName)) {
|
||||||
// Different metric name.
|
// Different metric name.
|
||||||
p.storeBaseLabels()
|
p.storeBaseLabels()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
var buf []byte
|
nextHash, _ := p.lset.HashWithoutLabels(p.hBuffer, labels.BucketLabel)
|
||||||
lastHash, _ := p.lastBaseHistLabels.HashWithoutLabels(buf) // We removed the bucket label in storeBaseLabels.
|
if p.lastHistogramLabelsHash != nextHash {
|
||||||
nextHash, _ := p.lset.HashWithoutLabels(buf, labels.BucketLabel)
|
|
||||||
if lastHash != nextHash {
|
|
||||||
// Different label values.
|
// Different label values.
|
||||||
p.storeBaseLabels()
|
p.storeBaseLabels()
|
||||||
return true
|
return true
|
||||||
|
@ -223,18 +223,8 @@ func (p *NHCBParser) compareLabels() bool {
|
||||||
|
|
||||||
// Save the label set of the classic histogram without suffix and bucket `le` label.
|
// Save the label set of the classic histogram without suffix and bucket `le` label.
|
||||||
func (p *NHCBParser) storeBaseLabels() {
|
func (p *NHCBParser) storeBaseLabels() {
|
||||||
p.builder.Reset()
|
p.lastHistogramName = convertnhcb.GetHistogramMetricBaseName(p.lset.Get(labels.MetricName))
|
||||||
p.lset.Range(func(l labels.Label) {
|
p.lastHistogramLabelsHash, _ = p.lset.HashWithoutLabels(p.hBuffer, labels.BucketLabel)
|
||||||
switch {
|
|
||||||
case l.Name == labels.BucketLabel:
|
|
||||||
case l.Name == labels.MetricName:
|
|
||||||
p.builder.Add(l.Name, convertnhcb.GetHistogramMetricBaseName(l.Value))
|
|
||||||
default:
|
|
||||||
p.builder.Add(l.Name, l.Value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// Note: we don't sort the labels as changing the name label value doesn't affect sorting.
|
|
||||||
p.lastBaseHistLabels = p.builder.Labels()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleClassicHistogramSeries collates the classic histogram series to be converted to NHCB
|
// handleClassicHistogramSeries collates the classic histogram series to be converted to NHCB
|
||||||
|
|
Loading…
Reference in a new issue