vendor: update metrics package to v1.40.1 (#9725)

### Describe Your Changes

Includes fix https://github.com/VictoriaMetrics/metrics/pull/99

### Checklist

The following checks are **mandatory**:

- [ ] My change adheres to [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/victoriametrics/contributing/#pull-request-checklist).
- [ ] My change adheres to [VictoriaMetrics development
goals](https://docs.victoriametrics.com/victoriametrics/goals/).
This commit is contained in:
Max Kotliar
2025-09-12 14:14:49 +03:00
committed by GitHub
parent 2a1b3866e1
commit 367cdb089f
8 changed files with 58 additions and 12 deletions

View File

@@ -35,6 +35,8 @@ See also [LTS releases](https://docs.victoriametrics.com/victoriametrics/lts-rel
* BUGFIX: [vmui](https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#vmui): properly apply rollup functions to metrics based on their name in vmui's [metrics explorer](https://docs.victoriametrics.com/victoriametrics/#metrics-explorer). See [#9655](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9655) for details. Thanks to @wbwren-eric for the fix.
* BUGFIX: all VictoriaMetrics [enterprise](https://docs.victoriametrics.com/enterprise/) components: fix support for automatic issuing of TLS certificates for HTTPS server via [Let's Encrypt service](https://letsencrypt.org/) using [TLS-ALPN-01 challenge](https://letsencrypt.org/docs/challenge-types/#tls-alpn-01). See [Automatic issuing of TLS certificates](https://docs.victoriametrics.com/victoriametrics/#automatic-issuing-of-tls-certificates) for more info.
* BUGFIX: [vmui](https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#vmui): fix VMUI backend URL, while using multitenant API. See more in [#9703](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/9703).
* BUGFIX: all components: properly expose metadata for summaries and histograms in VictoriaMetrics components with enabled `-metrics.exposeMetadata` cmd-line flag. See [metrics#98](https://github.com/VictoriaMetrics/metrics/issues/98) for details.
* BUGFIX: all components: lower severity of the log message for unavailable [Pressure Stall Information (PSI)](https://docs.kernel.org/accounting/psi.html) metrics from `ERROR` to `INFO` level. See [#9161](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/9161) for details.
## [v1.125.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.125.1)

2
go.mod
View File

@@ -29,7 +29,7 @@ require (
github.com/VictoriaMetrics/VictoriaLogs v0.0.0-20250728123024-98593029b5aa
github.com/VictoriaMetrics/easyproto v0.1.4
github.com/VictoriaMetrics/fastcache v1.13.0
github.com/VictoriaMetrics/metrics v1.39.1
github.com/VictoriaMetrics/metrics v1.40.1
github.com/VictoriaMetrics/metricsql v0.84.8
github.com/aws/aws-sdk-go-v2 v1.37.1
github.com/aws/aws-sdk-go-v2/config v1.30.2

2
go.sum
View File

@@ -60,6 +60,8 @@ github.com/VictoriaMetrics/fastcache v1.13.0 h1:AW4mheMR5Vd9FkAPUv+NH6Nhw+fmbTMG
github.com/VictoriaMetrics/fastcache v1.13.0/go.mod h1:hHXhl4DA2fTL2HTZDJFXWgW0LNjo6B+4aj2Wmng3TjU=
github.com/VictoriaMetrics/metrics v1.39.1 h1:AT7jz7oSpAK9phDl5O5Tmy06nXnnzALwqVnf4ros3Ow=
github.com/VictoriaMetrics/metrics v1.39.1/go.mod h1:XE4uudAAIRaJE614Tl5HMrtoEU6+GDZO4QTnNSsZRuA=
github.com/VictoriaMetrics/metrics v1.40.1 h1:FrF5uJRpIVj9fayWcn8xgiI+FYsKGMslzPuOXjdeyR4=
github.com/VictoriaMetrics/metrics v1.40.1/go.mod h1:XE4uudAAIRaJE614Tl5HMrtoEU6+GDZO4QTnNSsZRuA=
github.com/VictoriaMetrics/metricsql v0.84.7 h1:zMONjtEULMbwEYU/qL4Hkc3GDfTTrv1bO+a9lmJf3do=
github.com/VictoriaMetrics/metricsql v0.84.7/go.mod h1:d4EisFO6ONP/HIGDYTAtwrejJBBeKGQYiRl095bS4QQ=
github.com/VictoriaMetrics/metricsql v0.84.8 h1:5JXrvPJiYkYNqJVT7+hMZmpAwRHd3txBdlVIw4rJ1VM=

View File

@@ -338,6 +338,10 @@ func WriteMetadataIfNeeded(w io.Writer, metricName, metricType string) {
return
}
metricFamily := getMetricFamily(metricName)
writeMetadata(w, metricFamily, metricType)
}
func writeMetadata(w io.Writer, metricFamily, metricType string) {
fmt.Fprintf(w, "# HELP %s\n", metricFamily)
fmt.Fprintf(w, "# TYPE %s %s\n", metricFamily, metricType)
}

View File

@@ -240,7 +240,6 @@ func writeProcessMemMetrics(w io.Writer) {
WriteGaugeUint64(w, "process_resident_memory_anon_bytes", ms.rssAnon)
WriteGaugeUint64(w, "process_resident_memory_file_bytes", ms.rssFile)
WriteGaugeUint64(w, "process_resident_memory_shared_bytes", ms.rssShmem)
}
func getMemStats(path string) (*memStats, error) {
@@ -321,7 +320,7 @@ func psiTotalSecs(microsecs uint64) float64 {
var psiMetricsStart = func() *psiMetrics {
m, err := getPSIMetrics()
if err != nil {
log.Printf("ERROR: metrics: disable exposing PSI metrics because of failed init: %s", err)
log.Printf("INFO: metrics: disable exposing PSI metrics because of failed init: %s", err)
return nil
}
return m

View File

@@ -37,6 +37,25 @@ func (s *Set) WritePrometheus(w io.Writer) {
// Collect all the metrics in in-memory buffer in order to prevent from long locking due to slow w.
var bb bytes.Buffer
lessFunc := func(i, j int) bool {
// the sorting must be stable.
// see edge cases why we can't simply do `s.a[i].name < s.a[j].name` here:
// https://github.com/VictoriaMetrics/metrics/pull/99#issuecomment-3277072175
// sort by metric family name first, to group the same metric family in one place.
fName1, fName2 := getMetricFamily(s.a[i].name), getMetricFamily(s.a[j].name)
if fName1 != fName2 {
return fName1 < fName2
}
mType1 := s.a[i].metric.metricType()
mType2 := s.a[j].metric.metricType()
// stabilize the order for summary and quantiles.
if mType1 != mType2 {
return mType1 < mType2
}
// lastly by metric names, which is for quantiles and histogram buckets.
return s.a[i].name < s.a[j].name
}
s.mu.Lock()
@@ -50,18 +69,34 @@ func (s *Set) WritePrometheus(w io.Writer) {
metricsWriters := s.metricsWriters
s.mu.Unlock()
prevMetricFamily := ""
// metricsWithMetadataBuf is used to hold marshalTo temporary, and decide whether metadata is needed.
// it will be written to `bb` at the end and then reset for next *namedMetric in for-loop.
var metricsWithMetadataBuf bytes.Buffer
var prevMetricFamily string
for _, nm := range sa {
metricFamily := getMetricFamily(nm.name)
if metricFamily != prevMetricFamily {
// write meta info only once per metric family
metricType := nm.metric.metricType()
WriteMetadataIfNeeded(&bb, nm.name, metricType)
prevMetricFamily = metricFamily
if !isMetadataEnabled() {
// Call marshalTo without the global lock, since certain metric types such as Gauge
// can call a callback, which, in turn, can try calling s.mu.Lock again.
nm.metric.marshalTo(nm.name, &bb)
continue
}
metricsWithMetadataBuf.Reset()
// Call marshalTo without the global lock, since certain metric types such as Gauge
// can call a callback, which, in turn, can try calling s.mu.Lock again.
nm.metric.marshalTo(nm.name, &bb)
nm.metric.marshalTo(nm.name, &metricsWithMetadataBuf)
if metricsWithMetadataBuf.Len() == 0 {
continue
}
metricFamily := getMetricFamily(nm.name)
if metricFamily != prevMetricFamily {
// write metadata only once per metric family
metricType := nm.metric.metricType()
writeMetadata(&bb, metricFamily, metricType)
prevMetricFamily = metricFamily
}
bb.Write(metricsWithMetadataBuf.Bytes())
}
w.Write(bb.Bytes())

View File

@@ -201,6 +201,10 @@ func (qv *quantileValue) marshalTo(prefix string, w io.Writer) {
}
func (qv *quantileValue) metricType() string {
// this metricsType should not be printed, because summary (sum and count) of the same metric family will be printed first,
// and if metadata is needed, the metadata from summary should be used.
// quantile will be printed later, so its metrics type won't be printed as metadata.
// See: https://github.com/VictoriaMetrics/metrics/pull/99
return "unsupported"
}

2
vendor/modules.txt vendored
View File

@@ -139,7 +139,7 @@ github.com/VictoriaMetrics/easyproto
# github.com/VictoriaMetrics/fastcache v1.13.0
## explicit; go 1.24.0
github.com/VictoriaMetrics/fastcache
# github.com/VictoriaMetrics/metrics v1.39.1
# github.com/VictoriaMetrics/metrics v1.40.1
## explicit; go 1.18
github.com/VictoriaMetrics/metrics
# github.com/VictoriaMetrics/metricsql v0.84.8