Merge pull request #282 from alexgridx/dependabot/go_modules/github.com/prometheus/common-0.61.0

Bump github.com/prometheus/common from 0.60.0 to 0.61.0
This commit is contained in:
Alex 2025-01-16 12:24:18 +01:00 committed by GitHub
commit 12982296e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 44 additions and 47 deletions

2
go.mod
View file

@ -44,7 +44,7 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect github.com/prometheus/common v0.61.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect github.com/yuin/gopher-lua v1.1.1 // indirect
golang.org/x/sys v0.29.0 // indirect golang.org/x/sys v0.29.0 // indirect

8
go.sum
View file

@ -94,16 +94,16 @@ github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA= github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ=
github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=

View file

@ -68,7 +68,7 @@ func Negotiate(h http.Header) Format {
if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" { if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" {
switch Format(escapeParam) { switch Format(escapeParam) {
case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues: case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
escapingScheme = Format(fmt.Sprintf("; escaping=%s", escapeParam)) escapingScheme = Format("; escaping=" + escapeParam)
default: default:
// If the escaping parameter is unknown, ignore it. // If the escaping parameter is unknown, ignore it.
} }
@ -101,7 +101,7 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" { if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" {
switch Format(escapeParam) { switch Format(escapeParam) {
case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues: case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
escapingScheme = Format(fmt.Sprintf("; escaping=%s", escapeParam)) escapingScheme = Format("; escaping=" + escapeParam)
default: default:
// If the escaping parameter is unknown, ignore it. // If the escaping parameter is unknown, ignore it.
} }

View file

@ -15,7 +15,7 @@
package expfmt package expfmt
import ( import (
"fmt" "errors"
"strings" "strings"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
@ -109,7 +109,7 @@ func NewOpenMetricsFormat(version string) (Format, error) {
if version == OpenMetricsVersion_1_0_0 { if version == OpenMetricsVersion_1_0_0 {
return FmtOpenMetrics_1_0_0, nil return FmtOpenMetrics_1_0_0, nil
} }
return FmtUnknown, fmt.Errorf("unknown open metrics version string") return FmtUnknown, errors.New("unknown open metrics version string")
} }
// WithEscapingScheme returns a copy of Format with the specified escaping // WithEscapingScheme returns a copy of Format with the specified escaping

View file

@ -152,8 +152,8 @@ func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily, options ...E
if metricType == dto.MetricType_COUNTER && strings.HasSuffix(compliantName, "_total") { if metricType == dto.MetricType_COUNTER && strings.HasSuffix(compliantName, "_total") {
compliantName = name[:len(name)-6] compliantName = name[:len(name)-6]
} }
if toOM.withUnit && in.Unit != nil && !strings.HasSuffix(compliantName, fmt.Sprintf("_%s", *in.Unit)) { if toOM.withUnit && in.Unit != nil && !strings.HasSuffix(compliantName, "_"+*in.Unit) {
compliantName = compliantName + fmt.Sprintf("_%s", *in.Unit) compliantName = compliantName + "_" + *in.Unit
} }
// Comments, first HELP, then TYPE. // Comments, first HELP, then TYPE.

View file

@ -895,7 +895,7 @@ func histogramMetricName(name string) string {
func parseFloat(s string) (float64, error) { func parseFloat(s string) (float64, error) {
if strings.ContainsAny(s, "pP_") { if strings.ContainsAny(s, "pP_") {
return 0, fmt.Errorf("unsupported character in float") return 0, errors.New("unsupported character in float")
} }
return strconv.ParseFloat(s, 64) return strconv.ParseFloat(s, 64)
} }

View file

@ -14,6 +14,7 @@
package model package model
import ( import (
"errors"
"fmt" "fmt"
"time" "time"
) )
@ -89,16 +90,16 @@ func (a *Alert) StatusAt(ts time.Time) AlertStatus {
// Validate checks whether the alert data is inconsistent. // Validate checks whether the alert data is inconsistent.
func (a *Alert) Validate() error { func (a *Alert) Validate() error {
if a.StartsAt.IsZero() { if a.StartsAt.IsZero() {
return fmt.Errorf("start time missing") return errors.New("start time missing")
} }
if !a.EndsAt.IsZero() && a.EndsAt.Before(a.StartsAt) { if !a.EndsAt.IsZero() && a.EndsAt.Before(a.StartsAt) {
return fmt.Errorf("start time must be before end time") return errors.New("start time must be before end time")
} }
if err := a.Labels.Validate(); err != nil { if err := a.Labels.Validate(); err != nil {
return fmt.Errorf("invalid label set: %w", err) return fmt.Errorf("invalid label set: %w", err)
} }
if len(a.Labels) == 0 { if len(a.Labels) == 0 {
return fmt.Errorf("at least one label pair required") return errors.New("at least one label pair required")
} }
if err := a.Annotations.Validate(); err != nil { if err := a.Annotations.Validate(); err != nil {
return fmt.Errorf("invalid annotations: %w", err) return fmt.Errorf("invalid annotations: %w", err)

View file

@ -14,9 +14,11 @@
package model package model
import ( import (
"errors"
"fmt" "fmt"
"regexp" "regexp"
"sort" "sort"
"strconv"
"strings" "strings"
"unicode/utf8" "unicode/utf8"
@ -269,10 +271,6 @@ func metricNeedsEscaping(m *dto.Metric) bool {
return false return false
} }
const (
lowerhex = "0123456789abcdef"
)
// EscapeName escapes the incoming name according to the provided escaping // EscapeName escapes the incoming name according to the provided escaping
// scheme. Depending on the rules of escaping, this may cause no change in the // scheme. Depending on the rules of escaping, this may cause no change in the
// string that is returned. (Especially NoEscaping, which by definition is a // string that is returned. (Especially NoEscaping, which by definition is a
@ -307,7 +305,7 @@ func EscapeName(name string, scheme EscapingScheme) string {
} else if isValidLegacyRune(b, i) { } else if isValidLegacyRune(b, i) {
escaped.WriteRune(b) escaped.WriteRune(b)
} else { } else {
escaped.WriteRune('_') escaped.WriteString("__")
} }
} }
return escaped.String() return escaped.String()
@ -317,21 +315,15 @@ func EscapeName(name string, scheme EscapingScheme) string {
} }
escaped.WriteString("U__") escaped.WriteString("U__")
for i, b := range name { for i, b := range name {
if isValidLegacyRune(b, i) { if b == '_' {
escaped.WriteString("__")
} else if isValidLegacyRune(b, i) {
escaped.WriteRune(b) escaped.WriteRune(b)
} else if !utf8.ValidRune(b) { } else if !utf8.ValidRune(b) {
escaped.WriteString("_FFFD_") escaped.WriteString("_FFFD_")
} else if b < 0x100 { } else {
escaped.WriteRune('_') escaped.WriteRune('_')
for s := 4; s >= 0; s -= 4 { escaped.WriteString(strconv.FormatInt(int64(b), 16))
escaped.WriteByte(lowerhex[b>>uint(s)&0xF])
}
escaped.WriteRune('_')
} else if b < 0x10000 {
escaped.WriteRune('_')
for s := 12; s >= 0; s -= 4 {
escaped.WriteByte(lowerhex[b>>uint(s)&0xF])
}
escaped.WriteRune('_') escaped.WriteRune('_')
} }
} }
@ -389,8 +381,9 @@ func UnescapeName(name string, scheme EscapingScheme) string {
// We think we are in a UTF-8 code, process it. // We think we are in a UTF-8 code, process it.
var utf8Val uint var utf8Val uint
for j := 0; i < len(escapedName); j++ { for j := 0; i < len(escapedName); j++ {
// This is too many characters for a utf8 value. // This is too many characters for a utf8 value based on the MaxRune
if j > 4 { // value of '\U0010FFFF'.
if j >= 6 {
return name return name
} }
// Found a closing underscore, convert to a rune, check validity, and append. // Found a closing underscore, convert to a rune, check validity, and append.
@ -443,7 +436,7 @@ func (e EscapingScheme) String() string {
func ToEscapingScheme(s string) (EscapingScheme, error) { func ToEscapingScheme(s string) (EscapingScheme, error) {
if s == "" { if s == "" {
return NoEscaping, fmt.Errorf("got empty string instead of escaping scheme") return NoEscaping, errors.New("got empty string instead of escaping scheme")
} }
switch s { switch s {
case AllowUTF8: case AllowUTF8:

View file

@ -15,6 +15,7 @@ package model
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"regexp" "regexp"
"time" "time"
@ -34,7 +35,7 @@ func (m *Matcher) UnmarshalJSON(b []byte) error {
} }
if len(m.Name) == 0 { if len(m.Name) == 0 {
return fmt.Errorf("label name in matcher must not be empty") return errors.New("label name in matcher must not be empty")
} }
if m.IsRegex { if m.IsRegex {
if _, err := regexp.Compile(m.Value); err != nil { if _, err := regexp.Compile(m.Value); err != nil {
@ -77,7 +78,7 @@ type Silence struct {
// Validate returns true iff all fields of the silence have valid values. // Validate returns true iff all fields of the silence have valid values.
func (s *Silence) Validate() error { func (s *Silence) Validate() error {
if len(s.Matchers) == 0 { if len(s.Matchers) == 0 {
return fmt.Errorf("at least one matcher required") return errors.New("at least one matcher required")
} }
for _, m := range s.Matchers { for _, m := range s.Matchers {
if err := m.Validate(); err != nil { if err := m.Validate(); err != nil {
@ -85,22 +86,22 @@ func (s *Silence) Validate() error {
} }
} }
if s.StartsAt.IsZero() { if s.StartsAt.IsZero() {
return fmt.Errorf("start time missing") return errors.New("start time missing")
} }
if s.EndsAt.IsZero() { if s.EndsAt.IsZero() {
return fmt.Errorf("end time missing") return errors.New("end time missing")
} }
if s.EndsAt.Before(s.StartsAt) { if s.EndsAt.Before(s.StartsAt) {
return fmt.Errorf("start time must be before end time") return errors.New("start time must be before end time")
} }
if s.CreatedBy == "" { if s.CreatedBy == "" {
return fmt.Errorf("creator information missing") return errors.New("creator information missing")
} }
if s.Comment == "" { if s.Comment == "" {
return fmt.Errorf("comment missing") return errors.New("comment missing")
} }
if s.CreatedAt.IsZero() { if s.CreatedAt.IsZero() {
return fmt.Errorf("creation timestamp missing") return errors.New("creation timestamp missing")
} }
return nil return nil
} }

View file

@ -15,6 +15,7 @@ package model
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
@ -39,7 +40,7 @@ func (v SampleValue) MarshalJSON() ([]byte, error) {
// UnmarshalJSON implements json.Unmarshaler. // UnmarshalJSON implements json.Unmarshaler.
func (v *SampleValue) UnmarshalJSON(b []byte) error { func (v *SampleValue) UnmarshalJSON(b []byte) error {
if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' {
return fmt.Errorf("sample value must be a quoted string") return errors.New("sample value must be a quoted string")
} }
f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64)
if err != nil { if err != nil {

View file

@ -15,6 +15,7 @@ package model
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
@ -32,7 +33,7 @@ func (v FloatString) MarshalJSON() ([]byte, error) {
func (v *FloatString) UnmarshalJSON(b []byte) error { func (v *FloatString) UnmarshalJSON(b []byte) error {
if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' {
return fmt.Errorf("float value must be a quoted string") return errors.New("float value must be a quoted string")
} }
f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64) f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64)
if err != nil { if err != nil {
@ -141,7 +142,7 @@ type SampleHistogramPair struct {
func (s SampleHistogramPair) MarshalJSON() ([]byte, error) { func (s SampleHistogramPair) MarshalJSON() ([]byte, error) {
if s.Histogram == nil { if s.Histogram == nil {
return nil, fmt.Errorf("histogram is nil") return nil, errors.New("histogram is nil")
} }
t, err := json.Marshal(s.Timestamp) t, err := json.Marshal(s.Timestamp)
if err != nil { if err != nil {
@ -164,7 +165,7 @@ func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error {
return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen) return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen)
} }
if s.Histogram == nil { if s.Histogram == nil {
return fmt.Errorf("histogram is null") return errors.New("histogram is null")
} }
return nil return nil
} }

2
vendor/modules.txt vendored
View file

@ -181,7 +181,7 @@ github.com/prometheus/client_golang/prometheus/internal
# github.com/prometheus/client_model v0.6.1 # github.com/prometheus/client_model v0.6.1
## explicit; go 1.19 ## explicit; go 1.19
github.com/prometheus/client_model/go github.com/prometheus/client_model/go
# github.com/prometheus/common v0.60.0 # github.com/prometheus/common v0.61.0
## explicit; go 1.21 ## explicit; go 1.21
github.com/prometheus/common/expfmt github.com/prometheus/common/expfmt
github.com/prometheus/common/model github.com/prometheus/common/model