From ba4a543ab417498535a9ff5f31b46d2b128b8079 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 19 Jul 2022 15:50:45 +0100 Subject: [PATCH] Raise exemplar labels limit from 64 to 128 (#1091) 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 --- prometheus/counter_test.go | 4 +++- prometheus/value.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/prometheus/counter_test.go b/prometheus/counter_test.go index 40ba427..9398e28 100644 --- a/prometheus/counter_test.go +++ b/prometheus/counter_test.go @@ -16,6 +16,7 @@ package prometheus import ( "fmt" "math" + "strings" "testing" "time" @@ -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 } diff --git a/prometheus/value.go b/prometheus/value.go index 2dfa659..2d3abc1 100644 --- a/prometheus/value.go +++ b/prometheus/value.go @@ -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