Skip to content

Commit

Permalink
Raise exemplar labels limit from 64 to 128 (#1091)
Browse files Browse the repository at this point in the history
In line with the OpenMetrics spec:
"The combined length of the label names and values of an Exemplar's
LabelSet MUST NOT exceed 128 UTF-8 character code points"

https://github.com/OpenObservability/OpenMetrics/blob/98ae26c87b/specification/OpenMetrics.md#exemplars

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
  • Loading branch information
bboreham committed Jul 19, 2022
1 parent 3d482bb commit ba4a543
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion prometheus/counter_test.go
Expand Up @@ -16,6 +16,7 @@ package prometheus
import (
"fmt"
"math"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -262,10 +263,11 @@ func TestCounterExemplar(t *testing.T) {
err = e.(error)
}
}()
// Should panic because of 65 runes.
// Should panic because of 129 runes.
counter.AddWithExemplar(42, Labels{
"abcdefghijklmnopqrstuvwxyz": "26+16 characters",
"x1234567": "8+15 characters",
"z": strings.Repeat("x", 63),
})
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion prometheus/value.go
Expand Up @@ -200,7 +200,7 @@ func MakeLabelPairs(desc *Desc, labelValues []string) []*dto.LabelPair {
}

// ExemplarMaxRunes is the max total number of runes allowed in exemplar labels.
const ExemplarMaxRunes = 64
const ExemplarMaxRunes = 128

// newExemplar creates a new dto.Exemplar from the provided values. An error is
// returned if any of the label names or values are invalid or if the total
Expand Down

0 comments on commit ba4a543

Please sign in to comment.