mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -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
|
||||
// a classic histogram) so we can tell if the next float series
|
||||
// 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 {
|
||||
|
@ -192,7 +194,7 @@ func (p *NHCBParser) Next() (Entry, error) {
|
|||
// Update the stored labels if the labels have changed.
|
||||
func (p *NHCBParser) compareLabels() bool {
|
||||
// Collection not in progress.
|
||||
if p.lastBaseHistLabels.IsEmpty() {
|
||||
if p.lastHistogramName == "" {
|
||||
if p.typ == model.MetricTypeHistogram {
|
||||
p.storeBaseLabels()
|
||||
}
|
||||
|
@ -200,19 +202,17 @@ func (p *NHCBParser) compareLabels() bool {
|
|||
}
|
||||
if p.typ != model.MetricTypeHistogram {
|
||||
// Different metric type, emit the NHCB.
|
||||
p.lastBaseHistLabels = labels.EmptyLabels()
|
||||
p.lastHistogramName = ""
|
||||
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.
|
||||
p.storeBaseLabels()
|
||||
return true
|
||||
}
|
||||
var buf []byte
|
||||
lastHash, _ := p.lastBaseHistLabels.HashWithoutLabels(buf) // We removed the bucket label in storeBaseLabels.
|
||||
nextHash, _ := p.lset.HashWithoutLabels(buf, labels.BucketLabel)
|
||||
if lastHash != nextHash {
|
||||
nextHash, _ := p.lset.HashWithoutLabels(p.hBuffer, labels.BucketLabel)
|
||||
if p.lastHistogramLabelsHash != nextHash {
|
||||
// Different label values.
|
||||
p.storeBaseLabels()
|
||||
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.
|
||||
func (p *NHCBParser) storeBaseLabels() {
|
||||
p.builder.Reset()
|
||||
p.lset.Range(func(l labels.Label) {
|
||||
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()
|
||||
p.lastHistogramName = convertnhcb.GetHistogramMetricBaseName(p.lset.Get(labels.MetricName))
|
||||
p.lastHistogramLabelsHash, _ = p.lset.HashWithoutLabels(p.hBuffer, labels.BucketLabel)
|
||||
}
|
||||
|
||||
// handleClassicHistogramSeries collates the classic histogram series to be converted to NHCB
|
||||
|
|
Loading…
Reference in a new issue