diff --git a/go.mod b/go.mod index df6034e5..5ad0bdbe 100644 --- a/go.mod +++ b/go.mod @@ -14,9 +14,9 @@ require ( github.com/onsi/gomega v1.44.0 github.com/pelletier/go-toml/v2 v2.4.3 github.com/pires/go-proxyproto v0.15.0 - github.com/prometheus/client_golang v1.19.1 - github.com/prometheus/client_model v0.5.0 - github.com/prometheus/common v0.48.0 + github.com/prometheus/client_golang v1.25.0 + github.com/prometheus/client_model v0.6.3 + github.com/prometheus/common v0.72.0 github.com/quic-go/quic-go v0.60.0 github.com/rodaine/table v1.4.1 github.com/samber/lo v1.53.0 @@ -44,7 +44,7 @@ require ( github.com/Azure/go-ntlmssp v0.1.1 // indirect github.com/Masterminds/semver/v3 v3.4.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/go-jose/go-jose/v4 v4.1.4 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect @@ -54,8 +54,9 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/klauspost/cpuid/v2 v2.2.6 // indirect github.com/klauspost/reedsolomon v1.12.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/procfs v0.22.0 // indirect github.com/templexxx/cpu v0.1.1 // indirect github.com/templexxx/xorsimd v0.4.3 // indirect github.com/tidwall/match v1.1.1 // indirect @@ -67,7 +68,7 @@ require ( golang.org/x/text v0.43.0 // indirect golang.org/x/tools v0.51.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/protobuf v1.36.7 // indirect + google.golang.org/protobuf v1.36.12 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/go.sum b/go.sum index 05fd703c..3bd3c183 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY= github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= @@ -75,6 +75,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE= github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung= +github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ= +github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/reedsolomon v1.12.0 h1:I5FEp3xSwVCcEh3F5A7dofEfhXdF/bWhQWPH+XwBFno= @@ -83,12 +85,16 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 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/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/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= github.com/mattn/go-runewidth v0.0.31 h1:1oCV4ReTlosDBc6rYRw5cL8S/4y8iv5oRl4SJ5IBgwo= github.com/mattn/go-runewidth v0.0.31/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8= github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo/v2 v2.34.0 h1:aN3Us823mHHTSWMIi8WIQTdYuSPhl2lWY46E/w3SiAk= github.com/onsi/ginkgo/v2 v2.34.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= github.com/onsi/gomega v1.44.0 h1:eAiGl3Pw5jz5GQdDff0BcxYpAX1JxW8xD7mFUuwNfZQ= @@ -100,15 +106,15 @@ github.com/pires/go-proxyproto v0.15.0/go.mod h1:OXsCrKwrK2tXS9YrI5tkHx5xaQlO8FH github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0= +github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= -github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= -github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo= +github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM= +github.com/prometheus/common v0.72.0 h1:tAYsE+sPJxIncDAobm4H5aQjmox9ZxEIIqPbiffa8G4= +github.com/prometheus/common v0.72.0/go.mod h1:77NWqAQ2tXT7BIK40qjJdw5Acrsrg1TlHAnsQi3i6mk= +github.com/prometheus/procfs v0.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics= +github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58= github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0= github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk= github.com/quic-go/quic-go v0.60.0 h1:xcQioE8OM66UQLeUMHltK1CCcOu3JbVB4JAQdDQSB+0= @@ -159,8 +165,12 @@ github.com/xtaci/kcp-go/v5 v5.6.13 h1:FEjtz9+D4p8t2x4WjciGt/jsIuhlWjjgPCCWjrVR4H github.com/xtaci/kcp-go/v5 v5.6.13/go.mod h1:75S1AKYYzNUSXIv30h+jPKJYZUwqpfvLshu63nCNSOM= github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 h1:EWU6Pktpas0n8lLQwDsRyZfmkPeRbdgPtW609es+/9E= github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37/go.mod h1:HpMP7DB2CyokmAh4lp0EQnnWhmycP/TvwBGzvuie+H0= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko= go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o= +go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= +go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= @@ -234,8 +244,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A= -google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= +google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= +google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/pkg/metrics/text/runtime.go b/pkg/metrics/text/runtime.go index 88ede04a..77483780 100644 --- a/pkg/metrics/text/runtime.go +++ b/pkg/metrics/text/runtime.go @@ -37,133 +37,131 @@ type memstats struct { var memstatsFamilies = []memstats{ { name: "go_memstats_alloc_bytes", - help: "Number of bytes allocated and still in use.", + help: "Number of bytes allocated in heap and currently in use. Equals to /memory/classes/heap/objects:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.Alloc) }, }, { name: "go_memstats_alloc_bytes_total", - help: "Total number of bytes allocated, even if freed.", + help: "Total number of bytes allocated in heap until now, even if released already. Equals to /gc/heap/allocs:bytes.", typ: typeCounter, get: func(ms *runtime.MemStats) float64 { return float64(ms.TotalAlloc) }, }, { name: "go_memstats_buck_hash_sys_bytes", - help: "Number of bytes used by the profiling bucket hash table.", + help: "Number of bytes used by the profiling bucket hash table. Equals to /memory/classes/profiling/buckets:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.BuckHashSys) }, }, { name: "go_memstats_frees_total", - help: "Total number of frees.", + help: "Total number of heap objects frees. Equals to /gc/heap/frees:objects + /gc/heap/tiny/allocs:objects.", typ: typeCounter, get: func(ms *runtime.MemStats) float64 { return float64(ms.Frees) }, }, { name: "go_memstats_gc_sys_bytes", - help: "Number of bytes used for garbage collection system metadata.", + help: "Number of bytes used for garbage collection system metadata. Equals to /memory/classes/metadata/other:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.GCSys) }, }, { name: "go_memstats_heap_alloc_bytes", - help: "Number of heap bytes allocated and still in use.", + help: "Number of heap bytes allocated and currently in use, same as go_memstats_alloc_bytes. Equals to /memory/classes/heap/objects:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.HeapAlloc) }, }, { name: "go_memstats_heap_idle_bytes", - help: "Number of heap bytes waiting to be used.", + help: "Number of heap bytes waiting to be used. Equals to /memory/classes/heap/released:bytes + /memory/classes/heap/free:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.HeapIdle) }, }, { name: "go_memstats_heap_inuse_bytes", - help: "Number of heap bytes that are in use.", + help: "Number of heap bytes that are in use. Equals to /memory/classes/heap/objects:bytes + /memory/classes/heap/unused:bytes", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.HeapInuse) }, }, { name: "go_memstats_heap_objects", - help: "Number of allocated objects.", + help: "Number of currently allocated objects. Equals to /gc/heap/objects:objects.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.HeapObjects) }, }, { name: "go_memstats_heap_released_bytes", - help: "Number of heap bytes released to OS.", + help: "Number of heap bytes released to OS. Equals to /memory/classes/heap/released:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.HeapReleased) }, }, { name: "go_memstats_heap_sys_bytes", - help: "Number of heap bytes obtained from system.", - typ: typeGauge, - get: func(ms *runtime.MemStats) float64 { return float64(ms.HeapSys) }, - }, - { - name: "go_memstats_lookups_total", - help: "Total number of pointer lookups.", - typ: typeCounter, - get: func(ms *runtime.MemStats) float64 { return float64(ms.Lookups) }, + help: "Number of heap bytes obtained from system. Equals to /memory/classes/heap/objects:bytes + /memory/classes/heap/unused:bytes + /memory/classe" + + "s/heap/released:bytes + /memory/classes/heap/free:bytes.", + typ: typeGauge, + get: func(ms *runtime.MemStats) float64 { return float64(ms.HeapSys) }, }, { name: "go_memstats_mallocs_total", - help: "Total number of mallocs.", - typ: typeCounter, - get: func(ms *runtime.MemStats) float64 { return float64(ms.Mallocs) }, + help: "Total number of heap objects allocated, both live and gc-ed. Semantically a counter version for go_memstats_heap_objects gauge. Equals to /g" + + "c/heap/allocs:objects + /gc/heap/tiny/allocs:objects.", + typ: typeCounter, + get: func(ms *runtime.MemStats) float64 { return float64(ms.Mallocs) }, }, { name: "go_memstats_mcache_inuse_bytes", - help: "Number of bytes in use by mcache structures.", + help: "Number of bytes in use by mcache structures. Equals to /memory/classes/metadata/mcache/inuse:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheInuse) }, }, { name: "go_memstats_mcache_sys_bytes", - help: "Number of bytes used for mcache structures obtained from system.", - typ: typeGauge, - get: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheSys) }, + help: "Number of bytes used for mcache structures obtained from system. Equals to /memory/classes/metadata/mcache/inuse:bytes + /memory/classes/met" + + "adata/mcache/free:bytes.", + typ: typeGauge, + get: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheSys) }, }, { name: "go_memstats_mspan_inuse_bytes", - help: "Number of bytes in use by mspan structures.", + help: "Number of bytes in use by mspan structures. Equals to /memory/classes/metadata/mspan/inuse:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanInuse) }, }, { name: "go_memstats_mspan_sys_bytes", - help: "Number of bytes used for mspan structures obtained from system.", - typ: typeGauge, - get: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanSys) }, + help: "Number of bytes used for mspan structures obtained from system. Equals to /memory/classes/metadata/mspan/inuse:bytes + /memory/classes/metad" + + "ata/mspan/free:bytes.", + typ: typeGauge, + get: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanSys) }, }, { name: "go_memstats_next_gc_bytes", - help: "Number of heap bytes when next garbage collection will take place.", + help: "Number of heap bytes when next garbage collection will take place. Equals to /gc/heap/goal:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.NextGC) }, }, { name: "go_memstats_other_sys_bytes", - help: "Number of bytes used for other system allocations.", + help: "Number of bytes used for other system allocations. Equals to /memory/classes/other:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.OtherSys) }, }, { name: "go_memstats_stack_inuse_bytes", - help: "Number of bytes in use by the stack allocator.", + help: "Number of bytes obtained from system for stack allocator in non-CGO environments. Equals to /memory/classes/heap/stacks:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.StackInuse) }, }, { name: "go_memstats_stack_sys_bytes", - help: "Number of bytes obtained from system for stack allocator.", + help: "Number of bytes obtained from system for stack allocator. Equals to /memory/classes/heap/stacks:bytes + /memory/classes/os-stacks:bytes.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.StackSys) }, }, { name: "go_memstats_sys_bytes", - help: "Number of bytes obtained from system.", + help: "Number of bytes obtained from system. Equals to /memory/classes/total:byte.", typ: typeGauge, get: func(ms *runtime.MemStats) float64 { return float64(ms.Sys) }, }, @@ -359,7 +357,7 @@ func runtimeFamilies() []family { return append(out, family{ name: "go_gc_duration_seconds", - help: "A summary of the pause duration of garbage collection cycles.", + help: "A summary of the wall-time pause (stop-the-world) duration in garbage collection cycles.", typ: typeSummary, samples: gcSamples, }, @@ -389,9 +387,37 @@ func runtimeFamilies() []family { typ: typeGauge, samples: []sample{{value: float64(threadCount())}}, }, + family{ + name: "go_gc_gogc_percent", + help: "Heap size target percentage configured by the user, otherwise 100. This value is set by the GOGC environment variable, and the runtime/debug" + + ".SetGCPercent function. Sourced from /gc/gogc:percent.", + typ: typeGauge, + samples: []sample{{value: float64(readRuntimeMetric("/gc/gogc:percent"))}}, + }, + family{ + name: "go_gc_gomemlimit_bytes", + help: "Go runtime memory limit configured by the user, otherwise math.MaxInt64. This value is set by the GOMEMLIMIT environment variable, and the r" + + "untime/debug.SetMemoryLimit function. Sourced from /gc/gomemlimit:bytes.", + typ: typeGauge, + samples: []sample{{value: float64(readRuntimeMetric("/gc/gomemlimit:bytes"))}}, + }, + family{ + name: "go_sched_gomaxprocs_threads", + help: "The current runtime.GOMAXPROCS setting, or the number of operating system threads that can execute user-level Go code simultaneously. Source" + + "d from /sched/gomaxprocs:threads.", + typ: typeGauge, + samples: []sample{{value: float64(runtime.GOMAXPROCS(0))}}, + }, ) } +// readRuntimeMetric reads one runtime/metrics gauge. +func readRuntimeMetric(name string) uint64 { + s := []metrics.Sample{{Name: name}} + metrics.Read(s) + return s[0].Value.Uint64() +} + func threadCount() int { n, _ := runtime.ThreadCreateProfile(nil) return n diff --git a/pkg/metrics/text/runtime_test.go b/pkg/metrics/text/runtime_test.go index 2484e041..04911a42 100644 --- a/pkg/metrics/text/runtime_test.go +++ b/pkg/metrics/text/runtime_test.go @@ -74,8 +74,7 @@ func TestMemStatsMapping(t *testing.T) { "go_memstats_heap_objects": 900, "go_memstats_heap_released_bytes": 5 << 20, "go_memstats_heap_sys_bytes": 17 << 20, // inuse + idle - "go_memstats_lookups_total": 0, - "go_memstats_mallocs_total": 103, // 100 mallocs + 3 tiny allocs + "go_memstats_mallocs_total": 103, // 100 mallocs + 3 tiny allocs "go_memstats_mcache_inuse_bytes": 1 << 17, "go_memstats_mcache_sys_bytes": 3 << 16, // inuse + free "go_memstats_mspan_inuse_bytes": 1 << 19, diff --git a/pkg/metrics/text/text_test.go b/pkg/metrics/text/text_test.go index 3bc1bbb3..e574aa0b 100644 --- a/pkg/metrics/text/text_test.go +++ b/pkg/metrics/text/text_test.go @@ -24,6 +24,7 @@ import ( "github.com/prometheus/client_golang/prometheus/collectors" dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" + "github.com/prometheus/common/model" "github.com/stretchr/testify/require" ) @@ -41,7 +42,7 @@ func gather(t *testing.T) string { // so anything a scraper would reject fails the test. func parseFamilies(t *testing.T, body string) map[string]*dto.MetricFamily { t.Helper() - parser := expfmt.TextParser{} + parser := expfmt.NewTextParser(model.UTF8Validation) families, err := parser.TextToMetricFamilies(strings.NewReader(body)) require.NoError(t, err, "output must be valid text exposition format") return families