build(deps): bump github.com/prometheus/client_golang
Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.19.1 to 1.20.1. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/v1.20.1/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.19.1...v1.20.1) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
7b948faa08
commit
1195b68eb2
2
go.mod
2
go.mod
@ -55,7 +55,7 @@ require (
|
|||||||
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626
|
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626
|
||||||
github.com/opencontainers/selinux v1.11.0
|
github.com/opencontainers/selinux v1.11.0
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2
|
github.com/pelletier/go-toml/v2 v2.2.2
|
||||||
github.com/prometheus/client_golang v1.19.1
|
github.com/prometheus/client_golang v1.20.1
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
github.com/tchap/go-patricia/v2 v2.3.1
|
github.com/tchap/go-patricia/v2 v2.3.1
|
||||||
|
6
go.sum
6
go.sum
@ -195,6 +195,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
|||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
|
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
@ -263,8 +265,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
|
|||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||||
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
|
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
|
||||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8=
|
||||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
5
vendor/github.com/prometheus/client_golang/NOTICE
generated
vendored
5
vendor/github.com/prometheus/client_golang/NOTICE
generated
vendored
@ -16,8 +16,3 @@ Go support for Protocol Buffers - Google's data interchange format
|
|||||||
http://github.com/golang/protobuf/
|
http://github.com/golang/protobuf/
|
||||||
Copyright 2010 The Go Authors
|
Copyright 2010 The Go Authors
|
||||||
See source code for license details.
|
See source code for license details.
|
||||||
|
|
||||||
Support for streaming Protocol Buffer messages for the Go language (golang).
|
|
||||||
https://github.com/matttproud/golang_protobuf_extensions
|
|
||||||
Copyright 2013 Matt T. Proud
|
|
||||||
Licensed under the Apache License, Version 2.0
|
|
||||||
|
27
vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/LICENSE
generated
vendored
Normal file
27
vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/LICENSE
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Copyright (c) 2013 The Go Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
145
vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header/header.go
generated
vendored
Normal file
145
vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header/header.go
generated
vendored
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file or at
|
||||||
|
// https://developers.google.com/open-source/licenses/bsd.
|
||||||
|
|
||||||
|
// Package header provides functions for parsing HTTP headers.
|
||||||
|
package header
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Octet types from RFC 2616.
|
||||||
|
var octetTypes [256]octetType
|
||||||
|
|
||||||
|
type octetType byte
|
||||||
|
|
||||||
|
const (
|
||||||
|
isToken octetType = 1 << iota
|
||||||
|
isSpace
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// OCTET = <any 8-bit sequence of data>
|
||||||
|
// CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||||
|
// CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
|
||||||
|
// CR = <US-ASCII CR, carriage return (13)>
|
||||||
|
// LF = <US-ASCII LF, linefeed (10)>
|
||||||
|
// SP = <US-ASCII SP, space (32)>
|
||||||
|
// HT = <US-ASCII HT, horizontal-tab (9)>
|
||||||
|
// <"> = <US-ASCII double-quote mark (34)>
|
||||||
|
// CRLF = CR LF
|
||||||
|
// LWS = [CRLF] 1*( SP | HT )
|
||||||
|
// TEXT = <any OCTET except CTLs, but including LWS>
|
||||||
|
// separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <">
|
||||||
|
// | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT
|
||||||
|
// token = 1*<any CHAR except CTLs or separators>
|
||||||
|
// qdtext = <any TEXT except <">>
|
||||||
|
|
||||||
|
for c := 0; c < 256; c++ {
|
||||||
|
var t octetType
|
||||||
|
isCtl := c <= 31 || c == 127
|
||||||
|
isChar := 0 <= c && c <= 127
|
||||||
|
isSeparator := strings.ContainsRune(" \t\"(),/:;<=>?@[]\\{}", rune(c))
|
||||||
|
if strings.ContainsRune(" \t\r\n", rune(c)) {
|
||||||
|
t |= isSpace
|
||||||
|
}
|
||||||
|
if isChar && !isCtl && !isSeparator {
|
||||||
|
t |= isToken
|
||||||
|
}
|
||||||
|
octetTypes[c] = t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AcceptSpec describes an Accept* header.
|
||||||
|
type AcceptSpec struct {
|
||||||
|
Value string
|
||||||
|
Q float64
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseAccept parses Accept* headers.
|
||||||
|
func ParseAccept(header http.Header, key string) (specs []AcceptSpec) {
|
||||||
|
loop:
|
||||||
|
for _, s := range header[key] {
|
||||||
|
for {
|
||||||
|
var spec AcceptSpec
|
||||||
|
spec.Value, s = expectTokenSlash(s)
|
||||||
|
if spec.Value == "" {
|
||||||
|
continue loop
|
||||||
|
}
|
||||||
|
spec.Q = 1.0
|
||||||
|
s = skipSpace(s)
|
||||||
|
if strings.HasPrefix(s, ";") {
|
||||||
|
s = skipSpace(s[1:])
|
||||||
|
if !strings.HasPrefix(s, "q=") {
|
||||||
|
continue loop
|
||||||
|
}
|
||||||
|
spec.Q, s = expectQuality(s[2:])
|
||||||
|
if spec.Q < 0.0 {
|
||||||
|
continue loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
specs = append(specs, spec)
|
||||||
|
s = skipSpace(s)
|
||||||
|
if !strings.HasPrefix(s, ",") {
|
||||||
|
continue loop
|
||||||
|
}
|
||||||
|
s = skipSpace(s[1:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func skipSpace(s string) (rest string) {
|
||||||
|
i := 0
|
||||||
|
for ; i < len(s); i++ {
|
||||||
|
if octetTypes[s[i]]&isSpace == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s[i:]
|
||||||
|
}
|
||||||
|
|
||||||
|
func expectTokenSlash(s string) (token, rest string) {
|
||||||
|
i := 0
|
||||||
|
for ; i < len(s); i++ {
|
||||||
|
b := s[i]
|
||||||
|
if (octetTypes[b]&isToken == 0) && b != '/' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s[:i], s[i:]
|
||||||
|
}
|
||||||
|
|
||||||
|
func expectQuality(s string) (q float64, rest string) {
|
||||||
|
switch {
|
||||||
|
case len(s) == 0:
|
||||||
|
return -1, ""
|
||||||
|
case s[0] == '0':
|
||||||
|
q = 0
|
||||||
|
case s[0] == '1':
|
||||||
|
q = 1
|
||||||
|
default:
|
||||||
|
return -1, ""
|
||||||
|
}
|
||||||
|
s = s[1:]
|
||||||
|
if !strings.HasPrefix(s, ".") {
|
||||||
|
return q, s
|
||||||
|
}
|
||||||
|
s = s[1:]
|
||||||
|
i := 0
|
||||||
|
n := 0
|
||||||
|
d := 1
|
||||||
|
for ; i < len(s); i++ {
|
||||||
|
b := s[i]
|
||||||
|
if b < '0' || b > '9' {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
n = n*10 + int(b) - '0'
|
||||||
|
d *= 10
|
||||||
|
}
|
||||||
|
return q + float64(n)/float64(d), s[i:]
|
||||||
|
}
|
36
vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/negotiate.go
generated
vendored
Normal file
36
vendor/github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/negotiate.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file or at
|
||||||
|
// https://developers.google.com/open-source/licenses/bsd.
|
||||||
|
|
||||||
|
package httputil
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NegotiateContentEncoding returns the best offered content encoding for the
|
||||||
|
// request's Accept-Encoding header. If two offers match with equal weight and
|
||||||
|
// then the offer earlier in the list is preferred. If no offers are
|
||||||
|
// acceptable, then "" is returned.
|
||||||
|
func NegotiateContentEncoding(r *http.Request, offers []string) string {
|
||||||
|
bestOffer := "identity"
|
||||||
|
bestQ := -1.0
|
||||||
|
specs := header.ParseAccept(r.Header, "Accept-Encoding")
|
||||||
|
for _, offer := range offers {
|
||||||
|
for _, spec := range specs {
|
||||||
|
if spec.Q > bestQ &&
|
||||||
|
(spec.Value == "*" || spec.Value == offer) {
|
||||||
|
bestQ = spec.Q
|
||||||
|
bestOffer = offer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if bestQ == 0 {
|
||||||
|
bestOffer = ""
|
||||||
|
}
|
||||||
|
return bestOffer
|
||||||
|
}
|
55
vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
generated
vendored
55
vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
generated
vendored
@ -22,13 +22,13 @@ import (
|
|||||||
// goRuntimeMemStats provides the metrics initially provided by runtime.ReadMemStats.
|
// goRuntimeMemStats provides the metrics initially provided by runtime.ReadMemStats.
|
||||||
// From Go 1.17 those similar (and better) statistics are provided by runtime/metrics, so
|
// From Go 1.17 those similar (and better) statistics are provided by runtime/metrics, so
|
||||||
// while eval closure works on runtime.MemStats, the struct from Go 1.17+ is
|
// while eval closure works on runtime.MemStats, the struct from Go 1.17+ is
|
||||||
// populated using runtime/metrics.
|
// populated using runtime/metrics. Those are the defaults we can't alter.
|
||||||
func goRuntimeMemStats() memStatsMetrics {
|
func goRuntimeMemStats() memStatsMetrics {
|
||||||
return memStatsMetrics{
|
return memStatsMetrics{
|
||||||
{
|
{
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("alloc_bytes"),
|
memstatNamespace("alloc_bytes"),
|
||||||
"Number of bytes allocated and still in use.",
|
"Number of bytes allocated in heap and currently in use. Equals to /memory/classes/heap/objects:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Alloc) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Alloc) },
|
||||||
@ -36,7 +36,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("alloc_bytes_total"),
|
memstatNamespace("alloc_bytes_total"),
|
||||||
"Total number of bytes allocated, even if freed.",
|
"Total number of bytes allocated in heap until now, even if released already. Equals to /gc/heap/allocs:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.TotalAlloc) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.TotalAlloc) },
|
||||||
@ -44,23 +44,16 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("sys_bytes"),
|
memstatNamespace("sys_bytes"),
|
||||||
"Number of bytes obtained from system.",
|
"Number of bytes obtained from system. Equals to /memory/classes/total:byte.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Sys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Sys) },
|
||||||
valType: GaugeValue,
|
valType: GaugeValue,
|
||||||
}, {
|
|
||||||
desc: NewDesc(
|
|
||||||
memstatNamespace("lookups_total"),
|
|
||||||
"Total number of pointer lookups.",
|
|
||||||
nil, nil,
|
|
||||||
),
|
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Lookups) },
|
|
||||||
valType: CounterValue,
|
|
||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mallocs_total"),
|
memstatNamespace("mallocs_total"),
|
||||||
"Total number of mallocs.",
|
// TODO(bwplotka): We could add go_memstats_heap_objects, probably useful for discovery. Let's gather more feedback, kind of a waste of bytes for everybody for compatibility reasons to keep both, and we can't really rename/remove useful metric.
|
||||||
|
"Total number of heap objects allocated, both live and gc-ed. Semantically a counter version for go_memstats_heap_objects gauge. Equals to /gc/heap/allocs:objects + /gc/heap/tiny/allocs:objects.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Mallocs) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Mallocs) },
|
||||||
@ -68,7 +61,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("frees_total"),
|
memstatNamespace("frees_total"),
|
||||||
"Total number of frees.",
|
"Total number of heap objects frees. Equals to /gc/heap/frees:objects + /gc/heap/tiny/allocs:objects.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Frees) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Frees) },
|
||||||
@ -76,7 +69,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_alloc_bytes"),
|
memstatNamespace("heap_alloc_bytes"),
|
||||||
"Number of heap bytes allocated and still in use.",
|
"Number of heap bytes allocated and currently in use, same as go_memstats_alloc_bytes. Equals to /memory/classes/heap/objects:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapAlloc) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapAlloc) },
|
||||||
@ -84,7 +77,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_sys_bytes"),
|
memstatNamespace("heap_sys_bytes"),
|
||||||
"Number of heap bytes obtained from system.",
|
"Number of heap bytes obtained from system. Equals to /memory/classes/heap/objects:bytes + /memory/classes/heap/unused:bytes + /memory/classes/heap/released:bytes + /memory/classes/heap/free:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapSys) },
|
||||||
@ -92,7 +85,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_idle_bytes"),
|
memstatNamespace("heap_idle_bytes"),
|
||||||
"Number of heap bytes waiting to be used.",
|
"Number of heap bytes waiting to be used. Equals to /memory/classes/heap/released:bytes + /memory/classes/heap/free:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapIdle) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapIdle) },
|
||||||
@ -100,7 +93,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_inuse_bytes"),
|
memstatNamespace("heap_inuse_bytes"),
|
||||||
"Number of heap bytes that are in use.",
|
"Number of heap bytes that are in use. Equals to /memory/classes/heap/objects:bytes + /memory/classes/heap/unused:bytes",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapInuse) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapInuse) },
|
||||||
@ -108,7 +101,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_released_bytes"),
|
memstatNamespace("heap_released_bytes"),
|
||||||
"Number of heap bytes released to OS.",
|
"Number of heap bytes released to OS. Equals to /memory/classes/heap/released:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapReleased) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapReleased) },
|
||||||
@ -116,7 +109,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_objects"),
|
memstatNamespace("heap_objects"),
|
||||||
"Number of allocated objects.",
|
"Number of currently allocated objects. Equals to /gc/heap/objects:objects.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapObjects) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapObjects) },
|
||||||
@ -124,7 +117,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("stack_inuse_bytes"),
|
memstatNamespace("stack_inuse_bytes"),
|
||||||
"Number of bytes in use by the stack allocator.",
|
"Number of bytes obtained from system for stack allocator in non-CGO environments. Equals to /memory/classes/heap/stacks:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackInuse) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackInuse) },
|
||||||
@ -132,7 +125,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("stack_sys_bytes"),
|
memstatNamespace("stack_sys_bytes"),
|
||||||
"Number of bytes obtained from system for stack allocator.",
|
"Number of bytes obtained from system for stack allocator. Equals to /memory/classes/heap/stacks:bytes + /memory/classes/os-stacks:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackSys) },
|
||||||
@ -140,7 +133,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mspan_inuse_bytes"),
|
memstatNamespace("mspan_inuse_bytes"),
|
||||||
"Number of bytes in use by mspan structures.",
|
"Number of bytes in use by mspan structures. Equals to /memory/classes/metadata/mspan/inuse:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanInuse) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanInuse) },
|
||||||
@ -148,7 +141,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mspan_sys_bytes"),
|
memstatNamespace("mspan_sys_bytes"),
|
||||||
"Number of bytes used for mspan structures obtained from system.",
|
"Number of bytes used for mspan structures obtained from system. Equals to /memory/classes/metadata/mspan/inuse:bytes + /memory/classes/metadata/mspan/free:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanSys) },
|
||||||
@ -156,7 +149,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mcache_inuse_bytes"),
|
memstatNamespace("mcache_inuse_bytes"),
|
||||||
"Number of bytes in use by mcache structures.",
|
"Number of bytes in use by mcache structures. Equals to /memory/classes/metadata/mcache/inuse:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheInuse) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheInuse) },
|
||||||
@ -164,7 +157,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mcache_sys_bytes"),
|
memstatNamespace("mcache_sys_bytes"),
|
||||||
"Number of bytes used for mcache structures obtained from system.",
|
"Number of bytes used for mcache structures obtained from system. Equals to /memory/classes/metadata/mcache/inuse:bytes + /memory/classes/metadata/mcache/free:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheSys) },
|
||||||
@ -172,7 +165,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("buck_hash_sys_bytes"),
|
memstatNamespace("buck_hash_sys_bytes"),
|
||||||
"Number of bytes used by the profiling bucket hash table.",
|
"Number of bytes used by the profiling bucket hash table. Equals to /memory/classes/profiling/buckets:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.BuckHashSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.BuckHashSys) },
|
||||||
@ -180,7 +173,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("gc_sys_bytes"),
|
memstatNamespace("gc_sys_bytes"),
|
||||||
"Number of bytes used for garbage collection system metadata.",
|
"Number of bytes used for garbage collection system metadata. Equals to /memory/classes/metadata/other:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.GCSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.GCSys) },
|
||||||
@ -188,7 +181,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("other_sys_bytes"),
|
memstatNamespace("other_sys_bytes"),
|
||||||
"Number of bytes used for other system allocations.",
|
"Number of bytes used for other system allocations. Equals to /memory/classes/other:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.OtherSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.OtherSys) },
|
||||||
@ -196,7 +189,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("next_gc_bytes"),
|
memstatNamespace("next_gc_bytes"),
|
||||||
"Number of heap bytes when next garbage collection will take place.",
|
"Number of heap bytes when next garbage collection will take place. Equals to /gc/heap/goal:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.NextGC) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.NextGC) },
|
||||||
@ -225,7 +218,7 @@ func newBaseGoCollector() baseGoCollector {
|
|||||||
nil, nil),
|
nil, nil),
|
||||||
gcDesc: NewDesc(
|
gcDesc: NewDesc(
|
||||||
"go_gc_duration_seconds",
|
"go_gc_duration_seconds",
|
||||||
"A summary of the pause duration of garbage collection cycles.",
|
"A summary of the wall-time pause (stop-the-world) duration in garbage collection cycles.",
|
||||||
nil, nil),
|
nil, nil),
|
||||||
gcLastTimeDesc: NewDesc(
|
gcLastTimeDesc: NewDesc(
|
||||||
"go_memstats_last_gc_time_seconds",
|
"go_memstats_last_gc_time_seconds",
|
||||||
|
19
vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go
generated
vendored
19
vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go
generated
vendored
@ -17,6 +17,7 @@
|
|||||||
package prometheus
|
package prometheus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/metrics"
|
"runtime/metrics"
|
||||||
@ -153,7 +154,8 @@ func defaultGoCollectorOptions() internal.GoCollectorOptions {
|
|||||||
"/gc/heap/frees-by-size:bytes": goGCHeapFreesBytes,
|
"/gc/heap/frees-by-size:bytes": goGCHeapFreesBytes,
|
||||||
},
|
},
|
||||||
RuntimeMetricRules: []internal.GoCollectorRule{
|
RuntimeMetricRules: []internal.GoCollectorRule{
|
||||||
//{Matcher: regexp.MustCompile("")},
|
// Recommended metrics we want by default from runtime/metrics.
|
||||||
|
{Matcher: internal.GoCollectorDefaultRuntimeMetrics},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,6 +205,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
// to fail here. This condition is tested in TestExpectedRuntimeMetrics.
|
// to fail here. This condition is tested in TestExpectedRuntimeMetrics.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
help := attachOriginalName(d.Description.Description, d.Name)
|
||||||
|
|
||||||
sampleBuf = append(sampleBuf, metrics.Sample{Name: d.Name})
|
sampleBuf = append(sampleBuf, metrics.Sample{Name: d.Name})
|
||||||
sampleMap[d.Name] = &sampleBuf[len(sampleBuf)-1]
|
sampleMap[d.Name] = &sampleBuf[len(sampleBuf)-1]
|
||||||
@ -214,7 +217,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
m = newBatchHistogram(
|
m = newBatchHistogram(
|
||||||
NewDesc(
|
NewDesc(
|
||||||
BuildFQName(namespace, subsystem, name),
|
BuildFQName(namespace, subsystem, name),
|
||||||
d.Description.Description,
|
help,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
@ -226,7 +229,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: subsystem,
|
Subsystem: subsystem,
|
||||||
Name: name,
|
Name: name,
|
||||||
Help: d.Description.Description,
|
Help: help,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@ -234,7 +237,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: subsystem,
|
Subsystem: subsystem,
|
||||||
Name: name,
|
Name: name,
|
||||||
Help: d.Description.Description,
|
Help: help,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
metricSet = append(metricSet, m)
|
metricSet = append(metricSet, m)
|
||||||
@ -284,6 +287,10 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func attachOriginalName(desc, origName string) string {
|
||||||
|
return fmt.Sprintf("%s Sourced from %s", desc, origName)
|
||||||
|
}
|
||||||
|
|
||||||
// Describe returns all descriptions of the collector.
|
// Describe returns all descriptions of the collector.
|
||||||
func (c *goCollector) Describe(ch chan<- *Desc) {
|
func (c *goCollector) Describe(ch chan<- *Desc) {
|
||||||
c.base.Describe(ch)
|
c.base.Describe(ch)
|
||||||
@ -376,13 +383,13 @@ func unwrapScalarRMValue(v metrics.Value) float64 {
|
|||||||
//
|
//
|
||||||
// This should never happen because we always populate our metric
|
// This should never happen because we always populate our metric
|
||||||
// set from the runtime/metrics package.
|
// set from the runtime/metrics package.
|
||||||
panic("unexpected unsupported metric")
|
panic("unexpected bad kind metric")
|
||||||
default:
|
default:
|
||||||
// Unsupported metric kind.
|
// Unsupported metric kind.
|
||||||
//
|
//
|
||||||
// This should never happen because we check for this during initialization
|
// This should never happen because we check for this during initialization
|
||||||
// and flag and filter metrics whose kinds we don't understand.
|
// and flag and filter metrics whose kinds we don't understand.
|
||||||
panic("unexpected unsupported metric kind")
|
panic(fmt.Sprintf("unexpected unsupported metric: %v", v.Kind()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
226
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
generated
vendored
226
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
generated
vendored
@ -440,7 +440,7 @@ type HistogramOpts struct {
|
|||||||
// constant (or any negative float value).
|
// constant (or any negative float value).
|
||||||
NativeHistogramZeroThreshold float64
|
NativeHistogramZeroThreshold float64
|
||||||
|
|
||||||
// The remaining fields define a strategy to limit the number of
|
// The next three fields define a strategy to limit the number of
|
||||||
// populated sparse buckets. If NativeHistogramMaxBucketNumber is left
|
// populated sparse buckets. If NativeHistogramMaxBucketNumber is left
|
||||||
// at zero, the number of buckets is not limited. (Note that this might
|
// at zero, the number of buckets is not limited. (Note that this might
|
||||||
// lead to unbounded memory consumption if the values observed by the
|
// lead to unbounded memory consumption if the values observed by the
|
||||||
@ -473,6 +473,22 @@ type HistogramOpts struct {
|
|||||||
NativeHistogramMinResetDuration time.Duration
|
NativeHistogramMinResetDuration time.Duration
|
||||||
NativeHistogramMaxZeroThreshold float64
|
NativeHistogramMaxZeroThreshold float64
|
||||||
|
|
||||||
|
// NativeHistogramMaxExemplars limits the number of exemplars
|
||||||
|
// that are kept in memory for each native histogram. If you leave it at
|
||||||
|
// zero, a default value of 10 is used. If no exemplars should be kept specifically
|
||||||
|
// for native histograms, set it to a negative value. (Scrapers can
|
||||||
|
// still use the exemplars exposed for classic buckets, which are managed
|
||||||
|
// independently.)
|
||||||
|
NativeHistogramMaxExemplars int
|
||||||
|
// NativeHistogramExemplarTTL is only checked once
|
||||||
|
// NativeHistogramMaxExemplars is exceeded. In that case, the
|
||||||
|
// oldest exemplar is removed if it is older than NativeHistogramExemplarTTL.
|
||||||
|
// Otherwise, the older exemplar in the pair of exemplars that are closest
|
||||||
|
// together (on an exponential scale) is removed.
|
||||||
|
// If NativeHistogramExemplarTTL is left at its zero value, a default value of
|
||||||
|
// 5m is used. To always delete the oldest exemplar, set it to a negative value.
|
||||||
|
NativeHistogramExemplarTTL time.Duration
|
||||||
|
|
||||||
// now is for testing purposes, by default it's time.Now.
|
// now is for testing purposes, by default it's time.Now.
|
||||||
now func() time.Time
|
now func() time.Time
|
||||||
|
|
||||||
@ -532,6 +548,7 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr
|
|||||||
if opts.afterFunc == nil {
|
if opts.afterFunc == nil {
|
||||||
opts.afterFunc = time.AfterFunc
|
opts.afterFunc = time.AfterFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
h := &histogram{
|
h := &histogram{
|
||||||
desc: desc,
|
desc: desc,
|
||||||
upperBounds: opts.Buckets,
|
upperBounds: opts.Buckets,
|
||||||
@ -556,6 +573,7 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr
|
|||||||
h.nativeHistogramZeroThreshold = DefNativeHistogramZeroThreshold
|
h.nativeHistogramZeroThreshold = DefNativeHistogramZeroThreshold
|
||||||
} // Leave h.nativeHistogramZeroThreshold at 0 otherwise.
|
} // Leave h.nativeHistogramZeroThreshold at 0 otherwise.
|
||||||
h.nativeHistogramSchema = pickSchema(opts.NativeHistogramBucketFactor)
|
h.nativeHistogramSchema = pickSchema(opts.NativeHistogramBucketFactor)
|
||||||
|
h.nativeExemplars = makeNativeExemplars(opts.NativeHistogramExemplarTTL, opts.NativeHistogramMaxExemplars)
|
||||||
}
|
}
|
||||||
for i, upperBound := range h.upperBounds {
|
for i, upperBound := range h.upperBounds {
|
||||||
if i < len(h.upperBounds)-1 {
|
if i < len(h.upperBounds)-1 {
|
||||||
@ -725,7 +743,8 @@ type histogram struct {
|
|||||||
// resetScheduled is protected by mtx. It is true if a reset is
|
// resetScheduled is protected by mtx. It is true if a reset is
|
||||||
// scheduled for a later time (when nativeHistogramMinResetDuration has
|
// scheduled for a later time (when nativeHistogramMinResetDuration has
|
||||||
// passed).
|
// passed).
|
||||||
resetScheduled bool
|
resetScheduled bool
|
||||||
|
nativeExemplars nativeExemplars
|
||||||
|
|
||||||
// now is for testing purposes, by default it's time.Now.
|
// now is for testing purposes, by default it's time.Now.
|
||||||
now func() time.Time
|
now func() time.Time
|
||||||
@ -742,6 +761,9 @@ func (h *histogram) Observe(v float64) {
|
|||||||
h.observe(v, h.findBucket(v))
|
h.observe(v, h.findBucket(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ObserveWithExemplar should not be called in a high-frequency setting
|
||||||
|
// for a native histogram with configured exemplars. For this case,
|
||||||
|
// the implementation isn't lock-free and might suffer from lock contention.
|
||||||
func (h *histogram) ObserveWithExemplar(v float64, e Labels) {
|
func (h *histogram) ObserveWithExemplar(v float64, e Labels) {
|
||||||
i := h.findBucket(v)
|
i := h.findBucket(v)
|
||||||
h.observe(v, i)
|
h.observe(v, i)
|
||||||
@ -821,6 +843,15 @@ func (h *histogram) Write(out *dto.Metric) error {
|
|||||||
Length: proto.Uint32(0),
|
Length: proto.Uint32(0),
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If exemplars are not configured, the cap will be 0.
|
||||||
|
// So append is not needed in this case.
|
||||||
|
if cap(h.nativeExemplars.exemplars) > 0 {
|
||||||
|
h.nativeExemplars.Lock()
|
||||||
|
his.Exemplars = append(his.Exemplars, h.nativeExemplars.exemplars...)
|
||||||
|
h.nativeExemplars.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
addAndResetCounts(hotCounts, coldCounts)
|
addAndResetCounts(hotCounts, coldCounts)
|
||||||
return nil
|
return nil
|
||||||
@ -1091,8 +1122,10 @@ func (h *histogram) resetCounts(counts *histogramCounts) {
|
|||||||
deleteSyncMap(&counts.nativeHistogramBucketsPositive)
|
deleteSyncMap(&counts.nativeHistogramBucketsPositive)
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateExemplar replaces the exemplar for the provided bucket. With empty
|
// updateExemplar replaces the exemplar for the provided classic bucket.
|
||||||
// labels, it's a no-op. It panics if any of the labels is invalid.
|
// With empty labels, it's a no-op. It panics if any of the labels is invalid.
|
||||||
|
// If histogram is native, the exemplar will be cached into nativeExemplars,
|
||||||
|
// which has a limit, and will remove one exemplar when limit is reached.
|
||||||
func (h *histogram) updateExemplar(v float64, bucket int, l Labels) {
|
func (h *histogram) updateExemplar(v float64, bucket int, l Labels) {
|
||||||
if l == nil {
|
if l == nil {
|
||||||
return
|
return
|
||||||
@ -1102,6 +1135,10 @@ func (h *histogram) updateExemplar(v float64, bucket int, l Labels) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
h.exemplars[bucket].Store(e)
|
h.exemplars[bucket].Store(e)
|
||||||
|
doSparse := h.nativeHistogramSchema > math.MinInt32 && !math.IsNaN(v)
|
||||||
|
if doSparse {
|
||||||
|
h.nativeExemplars.addExemplar(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HistogramVec is a Collector that bundles a set of Histograms that all share the
|
// HistogramVec is a Collector that bundles a set of Histograms that all share the
|
||||||
@ -1336,6 +1373,48 @@ func MustNewConstHistogram(
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewConstHistogramWithCreatedTimestamp does the same thing as NewConstHistogram but sets the created timestamp.
|
||||||
|
func NewConstHistogramWithCreatedTimestamp(
|
||||||
|
desc *Desc,
|
||||||
|
count uint64,
|
||||||
|
sum float64,
|
||||||
|
buckets map[float64]uint64,
|
||||||
|
ct time.Time,
|
||||||
|
labelValues ...string,
|
||||||
|
) (Metric, error) {
|
||||||
|
if desc.err != nil {
|
||||||
|
return nil, desc.err
|
||||||
|
}
|
||||||
|
if err := validateLabelValues(labelValues, len(desc.variableLabels.names)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &constHistogram{
|
||||||
|
desc: desc,
|
||||||
|
count: count,
|
||||||
|
sum: sum,
|
||||||
|
buckets: buckets,
|
||||||
|
labelPairs: MakeLabelPairs(desc, labelValues),
|
||||||
|
createdTs: timestamppb.New(ct),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MustNewConstHistogramWithCreatedTimestamp is a version of NewConstHistogramWithCreatedTimestamp that panics where
|
||||||
|
// NewConstHistogramWithCreatedTimestamp would have returned an error.
|
||||||
|
func MustNewConstHistogramWithCreatedTimestamp(
|
||||||
|
desc *Desc,
|
||||||
|
count uint64,
|
||||||
|
sum float64,
|
||||||
|
buckets map[float64]uint64,
|
||||||
|
ct time.Time,
|
||||||
|
labelValues ...string,
|
||||||
|
) Metric {
|
||||||
|
m, err := NewConstHistogramWithCreatedTimestamp(desc, count, sum, buckets, ct, labelValues...)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
type buckSort []*dto.Bucket
|
type buckSort []*dto.Bucket
|
||||||
|
|
||||||
func (s buckSort) Len() int {
|
func (s buckSort) Len() int {
|
||||||
@ -1575,3 +1654,142 @@ func addAndResetCounts(hot, cold *histogramCounts) {
|
|||||||
atomic.AddUint64(&hot.nativeHistogramZeroBucket, atomic.LoadUint64(&cold.nativeHistogramZeroBucket))
|
atomic.AddUint64(&hot.nativeHistogramZeroBucket, atomic.LoadUint64(&cold.nativeHistogramZeroBucket))
|
||||||
atomic.StoreUint64(&cold.nativeHistogramZeroBucket, 0)
|
atomic.StoreUint64(&cold.nativeHistogramZeroBucket, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type nativeExemplars struct {
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
|
ttl time.Duration
|
||||||
|
exemplars []*dto.Exemplar
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeNativeExemplars(ttl time.Duration, maxCount int) nativeExemplars {
|
||||||
|
if ttl == 0 {
|
||||||
|
ttl = 5 * time.Minute
|
||||||
|
}
|
||||||
|
|
||||||
|
if maxCount == 0 {
|
||||||
|
maxCount = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
if maxCount < 0 {
|
||||||
|
maxCount = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return nativeExemplars{
|
||||||
|
ttl: ttl,
|
||||||
|
exemplars: make([]*dto.Exemplar, 0, maxCount),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *nativeExemplars) addExemplar(e *dto.Exemplar) {
|
||||||
|
if cap(n.exemplars) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
n.Lock()
|
||||||
|
defer n.Unlock()
|
||||||
|
|
||||||
|
// The index where to insert the new exemplar.
|
||||||
|
var nIdx int = -1
|
||||||
|
|
||||||
|
// When the number of exemplars has not yet exceeded or
|
||||||
|
// is equal to cap(n.exemplars), then
|
||||||
|
// insert the new exemplar directly.
|
||||||
|
if len(n.exemplars) < cap(n.exemplars) {
|
||||||
|
for nIdx = 0; nIdx < len(n.exemplars); nIdx++ {
|
||||||
|
if *e.Value < *n.exemplars[nIdx].Value {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n.exemplars = append(n.exemplars[:nIdx], append([]*dto.Exemplar{e}, n.exemplars[nIdx:]...)...)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// When the number of exemplars exceeds the limit, remove one exemplar.
|
||||||
|
var (
|
||||||
|
rIdx int // The index where to remove the old exemplar.
|
||||||
|
|
||||||
|
ot = time.Now() // Oldest timestamp seen.
|
||||||
|
otIdx = -1 // Index of the exemplar with the oldest timestamp.
|
||||||
|
|
||||||
|
md = -1.0 // Logarithm of the delta of the closest pair of exemplars.
|
||||||
|
mdIdx = -1 // Index of the older exemplar within the closest pair.
|
||||||
|
cLog float64 // Logarithm of the current exemplar.
|
||||||
|
pLog float64 // Logarithm of the previous exemplar.
|
||||||
|
)
|
||||||
|
|
||||||
|
for i, exemplar := range n.exemplars {
|
||||||
|
// Find the exemplar with the oldest timestamp.
|
||||||
|
if otIdx == -1 || exemplar.Timestamp.AsTime().Before(ot) {
|
||||||
|
ot = exemplar.Timestamp.AsTime()
|
||||||
|
otIdx = i
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the index at which to insert new the exemplar.
|
||||||
|
if *e.Value <= *exemplar.Value && nIdx == -1 {
|
||||||
|
nIdx = i
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the two closest exemplars and pick the one the with older timestamp.
|
||||||
|
pLog = cLog
|
||||||
|
cLog = math.Log(exemplar.GetValue())
|
||||||
|
if i == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
diff := math.Abs(cLog - pLog)
|
||||||
|
if md == -1 || diff < md {
|
||||||
|
md = diff
|
||||||
|
if n.exemplars[i].Timestamp.AsTime().Before(n.exemplars[i-1].Timestamp.AsTime()) {
|
||||||
|
mdIdx = i
|
||||||
|
} else {
|
||||||
|
mdIdx = i - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// If all existing exemplar are smaller than new exemplar,
|
||||||
|
// then the exemplar should be inserted at the end.
|
||||||
|
if nIdx == -1 {
|
||||||
|
nIdx = len(n.exemplars)
|
||||||
|
}
|
||||||
|
|
||||||
|
if otIdx != -1 && e.Timestamp.AsTime().Sub(ot) > n.ttl {
|
||||||
|
rIdx = otIdx
|
||||||
|
} else {
|
||||||
|
// In the previous for loop, when calculating the closest pair of exemplars,
|
||||||
|
// we did not take into account the newly inserted exemplar.
|
||||||
|
// So we need to calculate with the newly inserted exemplar again.
|
||||||
|
elog := math.Log(e.GetValue())
|
||||||
|
if nIdx > 0 {
|
||||||
|
diff := math.Abs(elog - math.Log(n.exemplars[nIdx-1].GetValue()))
|
||||||
|
if diff < md {
|
||||||
|
md = diff
|
||||||
|
mdIdx = nIdx
|
||||||
|
if n.exemplars[nIdx-1].Timestamp.AsTime().Before(e.Timestamp.AsTime()) {
|
||||||
|
mdIdx = nIdx - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if nIdx < len(n.exemplars) {
|
||||||
|
diff := math.Abs(math.Log(n.exemplars[nIdx].GetValue()) - elog)
|
||||||
|
if diff < md {
|
||||||
|
mdIdx = nIdx
|
||||||
|
if n.exemplars[nIdx].Timestamp.AsTime().Before(e.Timestamp.AsTime()) {
|
||||||
|
mdIdx = nIdx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rIdx = mdIdx
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust the slice according to rIdx and nIdx.
|
||||||
|
switch {
|
||||||
|
case rIdx == nIdx:
|
||||||
|
n.exemplars[nIdx] = e
|
||||||
|
case rIdx < nIdx:
|
||||||
|
n.exemplars = append(n.exemplars[:rIdx], append(n.exemplars[rIdx+1:nIdx], append([]*dto.Exemplar{e}, n.exemplars[nIdx:]...)...)...)
|
||||||
|
case rIdx > nIdx:
|
||||||
|
n.exemplars = append(n.exemplars[:nIdx], append([]*dto.Exemplar{e}, append(n.exemplars[nIdx:rIdx], n.exemplars[rIdx+1:]...)...)...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -30,3 +30,5 @@ type GoCollectorOptions struct {
|
|||||||
RuntimeMetricSumForHist map[string]string
|
RuntimeMetricSumForHist map[string]string
|
||||||
RuntimeMetricRules []GoCollectorRule
|
RuntimeMetricRules []GoCollectorRule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var GoCollectorDefaultRuntimeMetrics = regexp.MustCompile(`/gc/gogc:percent|/gc/gomemlimit:bytes|/sched/gomaxprocs:threads`)
|
||||||
|
2
vendor/github.com/prometheus/client_golang/prometheus/metric.go
generated
vendored
2
vendor/github.com/prometheus/client_golang/prometheus/metric.go
generated
vendored
@ -234,7 +234,7 @@ func NewMetricWithExemplars(m Metric, exemplars ...Exemplar) (Metric, error) {
|
|||||||
)
|
)
|
||||||
for i, e := range exemplars {
|
for i, e := range exemplars {
|
||||||
ts := e.Timestamp
|
ts := e.Timestamp
|
||||||
if ts == (time.Time{}) {
|
if ts.IsZero() {
|
||||||
ts = now
|
ts = now
|
||||||
}
|
}
|
||||||
exs[i], err = newExemplar(e.Value, ts, e.Labels)
|
exs[i], err = newExemplar(e.Value, ts, e.Labels)
|
||||||
|
29
vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
generated
vendored
29
vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
generated
vendored
@ -22,14 +22,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type processCollector struct {
|
type processCollector struct {
|
||||||
collectFn func(chan<- Metric)
|
collectFn func(chan<- Metric)
|
||||||
pidFn func() (int, error)
|
pidFn func() (int, error)
|
||||||
reportErrors bool
|
reportErrors bool
|
||||||
cpuTotal *Desc
|
cpuTotal *Desc
|
||||||
openFDs, maxFDs *Desc
|
openFDs, maxFDs *Desc
|
||||||
vsize, maxVsize *Desc
|
vsize, maxVsize *Desc
|
||||||
rss *Desc
|
rss *Desc
|
||||||
startTime *Desc
|
startTime *Desc
|
||||||
|
inBytes, outBytes *Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessCollectorOpts defines the behavior of a process metrics collector
|
// ProcessCollectorOpts defines the behavior of a process metrics collector
|
||||||
@ -100,6 +101,16 @@ func NewProcessCollector(opts ProcessCollectorOpts) Collector {
|
|||||||
"Start time of the process since unix epoch in seconds.",
|
"Start time of the process since unix epoch in seconds.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
|
inBytes: NewDesc(
|
||||||
|
ns+"process_network_receive_bytes_total",
|
||||||
|
"Number of bytes received by the process over the network.",
|
||||||
|
nil, nil,
|
||||||
|
),
|
||||||
|
outBytes: NewDesc(
|
||||||
|
ns+"process_network_transmit_bytes_total",
|
||||||
|
"Number of bytes sent by the process over the network.",
|
||||||
|
nil, nil,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.PidFn == nil {
|
if opts.PidFn == nil {
|
||||||
@ -129,6 +140,8 @@ func (c *processCollector) Describe(ch chan<- *Desc) {
|
|||||||
ch <- c.maxVsize
|
ch <- c.maxVsize
|
||||||
ch <- c.rss
|
ch <- c.rss
|
||||||
ch <- c.startTime
|
ch <- c.startTime
|
||||||
|
ch <- c.inBytes
|
||||||
|
ch <- c.outBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect returns the current state of all metrics of the collector.
|
// Collect returns the current state of all metrics of the collector.
|
||||||
|
14
vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
generated
vendored
14
vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
generated
vendored
@ -63,4 +63,18 @@ func (c *processCollector) processCollect(ch chan<- Metric) {
|
|||||||
} else {
|
} else {
|
||||||
c.reportError(ch, nil, err)
|
c.reportError(ch, nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if netstat, err := p.Netstat(); err == nil {
|
||||||
|
var inOctets, outOctets float64
|
||||||
|
if netstat.IpExt.InOctets != nil {
|
||||||
|
inOctets = *netstat.IpExt.InOctets
|
||||||
|
}
|
||||||
|
if netstat.IpExt.OutOctets != nil {
|
||||||
|
outOctets = *netstat.IpExt.OutOctets
|
||||||
|
}
|
||||||
|
ch <- MustNewConstMetric(c.inBytes, CounterValue, inOctets)
|
||||||
|
ch <- MustNewConstMetric(c.outBytes, CounterValue, outOctets)
|
||||||
|
} else {
|
||||||
|
c.reportError(ch, nil, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
6
vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go
generated
vendored
6
vendor/github.com/prometheus/client_golang/prometheus/promhttp/delegator.go
generated
vendored
@ -76,6 +76,12 @@ func (r *responseWriterDelegator) Write(b []byte) (int, error) {
|
|||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unwrap lets http.ResponseController get the underlying http.ResponseWriter,
|
||||||
|
// by implementing the [rwUnwrapper](https://cs.opensource.google/go/go/+/refs/tags/go1.21.4:src/net/http/responsecontroller.go;l=42-44) interface.
|
||||||
|
func (r *responseWriterDelegator) Unwrap() http.ResponseWriter {
|
||||||
|
return r.ResponseWriter
|
||||||
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
closeNotifierDelegator struct{ *responseWriterDelegator }
|
closeNotifierDelegator struct{ *responseWriterDelegator }
|
||||||
flusherDelegator struct{ *responseWriterDelegator }
|
flusherDelegator struct{ *responseWriterDelegator }
|
||||||
|
113
vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go
generated
vendored
113
vendor/github.com/prometheus/client_golang/prometheus/promhttp/http.go
generated
vendored
@ -38,12 +38,13 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/klauspost/compress/zstd"
|
||||||
"github.com/prometheus/common/expfmt"
|
"github.com/prometheus/common/expfmt"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,6 +55,18 @@ const (
|
|||||||
processStartTimeHeader = "Process-Start-Time-Unix"
|
processStartTimeHeader = "Process-Start-Time-Unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Compression represents the content encodings handlers support for the HTTP
|
||||||
|
// responses.
|
||||||
|
type Compression string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Identity Compression = "identity"
|
||||||
|
Gzip Compression = "gzip"
|
||||||
|
Zstd Compression = "zstd"
|
||||||
|
)
|
||||||
|
|
||||||
|
var defaultCompressionFormats = []Compression{Identity, Gzip, Zstd}
|
||||||
|
|
||||||
var gzipPool = sync.Pool{
|
var gzipPool = sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() interface{} {
|
||||||
return gzip.NewWriter(nil)
|
return gzip.NewWriter(nil)
|
||||||
@ -122,6 +135,18 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Select compression formats to offer based on default or user choice.
|
||||||
|
var compressions []string
|
||||||
|
if !opts.DisableCompression {
|
||||||
|
offers := defaultCompressionFormats
|
||||||
|
if len(opts.OfferedCompressions) > 0 {
|
||||||
|
offers = opts.OfferedCompressions
|
||||||
|
}
|
||||||
|
for _, comp := range offers {
|
||||||
|
compressions = append(compressions, string(comp))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
h := http.HandlerFunc(func(rsp http.ResponseWriter, req *http.Request) {
|
h := http.HandlerFunc(func(rsp http.ResponseWriter, req *http.Request) {
|
||||||
if !opts.ProcessStartTime.IsZero() {
|
if !opts.ProcessStartTime.IsZero() {
|
||||||
rsp.Header().Set(processStartTimeHeader, strconv.FormatInt(opts.ProcessStartTime.Unix(), 10))
|
rsp.Header().Set(processStartTimeHeader, strconv.FormatInt(opts.ProcessStartTime.Unix(), 10))
|
||||||
@ -165,21 +190,21 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO
|
|||||||
} else {
|
} else {
|
||||||
contentType = expfmt.Negotiate(req.Header)
|
contentType = expfmt.Negotiate(req.Header)
|
||||||
}
|
}
|
||||||
header := rsp.Header()
|
rsp.Header().Set(contentTypeHeader, string(contentType))
|
||||||
header.Set(contentTypeHeader, string(contentType))
|
|
||||||
|
|
||||||
w := io.Writer(rsp)
|
w, encodingHeader, closeWriter, err := negotiateEncodingWriter(req, rsp, compressions)
|
||||||
if !opts.DisableCompression && gzipAccepted(req.Header) {
|
if err != nil {
|
||||||
header.Set(contentEncodingHeader, "gzip")
|
if opts.ErrorLog != nil {
|
||||||
gz := gzipPool.Get().(*gzip.Writer)
|
opts.ErrorLog.Println("error getting writer", err)
|
||||||
defer gzipPool.Put(gz)
|
}
|
||||||
|
w = io.Writer(rsp)
|
||||||
gz.Reset(w)
|
encodingHeader = string(Identity)
|
||||||
defer gz.Close()
|
|
||||||
|
|
||||||
w = gz
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer closeWriter()
|
||||||
|
|
||||||
|
rsp.Header().Set(contentEncodingHeader, encodingHeader)
|
||||||
|
|
||||||
enc := expfmt.NewEncoder(w, contentType)
|
enc := expfmt.NewEncoder(w, contentType)
|
||||||
|
|
||||||
// handleError handles the error according to opts.ErrorHandling
|
// handleError handles the error according to opts.ErrorHandling
|
||||||
@ -343,9 +368,19 @@ type HandlerOpts struct {
|
|||||||
// no effect on the HTTP status code because ErrorHandling is set to
|
// no effect on the HTTP status code because ErrorHandling is set to
|
||||||
// ContinueOnError.
|
// ContinueOnError.
|
||||||
Registry prometheus.Registerer
|
Registry prometheus.Registerer
|
||||||
// If DisableCompression is true, the handler will never compress the
|
// DisableCompression disables the response encoding (compression) and
|
||||||
// response, even if requested by the client.
|
// encoding negotiation. If true, the handler will
|
||||||
|
// never compress the response, even if requested
|
||||||
|
// by the client and the OfferedCompressions field is set.
|
||||||
DisableCompression bool
|
DisableCompression bool
|
||||||
|
// OfferedCompressions is a set of encodings (compressions) handler will
|
||||||
|
// try to offer when negotiating with the client. This defaults to identity, gzip
|
||||||
|
// and zstd.
|
||||||
|
// NOTE: If handler can't agree with the client on the encodings or
|
||||||
|
// unsupported or empty encodings are set in OfferedCompressions,
|
||||||
|
// handler always fallbacks to no compression (identity), for
|
||||||
|
// compatibility reasons. In such cases ErrorLog will be used if set.
|
||||||
|
OfferedCompressions []Compression
|
||||||
// The number of concurrent HTTP requests is limited to
|
// The number of concurrent HTTP requests is limited to
|
||||||
// MaxRequestsInFlight. Additional requests are responded to with 503
|
// MaxRequestsInFlight. Additional requests are responded to with 503
|
||||||
// Service Unavailable and a suitable message in the body. If
|
// Service Unavailable and a suitable message in the body. If
|
||||||
@ -381,19 +416,6 @@ type HandlerOpts struct {
|
|||||||
ProcessStartTime time.Time
|
ProcessStartTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// gzipAccepted returns whether the client will accept gzip-encoded content.
|
|
||||||
func gzipAccepted(header http.Header) bool {
|
|
||||||
a := header.Get(acceptEncodingHeader)
|
|
||||||
parts := strings.Split(a, ",")
|
|
||||||
for _, part := range parts {
|
|
||||||
part = strings.TrimSpace(part)
|
|
||||||
if part == "gzip" || strings.HasPrefix(part, "gzip;") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// httpError removes any content-encoding header and then calls http.Error with
|
// httpError removes any content-encoding header and then calls http.Error with
|
||||||
// the provided error and http.StatusInternalServerError. Error contents is
|
// the provided error and http.StatusInternalServerError. Error contents is
|
||||||
// supposed to be uncompressed plain text. Same as with a plain http.Error, this
|
// supposed to be uncompressed plain text. Same as with a plain http.Error, this
|
||||||
@ -406,3 +428,38 @@ func httpError(rsp http.ResponseWriter, err error) {
|
|||||||
http.StatusInternalServerError,
|
http.StatusInternalServerError,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// negotiateEncodingWriter reads the Accept-Encoding header from a request and
|
||||||
|
// selects the right compression based on an allow-list of supported
|
||||||
|
// compressions. It returns a writer implementing the compression and an the
|
||||||
|
// correct value that the caller can set in the response header.
|
||||||
|
func negotiateEncodingWriter(r *http.Request, rw io.Writer, compressions []string) (_ io.Writer, encodingHeaderValue string, closeWriter func(), _ error) {
|
||||||
|
if len(compressions) == 0 {
|
||||||
|
return rw, string(Identity), func() {}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(mrueg): Replace internal/github.com/gddo once https://github.com/golang/go/issues/19307 is implemented.
|
||||||
|
selected := httputil.NegotiateContentEncoding(r, compressions)
|
||||||
|
|
||||||
|
switch selected {
|
||||||
|
case "zstd":
|
||||||
|
// TODO(mrueg): Replace klauspost/compress with stdlib implementation once https://github.com/golang/go/issues/62513 is implemented.
|
||||||
|
z, err := zstd.NewWriter(rw, zstd.WithEncoderLevel(zstd.SpeedFastest))
|
||||||
|
if err != nil {
|
||||||
|
return nil, "", func() {}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
z.Reset(rw)
|
||||||
|
return z, selected, func() { _ = z.Close() }, nil
|
||||||
|
case "gzip":
|
||||||
|
gz := gzipPool.Get().(*gzip.Writer)
|
||||||
|
gz.Reset(rw)
|
||||||
|
return gz, selected, func() { _ = gz.Close(); gzipPool.Put(gz) }, nil
|
||||||
|
case "identity":
|
||||||
|
// This means the content is not compressed.
|
||||||
|
return rw, selected, func() {}, nil
|
||||||
|
default:
|
||||||
|
// The content encoding was not implemented yet.
|
||||||
|
return nil, "", func() {}, fmt.Errorf("content compression format not recognized: %s. Valid formats are: %s", selected, defaultCompressionFormats)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
19
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
19
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
@ -314,16 +314,17 @@ func (r *Registry) Register(c Collector) error {
|
|||||||
if dimHash != desc.dimHash {
|
if dimHash != desc.dimHash {
|
||||||
return fmt.Errorf("a previously registered descriptor with the same fully-qualified name as %s has different label names or a different help string", desc)
|
return fmt.Errorf("a previously registered descriptor with the same fully-qualified name as %s has different label names or a different help string", desc)
|
||||||
}
|
}
|
||||||
} else {
|
continue
|
||||||
// ...then check the new descriptors already seen.
|
|
||||||
if dimHash, exists := newDimHashesByName[desc.fqName]; exists {
|
|
||||||
if dimHash != desc.dimHash {
|
|
||||||
return fmt.Errorf("descriptors reported by collector have inconsistent label names or help strings for the same fully-qualified name, offender is %s", desc)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newDimHashesByName[desc.fqName] = desc.dimHash
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ...then check the new descriptors already seen.
|
||||||
|
if dimHash, exists := newDimHashesByName[desc.fqName]; exists {
|
||||||
|
if dimHash != desc.dimHash {
|
||||||
|
return fmt.Errorf("descriptors reported by collector have inconsistent label names or help strings for the same fully-qualified name, offender is %s", desc)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newDimHashesByName[desc.fqName] = desc.dimHash
|
||||||
}
|
}
|
||||||
// A Collector yielding no Desc at all is considered unchecked.
|
// A Collector yielding no Desc at all is considered unchecked.
|
||||||
if len(newDescIDs) == 0 {
|
if len(newDescIDs) == 0 {
|
||||||
|
42
vendor/github.com/prometheus/client_golang/prometheus/summary.go
generated
vendored
42
vendor/github.com/prometheus/client_golang/prometheus/summary.go
generated
vendored
@ -783,3 +783,45 @@ func MustNewConstSummary(
|
|||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewConstSummaryWithCreatedTimestamp does the same thing as NewConstSummary but sets the created timestamp.
|
||||||
|
func NewConstSummaryWithCreatedTimestamp(
|
||||||
|
desc *Desc,
|
||||||
|
count uint64,
|
||||||
|
sum float64,
|
||||||
|
quantiles map[float64]float64,
|
||||||
|
ct time.Time,
|
||||||
|
labelValues ...string,
|
||||||
|
) (Metric, error) {
|
||||||
|
if desc.err != nil {
|
||||||
|
return nil, desc.err
|
||||||
|
}
|
||||||
|
if err := validateLabelValues(labelValues, len(desc.variableLabels.names)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &constSummary{
|
||||||
|
desc: desc,
|
||||||
|
count: count,
|
||||||
|
sum: sum,
|
||||||
|
quantiles: quantiles,
|
||||||
|
labelPairs: MakeLabelPairs(desc, labelValues),
|
||||||
|
createdTs: timestamppb.New(ct),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MustNewConstSummaryWithCreatedTimestamp is a version of NewConstSummaryWithCreatedTimestamp that panics where
|
||||||
|
// NewConstSummaryWithCreatedTimestamp would have returned an error.
|
||||||
|
func MustNewConstSummaryWithCreatedTimestamp(
|
||||||
|
desc *Desc,
|
||||||
|
count uint64,
|
||||||
|
sum float64,
|
||||||
|
quantiles map[float64]float64,
|
||||||
|
ct time.Time,
|
||||||
|
labelValues ...string,
|
||||||
|
) Metric {
|
||||||
|
m, err := NewConstSummaryWithCreatedTimestamp(desc, count, sum, quantiles, ct, labelValues...)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
2
vendor/github.com/prometheus/client_golang/prometheus/vec.go
generated
vendored
2
vendor/github.com/prometheus/client_golang/prometheus/vec.go
generated
vendored
@ -507,7 +507,7 @@ func (m *metricMap) getOrCreateMetricWithLabelValues(
|
|||||||
return metric
|
return metric
|
||||||
}
|
}
|
||||||
|
|
||||||
// getOrCreateMetricWithLabelValues retrieves the metric by hash and label value
|
// getOrCreateMetricWithLabels retrieves the metric by hash and label value
|
||||||
// or creates it and returns the new one.
|
// or creates it and returns the new one.
|
||||||
//
|
//
|
||||||
// This function holds the mutex.
|
// This function holds the mutex.
|
||||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -421,8 +421,10 @@ github.com/pkg/errors
|
|||||||
# github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
|
# github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
|
||||||
## explicit
|
## explicit
|
||||||
github.com/pmezard/go-difflib/difflib
|
github.com/pmezard/go-difflib/difflib
|
||||||
# github.com/prometheus/client_golang v1.19.1
|
# github.com/prometheus/client_golang v1.20.1
|
||||||
## explicit; go 1.20
|
## explicit; go 1.20
|
||||||
|
github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil
|
||||||
|
github.com/prometheus/client_golang/internal/github.com/golang/gddo/httputil/header
|
||||||
github.com/prometheus/client_golang/prometheus
|
github.com/prometheus/client_golang/prometheus
|
||||||
github.com/prometheus/client_golang/prometheus/internal
|
github.com/prometheus/client_golang/prometheus/internal
|
||||||
github.com/prometheus/client_golang/prometheus/promhttp
|
github.com/prometheus/client_golang/prometheus/promhttp
|
||||||
|
Loading…
Reference in New Issue
Block a user