Browse Source

validate exemplar labelSet length first (#8816)

* ignore check exemplar labelSet length when append

Signed-off-by: XiaoYu Zhang <ideoutrea@163.com>

* validate exemplar labelSet length firstly

Signed-off-by: XiaoYu Zhang <ideoutrea@163.com>
pull/6671/head
ide-rea 4 years ago committed by GitHub
parent
commit
277bac622a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      tsdb/exemplar.go

16
tsdb/exemplar.go

@ -176,16 +176,11 @@ func (ce *CircularExemplarStorage) ValidateExemplar(l labels.Labels, e exemplar.
return ce.validateExemplar(seriesLabels, e, false)
}
// Not thread safe. The append parameters tells us whether this is an external validation, or interal
// as a reuslt of an AddExemplar call, in which case we should update any relevant metrics.
// Not thread safe. The append parameters tells us whether this is an external validation, or internal
// as a result of an AddExemplar call, in which case we should update any relevant metrics.
func (ce *CircularExemplarStorage) validateExemplar(l string, e exemplar.Exemplar, append bool) error {
idx, ok := ce.index[l]
if !ok {
return nil
}
// Exemplar label length does not include chars involved in text rendering such as quotes
// equals sign, or commas. See definiton of const ExemplarMaxLabelLength.
// equals sign, or commas. See definition of const ExemplarMaxLabelLength.
labelSetLen := 0
for _, l := range e.Labels {
labelSetLen += utf8.RuneCountInString(l.Name)
@ -196,6 +191,11 @@ func (ce *CircularExemplarStorage) validateExemplar(l string, e exemplar.Exempla
}
}
idx, ok := ce.index[l]
if !ok {
return nil
}
// Check for duplicate vs last stored exemplar for this series.
// NB these are expected, and appending them is a no-op.
if ce.exemplars[idx.newest].exemplar.Equals(e) {

Loading…
Cancel
Save