diff --git a/go.mod b/go.mod
index 75cafbe..03fd099 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,6 @@ require (
github.com/jacobbrewer1/vaulty v0.1.5
github.com/jmoiron/sqlx v1.4.0
github.com/pingcap/tidb/pkg/parser v0.0.0-20241101162255-241c10294b9c
- github.com/prometheus/client_golang v1.20.5
github.com/stretchr/testify v1.10.0
)
@@ -21,11 +20,10 @@ require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
- github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
- github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
+ github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
@@ -40,30 +38,26 @@ require (
github.com/hashicorp/vault/api/auth/kubernetes v0.8.0 // indirect
github.com/hashicorp/vault/api/auth/userpass v0.8.0 // indirect
github.com/imdario/mergo v0.3.11 // indirect
+ github.com/kr/pretty v0.3.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
- github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb // indirect
github.com/pingcap/failpoint v0.0.0-20240528011301-b51a646c7c86 // indirect
github.com/pingcap/log v1.1.1-0.20230317032135-a0d097d16e22 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_model v0.6.1 // indirect
- github.com/prometheus/common v0.55.0 // indirect
- github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
- golang.org/x/crypto v0.26.0 // indirect
+ golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.26.0 // indirect
- golang.org/x/sys v0.23.0 // indirect
- golang.org/x/text v0.19.0 // indirect
+ golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.6.0 // indirect
- google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
+ gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/go.sum b/go.sum
index ea3ab14..ec71e1e 100644
--- a/go.sum
+++ b/go.sum
@@ -9,13 +9,10 @@ github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZC
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
-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/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
-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/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
@@ -74,8 +71,6 @@ github.com/jacobbrewer1/vaulty v0.1.5 h1:VWVlu4DnFNLWvVaM2K8fFaqEMVkI/3L8bKUiSm0
github.com/jacobbrewer1/vaulty v0.1.5/go.mod h1:3x2pJ0lPDGQWud6TPcrB+dc0tu1A/3s9bnRi265HtMI=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
-github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
-github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
@@ -104,8 +99,6 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
-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/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb h1:3pSi4EDG6hg0orE1ndHkXvX6Qdq2cZn8gAPir8ymKZk=
github.com/pingcap/errors v0.11.5-0.20240311024730-e056997136bb/go.mod h1:X2r9ueLEUZgtx2cIogM0v4Zj5uvvzhuuiu7Pn8HzMPg=
@@ -115,19 +108,13 @@ github.com/pingcap/log v1.1.1-0.20230317032135-a0d097d16e22 h1:2SOzvGvE8beiC1Y4g
github.com/pingcap/log v1.1.1-0.20230317032135-a0d097d16e22/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/tidb/pkg/parser v0.0.0-20241101162255-241c10294b9c h1:YRD6Qlb71cbKkU4utVKMka4GcZf0K9BJWErUhFOA8D8=
github.com/pingcap/tidb/pkg/parser v0.0.0-20241101162255-241c10294b9c/go.mod h1:Hju1TEWZvrctQKbztTRwXH7rd41Yq0Pgmq4PrEKcq7o=
+github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
-github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
-github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
-github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
-github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
-github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
-github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
-github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
-github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
+github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
@@ -157,8 +144,8 @@ go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
-golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
+golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
+golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -167,19 +154,17 @@ golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
-golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
+golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
-golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
+golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
diff --git a/vendor/github.com/beorn7/perks/LICENSE b/vendor/github.com/beorn7/perks/LICENSE
deleted file mode 100644
index 339177b..0000000
--- a/vendor/github.com/beorn7/perks/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (C) 2013 Blake Mizerany
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/beorn7/perks/quantile/exampledata.txt b/vendor/github.com/beorn7/perks/quantile/exampledata.txt
deleted file mode 100644
index 1602287..0000000
--- a/vendor/github.com/beorn7/perks/quantile/exampledata.txt
+++ /dev/null
@@ -1,2388 +0,0 @@
-8
-5
-26
-12
-5
-235
-13
-6
-28
-30
-3
-3
-3
-3
-5
-2
-33
-7
-2
-4
-7
-12
-14
-5
-8
-3
-10
-4
-5
-3
-6
-6
-209
-20
-3
-10
-14
-3
-4
-6
-8
-5
-11
-7
-3
-2
-3
-3
-212
-5
-222
-4
-10
-10
-5
-6
-3
-8
-3
-10
-254
-220
-2
-3
-5
-24
-5
-4
-222
-7
-3
-3
-223
-8
-15
-12
-14
-14
-3
-2
-2
-3
-13
-3
-11
-4
-4
-6
-5
-7
-13
-5
-3
-5
-2
-5
-3
-5
-2
-7
-15
-17
-14
-3
-6
-6
-3
-17
-5
-4
-7
-6
-4
-4
-8
-6
-8
-3
-9
-3
-6
-3
-4
-5
-3
-3
-660
-4
-6
-10
-3
-6
-3
-2
-5
-13
-2
-4
-4
-10
-4
-8
-4
-3
-7
-9
-9
-3
-10
-37
-3
-13
-4
-12
-3
-6
-10
-8
-5
-21
-2
-3
-8
-3
-2
-3
-3
-4
-12
-2
-4
-8
-8
-4
-3
-2
-20
-1
-6
-32
-2
-11
-6
-18
-3
-8
-11
-3
-212
-3
-4
-2
-6
-7
-12
-11
-3
-2
-16
-10
-6
-4
-6
-3
-2
-7
-3
-2
-2
-2
-2
-5
-6
-4
-3
-10
-3
-4
-6
-5
-3
-4
-4
-5
-6
-4
-3
-4
-4
-5
-7
-5
-5
-3
-2
-7
-2
-4
-12
-4
-5
-6
-2
-4
-4
-8
-4
-15
-13
-7
-16
-5
-3
-23
-5
-5
-7
-3
-2
-9
-8
-7
-5
-8
-11
-4
-10
-76
-4
-47
-4
-3
-2
-7
-4
-2
-3
-37
-10
-4
-2
-20
-5
-4
-4
-10
-10
-4
-3
-7
-23
-240
-7
-13
-5
-5
-3
-3
-2
-5
-4
-2
-8
-7
-19
-2
-23
-8
-7
-2
-5
-3
-8
-3
-8
-13
-5
-5
-5
-2
-3
-23
-4
-9
-8
-4
-3
-3
-5
-220
-2
-3
-4
-6
-14
-3
-53
-6
-2
-5
-18
-6
-3
-219
-6
-5
-2
-5
-3
-6
-5
-15
-4
-3
-17
-3
-2
-4
-7
-2
-3
-3
-4
-4
-3
-2
-664
-6
-3
-23
-5
-5
-16
-5
-8
-2
-4
-2
-24
-12
-3
-2
-3
-5
-8
-3
-5
-4
-3
-14
-3
-5
-8
-2
-3
-7
-9
-4
-2
-3
-6
-8
-4
-3
-4
-6
-5
-3
-3
-6
-3
-19
-4
-4
-6
-3
-6
-3
-5
-22
-5
-4
-4
-3
-8
-11
-4
-9
-7
-6
-13
-4
-4
-4
-6
-17
-9
-3
-3
-3
-4
-3
-221
-5
-11
-3
-4
-2
-12
-6
-3
-5
-7
-5
-7
-4
-9
-7
-14
-37
-19
-217
-16
-3
-5
-2
-2
-7
-19
-7
-6
-7
-4
-24
-5
-11
-4
-7
-7
-9
-13
-3
-4
-3
-6
-28
-4
-4
-5
-5
-2
-5
-6
-4
-4
-6
-10
-5
-4
-3
-2
-3
-3
-6
-5
-5
-4
-3
-2
-3
-7
-4
-6
-18
-16
-8
-16
-4
-5
-8
-6
-9
-13
-1545
-6
-215
-6
-5
-6
-3
-45
-31
-5
-2
-2
-4
-3
-3
-2
-5
-4
-3
-5
-7
-7
-4
-5
-8
-5
-4
-749
-2
-31
-9
-11
-2
-11
-5
-4
-4
-7
-9
-11
-4
-5
-4
-7
-3
-4
-6
-2
-15
-3
-4
-3
-4
-3
-5
-2
-13
-5
-5
-3
-3
-23
-4
-4
-5
-7
-4
-13
-2
-4
-3
-4
-2
-6
-2
-7
-3
-5
-5
-3
-29
-5
-4
-4
-3
-10
-2
-3
-79
-16
-6
-6
-7
-7
-3
-5
-5
-7
-4
-3
-7
-9
-5
-6
-5
-9
-6
-3
-6
-4
-17
-2
-10
-9
-3
-6
-2
-3
-21
-22
-5
-11
-4
-2
-17
-2
-224
-2
-14
-3
-4
-4
-2
-4
-4
-4
-4
-5
-3
-4
-4
-10
-2
-6
-3
-3
-5
-7
-2
-7
-5
-6
-3
-218
-2
-2
-5
-2
-6
-3
-5
-222
-14
-6
-33
-3
-2
-5
-3
-3
-3
-9
-5
-3
-3
-2
-7
-4
-3
-4
-3
-5
-6
-5
-26
-4
-13
-9
-7
-3
-221
-3
-3
-4
-4
-4
-4
-2
-18
-5
-3
-7
-9
-6
-8
-3
-10
-3
-11
-9
-5
-4
-17
-5
-5
-6
-6
-3
-2
-4
-12
-17
-6
-7
-218
-4
-2
-4
-10
-3
-5
-15
-3
-9
-4
-3
-3
-6
-29
-3
-3
-4
-5
-5
-3
-8
-5
-6
-6
-7
-5
-3
-5
-3
-29
-2
-31
-5
-15
-24
-16
-5
-207
-4
-3
-3
-2
-15
-4
-4
-13
-5
-5
-4
-6
-10
-2
-7
-8
-4
-6
-20
-5
-3
-4
-3
-12
-12
-5
-17
-7
-3
-3
-3
-6
-10
-3
-5
-25
-80
-4
-9
-3
-2
-11
-3
-3
-2
-3
-8
-7
-5
-5
-19
-5
-3
-3
-12
-11
-2
-6
-5
-5
-5
-3
-3
-3
-4
-209
-14
-3
-2
-5
-19
-4
-4
-3
-4
-14
-5
-6
-4
-13
-9
-7
-4
-7
-10
-2
-9
-5
-7
-2
-8
-4
-6
-5
-5
-222
-8
-7
-12
-5
-216
-3
-4
-4
-6
-3
-14
-8
-7
-13
-4
-3
-3
-3
-3
-17
-5
-4
-3
-33
-6
-6
-33
-7
-5
-3
-8
-7
-5
-2
-9
-4
-2
-233
-24
-7
-4
-8
-10
-3
-4
-15
-2
-16
-3
-3
-13
-12
-7
-5
-4
-207
-4
-2
-4
-27
-15
-2
-5
-2
-25
-6
-5
-5
-6
-13
-6
-18
-6
-4
-12
-225
-10
-7
-5
-2
-2
-11
-4
-14
-21
-8
-10
-3
-5
-4
-232
-2
-5
-5
-3
-7
-17
-11
-6
-6
-23
-4
-6
-3
-5
-4
-2
-17
-3
-6
-5
-8
-3
-2
-2
-14
-9
-4
-4
-2
-5
-5
-3
-7
-6
-12
-6
-10
-3
-6
-2
-2
-19
-5
-4
-4
-9
-2
-4
-13
-3
-5
-6
-3
-6
-5
-4
-9
-6
-3
-5
-7
-3
-6
-6
-4
-3
-10
-6
-3
-221
-3
-5
-3
-6
-4
-8
-5
-3
-6
-4
-4
-2
-54
-5
-6
-11
-3
-3
-4
-4
-4
-3
-7
-3
-11
-11
-7
-10
-6
-13
-223
-213
-15
-231
-7
-3
-7
-228
-2
-3
-4
-4
-5
-6
-7
-4
-13
-3
-4
-5
-3
-6
-4
-6
-7
-2
-4
-3
-4
-3
-3
-6
-3
-7
-3
-5
-18
-5
-6
-8
-10
-3
-3
-3
-2
-4
-2
-4
-4
-5
-6
-6
-4
-10
-13
-3
-12
-5
-12
-16
-8
-4
-19
-11
-2
-4
-5
-6
-8
-5
-6
-4
-18
-10
-4
-2
-216
-6
-6
-6
-2
-4
-12
-8
-3
-11
-5
-6
-14
-5
-3
-13
-4
-5
-4
-5
-3
-28
-6
-3
-7
-219
-3
-9
-7
-3
-10
-6
-3
-4
-19
-5
-7
-11
-6
-15
-19
-4
-13
-11
-3
-7
-5
-10
-2
-8
-11
-2
-6
-4
-6
-24
-6
-3
-3
-3
-3
-6
-18
-4
-11
-4
-2
-5
-10
-8
-3
-9
-5
-3
-4
-5
-6
-2
-5
-7
-4
-4
-14
-6
-4
-4
-5
-5
-7
-2
-4
-3
-7
-3
-3
-6
-4
-5
-4
-4
-4
-3
-3
-3
-3
-8
-14
-2
-3
-5
-3
-2
-4
-5
-3
-7
-3
-3
-18
-3
-4
-4
-5
-7
-3
-3
-3
-13
-5
-4
-8
-211
-5
-5
-3
-5
-2
-5
-4
-2
-655
-6
-3
-5
-11
-2
-5
-3
-12
-9
-15
-11
-5
-12
-217
-2
-6
-17
-3
-3
-207
-5
-5
-4
-5
-9
-3
-2
-8
-5
-4
-3
-2
-5
-12
-4
-14
-5
-4
-2
-13
-5
-8
-4
-225
-4
-3
-4
-5
-4
-3
-3
-6
-23
-9
-2
-6
-7
-233
-4
-4
-6
-18
-3
-4
-6
-3
-4
-4
-2
-3
-7
-4
-13
-227
-4
-3
-5
-4
-2
-12
-9
-17
-3
-7
-14
-6
-4
-5
-21
-4
-8
-9
-2
-9
-25
-16
-3
-6
-4
-7
-8
-5
-2
-3
-5
-4
-3
-3
-5
-3
-3
-3
-2
-3
-19
-2
-4
-3
-4
-2
-3
-4
-4
-2
-4
-3
-3
-3
-2
-6
-3
-17
-5
-6
-4
-3
-13
-5
-3
-3
-3
-4
-9
-4
-2
-14
-12
-4
-5
-24
-4
-3
-37
-12
-11
-21
-3
-4
-3
-13
-4
-2
-3
-15
-4
-11
-4
-4
-3
-8
-3
-4
-4
-12
-8
-5
-3
-3
-4
-2
-220
-3
-5
-223
-3
-3
-3
-10
-3
-15
-4
-241
-9
-7
-3
-6
-6
-23
-4
-13
-7
-3
-4
-7
-4
-9
-3
-3
-4
-10
-5
-5
-1
-5
-24
-2
-4
-5
-5
-6
-14
-3
-8
-2
-3
-5
-13
-13
-3
-5
-2
-3
-15
-3
-4
-2
-10
-4
-4
-4
-5
-5
-3
-5
-3
-4
-7
-4
-27
-3
-6
-4
-15
-3
-5
-6
-6
-5
-4
-8
-3
-9
-2
-6
-3
-4
-3
-7
-4
-18
-3
-11
-3
-3
-8
-9
-7
-24
-3
-219
-7
-10
-4
-5
-9
-12
-2
-5
-4
-4
-4
-3
-3
-19
-5
-8
-16
-8
-6
-22
-3
-23
-3
-242
-9
-4
-3
-3
-5
-7
-3
-3
-5
-8
-3
-7
-5
-14
-8
-10
-3
-4
-3
-7
-4
-6
-7
-4
-10
-4
-3
-11
-3
-7
-10
-3
-13
-6
-8
-12
-10
-5
-7
-9
-3
-4
-7
-7
-10
-8
-30
-9
-19
-4
-3
-19
-15
-4
-13
-3
-215
-223
-4
-7
-4
-8
-17
-16
-3
-7
-6
-5
-5
-4
-12
-3
-7
-4
-4
-13
-4
-5
-2
-5
-6
-5
-6
-6
-7
-10
-18
-23
-9
-3
-3
-6
-5
-2
-4
-2
-7
-3
-3
-2
-5
-5
-14
-10
-224
-6
-3
-4
-3
-7
-5
-9
-3
-6
-4
-2
-5
-11
-4
-3
-3
-2
-8
-4
-7
-4
-10
-7
-3
-3
-18
-18
-17
-3
-3
-3
-4
-5
-3
-3
-4
-12
-7
-3
-11
-13
-5
-4
-7
-13
-5
-4
-11
-3
-12
-3
-6
-4
-4
-21
-4
-6
-9
-5
-3
-10
-8
-4
-6
-4
-4
-6
-5
-4
-8
-6
-4
-6
-4
-4
-5
-9
-6
-3
-4
-2
-9
-3
-18
-2
-4
-3
-13
-3
-6
-6
-8
-7
-9
-3
-2
-16
-3
-4
-6
-3
-2
-33
-22
-14
-4
-9
-12
-4
-5
-6
-3
-23
-9
-4
-3
-5
-5
-3
-4
-5
-3
-5
-3
-10
-4
-5
-5
-8
-4
-4
-6
-8
-5
-4
-3
-4
-6
-3
-3
-3
-5
-9
-12
-6
-5
-9
-3
-5
-3
-2
-2
-2
-18
-3
-2
-21
-2
-5
-4
-6
-4
-5
-10
-3
-9
-3
-2
-10
-7
-3
-6
-6
-4
-4
-8
-12
-7
-3
-7
-3
-3
-9
-3
-4
-5
-4
-4
-5
-5
-10
-15
-4
-4
-14
-6
-227
-3
-14
-5
-216
-22
-5
-4
-2
-2
-6
-3
-4
-2
-9
-9
-4
-3
-28
-13
-11
-4
-5
-3
-3
-2
-3
-3
-5
-3
-4
-3
-5
-23
-26
-3
-4
-5
-6
-4
-6
-3
-5
-5
-3
-4
-3
-2
-2
-2
-7
-14
-3
-6
-7
-17
-2
-2
-15
-14
-16
-4
-6
-7
-13
-6
-4
-5
-6
-16
-3
-3
-28
-3
-6
-15
-3
-9
-2
-4
-6
-3
-3
-22
-4
-12
-6
-7
-2
-5
-4
-10
-3
-16
-6
-9
-2
-5
-12
-7
-5
-5
-5
-5
-2
-11
-9
-17
-4
-3
-11
-7
-3
-5
-15
-4
-3
-4
-211
-8
-7
-5
-4
-7
-6
-7
-6
-3
-6
-5
-6
-5
-3
-4
-4
-26
-4
-6
-10
-4
-4
-3
-2
-3
-3
-4
-5
-9
-3
-9
-4
-4
-5
-5
-8
-2
-4
-2
-3
-8
-4
-11
-19
-5
-8
-6
-3
-5
-6
-12
-3
-2
-4
-16
-12
-3
-4
-4
-8
-6
-5
-6
-6
-219
-8
-222
-6
-16
-3
-13
-19
-5
-4
-3
-11
-6
-10
-4
-7
-7
-12
-5
-3
-3
-5
-6
-10
-3
-8
-2
-5
-4
-7
-2
-4
-4
-2
-12
-9
-6
-4
-2
-40
-2
-4
-10
-4
-223
-4
-2
-20
-6
-7
-24
-5
-4
-5
-2
-20
-16
-6
-5
-13
-2
-3
-3
-19
-3
-2
-4
-5
-6
-7
-11
-12
-5
-6
-7
-7
-3
-5
-3
-5
-3
-14
-3
-4
-4
-2
-11
-1
-7
-3
-9
-6
-11
-12
-5
-8
-6
-221
-4
-2
-12
-4
-3
-15
-4
-5
-226
-7
-218
-7
-5
-4
-5
-18
-4
-5
-9
-4
-4
-2
-9
-18
-18
-9
-5
-6
-6
-3
-3
-7
-3
-5
-4
-4
-4
-12
-3
-6
-31
-5
-4
-7
-3
-6
-5
-6
-5
-11
-2
-2
-11
-11
-6
-7
-5
-8
-7
-10
-5
-23
-7
-4
-3
-5
-34
-2
-5
-23
-7
-3
-6
-8
-4
-4
-4
-2
-5
-3
-8
-5
-4
-8
-25
-2
-3
-17
-8
-3
-4
-8
-7
-3
-15
-6
-5
-7
-21
-9
-5
-6
-6
-5
-3
-2
-3
-10
-3
-6
-3
-14
-7
-4
-4
-8
-7
-8
-2
-6
-12
-4
-213
-6
-5
-21
-8
-2
-5
-23
-3
-11
-2
-3
-6
-25
-2
-3
-6
-7
-6
-6
-4
-4
-6
-3
-17
-9
-7
-6
-4
-3
-10
-7
-2
-3
-3
-3
-11
-8
-3
-7
-6
-4
-14
-36
-3
-4
-3
-3
-22
-13
-21
-4
-2
-7
-4
-4
-17
-15
-3
-7
-11
-2
-4
-7
-6
-209
-6
-3
-2
-2
-24
-4
-9
-4
-3
-3
-3
-29
-2
-2
-4
-3
-3
-5
-4
-6
-3
-3
-2
-4
diff --git a/vendor/github.com/beorn7/perks/quantile/stream.go b/vendor/github.com/beorn7/perks/quantile/stream.go
deleted file mode 100644
index d7d14f8..0000000
--- a/vendor/github.com/beorn7/perks/quantile/stream.go
+++ /dev/null
@@ -1,316 +0,0 @@
-// Package quantile computes approximate quantiles over an unbounded data
-// stream within low memory and CPU bounds.
-//
-// A small amount of accuracy is traded to achieve the above properties.
-//
-// Multiple streams can be merged before calling Query to generate a single set
-// of results. This is meaningful when the streams represent the same type of
-// data. See Merge and Samples.
-//
-// For more detailed information about the algorithm used, see:
-//
-// Effective Computation of Biased Quantiles over Data Streams
-//
-// http://www.cs.rutgers.edu/~muthu/bquant.pdf
-package quantile
-
-import (
- "math"
- "sort"
-)
-
-// Sample holds an observed value and meta information for compression. JSON
-// tags have been added for convenience.
-type Sample struct {
- Value float64 `json:",string"`
- Width float64 `json:",string"`
- Delta float64 `json:",string"`
-}
-
-// Samples represents a slice of samples. It implements sort.Interface.
-type Samples []Sample
-
-func (a Samples) Len() int { return len(a) }
-func (a Samples) Less(i, j int) bool { return a[i].Value < a[j].Value }
-func (a Samples) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
-
-type invariant func(s *stream, r float64) float64
-
-// NewLowBiased returns an initialized Stream for low-biased quantiles
-// (e.g. 0.01, 0.1, 0.5) where the needed quantiles are not known a priori, but
-// error guarantees can still be given even for the lower ranks of the data
-// distribution.
-//
-// The provided epsilon is a relative error, i.e. the true quantile of a value
-// returned by a query is guaranteed to be within (1±Epsilon)*Quantile.
-//
-// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error
-// properties.
-func NewLowBiased(epsilon float64) *Stream {
- ƒ := func(s *stream, r float64) float64 {
- return 2 * epsilon * r
- }
- return newStream(ƒ)
-}
-
-// NewHighBiased returns an initialized Stream for high-biased quantiles
-// (e.g. 0.01, 0.1, 0.5) where the needed quantiles are not known a priori, but
-// error guarantees can still be given even for the higher ranks of the data
-// distribution.
-//
-// The provided epsilon is a relative error, i.e. the true quantile of a value
-// returned by a query is guaranteed to be within 1-(1±Epsilon)*(1-Quantile).
-//
-// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error
-// properties.
-func NewHighBiased(epsilon float64) *Stream {
- ƒ := func(s *stream, r float64) float64 {
- return 2 * epsilon * (s.n - r)
- }
- return newStream(ƒ)
-}
-
-// NewTargeted returns an initialized Stream concerned with a particular set of
-// quantile values that are supplied a priori. Knowing these a priori reduces
-// space and computation time. The targets map maps the desired quantiles to
-// their absolute errors, i.e. the true quantile of a value returned by a query
-// is guaranteed to be within (Quantile±Epsilon).
-//
-// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error properties.
-func NewTargeted(targetMap map[float64]float64) *Stream {
- // Convert map to slice to avoid slow iterations on a map.
- // ƒ is called on the hot path, so converting the map to a slice
- // beforehand results in significant CPU savings.
- targets := targetMapToSlice(targetMap)
-
- ƒ := func(s *stream, r float64) float64 {
- var m = math.MaxFloat64
- var f float64
- for _, t := range targets {
- if t.quantile*s.n <= r {
- f = (2 * t.epsilon * r) / t.quantile
- } else {
- f = (2 * t.epsilon * (s.n - r)) / (1 - t.quantile)
- }
- if f < m {
- m = f
- }
- }
- return m
- }
- return newStream(ƒ)
-}
-
-type target struct {
- quantile float64
- epsilon float64
-}
-
-func targetMapToSlice(targetMap map[float64]float64) []target {
- targets := make([]target, 0, len(targetMap))
-
- for quantile, epsilon := range targetMap {
- t := target{
- quantile: quantile,
- epsilon: epsilon,
- }
- targets = append(targets, t)
- }
-
- return targets
-}
-
-// Stream computes quantiles for a stream of float64s. It is not thread-safe by
-// design. Take care when using across multiple goroutines.
-type Stream struct {
- *stream
- b Samples
- sorted bool
-}
-
-func newStream(ƒ invariant) *Stream {
- x := &stream{ƒ: ƒ}
- return &Stream{x, make(Samples, 0, 500), true}
-}
-
-// Insert inserts v into the stream.
-func (s *Stream) Insert(v float64) {
- s.insert(Sample{Value: v, Width: 1})
-}
-
-func (s *Stream) insert(sample Sample) {
- s.b = append(s.b, sample)
- s.sorted = false
- if len(s.b) == cap(s.b) {
- s.flush()
- }
-}
-
-// Query returns the computed qth percentiles value. If s was created with
-// NewTargeted, and q is not in the set of quantiles provided a priori, Query
-// will return an unspecified result.
-func (s *Stream) Query(q float64) float64 {
- if !s.flushed() {
- // Fast path when there hasn't been enough data for a flush;
- // this also yields better accuracy for small sets of data.
- l := len(s.b)
- if l == 0 {
- return 0
- }
- i := int(math.Ceil(float64(l) * q))
- if i > 0 {
- i -= 1
- }
- s.maybeSort()
- return s.b[i].Value
- }
- s.flush()
- return s.stream.query(q)
-}
-
-// Merge merges samples into the underlying streams samples. This is handy when
-// merging multiple streams from separate threads, database shards, etc.
-//
-// ATTENTION: This method is broken and does not yield correct results. The
-// underlying algorithm is not capable of merging streams correctly.
-func (s *Stream) Merge(samples Samples) {
- sort.Sort(samples)
- s.stream.merge(samples)
-}
-
-// Reset reinitializes and clears the list reusing the samples buffer memory.
-func (s *Stream) Reset() {
- s.stream.reset()
- s.b = s.b[:0]
-}
-
-// Samples returns stream samples held by s.
-func (s *Stream) Samples() Samples {
- if !s.flushed() {
- return s.b
- }
- s.flush()
- return s.stream.samples()
-}
-
-// Count returns the total number of samples observed in the stream
-// since initialization.
-func (s *Stream) Count() int {
- return len(s.b) + s.stream.count()
-}
-
-func (s *Stream) flush() {
- s.maybeSort()
- s.stream.merge(s.b)
- s.b = s.b[:0]
-}
-
-func (s *Stream) maybeSort() {
- if !s.sorted {
- s.sorted = true
- sort.Sort(s.b)
- }
-}
-
-func (s *Stream) flushed() bool {
- return len(s.stream.l) > 0
-}
-
-type stream struct {
- n float64
- l []Sample
- ƒ invariant
-}
-
-func (s *stream) reset() {
- s.l = s.l[:0]
- s.n = 0
-}
-
-func (s *stream) insert(v float64) {
- s.merge(Samples{{v, 1, 0}})
-}
-
-func (s *stream) merge(samples Samples) {
- // TODO(beorn7): This tries to merge not only individual samples, but
- // whole summaries. The paper doesn't mention merging summaries at
- // all. Unittests show that the merging is inaccurate. Find out how to
- // do merges properly.
- var r float64
- i := 0
- for _, sample := range samples {
- for ; i < len(s.l); i++ {
- c := s.l[i]
- if c.Value > sample.Value {
- // Insert at position i.
- s.l = append(s.l, Sample{})
- copy(s.l[i+1:], s.l[i:])
- s.l[i] = Sample{
- sample.Value,
- sample.Width,
- math.Max(sample.Delta, math.Floor(s.ƒ(s, r))-1),
- // TODO(beorn7): How to calculate delta correctly?
- }
- i++
- goto inserted
- }
- r += c.Width
- }
- s.l = append(s.l, Sample{sample.Value, sample.Width, 0})
- i++
- inserted:
- s.n += sample.Width
- r += sample.Width
- }
- s.compress()
-}
-
-func (s *stream) count() int {
- return int(s.n)
-}
-
-func (s *stream) query(q float64) float64 {
- t := math.Ceil(q * s.n)
- t += math.Ceil(s.ƒ(s, t) / 2)
- p := s.l[0]
- var r float64
- for _, c := range s.l[1:] {
- r += p.Width
- if r+c.Width+c.Delta > t {
- return p.Value
- }
- p = c
- }
- return p.Value
-}
-
-func (s *stream) compress() {
- if len(s.l) < 2 {
- return
- }
- x := s.l[len(s.l)-1]
- xi := len(s.l) - 1
- r := s.n - 1 - x.Width
-
- for i := len(s.l) - 2; i >= 0; i-- {
- c := s.l[i]
- if c.Width+x.Width+x.Delta <= s.ƒ(s, r) {
- x.Width += c.Width
- s.l[xi] = x
- // Remove element at i.
- copy(s.l[i:], s.l[i+1:])
- s.l = s.l[:len(s.l)-1]
- xi -= 1
- } else {
- x = c
- xi = i
- }
- r -= c.Width
- }
-}
-
-func (s *stream) samples() Samples {
- samples := make(Samples, len(s.l))
- copy(samples, s.l)
- return samples
-}
diff --git a/vendor/github.com/cespare/xxhash/v2/LICENSE.txt b/vendor/github.com/cespare/xxhash/v2/LICENSE.txt
deleted file mode 100644
index 24b5306..0000000
--- a/vendor/github.com/cespare/xxhash/v2/LICENSE.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-Copyright (c) 2016 Caleb Spare
-
-MIT License
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/cespare/xxhash/v2/README.md b/vendor/github.com/cespare/xxhash/v2/README.md
deleted file mode 100644
index 33c8830..0000000
--- a/vendor/github.com/cespare/xxhash/v2/README.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# xxhash
-
-[![Go Reference](https://pkg.go.dev/badge/github.com/cespare/xxhash/v2.svg)](https://pkg.go.dev/github.com/cespare/xxhash/v2)
-[![Test](https://github.com/cespare/xxhash/actions/workflows/test.yml/badge.svg)](https://github.com/cespare/xxhash/actions/workflows/test.yml)
-
-xxhash is a Go implementation of the 64-bit [xxHash] algorithm, XXH64. This is a
-high-quality hashing algorithm that is much faster than anything in the Go
-standard library.
-
-This package provides a straightforward API:
-
-```
-func Sum64(b []byte) uint64
-func Sum64String(s string) uint64
-type Digest struct{ ... }
- func New() *Digest
-```
-
-The `Digest` type implements hash.Hash64. Its key methods are:
-
-```
-func (*Digest) Write([]byte) (int, error)
-func (*Digest) WriteString(string) (int, error)
-func (*Digest) Sum64() uint64
-```
-
-The package is written with optimized pure Go and also contains even faster
-assembly implementations for amd64 and arm64. If desired, the `purego` build tag
-opts into using the Go code even on those architectures.
-
-[xxHash]: http://cyan4973.github.io/xxHash/
-
-## Compatibility
-
-This package is in a module and the latest code is in version 2 of the module.
-You need a version of Go with at least "minimal module compatibility" to use
-github.com/cespare/xxhash/v2:
-
-* 1.9.7+ for Go 1.9
-* 1.10.3+ for Go 1.10
-* Go 1.11 or later
-
-I recommend using the latest release of Go.
-
-## Benchmarks
-
-Here are some quick benchmarks comparing the pure-Go and assembly
-implementations of Sum64.
-
-| input size | purego | asm |
-| ---------- | --------- | --------- |
-| 4 B | 1.3 GB/s | 1.2 GB/s |
-| 16 B | 2.9 GB/s | 3.5 GB/s |
-| 100 B | 6.9 GB/s | 8.1 GB/s |
-| 4 KB | 11.7 GB/s | 16.7 GB/s |
-| 10 MB | 12.0 GB/s | 17.3 GB/s |
-
-These numbers were generated on Ubuntu 20.04 with an Intel Xeon Platinum 8252C
-CPU using the following commands under Go 1.19.2:
-
-```
-benchstat <(go test -tags purego -benchtime 500ms -count 15 -bench 'Sum64$')
-benchstat <(go test -benchtime 500ms -count 15 -bench 'Sum64$')
-```
-
-## Projects using this package
-
-- [InfluxDB](https://github.com/influxdata/influxdb)
-- [Prometheus](https://github.com/prometheus/prometheus)
-- [VictoriaMetrics](https://github.com/VictoriaMetrics/VictoriaMetrics)
-- [FreeCache](https://github.com/coocood/freecache)
-- [FastCache](https://github.com/VictoriaMetrics/fastcache)
-- [Ristretto](https://github.com/dgraph-io/ristretto)
-- [Badger](https://github.com/dgraph-io/badger)
diff --git a/vendor/github.com/cespare/xxhash/v2/testall.sh b/vendor/github.com/cespare/xxhash/v2/testall.sh
deleted file mode 100644
index 94b9c44..0000000
--- a/vendor/github.com/cespare/xxhash/v2/testall.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-set -eu -o pipefail
-
-# Small convenience script for running the tests with various combinations of
-# arch/tags. This assumes we're running on amd64 and have qemu available.
-
-go test ./...
-go test -tags purego ./...
-GOARCH=arm64 go test
-GOARCH=arm64 go test -tags purego
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash.go b/vendor/github.com/cespare/xxhash/v2/xxhash.go
deleted file mode 100644
index 78bddf1..0000000
--- a/vendor/github.com/cespare/xxhash/v2/xxhash.go
+++ /dev/null
@@ -1,243 +0,0 @@
-// Package xxhash implements the 64-bit variant of xxHash (XXH64) as described
-// at http://cyan4973.github.io/xxHash/.
-package xxhash
-
-import (
- "encoding/binary"
- "errors"
- "math/bits"
-)
-
-const (
- prime1 uint64 = 11400714785074694791
- prime2 uint64 = 14029467366897019727
- prime3 uint64 = 1609587929392839161
- prime4 uint64 = 9650029242287828579
- prime5 uint64 = 2870177450012600261
-)
-
-// Store the primes in an array as well.
-//
-// The consts are used when possible in Go code to avoid MOVs but we need a
-// contiguous array for the assembly code.
-var primes = [...]uint64{prime1, prime2, prime3, prime4, prime5}
-
-// Digest implements hash.Hash64.
-//
-// Note that a zero-valued Digest is not ready to receive writes.
-// Call Reset or create a Digest using New before calling other methods.
-type Digest struct {
- v1 uint64
- v2 uint64
- v3 uint64
- v4 uint64
- total uint64
- mem [32]byte
- n int // how much of mem is used
-}
-
-// New creates a new Digest with a zero seed.
-func New() *Digest {
- return NewWithSeed(0)
-}
-
-// NewWithSeed creates a new Digest with the given seed.
-func NewWithSeed(seed uint64) *Digest {
- var d Digest
- d.ResetWithSeed(seed)
- return &d
-}
-
-// Reset clears the Digest's state so that it can be reused.
-// It uses a seed value of zero.
-func (d *Digest) Reset() {
- d.ResetWithSeed(0)
-}
-
-// ResetWithSeed clears the Digest's state so that it can be reused.
-// It uses the given seed to initialize the state.
-func (d *Digest) ResetWithSeed(seed uint64) {
- d.v1 = seed + prime1 + prime2
- d.v2 = seed + prime2
- d.v3 = seed
- d.v4 = seed - prime1
- d.total = 0
- d.n = 0
-}
-
-// Size always returns 8 bytes.
-func (d *Digest) Size() int { return 8 }
-
-// BlockSize always returns 32 bytes.
-func (d *Digest) BlockSize() int { return 32 }
-
-// Write adds more data to d. It always returns len(b), nil.
-func (d *Digest) Write(b []byte) (n int, err error) {
- n = len(b)
- d.total += uint64(n)
-
- memleft := d.mem[d.n&(len(d.mem)-1):]
-
- if d.n+n < 32 {
- // This new data doesn't even fill the current block.
- copy(memleft, b)
- d.n += n
- return
- }
-
- if d.n > 0 {
- // Finish off the partial block.
- c := copy(memleft, b)
- d.v1 = round(d.v1, u64(d.mem[0:8]))
- d.v2 = round(d.v2, u64(d.mem[8:16]))
- d.v3 = round(d.v3, u64(d.mem[16:24]))
- d.v4 = round(d.v4, u64(d.mem[24:32]))
- b = b[c:]
- d.n = 0
- }
-
- if len(b) >= 32 {
- // One or more full blocks left.
- nw := writeBlocks(d, b)
- b = b[nw:]
- }
-
- // Store any remaining partial block.
- copy(d.mem[:], b)
- d.n = len(b)
-
- return
-}
-
-// Sum appends the current hash to b and returns the resulting slice.
-func (d *Digest) Sum(b []byte) []byte {
- s := d.Sum64()
- return append(
- b,
- byte(s>>56),
- byte(s>>48),
- byte(s>>40),
- byte(s>>32),
- byte(s>>24),
- byte(s>>16),
- byte(s>>8),
- byte(s),
- )
-}
-
-// Sum64 returns the current hash.
-func (d *Digest) Sum64() uint64 {
- var h uint64
-
- if d.total >= 32 {
- v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4
- h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4)
- h = mergeRound(h, v1)
- h = mergeRound(h, v2)
- h = mergeRound(h, v3)
- h = mergeRound(h, v4)
- } else {
- h = d.v3 + prime5
- }
-
- h += d.total
-
- b := d.mem[:d.n&(len(d.mem)-1)]
- for ; len(b) >= 8; b = b[8:] {
- k1 := round(0, u64(b[:8]))
- h ^= k1
- h = rol27(h)*prime1 + prime4
- }
- if len(b) >= 4 {
- h ^= uint64(u32(b[:4])) * prime1
- h = rol23(h)*prime2 + prime3
- b = b[4:]
- }
- for ; len(b) > 0; b = b[1:] {
- h ^= uint64(b[0]) * prime5
- h = rol11(h) * prime1
- }
-
- h ^= h >> 33
- h *= prime2
- h ^= h >> 29
- h *= prime3
- h ^= h >> 32
-
- return h
-}
-
-const (
- magic = "xxh\x06"
- marshaledSize = len(magic) + 8*5 + 32
-)
-
-// MarshalBinary implements the encoding.BinaryMarshaler interface.
-func (d *Digest) MarshalBinary() ([]byte, error) {
- b := make([]byte, 0, marshaledSize)
- b = append(b, magic...)
- b = appendUint64(b, d.v1)
- b = appendUint64(b, d.v2)
- b = appendUint64(b, d.v3)
- b = appendUint64(b, d.v4)
- b = appendUint64(b, d.total)
- b = append(b, d.mem[:d.n]...)
- b = b[:len(b)+len(d.mem)-d.n]
- return b, nil
-}
-
-// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
-func (d *Digest) UnmarshalBinary(b []byte) error {
- if len(b) < len(magic) || string(b[:len(magic)]) != magic {
- return errors.New("xxhash: invalid hash state identifier")
- }
- if len(b) != marshaledSize {
- return errors.New("xxhash: invalid hash state size")
- }
- b = b[len(magic):]
- b, d.v1 = consumeUint64(b)
- b, d.v2 = consumeUint64(b)
- b, d.v3 = consumeUint64(b)
- b, d.v4 = consumeUint64(b)
- b, d.total = consumeUint64(b)
- copy(d.mem[:], b)
- d.n = int(d.total % uint64(len(d.mem)))
- return nil
-}
-
-func appendUint64(b []byte, x uint64) []byte {
- var a [8]byte
- binary.LittleEndian.PutUint64(a[:], x)
- return append(b, a[:]...)
-}
-
-func consumeUint64(b []byte) ([]byte, uint64) {
- x := u64(b)
- return b[8:], x
-}
-
-func u64(b []byte) uint64 { return binary.LittleEndian.Uint64(b) }
-func u32(b []byte) uint32 { return binary.LittleEndian.Uint32(b) }
-
-func round(acc, input uint64) uint64 {
- acc += input * prime2
- acc = rol31(acc)
- acc *= prime1
- return acc
-}
-
-func mergeRound(acc, val uint64) uint64 {
- val = round(0, val)
- acc ^= val
- acc = acc*prime1 + prime4
- return acc
-}
-
-func rol1(x uint64) uint64 { return bits.RotateLeft64(x, 1) }
-func rol7(x uint64) uint64 { return bits.RotateLeft64(x, 7) }
-func rol11(x uint64) uint64 { return bits.RotateLeft64(x, 11) }
-func rol12(x uint64) uint64 { return bits.RotateLeft64(x, 12) }
-func rol18(x uint64) uint64 { return bits.RotateLeft64(x, 18) }
-func rol23(x uint64) uint64 { return bits.RotateLeft64(x, 23) }
-func rol27(x uint64) uint64 { return bits.RotateLeft64(x, 27) }
-func rol31(x uint64) uint64 { return bits.RotateLeft64(x, 31) }
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s b/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s
deleted file mode 100644
index 3e8b132..0000000
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s
+++ /dev/null
@@ -1,209 +0,0 @@
-//go:build !appengine && gc && !purego
-// +build !appengine
-// +build gc
-// +build !purego
-
-#include "textflag.h"
-
-// Registers:
-#define h AX
-#define d AX
-#define p SI // pointer to advance through b
-#define n DX
-#define end BX // loop end
-#define v1 R8
-#define v2 R9
-#define v3 R10
-#define v4 R11
-#define x R12
-#define prime1 R13
-#define prime2 R14
-#define prime4 DI
-
-#define round(acc, x) \
- IMULQ prime2, x \
- ADDQ x, acc \
- ROLQ $31, acc \
- IMULQ prime1, acc
-
-// round0 performs the operation x = round(0, x).
-#define round0(x) \
- IMULQ prime2, x \
- ROLQ $31, x \
- IMULQ prime1, x
-
-// mergeRound applies a merge round on the two registers acc and x.
-// It assumes that prime1, prime2, and prime4 have been loaded.
-#define mergeRound(acc, x) \
- round0(x) \
- XORQ x, acc \
- IMULQ prime1, acc \
- ADDQ prime4, acc
-
-// blockLoop processes as many 32-byte blocks as possible,
-// updating v1, v2, v3, and v4. It assumes that there is at least one block
-// to process.
-#define blockLoop() \
-loop: \
- MOVQ +0(p), x \
- round(v1, x) \
- MOVQ +8(p), x \
- round(v2, x) \
- MOVQ +16(p), x \
- round(v3, x) \
- MOVQ +24(p), x \
- round(v4, x) \
- ADDQ $32, p \
- CMPQ p, end \
- JLE loop
-
-// func Sum64(b []byte) uint64
-TEXT ·Sum64(SB), NOSPLIT|NOFRAME, $0-32
- // Load fixed primes.
- MOVQ ·primes+0(SB), prime1
- MOVQ ·primes+8(SB), prime2
- MOVQ ·primes+24(SB), prime4
-
- // Load slice.
- MOVQ b_base+0(FP), p
- MOVQ b_len+8(FP), n
- LEAQ (p)(n*1), end
-
- // The first loop limit will be len(b)-32.
- SUBQ $32, end
-
- // Check whether we have at least one block.
- CMPQ n, $32
- JLT noBlocks
-
- // Set up initial state (v1, v2, v3, v4).
- MOVQ prime1, v1
- ADDQ prime2, v1
- MOVQ prime2, v2
- XORQ v3, v3
- XORQ v4, v4
- SUBQ prime1, v4
-
- blockLoop()
-
- MOVQ v1, h
- ROLQ $1, h
- MOVQ v2, x
- ROLQ $7, x
- ADDQ x, h
- MOVQ v3, x
- ROLQ $12, x
- ADDQ x, h
- MOVQ v4, x
- ROLQ $18, x
- ADDQ x, h
-
- mergeRound(h, v1)
- mergeRound(h, v2)
- mergeRound(h, v3)
- mergeRound(h, v4)
-
- JMP afterBlocks
-
-noBlocks:
- MOVQ ·primes+32(SB), h
-
-afterBlocks:
- ADDQ n, h
-
- ADDQ $24, end
- CMPQ p, end
- JG try4
-
-loop8:
- MOVQ (p), x
- ADDQ $8, p
- round0(x)
- XORQ x, h
- ROLQ $27, h
- IMULQ prime1, h
- ADDQ prime4, h
-
- CMPQ p, end
- JLE loop8
-
-try4:
- ADDQ $4, end
- CMPQ p, end
- JG try1
-
- MOVL (p), x
- ADDQ $4, p
- IMULQ prime1, x
- XORQ x, h
-
- ROLQ $23, h
- IMULQ prime2, h
- ADDQ ·primes+16(SB), h
-
-try1:
- ADDQ $4, end
- CMPQ p, end
- JGE finalize
-
-loop1:
- MOVBQZX (p), x
- ADDQ $1, p
- IMULQ ·primes+32(SB), x
- XORQ x, h
- ROLQ $11, h
- IMULQ prime1, h
-
- CMPQ p, end
- JL loop1
-
-finalize:
- MOVQ h, x
- SHRQ $33, x
- XORQ x, h
- IMULQ prime2, h
- MOVQ h, x
- SHRQ $29, x
- XORQ x, h
- IMULQ ·primes+16(SB), h
- MOVQ h, x
- SHRQ $32, x
- XORQ x, h
-
- MOVQ h, ret+24(FP)
- RET
-
-// func writeBlocks(d *Digest, b []byte) int
-TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40
- // Load fixed primes needed for round.
- MOVQ ·primes+0(SB), prime1
- MOVQ ·primes+8(SB), prime2
-
- // Load slice.
- MOVQ b_base+8(FP), p
- MOVQ b_len+16(FP), n
- LEAQ (p)(n*1), end
- SUBQ $32, end
-
- // Load vN from d.
- MOVQ s+0(FP), d
- MOVQ 0(d), v1
- MOVQ 8(d), v2
- MOVQ 16(d), v3
- MOVQ 24(d), v4
-
- // We don't need to check the loop condition here; this function is
- // always called with at least one block of data to process.
- blockLoop()
-
- // Copy vN back to d.
- MOVQ v1, 0(d)
- MOVQ v2, 8(d)
- MOVQ v3, 16(d)
- MOVQ v4, 24(d)
-
- // The number of bytes written is p minus the old base pointer.
- SUBQ b_base+8(FP), p
- MOVQ p, ret+32(FP)
-
- RET
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_arm64.s b/vendor/github.com/cespare/xxhash/v2/xxhash_arm64.s
deleted file mode 100644
index 7e3145a..0000000
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_arm64.s
+++ /dev/null
@@ -1,183 +0,0 @@
-//go:build !appengine && gc && !purego
-// +build !appengine
-// +build gc
-// +build !purego
-
-#include "textflag.h"
-
-// Registers:
-#define digest R1
-#define h R2 // return value
-#define p R3 // input pointer
-#define n R4 // input length
-#define nblocks R5 // n / 32
-#define prime1 R7
-#define prime2 R8
-#define prime3 R9
-#define prime4 R10
-#define prime5 R11
-#define v1 R12
-#define v2 R13
-#define v3 R14
-#define v4 R15
-#define x1 R20
-#define x2 R21
-#define x3 R22
-#define x4 R23
-
-#define round(acc, x) \
- MADD prime2, acc, x, acc \
- ROR $64-31, acc \
- MUL prime1, acc
-
-// round0 performs the operation x = round(0, x).
-#define round0(x) \
- MUL prime2, x \
- ROR $64-31, x \
- MUL prime1, x
-
-#define mergeRound(acc, x) \
- round0(x) \
- EOR x, acc \
- MADD acc, prime4, prime1, acc
-
-// blockLoop processes as many 32-byte blocks as possible,
-// updating v1, v2, v3, and v4. It assumes that n >= 32.
-#define blockLoop() \
- LSR $5, n, nblocks \
- PCALIGN $16 \
- loop: \
- LDP.P 16(p), (x1, x2) \
- LDP.P 16(p), (x3, x4) \
- round(v1, x1) \
- round(v2, x2) \
- round(v3, x3) \
- round(v4, x4) \
- SUB $1, nblocks \
- CBNZ nblocks, loop
-
-// func Sum64(b []byte) uint64
-TEXT ·Sum64(SB), NOSPLIT|NOFRAME, $0-32
- LDP b_base+0(FP), (p, n)
-
- LDP ·primes+0(SB), (prime1, prime2)
- LDP ·primes+16(SB), (prime3, prime4)
- MOVD ·primes+32(SB), prime5
-
- CMP $32, n
- CSEL LT, prime5, ZR, h // if n < 32 { h = prime5 } else { h = 0 }
- BLT afterLoop
-
- ADD prime1, prime2, v1
- MOVD prime2, v2
- MOVD $0, v3
- NEG prime1, v4
-
- blockLoop()
-
- ROR $64-1, v1, x1
- ROR $64-7, v2, x2
- ADD x1, x2
- ROR $64-12, v3, x3
- ROR $64-18, v4, x4
- ADD x3, x4
- ADD x2, x4, h
-
- mergeRound(h, v1)
- mergeRound(h, v2)
- mergeRound(h, v3)
- mergeRound(h, v4)
-
-afterLoop:
- ADD n, h
-
- TBZ $4, n, try8
- LDP.P 16(p), (x1, x2)
-
- round0(x1)
-
- // NOTE: here and below, sequencing the EOR after the ROR (using a
- // rotated register) is worth a small but measurable speedup for small
- // inputs.
- ROR $64-27, h
- EOR x1 @> 64-27, h, h
- MADD h, prime4, prime1, h
-
- round0(x2)
- ROR $64-27, h
- EOR x2 @> 64-27, h, h
- MADD h, prime4, prime1, h
-
-try8:
- TBZ $3, n, try4
- MOVD.P 8(p), x1
-
- round0(x1)
- ROR $64-27, h
- EOR x1 @> 64-27, h, h
- MADD h, prime4, prime1, h
-
-try4:
- TBZ $2, n, try2
- MOVWU.P 4(p), x2
-
- MUL prime1, x2
- ROR $64-23, h
- EOR x2 @> 64-23, h, h
- MADD h, prime3, prime2, h
-
-try2:
- TBZ $1, n, try1
- MOVHU.P 2(p), x3
- AND $255, x3, x1
- LSR $8, x3, x2
-
- MUL prime5, x1
- ROR $64-11, h
- EOR x1 @> 64-11, h, h
- MUL prime1, h
-
- MUL prime5, x2
- ROR $64-11, h
- EOR x2 @> 64-11, h, h
- MUL prime1, h
-
-try1:
- TBZ $0, n, finalize
- MOVBU (p), x4
-
- MUL prime5, x4
- ROR $64-11, h
- EOR x4 @> 64-11, h, h
- MUL prime1, h
-
-finalize:
- EOR h >> 33, h
- MUL prime2, h
- EOR h >> 29, h
- MUL prime3, h
- EOR h >> 32, h
-
- MOVD h, ret+24(FP)
- RET
-
-// func writeBlocks(d *Digest, b []byte) int
-TEXT ·writeBlocks(SB), NOSPLIT|NOFRAME, $0-40
- LDP ·primes+0(SB), (prime1, prime2)
-
- // Load state. Assume v[1-4] are stored contiguously.
- MOVD d+0(FP), digest
- LDP 0(digest), (v1, v2)
- LDP 16(digest), (v3, v4)
-
- LDP b_base+8(FP), (p, n)
-
- blockLoop()
-
- // Store updated state.
- STP (v1, v2), 0(digest)
- STP (v3, v4), 16(digest)
-
- BIC $31, n
- MOVD n, ret+32(FP)
- RET
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_asm.go b/vendor/github.com/cespare/xxhash/v2/xxhash_asm.go
deleted file mode 100644
index 78f95f2..0000000
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_asm.go
+++ /dev/null
@@ -1,15 +0,0 @@
-//go:build (amd64 || arm64) && !appengine && gc && !purego
-// +build amd64 arm64
-// +build !appengine
-// +build gc
-// +build !purego
-
-package xxhash
-
-// Sum64 computes the 64-bit xxHash digest of b with a zero seed.
-//
-//go:noescape
-func Sum64(b []byte) uint64
-
-//go:noescape
-func writeBlocks(d *Digest, b []byte) int
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_other.go b/vendor/github.com/cespare/xxhash/v2/xxhash_other.go
deleted file mode 100644
index 118e49e..0000000
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_other.go
+++ /dev/null
@@ -1,76 +0,0 @@
-//go:build (!amd64 && !arm64) || appengine || !gc || purego
-// +build !amd64,!arm64 appengine !gc purego
-
-package xxhash
-
-// Sum64 computes the 64-bit xxHash digest of b with a zero seed.
-func Sum64(b []byte) uint64 {
- // A simpler version would be
- // d := New()
- // d.Write(b)
- // return d.Sum64()
- // but this is faster, particularly for small inputs.
-
- n := len(b)
- var h uint64
-
- if n >= 32 {
- v1 := primes[0] + prime2
- v2 := prime2
- v3 := uint64(0)
- v4 := -primes[0]
- for len(b) >= 32 {
- v1 = round(v1, u64(b[0:8:len(b)]))
- v2 = round(v2, u64(b[8:16:len(b)]))
- v3 = round(v3, u64(b[16:24:len(b)]))
- v4 = round(v4, u64(b[24:32:len(b)]))
- b = b[32:len(b):len(b)]
- }
- h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4)
- h = mergeRound(h, v1)
- h = mergeRound(h, v2)
- h = mergeRound(h, v3)
- h = mergeRound(h, v4)
- } else {
- h = prime5
- }
-
- h += uint64(n)
-
- for ; len(b) >= 8; b = b[8:] {
- k1 := round(0, u64(b[:8]))
- h ^= k1
- h = rol27(h)*prime1 + prime4
- }
- if len(b) >= 4 {
- h ^= uint64(u32(b[:4])) * prime1
- h = rol23(h)*prime2 + prime3
- b = b[4:]
- }
- for ; len(b) > 0; b = b[1:] {
- h ^= uint64(b[0]) * prime5
- h = rol11(h) * prime1
- }
-
- h ^= h >> 33
- h *= prime2
- h ^= h >> 29
- h *= prime3
- h ^= h >> 32
-
- return h
-}
-
-func writeBlocks(d *Digest, b []byte) int {
- v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4
- n := len(b)
- for len(b) >= 32 {
- v1 = round(v1, u64(b[0:8:len(b)]))
- v2 = round(v2, u64(b[8:16:len(b)]))
- v3 = round(v3, u64(b[16:24:len(b)]))
- v4 = round(v4, u64(b[24:32:len(b)]))
- b = b[32:len(b):len(b)]
- }
- d.v1, d.v2, d.v3, d.v4 = v1, v2, v3, v4
- return n - len(b)
-}
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go b/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
deleted file mode 100644
index 05f5e7d..0000000
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
+++ /dev/null
@@ -1,16 +0,0 @@
-//go:build appengine
-// +build appengine
-
-// This file contains the safe implementations of otherwise unsafe-using code.
-
-package xxhash
-
-// Sum64String computes the 64-bit xxHash digest of s with a zero seed.
-func Sum64String(s string) uint64 {
- return Sum64([]byte(s))
-}
-
-// WriteString adds more data to d. It always returns len(s), nil.
-func (d *Digest) WriteString(s string) (n int, err error) {
- return d.Write([]byte(s))
-}
diff --git a/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go b/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
deleted file mode 100644
index cf9d42a..0000000
--- a/vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
+++ /dev/null
@@ -1,58 +0,0 @@
-//go:build !appengine
-// +build !appengine
-
-// This file encapsulates usage of unsafe.
-// xxhash_safe.go contains the safe implementations.
-
-package xxhash
-
-import (
- "unsafe"
-)
-
-// In the future it's possible that compiler optimizations will make these
-// XxxString functions unnecessary by realizing that calls such as
-// Sum64([]byte(s)) don't need to copy s. See https://go.dev/issue/2205.
-// If that happens, even if we keep these functions they can be replaced with
-// the trivial safe code.
-
-// NOTE: The usual way of doing an unsafe string-to-[]byte conversion is:
-//
-// var b []byte
-// bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
-// bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data
-// bh.Len = len(s)
-// bh.Cap = len(s)
-//
-// Unfortunately, as of Go 1.15.3 the inliner's cost model assigns a high enough
-// weight to this sequence of expressions that any function that uses it will
-// not be inlined. Instead, the functions below use a different unsafe
-// conversion designed to minimize the inliner weight and allow both to be
-// inlined. There is also a test (TestInlining) which verifies that these are
-// inlined.
-//
-// See https://github.com/golang/go/issues/42739 for discussion.
-
-// Sum64String computes the 64-bit xxHash digest of s with a zero seed.
-// It may be faster than Sum64([]byte(s)) by avoiding a copy.
-func Sum64String(s string) uint64 {
- b := *(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)}))
- return Sum64(b)
-}
-
-// WriteString adds more data to d. It always returns len(s), nil.
-// It may be faster than Write([]byte(s)) by avoiding a copy.
-func (d *Digest) WriteString(s string) (n int, err error) {
- d.Write(*(*[]byte)(unsafe.Pointer(&sliceHeader{s, len(s)})))
- // d.Write always returns len(s), nil.
- // Ignoring the return output and returning these fixed values buys a
- // savings of 6 in the inliner's cost model.
- return len(s), nil
-}
-
-// sliceHeader is similar to reflect.SliceHeader, but it assumes that the layout
-// of the first two words is the same as the layout of a string.
-type sliceHeader struct {
- s string
- cap int
-}
diff --git a/vendor/github.com/munnerz/goautoneg/LICENSE b/vendor/github.com/munnerz/goautoneg/LICENSE
deleted file mode 100644
index bbc7b89..0000000
--- a/vendor/github.com/munnerz/goautoneg/LICENSE
+++ /dev/null
@@ -1,31 +0,0 @@
-Copyright (c) 2011, Open Knowledge Foundation Ltd.
-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 the Open Knowledge Foundation Ltd. 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
-HOLDER 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.
diff --git a/vendor/github.com/munnerz/goautoneg/Makefile b/vendor/github.com/munnerz/goautoneg/Makefile
deleted file mode 100644
index e33ee17..0000000
--- a/vendor/github.com/munnerz/goautoneg/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-include $(GOROOT)/src/Make.inc
-
-TARG=bitbucket.org/ww/goautoneg
-GOFILES=autoneg.go
-
-include $(GOROOT)/src/Make.pkg
-
-format:
- gofmt -w *.go
-
-docs:
- gomake clean
- godoc ${TARG} > README.txt
diff --git a/vendor/github.com/munnerz/goautoneg/README.txt b/vendor/github.com/munnerz/goautoneg/README.txt
deleted file mode 100644
index 7723656..0000000
--- a/vendor/github.com/munnerz/goautoneg/README.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-PACKAGE
-
-package goautoneg
-import "bitbucket.org/ww/goautoneg"
-
-HTTP Content-Type Autonegotiation.
-
-The functions in this package implement the behaviour specified in
-http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
-
-Copyright (c) 2011, Open Knowledge Foundation Ltd.
-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 the Open Knowledge Foundation Ltd. 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
-HOLDER 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.
-
-
-FUNCTIONS
-
-func Negotiate(header string, alternatives []string) (content_type string)
-Negotiate the most appropriate content_type given the accept header
-and a list of alternatives.
-
-func ParseAccept(header string) (accept []Accept)
-Parse an Accept Header string returning a sorted list
-of clauses
-
-
-TYPES
-
-type Accept struct {
- Type, SubType string
- Q float32
- Params map[string]string
-}
-Structure to represent a clause in an HTTP Accept Header
-
-
-SUBDIRECTORIES
-
- .hg
diff --git a/vendor/github.com/munnerz/goautoneg/autoneg.go b/vendor/github.com/munnerz/goautoneg/autoneg.go
deleted file mode 100644
index 1dd1cad..0000000
--- a/vendor/github.com/munnerz/goautoneg/autoneg.go
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
-HTTP Content-Type Autonegotiation.
-
-The functions in this package implement the behaviour specified in
-http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
-
-Copyright (c) 2011, Open Knowledge Foundation Ltd.
-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 the Open Knowledge Foundation Ltd. 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
-HOLDER 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.
-*/
-
-package goautoneg
-
-import (
- "sort"
- "strconv"
- "strings"
-)
-
-// Structure to represent a clause in an HTTP Accept Header
-type Accept struct {
- Type, SubType string
- Q float64
- Params map[string]string
-}
-
-// acceptSlice is defined to implement sort interface.
-type acceptSlice []Accept
-
-func (slice acceptSlice) Len() int {
- return len(slice)
-}
-
-func (slice acceptSlice) Less(i, j int) bool {
- ai, aj := slice[i], slice[j]
- if ai.Q > aj.Q {
- return true
- }
- if ai.Type != "*" && aj.Type == "*" {
- return true
- }
- if ai.SubType != "*" && aj.SubType == "*" {
- return true
- }
- return false
-}
-
-func (slice acceptSlice) Swap(i, j int) {
- slice[i], slice[j] = slice[j], slice[i]
-}
-
-func stringTrimSpaceCutset(r rune) bool {
- return r == ' '
-}
-
-func nextSplitElement(s, sep string) (item string, remaining string) {
- if index := strings.Index(s, sep); index != -1 {
- return s[:index], s[index+1:]
- }
- return s, ""
-}
-
-// Parse an Accept Header string returning a sorted list
-// of clauses
-func ParseAccept(header string) acceptSlice {
- partsCount := 0
- remaining := header
- for len(remaining) > 0 {
- partsCount++
- _, remaining = nextSplitElement(remaining, ",")
- }
- accept := make(acceptSlice, 0, partsCount)
-
- remaining = header
- var part string
- for len(remaining) > 0 {
- part, remaining = nextSplitElement(remaining, ",")
- part = strings.TrimFunc(part, stringTrimSpaceCutset)
-
- a := Accept{
- Q: 1.0,
- }
-
- sp, remainingPart := nextSplitElement(part, ";")
-
- sp0, spRemaining := nextSplitElement(sp, "/")
- a.Type = strings.TrimFunc(sp0, stringTrimSpaceCutset)
-
- switch {
- case len(spRemaining) == 0:
- if a.Type == "*" {
- a.SubType = "*"
- } else {
- continue
- }
- default:
- var sp1 string
- sp1, spRemaining = nextSplitElement(spRemaining, "/")
- if len(spRemaining) > 0 {
- continue
- }
- a.SubType = strings.TrimFunc(sp1, stringTrimSpaceCutset)
- }
-
- if len(remainingPart) == 0 {
- accept = append(accept, a)
- continue
- }
-
- a.Params = make(map[string]string)
- for len(remainingPart) > 0 {
- sp, remainingPart = nextSplitElement(remainingPart, ";")
- sp0, spRemaining = nextSplitElement(sp, "=")
- if len(spRemaining) == 0 {
- continue
- }
- var sp1 string
- sp1, spRemaining = nextSplitElement(spRemaining, "=")
- if len(spRemaining) != 0 {
- continue
- }
- token := strings.TrimFunc(sp0, stringTrimSpaceCutset)
- if token == "q" {
- a.Q, _ = strconv.ParseFloat(sp1, 32)
- } else {
- a.Params[token] = strings.TrimFunc(sp1, stringTrimSpaceCutset)
- }
- }
-
- accept = append(accept, a)
- }
-
- sort.Sort(accept)
- return accept
-}
-
-// Negotiate the most appropriate content_type given the accept header
-// and a list of alternatives.
-func Negotiate(header string, alternatives []string) (content_type string) {
- asp := make([][]string, 0, len(alternatives))
- for _, ctype := range alternatives {
- asp = append(asp, strings.SplitN(ctype, "/", 2))
- }
- for _, clause := range ParseAccept(header) {
- for i, ctsp := range asp {
- if clause.Type == ctsp[0] && clause.SubType == ctsp[1] {
- content_type = alternatives[i]
- return
- }
- if clause.Type == ctsp[0] && clause.SubType == "*" {
- content_type = alternatives[i]
- return
- }
- if clause.Type == "*" && clause.SubType == "*" {
- content_type = alternatives[i]
- return
- }
- }
- }
- return
-}
diff --git a/vendor/github.com/prometheus/client_golang/LICENSE b/vendor/github.com/prometheus/client_golang/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/vendor/github.com/prometheus/client_golang/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/prometheus/client_golang/NOTICE b/vendor/github.com/prometheus/client_golang/NOTICE
deleted file mode 100644
index b9cc55a..0000000
--- a/vendor/github.com/prometheus/client_golang/NOTICE
+++ /dev/null
@@ -1,18 +0,0 @@
-Prometheus instrumentation library for Go applications
-Copyright 2012-2015 The Prometheus Authors
-
-This product includes software developed at
-SoundCloud Ltd. (http://soundcloud.com/).
-
-
-The following components are included in this product:
-
-perks - a fork of https://github.com/bmizerany/perks
-https://github.com/beorn7/perks
-Copyright 2013-2015 Blake Mizerany, Björn Rabenstein
-See https://github.com/beorn7/perks/blob/master/README.md for license details.
-
-Go support for Protocol Buffers - Google's data interchange format
-http://github.com/golang/protobuf/
-Copyright 2010 The Go Authors
-See source code for license details.
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/.gitignore b/vendor/github.com/prometheus/client_golang/prometheus/.gitignore
deleted file mode 100644
index 3460f03..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-command-line-arguments.test
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/README.md b/vendor/github.com/prometheus/client_golang/prometheus/README.md
deleted file mode 100644
index c67ff1b..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/README.md
+++ /dev/null
@@ -1 +0,0 @@
-See [![Go Reference](https://pkg.go.dev/badge/github.com/prometheus/client_golang/prometheus.svg)](https://pkg.go.dev/github.com/prometheus/client_golang/prometheus).
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/build_info_collector.go b/vendor/github.com/prometheus/client_golang/prometheus/build_info_collector.go
deleted file mode 100644
index 450189f..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/build_info_collector.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2021 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import "runtime/debug"
-
-// NewBuildInfoCollector is the obsolete version of collectors.NewBuildInfoCollector.
-// See there for documentation.
-//
-// Deprecated: Use collectors.NewBuildInfoCollector instead.
-func NewBuildInfoCollector() Collector {
- path, version, sum := "unknown", "unknown", "unknown"
- if bi, ok := debug.ReadBuildInfo(); ok {
- path = bi.Main.Path
- version = bi.Main.Version
- sum = bi.Main.Sum
- }
- c := &selfCollector{MustNewConstMetric(
- NewDesc(
- "go_build_info",
- "Build information about the main Go module.",
- nil, Labels{"path": path, "version": version, "checksum": sum},
- ),
- GaugeValue, 1)}
- c.init(c.self)
- return c
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/collector.go b/vendor/github.com/prometheus/client_golang/prometheus/collector.go
deleted file mode 100644
index cf05079..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/collector.go
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-// Collector is the interface implemented by anything that can be used by
-// Prometheus to collect metrics. A Collector has to be registered for
-// collection. See Registerer.Register.
-//
-// The stock metrics provided by this package (Gauge, Counter, Summary,
-// Histogram, Untyped) are also Collectors (which only ever collect one metric,
-// namely itself). An implementer of Collector may, however, collect multiple
-// metrics in a coordinated fashion and/or create metrics on the fly. Examples
-// for collectors already implemented in this library are the metric vectors
-// (i.e. collection of multiple instances of the same Metric but with different
-// label values) like GaugeVec or SummaryVec, and the ExpvarCollector.
-type Collector interface {
- // Describe sends the super-set of all possible descriptors of metrics
- // collected by this Collector to the provided channel and returns once
- // the last descriptor has been sent. The sent descriptors fulfill the
- // consistency and uniqueness requirements described in the Desc
- // documentation.
- //
- // It is valid if one and the same Collector sends duplicate
- // descriptors. Those duplicates are simply ignored. However, two
- // different Collectors must not send duplicate descriptors.
- //
- // Sending no descriptor at all marks the Collector as “unchecked”,
- // i.e. no checks will be performed at registration time, and the
- // Collector may yield any Metric it sees fit in its Collect method.
- //
- // This method idempotently sends the same descriptors throughout the
- // lifetime of the Collector. It may be called concurrently and
- // therefore must be implemented in a concurrency safe way.
- //
- // If a Collector encounters an error while executing this method, it
- // must send an invalid descriptor (created with NewInvalidDesc) to
- // signal the error to the registry.
- Describe(chan<- *Desc)
- // Collect is called by the Prometheus registry when collecting
- // metrics. The implementation sends each collected metric via the
- // provided channel and returns once the last metric has been sent. The
- // descriptor of each sent metric is one of those returned by Describe
- // (unless the Collector is unchecked, see above). Returned metrics that
- // share the same descriptor must differ in their variable label
- // values.
- //
- // This method may be called concurrently and must therefore be
- // implemented in a concurrency safe way. Blocking occurs at the expense
- // of total performance of rendering all registered metrics. Ideally,
- // Collector implementations support concurrent readers.
- Collect(chan<- Metric)
-}
-
-// DescribeByCollect is a helper to implement the Describe method of a custom
-// Collector. It collects the metrics from the provided Collector and sends
-// their descriptors to the provided channel.
-//
-// If a Collector collects the same metrics throughout its lifetime, its
-// Describe method can simply be implemented as:
-//
-// func (c customCollector) Describe(ch chan<- *Desc) {
-// DescribeByCollect(c, ch)
-// }
-//
-// However, this will not work if the metrics collected change dynamically over
-// the lifetime of the Collector in a way that their combined set of descriptors
-// changes as well. The shortcut implementation will then violate the contract
-// of the Describe method. If a Collector sometimes collects no metrics at all
-// (for example vectors like CounterVec, GaugeVec, etc., which only collect
-// metrics after a metric with a fully specified label set has been accessed),
-// it might even get registered as an unchecked Collector (cf. the Register
-// method of the Registerer interface). Hence, only use this shortcut
-// implementation of Describe if you are certain to fulfill the contract.
-//
-// The Collector example demonstrates a use of DescribeByCollect.
-func DescribeByCollect(c Collector, descs chan<- *Desc) {
- metrics := make(chan Metric)
- go func() {
- c.Collect(metrics)
- close(metrics)
- }()
- for m := range metrics {
- descs <- m.Desc()
- }
-}
-
-// selfCollector implements Collector for a single Metric so that the Metric
-// collects itself. Add it as an anonymous field to a struct that implements
-// Metric, and call init with the Metric itself as an argument.
-type selfCollector struct {
- self Metric
-}
-
-// init provides the selfCollector with a reference to the metric it is supposed
-// to collect. It is usually called within the factory function to create a
-// metric. See example.
-func (c *selfCollector) init(self Metric) {
- c.self = self
-}
-
-// Describe implements Collector.
-func (c *selfCollector) Describe(ch chan<- *Desc) {
- ch <- c.self.Desc()
-}
-
-// Collect implements Collector.
-func (c *selfCollector) Collect(ch chan<- Metric) {
- ch <- c.self
-}
-
-// collectorMetric is a metric that is also a collector.
-// Because of selfCollector, most (if not all) Metrics in
-// this package are also collectors.
-type collectorMetric interface {
- Metric
- Collector
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/counter.go b/vendor/github.com/prometheus/client_golang/prometheus/counter.go
deleted file mode 100644
index 4ce84e7..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/counter.go
+++ /dev/null
@@ -1,358 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "errors"
- "math"
- "sync/atomic"
- "time"
-
- dto "github.com/prometheus/client_model/go"
- "google.golang.org/protobuf/types/known/timestamppb"
-)
-
-// Counter is a Metric that represents a single numerical value that only ever
-// goes up. That implies that it cannot be used to count items whose number can
-// also go down, e.g. the number of currently running goroutines. Those
-// "counters" are represented by Gauges.
-//
-// A Counter is typically used to count requests served, tasks completed, errors
-// occurred, etc.
-//
-// To create Counter instances, use NewCounter.
-type Counter interface {
- Metric
- Collector
-
- // Inc increments the counter by 1. Use Add to increment it by arbitrary
- // non-negative values.
- Inc()
- // Add adds the given value to the counter. It panics if the value is <
- // 0.
- Add(float64)
-}
-
-// ExemplarAdder is implemented by Counters that offer the option of adding a
-// value to the Counter together with an exemplar. Its AddWithExemplar method
-// works like the Add method of the Counter interface but also replaces the
-// currently saved exemplar (if any) with a new one, created from the provided
-// value, the current time as timestamp, and the provided labels. Empty Labels
-// will lead to a valid (label-less) exemplar. But if Labels is nil, the current
-// exemplar is left in place. AddWithExemplar panics if the value is < 0, if any
-// of the provided labels are invalid, or if the provided labels contain more
-// than 128 runes in total.
-type ExemplarAdder interface {
- AddWithExemplar(value float64, exemplar Labels)
-}
-
-// CounterOpts is an alias for Opts. See there for doc comments.
-type CounterOpts Opts
-
-// CounterVecOpts bundles the options to create a CounterVec metric.
-// It is mandatory to set CounterOpts, see there for mandatory fields. VariableLabels
-// is optional and can safely be left to its default value.
-type CounterVecOpts struct {
- CounterOpts
-
- // VariableLabels are used to partition the metric vector by the given set
- // of labels. Each label value will be constrained with the optional Constraint
- // function, if provided.
- VariableLabels ConstrainableLabels
-}
-
-// NewCounter creates a new Counter based on the provided CounterOpts.
-//
-// The returned implementation also implements ExemplarAdder. It is safe to
-// perform the corresponding type assertion.
-//
-// The returned implementation tracks the counter value in two separate
-// variables, a float64 and a uint64. The latter is used to track calls of the
-// Inc method and calls of the Add method with a value that can be represented
-// as a uint64. This allows atomic increments of the counter with optimal
-// performance. (It is common to have an Inc call in very hot execution paths.)
-// Both internal tracking values are added up in the Write method. This has to
-// be taken into account when it comes to precision and overflow behavior.
-func NewCounter(opts CounterOpts) Counter {
- desc := NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- nil,
- opts.ConstLabels,
- )
- if opts.now == nil {
- opts.now = time.Now
- }
- result := &counter{desc: desc, labelPairs: desc.constLabelPairs, now: opts.now}
- result.init(result) // Init self-collection.
- result.createdTs = timestamppb.New(opts.now())
- return result
-}
-
-type counter struct {
- // valBits contains the bits of the represented float64 value, while
- // valInt stores values that are exact integers. Both have to go first
- // in the struct to guarantee alignment for atomic operations.
- // http://golang.org/pkg/sync/atomic/#pkg-note-BUG
- valBits uint64
- valInt uint64
-
- selfCollector
- desc *Desc
-
- createdTs *timestamppb.Timestamp
- labelPairs []*dto.LabelPair
- exemplar atomic.Value // Containing nil or a *dto.Exemplar.
-
- // now is for testing purposes, by default it's time.Now.
- now func() time.Time
-}
-
-func (c *counter) Desc() *Desc {
- return c.desc
-}
-
-func (c *counter) Add(v float64) {
- if v < 0 {
- panic(errors.New("counter cannot decrease in value"))
- }
-
- ival := uint64(v)
- if float64(ival) == v {
- atomic.AddUint64(&c.valInt, ival)
- return
- }
-
- for {
- oldBits := atomic.LoadUint64(&c.valBits)
- newBits := math.Float64bits(math.Float64frombits(oldBits) + v)
- if atomic.CompareAndSwapUint64(&c.valBits, oldBits, newBits) {
- return
- }
- }
-}
-
-func (c *counter) AddWithExemplar(v float64, e Labels) {
- c.Add(v)
- c.updateExemplar(v, e)
-}
-
-func (c *counter) Inc() {
- atomic.AddUint64(&c.valInt, 1)
-}
-
-func (c *counter) get() float64 {
- fval := math.Float64frombits(atomic.LoadUint64(&c.valBits))
- ival := atomic.LoadUint64(&c.valInt)
- return fval + float64(ival)
-}
-
-func (c *counter) Write(out *dto.Metric) error {
- // Read the Exemplar first and the value second. This is to avoid a race condition
- // where users see an exemplar for a not-yet-existing observation.
- var exemplar *dto.Exemplar
- if e := c.exemplar.Load(); e != nil {
- exemplar = e.(*dto.Exemplar)
- }
- val := c.get()
- return populateMetric(CounterValue, val, c.labelPairs, exemplar, out, c.createdTs)
-}
-
-func (c *counter) updateExemplar(v float64, l Labels) {
- if l == nil {
- return
- }
- e, err := newExemplar(v, c.now(), l)
- if err != nil {
- panic(err)
- }
- c.exemplar.Store(e)
-}
-
-// CounterVec is a Collector that bundles a set of Counters that all share the
-// same Desc, but have different values for their variable labels. This is used
-// if you want to count the same thing partitioned by various dimensions
-// (e.g. number of HTTP requests, partitioned by response code and
-// method). Create instances with NewCounterVec.
-type CounterVec struct {
- *MetricVec
-}
-
-// NewCounterVec creates a new CounterVec based on the provided CounterOpts and
-// partitioned by the given label names.
-func NewCounterVec(opts CounterOpts, labelNames []string) *CounterVec {
- return V2.NewCounterVec(CounterVecOpts{
- CounterOpts: opts,
- VariableLabels: UnconstrainedLabels(labelNames),
- })
-}
-
-// NewCounterVec creates a new CounterVec based on the provided CounterVecOpts.
-func (v2) NewCounterVec(opts CounterVecOpts) *CounterVec {
- desc := V2.NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- opts.VariableLabels,
- opts.ConstLabels,
- )
- if opts.now == nil {
- opts.now = time.Now
- }
- return &CounterVec{
- MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
- if len(lvs) != len(desc.variableLabels.names) {
- panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.names, lvs))
- }
- result := &counter{desc: desc, labelPairs: MakeLabelPairs(desc, lvs), now: opts.now}
- result.init(result) // Init self-collection.
- result.createdTs = timestamppb.New(opts.now())
- return result
- }),
- }
-}
-
-// GetMetricWithLabelValues returns the Counter for the given slice of label
-// values (same order as the variable labels in Desc). If that combination of
-// label values is accessed for the first time, a new Counter is created.
-//
-// It is possible to call this method without using the returned Counter to only
-// create the new Counter but leave it at its starting value 0. See also the
-// SummaryVec example.
-//
-// Keeping the Counter for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// Delete can be used to delete the Counter from the CounterVec. In that case,
-// the Counter will still exist, but it will not be exported anymore, even if a
-// Counter with the same label values is created later.
-//
-// An error is returned if the number of label values is not the same as the
-// number of variable labels in Desc (minus any curried labels).
-//
-// Note that for more than one label value, this method is prone to mistakes
-// caused by an incorrect order of arguments. Consider GetMetricWith(Labels) as
-// an alternative to avoid that type of mistake. For higher label numbers, the
-// latter has a much more readable (albeit more verbose) syntax, but it comes
-// with a performance overhead (for creating and processing the Labels map).
-// See also the GaugeVec example.
-func (v *CounterVec) GetMetricWithLabelValues(lvs ...string) (Counter, error) {
- metric, err := v.MetricVec.GetMetricWithLabelValues(lvs...)
- if metric != nil {
- return metric.(Counter), err
- }
- return nil, err
-}
-
-// GetMetricWith returns the Counter for the given Labels map (the label names
-// must match those of the variable labels in Desc). If that label map is
-// accessed for the first time, a new Counter is created. Implications of
-// creating a Counter without using it and keeping the Counter for later use are
-// the same as for GetMetricWithLabelValues.
-//
-// An error is returned if the number and names of the Labels are inconsistent
-// with those of the variable labels in Desc (minus any curried labels).
-//
-// This method is used for the same purpose as
-// GetMetricWithLabelValues(...string). See there for pros and cons of the two
-// methods.
-func (v *CounterVec) GetMetricWith(labels Labels) (Counter, error) {
- metric, err := v.MetricVec.GetMetricWith(labels)
- if metric != nil {
- return metric.(Counter), err
- }
- return nil, err
-}
-
-// WithLabelValues works as GetMetricWithLabelValues, but panics where
-// GetMetricWithLabelValues would have returned an error. Not returning an
-// error allows shortcuts like
-//
-// myVec.WithLabelValues("404", "GET").Add(42)
-func (v *CounterVec) WithLabelValues(lvs ...string) Counter {
- c, err := v.GetMetricWithLabelValues(lvs...)
- if err != nil {
- panic(err)
- }
- return c
-}
-
-// With works as GetMetricWith, but panics where GetMetricWithLabels would have
-// returned an error. Not returning an error allows shortcuts like
-//
-// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42)
-func (v *CounterVec) With(labels Labels) Counter {
- c, err := v.GetMetricWith(labels)
- if err != nil {
- panic(err)
- }
- return c
-}
-
-// CurryWith returns a vector curried with the provided labels, i.e. the
-// returned vector has those labels pre-set for all labeled operations performed
-// on it. The cardinality of the curried vector is reduced accordingly. The
-// order of the remaining labels stays the same (just with the curried labels
-// taken out of the sequence – which is relevant for the
-// (GetMetric)WithLabelValues methods). It is possible to curry a curried
-// vector, but only with labels not yet used for currying before.
-//
-// The metrics contained in the CounterVec are shared between the curried and
-// uncurried vectors. They are just accessed differently. Curried and uncurried
-// vectors behave identically in terms of collection. Only one must be
-// registered with a given registry (usually the uncurried version). The Reset
-// method deletes all metrics, even if called on a curried vector.
-func (v *CounterVec) CurryWith(labels Labels) (*CounterVec, error) {
- vec, err := v.MetricVec.CurryWith(labels)
- if vec != nil {
- return &CounterVec{vec}, err
- }
- return nil, err
-}
-
-// MustCurryWith works as CurryWith but panics where CurryWith would have
-// returned an error.
-func (v *CounterVec) MustCurryWith(labels Labels) *CounterVec {
- vec, err := v.CurryWith(labels)
- if err != nil {
- panic(err)
- }
- return vec
-}
-
-// CounterFunc is a Counter whose value is determined at collect time by calling a
-// provided function.
-//
-// To create CounterFunc instances, use NewCounterFunc.
-type CounterFunc interface {
- Metric
- Collector
-}
-
-// NewCounterFunc creates a new CounterFunc based on the provided
-// CounterOpts. The value reported is determined by calling the given function
-// from within the Write method. Take into account that metric collection may
-// happen concurrently. If that results in concurrent calls to Write, like in
-// the case where a CounterFunc is directly registered with Prometheus, the
-// provided function must be concurrency-safe. The function should also honor
-// the contract for a Counter (values only go up, not down), but compliance will
-// not be checked.
-//
-// Check out the ExampleGaugeFunc examples for the similar GaugeFunc.
-func NewCounterFunc(opts CounterOpts, function func() float64) CounterFunc {
- return newValueFunc(NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- nil,
- opts.ConstLabels,
- ), CounterValue, function)
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/desc.go b/vendor/github.com/prometheus/client_golang/prometheus/desc.go
deleted file mode 100644
index 68ffe3c..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/desc.go
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright 2016 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "fmt"
- "sort"
- "strings"
-
- "github.com/cespare/xxhash/v2"
- dto "github.com/prometheus/client_model/go"
- "github.com/prometheus/common/model"
- "google.golang.org/protobuf/proto"
-
- "github.com/prometheus/client_golang/prometheus/internal"
-)
-
-// Desc is the descriptor used by every Prometheus Metric. It is essentially
-// the immutable meta-data of a Metric. The normal Metric implementations
-// included in this package manage their Desc under the hood. Users only have to
-// deal with Desc if they use advanced features like the ExpvarCollector or
-// custom Collectors and Metrics.
-//
-// Descriptors registered with the same registry have to fulfill certain
-// consistency and uniqueness criteria if they share the same fully-qualified
-// name: They must have the same help string and the same label names (aka label
-// dimensions) in each, constLabels and variableLabels, but they must differ in
-// the values of the constLabels.
-//
-// Descriptors that share the same fully-qualified names and the same label
-// values of their constLabels are considered equal.
-//
-// Use NewDesc to create new Desc instances.
-type Desc struct {
- // fqName has been built from Namespace, Subsystem, and Name.
- fqName string
- // help provides some helpful information about this metric.
- help string
- // constLabelPairs contains precalculated DTO label pairs based on
- // the constant labels.
- constLabelPairs []*dto.LabelPair
- // variableLabels contains names of labels and normalization function for
- // which the metric maintains variable values.
- variableLabels *compiledLabels
- // id is a hash of the values of the ConstLabels and fqName. This
- // must be unique among all registered descriptors and can therefore be
- // used as an identifier of the descriptor.
- id uint64
- // dimHash is a hash of the label names (preset and variable) and the
- // Help string. Each Desc with the same fqName must have the same
- // dimHash.
- dimHash uint64
- // err is an error that occurred during construction. It is reported on
- // registration time.
- err error
-}
-
-// NewDesc allocates and initializes a new Desc. Errors are recorded in the Desc
-// and will be reported on registration time. variableLabels and constLabels can
-// be nil if no such labels should be set. fqName must not be empty.
-//
-// variableLabels only contain the label names. Their label values are variable
-// and therefore not part of the Desc. (They are managed within the Metric.)
-//
-// For constLabels, the label values are constant. Therefore, they are fully
-// specified in the Desc. See the Collector example for a usage pattern.
-func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *Desc {
- return V2.NewDesc(fqName, help, UnconstrainedLabels(variableLabels), constLabels)
-}
-
-// NewDesc allocates and initializes a new Desc. Errors are recorded in the Desc
-// and will be reported on registration time. variableLabels and constLabels can
-// be nil if no such labels should be set. fqName must not be empty.
-//
-// variableLabels only contain the label names and normalization functions. Their
-// label values are variable and therefore not part of the Desc. (They are managed
-// within the Metric.)
-//
-// For constLabels, the label values are constant. Therefore, they are fully
-// specified in the Desc. See the Collector example for a usage pattern.
-func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, constLabels Labels) *Desc {
- d := &Desc{
- fqName: fqName,
- help: help,
- variableLabels: variableLabels.compile(),
- }
- if !model.IsValidMetricName(model.LabelValue(fqName)) {
- d.err = fmt.Errorf("%q is not a valid metric name", fqName)
- return d
- }
- // labelValues contains the label values of const labels (in order of
- // their sorted label names) plus the fqName (at position 0).
- labelValues := make([]string, 1, len(constLabels)+1)
- labelValues[0] = fqName
- labelNames := make([]string, 0, len(constLabels)+len(d.variableLabels.names))
- labelNameSet := map[string]struct{}{}
- // First add only the const label names and sort them...
- for labelName := range constLabels {
- if !checkLabelName(labelName) {
- d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName)
- return d
- }
- labelNames = append(labelNames, labelName)
- labelNameSet[labelName] = struct{}{}
- }
- sort.Strings(labelNames)
- // ... so that we can now add const label values in the order of their names.
- for _, labelName := range labelNames {
- labelValues = append(labelValues, constLabels[labelName])
- }
- // Validate the const label values. They can't have a wrong cardinality, so
- // use in len(labelValues) as expectedNumberOfValues.
- if err := validateLabelValues(labelValues, len(labelValues)); err != nil {
- d.err = err
- return d
- }
- // Now add the variable label names, but prefix them with something that
- // cannot be in a regular label name. That prevents matching the label
- // dimension with a different mix between preset and variable labels.
- for _, label := range d.variableLabels.names {
- if !checkLabelName(label) {
- d.err = fmt.Errorf("%q is not a valid label name for metric %q", label, fqName)
- return d
- }
- labelNames = append(labelNames, "$"+label)
- labelNameSet[label] = struct{}{}
- }
- if len(labelNames) != len(labelNameSet) {
- d.err = fmt.Errorf("duplicate label names in constant and variable labels for metric %q", fqName)
- return d
- }
-
- xxh := xxhash.New()
- for _, val := range labelValues {
- xxh.WriteString(val)
- xxh.Write(separatorByteSlice)
- }
- d.id = xxh.Sum64()
- // Sort labelNames so that order doesn't matter for the hash.
- sort.Strings(labelNames)
- // Now hash together (in this order) the help string and the sorted
- // label names.
- xxh.Reset()
- xxh.WriteString(help)
- xxh.Write(separatorByteSlice)
- for _, labelName := range labelNames {
- xxh.WriteString(labelName)
- xxh.Write(separatorByteSlice)
- }
- d.dimHash = xxh.Sum64()
-
- d.constLabelPairs = make([]*dto.LabelPair, 0, len(constLabels))
- for n, v := range constLabels {
- d.constLabelPairs = append(d.constLabelPairs, &dto.LabelPair{
- Name: proto.String(n),
- Value: proto.String(v),
- })
- }
- sort.Sort(internal.LabelPairSorter(d.constLabelPairs))
- return d
-}
-
-// NewInvalidDesc returns an invalid descriptor, i.e. a descriptor with the
-// provided error set. If a collector returning such a descriptor is registered,
-// registration will fail with the provided error. NewInvalidDesc can be used by
-// a Collector to signal inability to describe itself.
-func NewInvalidDesc(err error) *Desc {
- return &Desc{
- err: err,
- }
-}
-
-func (d *Desc) String() string {
- lpStrings := make([]string, 0, len(d.constLabelPairs))
- for _, lp := range d.constLabelPairs {
- lpStrings = append(
- lpStrings,
- fmt.Sprintf("%s=%q", lp.GetName(), lp.GetValue()),
- )
- }
- vlStrings := make([]string, 0, len(d.variableLabels.names))
- for _, vl := range d.variableLabels.names {
- if fn, ok := d.variableLabels.labelConstraints[vl]; ok && fn != nil {
- vlStrings = append(vlStrings, fmt.Sprintf("c(%s)", vl))
- } else {
- vlStrings = append(vlStrings, vl)
- }
- }
- return fmt.Sprintf(
- "Desc{fqName: %q, help: %q, constLabels: {%s}, variableLabels: {%s}}",
- d.fqName,
- d.help,
- strings.Join(lpStrings, ","),
- strings.Join(vlStrings, ","),
- )
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/doc.go b/vendor/github.com/prometheus/client_golang/prometheus/doc.go
deleted file mode 100644
index 962608f..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/doc.go
+++ /dev/null
@@ -1,210 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package prometheus is the core instrumentation package. It provides metrics
-// primitives to instrument code for monitoring. It also offers a registry for
-// metrics. Sub-packages allow to expose the registered metrics via HTTP
-// (package promhttp) or push them to a Pushgateway (package push). There is
-// also a sub-package promauto, which provides metrics constructors with
-// automatic registration.
-//
-// All exported functions and methods are safe to be used concurrently unless
-// specified otherwise.
-//
-// # A Basic Example
-//
-// As a starting point, a very basic usage example:
-//
-// package main
-//
-// import (
-// "log"
-// "net/http"
-//
-// "github.com/prometheus/client_golang/prometheus"
-// "github.com/prometheus/client_golang/prometheus/promhttp"
-// )
-//
-// type metrics struct {
-// cpuTemp prometheus.Gauge
-// hdFailures *prometheus.CounterVec
-// }
-//
-// func NewMetrics(reg prometheus.Registerer) *metrics {
-// m := &metrics{
-// cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{
-// Name: "cpu_temperature_celsius",
-// Help: "Current temperature of the CPU.",
-// }),
-// hdFailures: prometheus.NewCounterVec(
-// prometheus.CounterOpts{
-// Name: "hd_errors_total",
-// Help: "Number of hard-disk errors.",
-// },
-// []string{"device"},
-// ),
-// }
-// reg.MustRegister(m.cpuTemp)
-// reg.MustRegister(m.hdFailures)
-// return m
-// }
-//
-// func main() {
-// // Create a non-global registry.
-// reg := prometheus.NewRegistry()
-//
-// // Create new metrics and register them using the custom registry.
-// m := NewMetrics(reg)
-// // Set values for the new created metrics.
-// m.cpuTemp.Set(65.3)
-// m.hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc()
-//
-// // Expose metrics and custom registry via an HTTP server
-// // using the HandleFor function. "/metrics" is the usual endpoint for that.
-// http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{Registry: reg}))
-// log.Fatal(http.ListenAndServe(":8080", nil))
-// }
-//
-// This is a complete program that exports two metrics, a Gauge and a Counter,
-// the latter with a label attached to turn it into a (one-dimensional) vector.
-// It register the metrics using a custom registry and exposes them via an HTTP server
-// on the /metrics endpoint.
-//
-// # Metrics
-//
-// The number of exported identifiers in this package might appear a bit
-// overwhelming. However, in addition to the basic plumbing shown in the example
-// above, you only need to understand the different metric types and their
-// vector versions for basic usage. Furthermore, if you are not concerned with
-// fine-grained control of when and how to register metrics with the registry,
-// have a look at the promauto package, which will effectively allow you to
-// ignore registration altogether in simple cases.
-//
-// Above, you have already touched the Counter and the Gauge. There are two more
-// advanced metric types: the Summary and Histogram. A more thorough description
-// of those four metric types can be found in the Prometheus docs:
-// https://prometheus.io/docs/concepts/metric_types/
-//
-// In addition to the fundamental metric types Gauge, Counter, Summary, and
-// Histogram, a very important part of the Prometheus data model is the
-// partitioning of samples along dimensions called labels, which results in
-// metric vectors. The fundamental types are GaugeVec, CounterVec, SummaryVec,
-// and HistogramVec.
-//
-// While only the fundamental metric types implement the Metric interface, both
-// the metrics and their vector versions implement the Collector interface. A
-// Collector manages the collection of a number of Metrics, but for convenience,
-// a Metric can also “collect itself”. Note that Gauge, Counter, Summary, and
-// Histogram are interfaces themselves while GaugeVec, CounterVec, SummaryVec,
-// and HistogramVec are not.
-//
-// To create instances of Metrics and their vector versions, you need a suitable
-// …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, or HistogramOpts.
-//
-// # Custom Collectors and constant Metrics
-//
-// While you could create your own implementations of Metric, most likely you
-// will only ever implement the Collector interface on your own. At a first
-// glance, a custom Collector seems handy to bundle Metrics for common
-// registration (with the prime example of the different metric vectors above,
-// which bundle all the metrics of the same name but with different labels).
-//
-// There is a more involved use case, too: If you already have metrics
-// available, created outside of the Prometheus context, you don't need the
-// interface of the various Metric types. You essentially want to mirror the
-// existing numbers into Prometheus Metrics during collection. An own
-// implementation of the Collector interface is perfect for that. You can create
-// Metric instances “on the fly” using NewConstMetric, NewConstHistogram, and
-// NewConstSummary (and their respective Must… versions). NewConstMetric is used
-// for all metric types with just a float64 as their value: Counter, Gauge, and
-// a special “type” called Untyped. Use the latter if you are not sure if the
-// mirrored metric is a Counter or a Gauge. Creation of the Metric instance
-// happens in the Collect method. The Describe method has to return separate
-// Desc instances, representative of the “throw-away” metrics to be created
-// later. NewDesc comes in handy to create those Desc instances. Alternatively,
-// you could return no Desc at all, which will mark the Collector “unchecked”.
-// No checks are performed at registration time, but metric consistency will
-// still be ensured at scrape time, i.e. any inconsistencies will lead to scrape
-// errors. Thus, with unchecked Collectors, the responsibility to not collect
-// metrics that lead to inconsistencies in the total scrape result lies with the
-// implementer of the Collector. While this is not a desirable state, it is
-// sometimes necessary. The typical use case is a situation where the exact
-// metrics to be returned by a Collector cannot be predicted at registration
-// time, but the implementer has sufficient knowledge of the whole system to
-// guarantee metric consistency.
-//
-// The Collector example illustrates the use case. You can also look at the
-// source code of the processCollector (mirroring process metrics), the
-// goCollector (mirroring Go metrics), or the expvarCollector (mirroring expvar
-// metrics) as examples that are used in this package itself.
-//
-// If you just need to call a function to get a single float value to collect as
-// a metric, GaugeFunc, CounterFunc, or UntypedFunc might be interesting
-// shortcuts.
-//
-// # Advanced Uses of the Registry
-//
-// While MustRegister is the by far most common way of registering a Collector,
-// sometimes you might want to handle the errors the registration might cause.
-// As suggested by the name, MustRegister panics if an error occurs. With the
-// Register function, the error is returned and can be handled.
-//
-// An error is returned if the registered Collector is incompatible or
-// inconsistent with already registered metrics. The registry aims for
-// consistency of the collected metrics according to the Prometheus data model.
-// Inconsistencies are ideally detected at registration time, not at collect
-// time. The former will usually be detected at start-up time of a program,
-// while the latter will only happen at scrape time, possibly not even on the
-// first scrape if the inconsistency only becomes relevant later. That is the
-// main reason why a Collector and a Metric have to describe themselves to the
-// registry.
-//
-// So far, everything we did operated on the so-called default registry, as it
-// can be found in the global DefaultRegisterer variable. With NewRegistry, you
-// can create a custom registry, or you can even implement the Registerer or
-// Gatherer interfaces yourself. The methods Register and Unregister work in the
-// same way on a custom registry as the global functions Register and Unregister
-// on the default registry.
-//
-// There are a number of uses for custom registries: You can use registries with
-// special properties, see NewPedanticRegistry. You can avoid global state, as
-// it is imposed by the DefaultRegisterer. You can use multiple registries at
-// the same time to expose different metrics in different ways. You can use
-// separate registries for testing purposes.
-//
-// Also note that the DefaultRegisterer comes registered with a Collector for Go
-// runtime metrics (via NewGoCollector) and a Collector for process metrics (via
-// NewProcessCollector). With a custom registry, you are in control and decide
-// yourself about the Collectors to register.
-//
-// # HTTP Exposition
-//
-// The Registry implements the Gatherer interface. The caller of the Gather
-// method can then expose the gathered metrics in some way. Usually, the metrics
-// are served via HTTP on the /metrics endpoint. That's happening in the example
-// above. The tools to expose metrics via HTTP are in the promhttp sub-package.
-//
-// # Pushing to the Pushgateway
-//
-// Function for pushing to the Pushgateway can be found in the push sub-package.
-//
-// # Graphite Bridge
-//
-// Functions and examples to push metrics from a Gatherer to Graphite can be
-// found in the graphite sub-package.
-//
-// # Other Means of Exposition
-//
-// More ways of exposing metrics can easily be added by following the approaches
-// of the existing implementations.
-package prometheus
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go b/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go
deleted file mode 100644
index de5a856..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/expvar_collector.go
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "encoding/json"
- "expvar"
-)
-
-type expvarCollector struct {
- exports map[string]*Desc
-}
-
-// NewExpvarCollector is the obsolete version of collectors.NewExpvarCollector.
-// See there for documentation.
-//
-// Deprecated: Use collectors.NewExpvarCollector instead.
-func NewExpvarCollector(exports map[string]*Desc) Collector {
- return &expvarCollector{
- exports: exports,
- }
-}
-
-// Describe implements Collector.
-func (e *expvarCollector) Describe(ch chan<- *Desc) {
- for _, desc := range e.exports {
- ch <- desc
- }
-}
-
-// Collect implements Collector.
-func (e *expvarCollector) Collect(ch chan<- Metric) {
- for name, desc := range e.exports {
- var m Metric
- expVar := expvar.Get(name)
- if expVar == nil {
- continue
- }
- var v interface{}
- labels := make([]string, len(desc.variableLabels.names))
- if err := json.Unmarshal([]byte(expVar.String()), &v); err != nil {
- ch <- NewInvalidMetric(desc, err)
- continue
- }
- var processValue func(v interface{}, i int)
- processValue = func(v interface{}, i int) {
- if i >= len(labels) {
- copiedLabels := append(make([]string, 0, len(labels)), labels...)
- switch v := v.(type) {
- case float64:
- m = MustNewConstMetric(desc, UntypedValue, v, copiedLabels...)
- case bool:
- if v {
- m = MustNewConstMetric(desc, UntypedValue, 1, copiedLabels...)
- } else {
- m = MustNewConstMetric(desc, UntypedValue, 0, copiedLabels...)
- }
- default:
- return
- }
- ch <- m
- return
- }
- vm, ok := v.(map[string]interface{})
- if !ok {
- return
- }
- for lv, val := range vm {
- labels[i] = lv
- processValue(val, i+1)
- }
- }
- processValue(v, 0)
- }
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/fnv.go b/vendor/github.com/prometheus/client_golang/prometheus/fnv.go
deleted file mode 100644
index 3d383a7..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/fnv.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-// Inline and byte-free variant of hash/fnv's fnv64a.
-
-const (
- offset64 = 14695981039346656037
- prime64 = 1099511628211
-)
-
-// hashNew initializies a new fnv64a hash value.
-func hashNew() uint64 {
- return offset64
-}
-
-// hashAdd adds a string to a fnv64a hash value, returning the updated hash.
-func hashAdd(h uint64, s string) uint64 {
- for i := 0; i < len(s); i++ {
- h ^= uint64(s[i])
- h *= prime64
- }
- return h
-}
-
-// hashAddByte adds a byte to a fnv64a hash value, returning the updated hash.
-func hashAddByte(h uint64, b byte) uint64 {
- h ^= uint64(b)
- h *= prime64
- return h
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/gauge.go b/vendor/github.com/prometheus/client_golang/prometheus/gauge.go
deleted file mode 100644
index dd2eac9..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/gauge.go
+++ /dev/null
@@ -1,311 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "math"
- "sync/atomic"
- "time"
-
- dto "github.com/prometheus/client_model/go"
-)
-
-// Gauge is a Metric that represents a single numerical value that can
-// arbitrarily go up and down.
-//
-// A Gauge is typically used for measured values like temperatures or current
-// memory usage, but also "counts" that can go up and down, like the number of
-// running goroutines.
-//
-// To create Gauge instances, use NewGauge.
-type Gauge interface {
- Metric
- Collector
-
- // Set sets the Gauge to an arbitrary value.
- Set(float64)
- // Inc increments the Gauge by 1. Use Add to increment it by arbitrary
- // values.
- Inc()
- // Dec decrements the Gauge by 1. Use Sub to decrement it by arbitrary
- // values.
- Dec()
- // Add adds the given value to the Gauge. (The value can be negative,
- // resulting in a decrease of the Gauge.)
- Add(float64)
- // Sub subtracts the given value from the Gauge. (The value can be
- // negative, resulting in an increase of the Gauge.)
- Sub(float64)
-
- // SetToCurrentTime sets the Gauge to the current Unix time in seconds.
- SetToCurrentTime()
-}
-
-// GaugeOpts is an alias for Opts. See there for doc comments.
-type GaugeOpts Opts
-
-// GaugeVecOpts bundles the options to create a GaugeVec metric.
-// It is mandatory to set GaugeOpts, see there for mandatory fields. VariableLabels
-// is optional and can safely be left to its default value.
-type GaugeVecOpts struct {
- GaugeOpts
-
- // VariableLabels are used to partition the metric vector by the given set
- // of labels. Each label value will be constrained with the optional Constraint
- // function, if provided.
- VariableLabels ConstrainableLabels
-}
-
-// NewGauge creates a new Gauge based on the provided GaugeOpts.
-//
-// The returned implementation is optimized for a fast Set method. If you have a
-// choice for managing the value of a Gauge via Set vs. Inc/Dec/Add/Sub, pick
-// the former. For example, the Inc method of the returned Gauge is slower than
-// the Inc method of a Counter returned by NewCounter. This matches the typical
-// scenarios for Gauges and Counters, where the former tends to be Set-heavy and
-// the latter Inc-heavy.
-func NewGauge(opts GaugeOpts) Gauge {
- desc := NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- nil,
- opts.ConstLabels,
- )
- result := &gauge{desc: desc, labelPairs: desc.constLabelPairs}
- result.init(result) // Init self-collection.
- return result
-}
-
-type gauge struct {
- // valBits contains the bits of the represented float64 value. It has
- // to go first in the struct to guarantee alignment for atomic
- // operations. http://golang.org/pkg/sync/atomic/#pkg-note-BUG
- valBits uint64
-
- selfCollector
-
- desc *Desc
- labelPairs []*dto.LabelPair
-}
-
-func (g *gauge) Desc() *Desc {
- return g.desc
-}
-
-func (g *gauge) Set(val float64) {
- atomic.StoreUint64(&g.valBits, math.Float64bits(val))
-}
-
-func (g *gauge) SetToCurrentTime() {
- g.Set(float64(time.Now().UnixNano()) / 1e9)
-}
-
-func (g *gauge) Inc() {
- g.Add(1)
-}
-
-func (g *gauge) Dec() {
- g.Add(-1)
-}
-
-func (g *gauge) Add(val float64) {
- for {
- oldBits := atomic.LoadUint64(&g.valBits)
- newBits := math.Float64bits(math.Float64frombits(oldBits) + val)
- if atomic.CompareAndSwapUint64(&g.valBits, oldBits, newBits) {
- return
- }
- }
-}
-
-func (g *gauge) Sub(val float64) {
- g.Add(val * -1)
-}
-
-func (g *gauge) Write(out *dto.Metric) error {
- val := math.Float64frombits(atomic.LoadUint64(&g.valBits))
- return populateMetric(GaugeValue, val, g.labelPairs, nil, out, nil)
-}
-
-// GaugeVec is a Collector that bundles a set of Gauges that all share the same
-// Desc, but have different values for their variable labels. This is used if
-// you want to count the same thing partitioned by various dimensions
-// (e.g. number of operations queued, partitioned by user and operation
-// type). Create instances with NewGaugeVec.
-type GaugeVec struct {
- *MetricVec
-}
-
-// NewGaugeVec creates a new GaugeVec based on the provided GaugeOpts and
-// partitioned by the given label names.
-func NewGaugeVec(opts GaugeOpts, labelNames []string) *GaugeVec {
- return V2.NewGaugeVec(GaugeVecOpts{
- GaugeOpts: opts,
- VariableLabels: UnconstrainedLabels(labelNames),
- })
-}
-
-// NewGaugeVec creates a new GaugeVec based on the provided GaugeVecOpts.
-func (v2) NewGaugeVec(opts GaugeVecOpts) *GaugeVec {
- desc := V2.NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- opts.VariableLabels,
- opts.ConstLabels,
- )
- return &GaugeVec{
- MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
- if len(lvs) != len(desc.variableLabels.names) {
- panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.names, lvs))
- }
- result := &gauge{desc: desc, labelPairs: MakeLabelPairs(desc, lvs)}
- result.init(result) // Init self-collection.
- return result
- }),
- }
-}
-
-// GetMetricWithLabelValues returns the Gauge for the given slice of label
-// values (same order as the variable labels in Desc). If that combination of
-// label values is accessed for the first time, a new Gauge is created.
-//
-// It is possible to call this method without using the returned Gauge to only
-// create the new Gauge but leave it at its starting value 0. See also the
-// SummaryVec example.
-//
-// Keeping the Gauge for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// Delete can be used to delete the Gauge from the GaugeVec. In that case, the
-// Gauge will still exist, but it will not be exported anymore, even if a
-// Gauge with the same label values is created later. See also the CounterVec
-// example.
-//
-// An error is returned if the number of label values is not the same as the
-// number of variable labels in Desc (minus any curried labels).
-//
-// Note that for more than one label value, this method is prone to mistakes
-// caused by an incorrect order of arguments. Consider GetMetricWith(Labels) as
-// an alternative to avoid that type of mistake. For higher label numbers, the
-// latter has a much more readable (albeit more verbose) syntax, but it comes
-// with a performance overhead (for creating and processing the Labels map).
-func (v *GaugeVec) GetMetricWithLabelValues(lvs ...string) (Gauge, error) {
- metric, err := v.MetricVec.GetMetricWithLabelValues(lvs...)
- if metric != nil {
- return metric.(Gauge), err
- }
- return nil, err
-}
-
-// GetMetricWith returns the Gauge for the given Labels map (the label names
-// must match those of the variable labels in Desc). If that label map is
-// accessed for the first time, a new Gauge is created. Implications of
-// creating a Gauge without using it and keeping the Gauge for later use are
-// the same as for GetMetricWithLabelValues.
-//
-// An error is returned if the number and names of the Labels are inconsistent
-// with those of the variable labels in Desc (minus any curried labels).
-//
-// This method is used for the same purpose as
-// GetMetricWithLabelValues(...string). See there for pros and cons of the two
-// methods.
-func (v *GaugeVec) GetMetricWith(labels Labels) (Gauge, error) {
- metric, err := v.MetricVec.GetMetricWith(labels)
- if metric != nil {
- return metric.(Gauge), err
- }
- return nil, err
-}
-
-// WithLabelValues works as GetMetricWithLabelValues, but panics where
-// GetMetricWithLabelValues would have returned an error. Not returning an
-// error allows shortcuts like
-//
-// myVec.WithLabelValues("404", "GET").Add(42)
-func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge {
- g, err := v.GetMetricWithLabelValues(lvs...)
- if err != nil {
- panic(err)
- }
- return g
-}
-
-// With works as GetMetricWith, but panics where GetMetricWithLabels would have
-// returned an error. Not returning an error allows shortcuts like
-//
-// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42)
-func (v *GaugeVec) With(labels Labels) Gauge {
- g, err := v.GetMetricWith(labels)
- if err != nil {
- panic(err)
- }
- return g
-}
-
-// CurryWith returns a vector curried with the provided labels, i.e. the
-// returned vector has those labels pre-set for all labeled operations performed
-// on it. The cardinality of the curried vector is reduced accordingly. The
-// order of the remaining labels stays the same (just with the curried labels
-// taken out of the sequence – which is relevant for the
-// (GetMetric)WithLabelValues methods). It is possible to curry a curried
-// vector, but only with labels not yet used for currying before.
-//
-// The metrics contained in the GaugeVec are shared between the curried and
-// uncurried vectors. They are just accessed differently. Curried and uncurried
-// vectors behave identically in terms of collection. Only one must be
-// registered with a given registry (usually the uncurried version). The Reset
-// method deletes all metrics, even if called on a curried vector.
-func (v *GaugeVec) CurryWith(labels Labels) (*GaugeVec, error) {
- vec, err := v.MetricVec.CurryWith(labels)
- if vec != nil {
- return &GaugeVec{vec}, err
- }
- return nil, err
-}
-
-// MustCurryWith works as CurryWith but panics where CurryWith would have
-// returned an error.
-func (v *GaugeVec) MustCurryWith(labels Labels) *GaugeVec {
- vec, err := v.CurryWith(labels)
- if err != nil {
- panic(err)
- }
- return vec
-}
-
-// GaugeFunc is a Gauge whose value is determined at collect time by calling a
-// provided function.
-//
-// To create GaugeFunc instances, use NewGaugeFunc.
-type GaugeFunc interface {
- Metric
- Collector
-}
-
-// NewGaugeFunc creates a new GaugeFunc based on the provided GaugeOpts. The
-// value reported is determined by calling the given function from within the
-// Write method. Take into account that metric collection may happen
-// concurrently. Therefore, it must be safe to call the provided function
-// concurrently.
-//
-// NewGaugeFunc is a good way to create an “info” style metric with a constant
-// value of 1. Example:
-// https://github.com/prometheus/common/blob/8558a5b7db3c84fa38b4766966059a7bd5bfa2ee/version/info.go#L36-L56
-func NewGaugeFunc(opts GaugeOpts, function func() float64) GaugeFunc {
- return newValueFunc(NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- nil,
- opts.ConstLabels,
- ), GaugeValue, function)
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/get_pid.go b/vendor/github.com/prometheus/client_golang/prometheus/get_pid.go
deleted file mode 100644
index 614fd61..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/get_pid.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !js || wasm
-// +build !js wasm
-
-package prometheus
-
-import "os"
-
-func getPIDFn() func() (int, error) {
- pid := os.Getpid()
- return func() (int, error) {
- return pid, nil
- }
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/get_pid_gopherjs.go b/vendor/github.com/prometheus/client_golang/prometheus/get_pid_gopherjs.go
deleted file mode 100644
index eaf8059..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/get_pid_gopherjs.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build js && !wasm
-// +build js,!wasm
-
-package prometheus
-
-func getPIDFn() func() (int, error) {
- return func() (int, error) {
- return 1, nil
- }
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/go_collector.go b/vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
deleted file mode 100644
index 520cbd7..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
+++ /dev/null
@@ -1,274 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "runtime"
- "runtime/debug"
- "time"
-)
-
-// goRuntimeMemStats provides the metrics initially provided by runtime.ReadMemStats.
-// 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
-// populated using runtime/metrics. Those are the defaults we can't alter.
-func goRuntimeMemStats() memStatsMetrics {
- return memStatsMetrics{
- {
- desc: NewDesc(
- memstatNamespace("alloc_bytes"),
- "Number of bytes allocated in heap and currently in use. Equals to /memory/classes/heap/objects:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.Alloc) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("alloc_bytes_total"),
- "Total number of bytes allocated in heap until now, even if released already. Equals to /gc/heap/allocs:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.TotalAlloc) },
- valType: CounterValue,
- }, {
- desc: NewDesc(
- memstatNamespace("sys_bytes"),
- "Number of bytes obtained from system. Equals to /memory/classes/total:byte.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.Sys) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("mallocs_total"),
- // 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,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.Mallocs) },
- valType: CounterValue,
- }, {
- desc: NewDesc(
- memstatNamespace("frees_total"),
- "Total number of heap objects frees. Equals to /gc/heap/frees:objects + /gc/heap/tiny/allocs:objects.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.Frees) },
- valType: CounterValue,
- }, {
- desc: NewDesc(
- memstatNamespace("heap_alloc_bytes"),
- "Number of heap bytes allocated and currently in use, same as go_memstats_alloc_bytes. Equals to /memory/classes/heap/objects:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapAlloc) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("heap_sys_bytes"),
- "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,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapSys) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("heap_idle_bytes"),
- "Number of heap bytes waiting to be used. Equals to /memory/classes/heap/released:bytes + /memory/classes/heap/free:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapIdle) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("heap_inuse_bytes"),
- "Number of heap bytes that are in use. Equals to /memory/classes/heap/objects:bytes + /memory/classes/heap/unused:bytes",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapInuse) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("heap_released_bytes"),
- "Number of heap bytes released to OS. Equals to /memory/classes/heap/released:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapReleased) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("heap_objects"),
- "Number of currently allocated objects. Equals to /gc/heap/objects:objects.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapObjects) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("stack_inuse_bytes"),
- "Number of bytes obtained from system for stack allocator in non-CGO environments. Equals to /memory/classes/heap/stacks:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackInuse) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("stack_sys_bytes"),
- "Number of bytes obtained from system for stack allocator. Equals to /memory/classes/heap/stacks:bytes + /memory/classes/os-stacks:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackSys) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("mspan_inuse_bytes"),
- "Number of bytes in use by mspan structures. Equals to /memory/classes/metadata/mspan/inuse:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanInuse) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("mspan_sys_bytes"),
- "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,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanSys) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("mcache_inuse_bytes"),
- "Number of bytes in use by mcache structures. Equals to /memory/classes/metadata/mcache/inuse:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheInuse) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("mcache_sys_bytes"),
- "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,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheSys) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("buck_hash_sys_bytes"),
- "Number of bytes used by the profiling bucket hash table. Equals to /memory/classes/profiling/buckets:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.BuckHashSys) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("gc_sys_bytes"),
- "Number of bytes used for garbage collection system metadata. Equals to /memory/classes/metadata/other:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.GCSys) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("other_sys_bytes"),
- "Number of bytes used for other system allocations. Equals to /memory/classes/other:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.OtherSys) },
- valType: GaugeValue,
- }, {
- desc: NewDesc(
- memstatNamespace("next_gc_bytes"),
- "Number of heap bytes when next garbage collection will take place. Equals to /gc/heap/goal:bytes.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return float64(ms.NextGC) },
- valType: GaugeValue,
- },
- }
-}
-
-type baseGoCollector struct {
- goroutinesDesc *Desc
- threadsDesc *Desc
- gcDesc *Desc
- gcLastTimeDesc *Desc
- goInfoDesc *Desc
-}
-
-func newBaseGoCollector() baseGoCollector {
- return baseGoCollector{
- goroutinesDesc: NewDesc(
- "go_goroutines",
- "Number of goroutines that currently exist.",
- nil, nil),
- threadsDesc: NewDesc(
- "go_threads",
- "Number of OS threads created.",
- nil, nil),
- gcDesc: NewDesc(
- "go_gc_duration_seconds",
- "A summary of the wall-time pause (stop-the-world) duration in garbage collection cycles.",
- nil, nil),
- gcLastTimeDesc: NewDesc(
- "go_memstats_last_gc_time_seconds",
- "Number of seconds since 1970 of last garbage collection.",
- nil, nil),
- goInfoDesc: NewDesc(
- "go_info",
- "Information about the Go environment.",
- nil, Labels{"version": runtime.Version()}),
- }
-}
-
-// Describe returns all descriptions of the collector.
-func (c *baseGoCollector) Describe(ch chan<- *Desc) {
- ch <- c.goroutinesDesc
- ch <- c.threadsDesc
- ch <- c.gcDesc
- ch <- c.gcLastTimeDesc
- ch <- c.goInfoDesc
-}
-
-// Collect returns the current state of all metrics of the collector.
-func (c *baseGoCollector) Collect(ch chan<- Metric) {
- ch <- MustNewConstMetric(c.goroutinesDesc, GaugeValue, float64(runtime.NumGoroutine()))
-
- n := getRuntimeNumThreads()
- ch <- MustNewConstMetric(c.threadsDesc, GaugeValue, n)
-
- var stats debug.GCStats
- stats.PauseQuantiles = make([]time.Duration, 5)
- debug.ReadGCStats(&stats)
-
- quantiles := make(map[float64]float64)
- for idx, pq := range stats.PauseQuantiles[1:] {
- quantiles[float64(idx+1)/float64(len(stats.PauseQuantiles)-1)] = pq.Seconds()
- }
- quantiles[0.0] = stats.PauseQuantiles[0].Seconds()
- ch <- MustNewConstSummary(c.gcDesc, uint64(stats.NumGC), stats.PauseTotal.Seconds(), quantiles)
- ch <- MustNewConstMetric(c.gcLastTimeDesc, GaugeValue, float64(stats.LastGC.UnixNano())/1e9)
- ch <- MustNewConstMetric(c.goInfoDesc, GaugeValue, 1)
-}
-
-func memstatNamespace(s string) string {
- return "go_memstats_" + s
-}
-
-// memStatsMetrics provide description, evaluator, runtime/metrics name, and
-// value type for memstat metrics.
-type memStatsMetrics []struct {
- desc *Desc
- eval func(*runtime.MemStats) float64
- valType ValueType
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_go116.go b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_go116.go
deleted file mode 100644
index 897a6e9..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_go116.go
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright 2021 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !go1.17
-// +build !go1.17
-
-package prometheus
-
-import (
- "runtime"
- "sync"
- "time"
-)
-
-type goCollector struct {
- base baseGoCollector
-
- // ms... are memstats related.
- msLast *runtime.MemStats // Previously collected memstats.
- msLastTimestamp time.Time
- msMtx sync.Mutex // Protects msLast and msLastTimestamp.
- msMetrics memStatsMetrics
- msRead func(*runtime.MemStats) // For mocking in tests.
- msMaxWait time.Duration // Wait time for fresh memstats.
- msMaxAge time.Duration // Maximum allowed age of old memstats.
-}
-
-// NewGoCollector is the obsolete version of collectors.NewGoCollector.
-// See there for documentation.
-//
-// Deprecated: Use collectors.NewGoCollector instead.
-func NewGoCollector() Collector {
- msMetrics := goRuntimeMemStats()
- msMetrics = append(msMetrics, struct {
- desc *Desc
- eval func(*runtime.MemStats) float64
- valType ValueType
- }{
- // This metric is omitted in Go1.17+, see https://github.com/prometheus/client_golang/issues/842#issuecomment-861812034
- desc: NewDesc(
- memstatNamespace("gc_cpu_fraction"),
- "The fraction of this program's available CPU time used by the GC since the program started.",
- nil, nil,
- ),
- eval: func(ms *runtime.MemStats) float64 { return ms.GCCPUFraction },
- valType: GaugeValue,
- })
- return &goCollector{
- base: newBaseGoCollector(),
- msLast: &runtime.MemStats{},
- msRead: runtime.ReadMemStats,
- msMaxWait: time.Second,
- msMaxAge: 5 * time.Minute,
- msMetrics: msMetrics,
- }
-}
-
-// Describe returns all descriptions of the collector.
-func (c *goCollector) Describe(ch chan<- *Desc) {
- c.base.Describe(ch)
- for _, i := range c.msMetrics {
- ch <- i.desc
- }
-}
-
-// Collect returns the current state of all metrics of the collector.
-func (c *goCollector) Collect(ch chan<- Metric) {
- var (
- ms = &runtime.MemStats{}
- done = make(chan struct{})
- )
- // Start reading memstats first as it might take a while.
- go func() {
- c.msRead(ms)
- c.msMtx.Lock()
- c.msLast = ms
- c.msLastTimestamp = time.Now()
- c.msMtx.Unlock()
- close(done)
- }()
-
- // Collect base non-memory metrics.
- c.base.Collect(ch)
-
- timer := time.NewTimer(c.msMaxWait)
- select {
- case <-done: // Our own ReadMemStats succeeded in time. Use it.
- timer.Stop() // Important for high collection frequencies to not pile up timers.
- c.msCollect(ch, ms)
- return
- case <-timer.C: // Time out, use last memstats if possible. Continue below.
- }
- c.msMtx.Lock()
- if time.Since(c.msLastTimestamp) < c.msMaxAge {
- // Last memstats are recent enough. Collect from them under the lock.
- c.msCollect(ch, c.msLast)
- c.msMtx.Unlock()
- return
- }
- // If we are here, the last memstats are too old or don't exist. We have
- // to wait until our own ReadMemStats finally completes. For that to
- // happen, we have to release the lock.
- c.msMtx.Unlock()
- <-done
- c.msCollect(ch, ms)
-}
-
-func (c *goCollector) msCollect(ch chan<- Metric, ms *runtime.MemStats) {
- for _, i := range c.msMetrics {
- ch <- MustNewConstMetric(i.desc, i.valType, i.eval(ms))
- }
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go b/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go
deleted file mode 100644
index 5117464..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go
+++ /dev/null
@@ -1,574 +0,0 @@
-// Copyright 2021 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build go1.17
-// +build go1.17
-
-package prometheus
-
-import (
- "fmt"
- "math"
- "runtime"
- "runtime/metrics"
- "strings"
- "sync"
-
- "github.com/prometheus/client_golang/prometheus/internal"
-
- dto "github.com/prometheus/client_model/go"
- "google.golang.org/protobuf/proto"
-)
-
-const (
- // constants for strings referenced more than once.
- goGCHeapTinyAllocsObjects = "/gc/heap/tiny/allocs:objects"
- goGCHeapAllocsObjects = "/gc/heap/allocs:objects"
- goGCHeapFreesObjects = "/gc/heap/frees:objects"
- goGCHeapFreesBytes = "/gc/heap/frees:bytes"
- goGCHeapAllocsBytes = "/gc/heap/allocs:bytes"
- goGCHeapObjects = "/gc/heap/objects:objects"
- goGCHeapGoalBytes = "/gc/heap/goal:bytes"
- goMemoryClassesTotalBytes = "/memory/classes/total:bytes"
- goMemoryClassesHeapObjectsBytes = "/memory/classes/heap/objects:bytes"
- goMemoryClassesHeapUnusedBytes = "/memory/classes/heap/unused:bytes"
- goMemoryClassesHeapReleasedBytes = "/memory/classes/heap/released:bytes"
- goMemoryClassesHeapFreeBytes = "/memory/classes/heap/free:bytes"
- goMemoryClassesHeapStacksBytes = "/memory/classes/heap/stacks:bytes"
- goMemoryClassesOSStacksBytes = "/memory/classes/os-stacks:bytes"
- goMemoryClassesMetadataMSpanInuseBytes = "/memory/classes/metadata/mspan/inuse:bytes"
- goMemoryClassesMetadataMSPanFreeBytes = "/memory/classes/metadata/mspan/free:bytes"
- goMemoryClassesMetadataMCacheInuseBytes = "/memory/classes/metadata/mcache/inuse:bytes"
- goMemoryClassesMetadataMCacheFreeBytes = "/memory/classes/metadata/mcache/free:bytes"
- goMemoryClassesProfilingBucketsBytes = "/memory/classes/profiling/buckets:bytes"
- goMemoryClassesMetadataOtherBytes = "/memory/classes/metadata/other:bytes"
- goMemoryClassesOtherBytes = "/memory/classes/other:bytes"
-)
-
-// rmNamesForMemStatsMetrics represents runtime/metrics names required to populate goRuntimeMemStats from like logic.
-var rmNamesForMemStatsMetrics = []string{
- goGCHeapTinyAllocsObjects,
- goGCHeapAllocsObjects,
- goGCHeapFreesObjects,
- goGCHeapAllocsBytes,
- goGCHeapObjects,
- goGCHeapGoalBytes,
- goMemoryClassesTotalBytes,
- goMemoryClassesHeapObjectsBytes,
- goMemoryClassesHeapUnusedBytes,
- goMemoryClassesHeapReleasedBytes,
- goMemoryClassesHeapFreeBytes,
- goMemoryClassesHeapStacksBytes,
- goMemoryClassesOSStacksBytes,
- goMemoryClassesMetadataMSpanInuseBytes,
- goMemoryClassesMetadataMSPanFreeBytes,
- goMemoryClassesMetadataMCacheInuseBytes,
- goMemoryClassesMetadataMCacheFreeBytes,
- goMemoryClassesProfilingBucketsBytes,
- goMemoryClassesMetadataOtherBytes,
- goMemoryClassesOtherBytes,
-}
-
-func bestEffortLookupRM(lookup []string) []metrics.Description {
- ret := make([]metrics.Description, 0, len(lookup))
- for _, rm := range metrics.All() {
- for _, m := range lookup {
- if m == rm.Name {
- ret = append(ret, rm)
- }
- }
- }
- return ret
-}
-
-type goCollector struct {
- base baseGoCollector
-
- // mu protects updates to all fields ensuring a consistent
- // snapshot is always produced by Collect.
- mu sync.Mutex
-
- // Contains all samples that has to retrieved from runtime/metrics (not all of them will be exposed).
- sampleBuf []metrics.Sample
- // sampleMap allows lookup for MemStats metrics and runtime/metrics histograms for exact sums.
- sampleMap map[string]*metrics.Sample
-
- // rmExposedMetrics represents all runtime/metrics package metrics
- // that were configured to be exposed.
- rmExposedMetrics []collectorMetric
- rmExactSumMapForHist map[string]string
-
- // With Go 1.17, the runtime/metrics package was introduced.
- // From that point on, metric names produced by the runtime/metrics
- // package could be generated from runtime/metrics names. However,
- // these differ from the old names for the same values.
- //
- // This field exists to export the same values under the old names
- // as well.
- msMetrics memStatsMetrics
- msMetricsEnabled bool
-}
-
-type rmMetricDesc struct {
- metrics.Description
-}
-
-func matchRuntimeMetricsRules(rules []internal.GoCollectorRule) []rmMetricDesc {
- var descs []rmMetricDesc
- for _, d := range metrics.All() {
- var (
- deny = true
- desc rmMetricDesc
- )
-
- for _, r := range rules {
- if !r.Matcher.MatchString(d.Name) {
- continue
- }
- deny = r.Deny
- }
- if deny {
- continue
- }
-
- desc.Description = d
- descs = append(descs, desc)
- }
- return descs
-}
-
-func defaultGoCollectorOptions() internal.GoCollectorOptions {
- return internal.GoCollectorOptions{
- RuntimeMetricSumForHist: map[string]string{
- "/gc/heap/allocs-by-size:bytes": goGCHeapAllocsBytes,
- "/gc/heap/frees-by-size:bytes": goGCHeapFreesBytes,
- },
- RuntimeMetricRules: []internal.GoCollectorRule{
- // Recommended metrics we want by default from runtime/metrics.
- {Matcher: internal.GoCollectorDefaultRuntimeMetrics},
- },
- }
-}
-
-// NewGoCollector is the obsolete version of collectors.NewGoCollector.
-// See there for documentation.
-//
-// Deprecated: Use collectors.NewGoCollector instead.
-func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
- opt := defaultGoCollectorOptions()
- for _, o := range opts {
- o(&opt)
- }
-
- exposedDescriptions := matchRuntimeMetricsRules(opt.RuntimeMetricRules)
-
- // Collect all histogram samples so that we can get their buckets.
- // The API guarantees that the buckets are always fixed for the lifetime
- // of the process.
- var histograms []metrics.Sample
- for _, d := range exposedDescriptions {
- if d.Kind == metrics.KindFloat64Histogram {
- histograms = append(histograms, metrics.Sample{Name: d.Name})
- }
- }
-
- if len(histograms) > 0 {
- metrics.Read(histograms)
- }
-
- bucketsMap := make(map[string][]float64)
- for i := range histograms {
- bucketsMap[histograms[i].Name] = histograms[i].Value.Float64Histogram().Buckets
- }
-
- // Generate a collector for each exposed runtime/metrics metric.
- metricSet := make([]collectorMetric, 0, len(exposedDescriptions))
- // SampleBuf is used for reading from runtime/metrics.
- // We are assuming the largest case to have stable pointers for sampleMap purposes.
- sampleBuf := make([]metrics.Sample, 0, len(exposedDescriptions)+len(opt.RuntimeMetricSumForHist)+len(rmNamesForMemStatsMetrics))
- sampleMap := make(map[string]*metrics.Sample, len(exposedDescriptions))
- for _, d := range exposedDescriptions {
- namespace, subsystem, name, ok := internal.RuntimeMetricsToProm(&d.Description)
- if !ok {
- // Just ignore this metric; we can't do anything with it here.
- // If a user decides to use the latest version of Go, we don't want
- // to fail here. This condition is tested in TestExpectedRuntimeMetrics.
- continue
- }
- help := attachOriginalName(d.Description.Description, d.Name)
-
- sampleBuf = append(sampleBuf, metrics.Sample{Name: d.Name})
- sampleMap[d.Name] = &sampleBuf[len(sampleBuf)-1]
-
- var m collectorMetric
- if d.Kind == metrics.KindFloat64Histogram {
- _, hasSum := opt.RuntimeMetricSumForHist[d.Name]
- unit := d.Name[strings.IndexRune(d.Name, ':')+1:]
- m = newBatchHistogram(
- NewDesc(
- BuildFQName(namespace, subsystem, name),
- help,
- nil,
- nil,
- ),
- internal.RuntimeMetricsBucketsForUnit(bucketsMap[d.Name], unit),
- hasSum,
- )
- } else if d.Cumulative {
- m = NewCounter(CounterOpts{
- Namespace: namespace,
- Subsystem: subsystem,
- Name: name,
- Help: help,
- },
- )
- } else {
- m = NewGauge(GaugeOpts{
- Namespace: namespace,
- Subsystem: subsystem,
- Name: name,
- Help: help,
- })
- }
- metricSet = append(metricSet, m)
- }
-
- // Add exact sum metrics to sampleBuf if not added before.
- for _, h := range histograms {
- sumMetric, ok := opt.RuntimeMetricSumForHist[h.Name]
- if !ok {
- continue
- }
-
- if _, ok := sampleMap[sumMetric]; ok {
- continue
- }
- sampleBuf = append(sampleBuf, metrics.Sample{Name: sumMetric})
- sampleMap[sumMetric] = &sampleBuf[len(sampleBuf)-1]
- }
-
- var (
- msMetrics memStatsMetrics
- msDescriptions []metrics.Description
- )
-
- if !opt.DisableMemStatsLikeMetrics {
- msMetrics = goRuntimeMemStats()
- msDescriptions = bestEffortLookupRM(rmNamesForMemStatsMetrics)
-
- // Check if metric was not exposed before and if not, add to sampleBuf.
- for _, mdDesc := range msDescriptions {
- if _, ok := sampleMap[mdDesc.Name]; ok {
- continue
- }
- sampleBuf = append(sampleBuf, metrics.Sample{Name: mdDesc.Name})
- sampleMap[mdDesc.Name] = &sampleBuf[len(sampleBuf)-1]
- }
- }
-
- return &goCollector{
- base: newBaseGoCollector(),
- sampleBuf: sampleBuf,
- sampleMap: sampleMap,
- rmExposedMetrics: metricSet,
- rmExactSumMapForHist: opt.RuntimeMetricSumForHist,
- msMetrics: msMetrics,
- msMetricsEnabled: !opt.DisableMemStatsLikeMetrics,
- }
-}
-
-func attachOriginalName(desc, origName string) string {
- return fmt.Sprintf("%s Sourced from %s", desc, origName)
-}
-
-// Describe returns all descriptions of the collector.
-func (c *goCollector) Describe(ch chan<- *Desc) {
- c.base.Describe(ch)
- for _, i := range c.msMetrics {
- ch <- i.desc
- }
- for _, m := range c.rmExposedMetrics {
- ch <- m.Desc()
- }
-}
-
-// Collect returns the current state of all metrics of the collector.
-func (c *goCollector) Collect(ch chan<- Metric) {
- // Collect base non-memory metrics.
- c.base.Collect(ch)
-
- if len(c.sampleBuf) == 0 {
- return
- }
-
- // Collect must be thread-safe, so prevent concurrent use of
- // sampleBuf elements. Just read into sampleBuf but write all the data
- // we get into our Metrics or MemStats.
- //
- // This lock also ensures that the Metrics we send out are all from
- // the same updates, ensuring their mutual consistency insofar as
- // is guaranteed by the runtime/metrics package.
- //
- // N.B. This locking is heavy-handed, but Collect is expected to be called
- // relatively infrequently. Also the core operation here, metrics.Read,
- // is fast (O(tens of microseconds)) so contention should certainly be
- // low, though channel operations and any allocations may add to that.
- c.mu.Lock()
- defer c.mu.Unlock()
-
- // Populate runtime/metrics sample buffer.
- metrics.Read(c.sampleBuf)
-
- // Collect all our runtime/metrics user chose to expose from sampleBuf (if any).
- for i, metric := range c.rmExposedMetrics {
- // We created samples for exposed metrics first in order, so indexes match.
- sample := c.sampleBuf[i]
-
- // N.B. switch on concrete type because it's significantly more efficient
- // than checking for the Counter and Gauge interface implementations. In
- // this case, we control all the types here.
- switch m := metric.(type) {
- case *counter:
- // Guard against decreases. This should never happen, but a failure
- // to do so will result in a panic, which is a harsh consequence for
- // a metrics collection bug.
- v0, v1 := m.get(), unwrapScalarRMValue(sample.Value)
- if v1 > v0 {
- m.Add(unwrapScalarRMValue(sample.Value) - m.get())
- }
- m.Collect(ch)
- case *gauge:
- m.Set(unwrapScalarRMValue(sample.Value))
- m.Collect(ch)
- case *batchHistogram:
- m.update(sample.Value.Float64Histogram(), c.exactSumFor(sample.Name))
- m.Collect(ch)
- default:
- panic("unexpected metric type")
- }
- }
-
- if c.msMetricsEnabled {
- // ms is a dummy MemStats that we populate ourselves so that we can
- // populate the old metrics from it if goMemStatsCollection is enabled.
- var ms runtime.MemStats
- memStatsFromRM(&ms, c.sampleMap)
- for _, i := range c.msMetrics {
- ch <- MustNewConstMetric(i.desc, i.valType, i.eval(&ms))
- }
- }
-}
-
-// unwrapScalarRMValue unwraps a runtime/metrics value that is assumed
-// to be scalar and returns the equivalent float64 value. Panics if the
-// value is not scalar.
-func unwrapScalarRMValue(v metrics.Value) float64 {
- switch v.Kind() {
- case metrics.KindUint64:
- return float64(v.Uint64())
- case metrics.KindFloat64:
- return v.Float64()
- case metrics.KindBad:
- // Unsupported metric.
- //
- // This should never happen because we always populate our metric
- // set from the runtime/metrics package.
- panic("unexpected bad kind metric")
- default:
- // Unsupported metric kind.
- //
- // This should never happen because we check for this during initialization
- // and flag and filter metrics whose kinds we don't understand.
- panic(fmt.Sprintf("unexpected unsupported metric: %v", v.Kind()))
- }
-}
-
-// exactSumFor takes a runtime/metrics metric name (that is assumed to
-// be of kind KindFloat64Histogram) and returns its exact sum and whether
-// its exact sum exists.
-//
-// The runtime/metrics API for histograms doesn't currently expose exact
-// sums, but some of the other metrics are in fact exact sums of histograms.
-func (c *goCollector) exactSumFor(rmName string) float64 {
- sumName, ok := c.rmExactSumMapForHist[rmName]
- if !ok {
- return 0
- }
- s, ok := c.sampleMap[sumName]
- if !ok {
- return 0
- }
- return unwrapScalarRMValue(s.Value)
-}
-
-func memStatsFromRM(ms *runtime.MemStats, rm map[string]*metrics.Sample) {
- lookupOrZero := func(name string) uint64 {
- if s, ok := rm[name]; ok {
- return s.Value.Uint64()
- }
- return 0
- }
-
- // Currently, MemStats adds tiny alloc count to both Mallocs AND Frees.
- // The reason for this is because MemStats couldn't be extended at the time
- // but there was a desire to have Mallocs at least be a little more representative,
- // while having Mallocs - Frees still represent a live object count.
- // Unfortunately, MemStats doesn't actually export a large allocation count,
- // so it's impossible to pull this number out directly.
- tinyAllocs := lookupOrZero(goGCHeapTinyAllocsObjects)
- ms.Mallocs = lookupOrZero(goGCHeapAllocsObjects) + tinyAllocs
- ms.Frees = lookupOrZero(goGCHeapFreesObjects) + tinyAllocs
-
- ms.TotalAlloc = lookupOrZero(goGCHeapAllocsBytes)
- ms.Sys = lookupOrZero(goMemoryClassesTotalBytes)
- ms.Lookups = 0 // Already always zero.
- ms.HeapAlloc = lookupOrZero(goMemoryClassesHeapObjectsBytes)
- ms.Alloc = ms.HeapAlloc
- ms.HeapInuse = ms.HeapAlloc + lookupOrZero(goMemoryClassesHeapUnusedBytes)
- ms.HeapReleased = lookupOrZero(goMemoryClassesHeapReleasedBytes)
- ms.HeapIdle = ms.HeapReleased + lookupOrZero(goMemoryClassesHeapFreeBytes)
- ms.HeapSys = ms.HeapInuse + ms.HeapIdle
- ms.HeapObjects = lookupOrZero(goGCHeapObjects)
- ms.StackInuse = lookupOrZero(goMemoryClassesHeapStacksBytes)
- ms.StackSys = ms.StackInuse + lookupOrZero(goMemoryClassesOSStacksBytes)
- ms.MSpanInuse = lookupOrZero(goMemoryClassesMetadataMSpanInuseBytes)
- ms.MSpanSys = ms.MSpanInuse + lookupOrZero(goMemoryClassesMetadataMSPanFreeBytes)
- ms.MCacheInuse = lookupOrZero(goMemoryClassesMetadataMCacheInuseBytes)
- ms.MCacheSys = ms.MCacheInuse + lookupOrZero(goMemoryClassesMetadataMCacheFreeBytes)
- ms.BuckHashSys = lookupOrZero(goMemoryClassesProfilingBucketsBytes)
- ms.GCSys = lookupOrZero(goMemoryClassesMetadataOtherBytes)
- ms.OtherSys = lookupOrZero(goMemoryClassesOtherBytes)
- ms.NextGC = lookupOrZero(goGCHeapGoalBytes)
-
- // N.B. GCCPUFraction is intentionally omitted. This metric is not useful,
- // and often misleading due to the fact that it's an average over the lifetime
- // of the process.
- // See https://github.com/prometheus/client_golang/issues/842#issuecomment-861812034
- // for more details.
- ms.GCCPUFraction = 0
-}
-
-// batchHistogram is a mutable histogram that is updated
-// in batches.
-type batchHistogram struct {
- selfCollector
-
- // Static fields updated only once.
- desc *Desc
- hasSum bool
-
- // Because this histogram operates in batches, it just uses a
- // single mutex for everything. updates are always serialized
- // but Write calls may operate concurrently with updates.
- // Contention between these two sources should be rare.
- mu sync.Mutex
- buckets []float64 // Inclusive lower bounds, like runtime/metrics.
- counts []uint64
- sum float64 // Used if hasSum is true.
-}
-
-// newBatchHistogram creates a new batch histogram value with the given
-// Desc, buckets, and whether or not it has an exact sum available.
-//
-// buckets must always be from the runtime/metrics package, following
-// the same conventions.
-func newBatchHistogram(desc *Desc, buckets []float64, hasSum bool) *batchHistogram {
- // We need to remove -Inf values. runtime/metrics keeps them around.
- // But -Inf bucket should not be allowed for prometheus histograms.
- if buckets[0] == math.Inf(-1) {
- buckets = buckets[1:]
- }
- h := &batchHistogram{
- desc: desc,
- buckets: buckets,
- // Because buckets follows runtime/metrics conventions, there's
- // 1 more value in the buckets list than there are buckets represented,
- // because in runtime/metrics, the bucket values represent *boundaries*,
- // and non-Inf boundaries are inclusive lower bounds for that bucket.
- counts: make([]uint64, len(buckets)-1),
- hasSum: hasSum,
- }
- h.init(h)
- return h
-}
-
-// update updates the batchHistogram from a runtime/metrics histogram.
-//
-// sum must be provided if the batchHistogram was created to have an exact sum.
-// h.buckets must be a strict subset of his.Buckets.
-func (h *batchHistogram) update(his *metrics.Float64Histogram, sum float64) {
- counts, buckets := his.Counts, his.Buckets
-
- h.mu.Lock()
- defer h.mu.Unlock()
-
- // Clear buckets.
- for i := range h.counts {
- h.counts[i] = 0
- }
- // Copy and reduce buckets.
- var j int
- for i, count := range counts {
- h.counts[j] += count
- if buckets[i+1] == h.buckets[j+1] {
- j++
- }
- }
- if h.hasSum {
- h.sum = sum
- }
-}
-
-func (h *batchHistogram) Desc() *Desc {
- return h.desc
-}
-
-func (h *batchHistogram) Write(out *dto.Metric) error {
- h.mu.Lock()
- defer h.mu.Unlock()
-
- sum := float64(0)
- if h.hasSum {
- sum = h.sum
- }
- dtoBuckets := make([]*dto.Bucket, 0, len(h.counts))
- totalCount := uint64(0)
- for i, count := range h.counts {
- totalCount += count
- if !h.hasSum {
- if count != 0 {
- // N.B. This computed sum is an underestimate.
- sum += h.buckets[i] * float64(count)
- }
- }
-
- // Skip the +Inf bucket, but only for the bucket list.
- // It must still count for sum and totalCount.
- if math.IsInf(h.buckets[i+1], 1) {
- break
- }
- // Float64Histogram's upper bound is exclusive, so make it inclusive
- // by obtaining the next float64 value down, in order.
- upperBound := math.Nextafter(h.buckets[i+1], h.buckets[i])
- dtoBuckets = append(dtoBuckets, &dto.Bucket{
- CumulativeCount: proto.Uint64(totalCount),
- UpperBound: proto.Float64(upperBound),
- })
- }
- out.Histogram = &dto.Histogram{
- Bucket: dtoBuckets,
- SampleCount: proto.Uint64(totalCount),
- SampleSum: proto.Float64(sum),
- }
- return nil
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go
deleted file mode 100644
index 519db34..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go
+++ /dev/null
@@ -1,1837 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "fmt"
- "math"
- "runtime"
- "sort"
- "sync"
- "sync/atomic"
- "time"
-
- dto "github.com/prometheus/client_model/go"
-
- "google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/types/known/timestamppb"
-)
-
-// nativeHistogramBounds for the frac of observed values. Only relevant for
-// schema > 0. The position in the slice is the schema. (0 is never used, just
-// here for convenience of using the schema directly as the index.)
-//
-// TODO(beorn7): Currently, we do a binary search into these slices. There are
-// ways to turn it into a small number of simple array lookups. It probably only
-// matters for schema 5 and beyond, but should be investigated. See this comment
-// as a starting point:
-// https://github.com/open-telemetry/opentelemetry-specification/issues/1776#issuecomment-870164310
-var nativeHistogramBounds = [][]float64{
- // Schema "0":
- {0.5},
- // Schema 1:
- {0.5, 0.7071067811865475},
- // Schema 2:
- {0.5, 0.5946035575013605, 0.7071067811865475, 0.8408964152537144},
- // Schema 3:
- {
- 0.5, 0.5452538663326288, 0.5946035575013605, 0.6484197773255048,
- 0.7071067811865475, 0.7711054127039704, 0.8408964152537144, 0.9170040432046711,
- },
- // Schema 4:
- {
- 0.5, 0.5221368912137069, 0.5452538663326288, 0.5693943173783458,
- 0.5946035575013605, 0.620928906036742, 0.6484197773255048, 0.6771277734684463,
- 0.7071067811865475, 0.7384130729697496, 0.7711054127039704, 0.805245165974627,
- 0.8408964152537144, 0.8781260801866495, 0.9170040432046711, 0.9576032806985735,
- },
- // Schema 5:
- {
- 0.5, 0.5109485743270583, 0.5221368912137069, 0.5335702003384117,
- 0.5452538663326288, 0.5571933712979462, 0.5693943173783458, 0.5818624293887887,
- 0.5946035575013605, 0.6076236799902344, 0.620928906036742, 0.6345254785958666,
- 0.6484197773255048, 0.6626183215798706, 0.6771277734684463, 0.6919549409819159,
- 0.7071067811865475, 0.7225904034885232, 0.7384130729697496, 0.7545822137967112,
- 0.7711054127039704, 0.7879904225539431, 0.805245165974627, 0.8228777390769823,
- 0.8408964152537144, 0.8593096490612387, 0.8781260801866495, 0.8973545375015533,
- 0.9170040432046711, 0.9370838170551498, 0.9576032806985735, 0.9785720620876999,
- },
- // Schema 6:
- {
- 0.5, 0.5054446430258502, 0.5109485743270583, 0.5165124395106142,
- 0.5221368912137069, 0.5278225891802786, 0.5335702003384117, 0.5393803988785598,
- 0.5452538663326288, 0.5511912916539204, 0.5571933712979462, 0.5632608093041209,
- 0.5693943173783458, 0.5755946149764913, 0.5818624293887887, 0.5881984958251406,
- 0.5946035575013605, 0.6010783657263515, 0.6076236799902344, 0.6142402680534349,
- 0.620928906036742, 0.6276903785123455, 0.6345254785958666, 0.6414350080393891,
- 0.6484197773255048, 0.6554806057623822, 0.6626183215798706, 0.6698337620266515,
- 0.6771277734684463, 0.6845012114872953, 0.6919549409819159, 0.6994898362691555,
- 0.7071067811865475, 0.7148066691959849, 0.7225904034885232, 0.7304588970903234,
- 0.7384130729697496, 0.7464538641456323, 0.7545822137967112, 0.762799075372269,
- 0.7711054127039704, 0.7795022001189185, 0.7879904225539431, 0.7965710756711334,
- 0.805245165974627, 0.8140137109286738, 0.8228777390769823, 0.8318382901633681,
- 0.8408964152537144, 0.8500531768592616, 0.8593096490612387, 0.8686669176368529,
- 0.8781260801866495, 0.8876882462632604, 0.8973545375015533, 0.9071260877501991,
- 0.9170040432046711, 0.9269895625416926, 0.9370838170551498, 0.9472879907934827,
- 0.9576032806985735, 0.9680308967461471, 0.9785720620876999, 0.9892280131939752,
- },
- // Schema 7:
- {
- 0.5, 0.5027149505564014, 0.5054446430258502, 0.5081891574554764,
- 0.5109485743270583, 0.5137229745593818, 0.5165124395106142, 0.5193170509806894,
- 0.5221368912137069, 0.5249720429003435, 0.5278225891802786, 0.5306886136446309,
- 0.5335702003384117, 0.5364674337629877, 0.5393803988785598, 0.5423091811066545,
- 0.5452538663326288, 0.5482145409081883, 0.5511912916539204, 0.5541842058618393,
- 0.5571933712979462, 0.5602188762048033, 0.5632608093041209, 0.5663192597993595,
- 0.5693943173783458, 0.572486072215902, 0.5755946149764913, 0.5787200368168754,
- 0.5818624293887887, 0.585021884841625, 0.5881984958251406, 0.5913923554921704,
- 0.5946035575013605, 0.5978321960199137, 0.6010783657263515, 0.6043421618132907,
- 0.6076236799902344, 0.6109230164863786, 0.6142402680534349, 0.6175755319684665,
- 0.620928906036742, 0.6243004885946023, 0.6276903785123455, 0.6310986751971253,
- 0.6345254785958666, 0.637970889198196, 0.6414350080393891, 0.6449179367033329,
- 0.6484197773255048, 0.6519406325959679, 0.6554806057623822, 0.659039800633032,
- 0.6626183215798706, 0.6662162735415805, 0.6698337620266515, 0.6734708931164728,
- 0.6771277734684463, 0.6808045103191123, 0.6845012114872953, 0.688217985377265,
- 0.6919549409819159, 0.6957121878859629, 0.6994898362691555, 0.7032879969095076,
- 0.7071067811865475, 0.7109463010845827, 0.7148066691959849, 0.718687998724491,
- 0.7225904034885232, 0.7265139979245261, 0.7304588970903234, 0.7344252166684908,
- 0.7384130729697496, 0.7424225829363761, 0.7464538641456323, 0.7505070348132126,
- 0.7545822137967112, 0.7586795205991071, 0.762799075372269, 0.7669409989204777,
- 0.7711054127039704, 0.7752924388424999, 0.7795022001189185, 0.7837348199827764,
- 0.7879904225539431, 0.7922691326262467, 0.7965710756711334, 0.8008963778413465,
- 0.805245165974627, 0.8096175675974316, 0.8140137109286738, 0.8184337248834821,
- 0.8228777390769823, 0.8273458838280969, 0.8318382901633681, 0.8363550898207981,
- 0.8408964152537144, 0.8454623996346523, 0.8500531768592616, 0.8546688815502312,
- 0.8593096490612387, 0.8639756154809185, 0.8686669176368529, 0.8733836930995842,
- 0.8781260801866495, 0.8828942179666361, 0.8876882462632604, 0.8925083056594671,
- 0.8973545375015533, 0.9022270839033115, 0.9071260877501991, 0.9120516927035263,
- 0.9170040432046711, 0.9219832844793128, 0.9269895625416926, 0.9320230241988943,
- 0.9370838170551498, 0.9421720895161669, 0.9472879907934827, 0.9524316709088368,
- 0.9576032806985735, 0.9628029718180622, 0.9680308967461471, 0.9732872087896164,
- 0.9785720620876999, 0.9838856116165875, 0.9892280131939752, 0.9945994234836328,
- },
- // Schema 8:
- {
- 0.5, 0.5013556375251013, 0.5027149505564014, 0.5040779490592088,
- 0.5054446430258502, 0.5068150424757447, 0.5081891574554764, 0.509566998038869,
- 0.5109485743270583, 0.5123338964485679, 0.5137229745593818, 0.5151158188430205,
- 0.5165124395106142, 0.5179128468009786, 0.5193170509806894, 0.520725062344158,
- 0.5221368912137069, 0.5235525479396449, 0.5249720429003435, 0.526395386502313,
- 0.5278225891802786, 0.5292536613972564, 0.5306886136446309, 0.5321274564422321,
- 0.5335702003384117, 0.5350168559101208, 0.5364674337629877, 0.5379219445313954,
- 0.5393803988785598, 0.5408428074966075, 0.5423091811066545, 0.5437795304588847,
- 0.5452538663326288, 0.5467321995364429, 0.5482145409081883, 0.549700901315111,
- 0.5511912916539204, 0.5526857228508706, 0.5541842058618393, 0.5556867516724088,
- 0.5571933712979462, 0.5587040757836845, 0.5602188762048033, 0.5617377836665098,
- 0.5632608093041209, 0.564787964283144, 0.5663192597993595, 0.5678547070789026,
- 0.5693943173783458, 0.5709381019847808, 0.572486072215902, 0.5740382394200894,
- 0.5755946149764913, 0.5771552102951081, 0.5787200368168754, 0.5802891060137493,
- 0.5818624293887887, 0.5834400184762408, 0.585021884841625, 0.5866080400818185,
- 0.5881984958251406, 0.5897932637314379, 0.5913923554921704, 0.5929957828304968,
- 0.5946035575013605, 0.5962156912915756, 0.5978321960199137, 0.5994530835371903,
- 0.6010783657263515, 0.6027080545025619, 0.6043421618132907, 0.6059806996384005,
- 0.6076236799902344, 0.6092711149137041, 0.6109230164863786, 0.6125793968185725,
- 0.6142402680534349, 0.6159056423670379, 0.6175755319684665, 0.6192499490999082,
- 0.620928906036742, 0.622612415087629, 0.6243004885946023, 0.6259931389331581,
- 0.6276903785123455, 0.6293922197748583, 0.6310986751971253, 0.6328097572894031,
- 0.6345254785958666, 0.6362458516947014, 0.637970889198196, 0.6397006037528346,
- 0.6414350080393891, 0.6431741147730128, 0.6449179367033329, 0.6466664866145447,
- 0.6484197773255048, 0.6501778216898253, 0.6519406325959679, 0.6537082229673385,
- 0.6554806057623822, 0.6572577939746774, 0.659039800633032, 0.6608266388015788,
- 0.6626183215798706, 0.6644148621029772, 0.6662162735415805, 0.6680225691020727,
- 0.6698337620266515, 0.6716498655934177, 0.6734708931164728, 0.6752968579460171,
- 0.6771277734684463, 0.6789636531064505, 0.6808045103191123, 0.6826503586020058,
- 0.6845012114872953, 0.6863570825438342, 0.688217985377265, 0.690083933630119,
- 0.6919549409819159, 0.6938310211492645, 0.6957121878859629, 0.6975984549830999,
- 0.6994898362691555, 0.7013863456101023, 0.7032879969095076, 0.7051948041086352,
- 0.7071067811865475, 0.7090239421602076, 0.7109463010845827, 0.7128738720527471,
- 0.7148066691959849, 0.7167447066838943, 0.718687998724491, 0.7206365595643126,
- 0.7225904034885232, 0.7245495448210174, 0.7265139979245261, 0.7284837772007218,
- 0.7304588970903234, 0.7324393720732029, 0.7344252166684908, 0.7364164454346837,
- 0.7384130729697496, 0.7404151139112358, 0.7424225829363761, 0.7444354947621984,
- 0.7464538641456323, 0.7484777058836176, 0.7505070348132126, 0.7525418658117031,
- 0.7545822137967112, 0.7566280937263048, 0.7586795205991071, 0.7607365094544071,
- 0.762799075372269, 0.7648672334736434, 0.7669409989204777, 0.7690203869158282,
- 0.7711054127039704, 0.7731960915705107, 0.7752924388424999, 0.7773944698885442,
- 0.7795022001189185, 0.7816156449856788, 0.7837348199827764, 0.7858597406461707,
- 0.7879904225539431, 0.7901268813264122, 0.7922691326262467, 0.7944171921585818,
- 0.7965710756711334, 0.7987307989543135, 0.8008963778413465, 0.8030678282083853,
- 0.805245165974627, 0.8074284071024302, 0.8096175675974316, 0.8118126635086642,
- 0.8140137109286738, 0.8162207259936375, 0.8184337248834821, 0.820652723822003,
- 0.8228777390769823, 0.8251087869603088, 0.8273458838280969, 0.8295890460808079,
- 0.8318382901633681, 0.8340936325652911, 0.8363550898207981, 0.8386226785089391,
- 0.8408964152537144, 0.8431763167241966, 0.8454623996346523, 0.8477546807446661,
- 0.8500531768592616, 0.8523579048290255, 0.8546688815502312, 0.8569861239649629,
- 0.8593096490612387, 0.8616394738731368, 0.8639756154809185, 0.8663180910111553,
- 0.8686669176368529, 0.871022112577578, 0.8733836930995842, 0.8757516765159389,
- 0.8781260801866495, 0.8805069215187917, 0.8828942179666361, 0.8852879870317771,
- 0.8876882462632604, 0.890095013257712, 0.8925083056594671, 0.8949281411607002,
- 0.8973545375015533, 0.8997875124702672, 0.9022270839033115, 0.9046732696855155,
- 0.9071260877501991, 0.909585556079304, 0.9120516927035263, 0.9145245157024483,
- 0.9170040432046711, 0.9194902933879467, 0.9219832844793128, 0.9244830347552253,
- 0.9269895625416926, 0.92950288621441, 0.9320230241988943, 0.9345499949706191,
- 0.9370838170551498, 0.93962450902828, 0.9421720895161669, 0.9447265771954693,
- 0.9472879907934827, 0.9498563490882775, 0.9524316709088368, 0.9550139751351947,
- 0.9576032806985735, 0.9601996065815236, 0.9628029718180622, 0.9654133954938133,
- 0.9680308967461471, 0.9706554947643201, 0.9732872087896164, 0.9759260581154889,
- 0.9785720620876999, 0.9812252401044634, 0.9838856116165875, 0.9865531961276168,
- 0.9892280131939752, 0.9919100824251095, 0.9945994234836328, 0.9972960560854698,
- },
-}
-
-// The nativeHistogramBounds above can be generated with the code below.
-//
-// TODO(beorn7): It's tempting to actually use `go generate` to generate the
-// code above. However, this could lead to slightly different numbers on
-// different architectures. We still need to come to terms if we are fine with
-// that, or if we might prefer to specify precise numbers in the standard.
-//
-// var nativeHistogramBounds [][]float64 = make([][]float64, 9)
-//
-// func init() {
-// // Populate nativeHistogramBounds.
-// numBuckets := 1
-// for i := range nativeHistogramBounds {
-// bounds := []float64{0.5}
-// factor := math.Exp2(math.Exp2(float64(-i)))
-// for j := 0; j < numBuckets-1; j++ {
-// var bound float64
-// if (j+1)%2 == 0 {
-// // Use previously calculated value for increased precision.
-// bound = nativeHistogramBounds[i-1][j/2+1]
-// } else {
-// bound = bounds[j] * factor
-// }
-// bounds = append(bounds, bound)
-// }
-// numBuckets *= 2
-// nativeHistogramBounds[i] = bounds
-// }
-// }
-
-// A Histogram counts individual observations from an event or sample stream in
-// configurable static buckets (or in dynamic sparse buckets as part of the
-// experimental Native Histograms, see below for more details). Similar to a
-// Summary, it also provides a sum of observations and an observation count.
-//
-// On the Prometheus server, quantiles can be calculated from a Histogram using
-// the histogram_quantile PromQL function.
-//
-// Note that Histograms, in contrast to Summaries, can be aggregated in PromQL
-// (see the documentation for detailed procedures). However, Histograms require
-// the user to pre-define suitable buckets, and they are in general less
-// accurate. (Both problems are addressed by the experimental Native
-// Histograms. To use them, configure a NativeHistogramBucketFactor in the
-// HistogramOpts. They also require a Prometheus server v2.40+ with the
-// corresponding feature flag enabled.)
-//
-// The Observe method of a Histogram has a very low performance overhead in
-// comparison with the Observe method of a Summary.
-//
-// To create Histogram instances, use NewHistogram.
-type Histogram interface {
- Metric
- Collector
-
- // Observe adds a single observation to the histogram. Observations are
- // usually positive or zero. Negative observations are accepted but
- // prevent current versions of Prometheus from properly detecting
- // counter resets in the sum of observations. (The experimental Native
- // Histograms handle negative observations properly.) See
- // https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations
- // for details.
- Observe(float64)
-}
-
-// bucketLabel is used for the label that defines the upper bound of a
-// bucket of a histogram ("le" -> "less or equal").
-const bucketLabel = "le"
-
-// DefBuckets are the default Histogram buckets. The default buckets are
-// tailored to broadly measure the response time (in seconds) of a network
-// service. Most likely, however, you will be required to define buckets
-// customized to your use case.
-var DefBuckets = []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}
-
-// DefNativeHistogramZeroThreshold is the default value for
-// NativeHistogramZeroThreshold in the HistogramOpts.
-//
-// The value is 2^-128 (or 0.5*2^-127 in the actual IEEE 754 representation),
-// which is a bucket boundary at all possible resolutions.
-const DefNativeHistogramZeroThreshold = 2.938735877055719e-39
-
-// NativeHistogramZeroThresholdZero can be used as NativeHistogramZeroThreshold
-// in the HistogramOpts to create a zero bucket of width zero, i.e. a zero
-// bucket that only receives observations of precisely zero.
-const NativeHistogramZeroThresholdZero = -1
-
-var errBucketLabelNotAllowed = fmt.Errorf(
- "%q is not allowed as label name in histograms", bucketLabel,
-)
-
-// LinearBuckets creates 'count' regular buckets, each 'width' wide, where the
-// lowest bucket has an upper bound of 'start'. The final +Inf bucket is not
-// counted and not included in the returned slice. The returned slice is meant
-// to be used for the Buckets field of HistogramOpts.
-//
-// The function panics if 'count' is zero or negative.
-func LinearBuckets(start, width float64, count int) []float64 {
- if count < 1 {
- panic("LinearBuckets needs a positive count")
- }
- buckets := make([]float64, count)
- for i := range buckets {
- buckets[i] = start
- start += width
- }
- return buckets
-}
-
-// ExponentialBuckets creates 'count' regular buckets, where the lowest bucket
-// has an upper bound of 'start' and each following bucket's upper bound is
-// 'factor' times the previous bucket's upper bound. The final +Inf bucket is
-// not counted and not included in the returned slice. The returned slice is
-// meant to be used for the Buckets field of HistogramOpts.
-//
-// The function panics if 'count' is 0 or negative, if 'start' is 0 or negative,
-// or if 'factor' is less than or equal 1.
-func ExponentialBuckets(start, factor float64, count int) []float64 {
- if count < 1 {
- panic("ExponentialBuckets needs a positive count")
- }
- if start <= 0 {
- panic("ExponentialBuckets needs a positive start value")
- }
- if factor <= 1 {
- panic("ExponentialBuckets needs a factor greater than 1")
- }
- buckets := make([]float64, count)
- for i := range buckets {
- buckets[i] = start
- start *= factor
- }
- return buckets
-}
-
-// ExponentialBucketsRange creates 'count' buckets, where the lowest bucket is
-// 'min' and the highest bucket is 'max'. The final +Inf bucket is not counted
-// and not included in the returned slice. The returned slice is meant to be
-// used for the Buckets field of HistogramOpts.
-//
-// The function panics if 'count' is 0 or negative, if 'min' is 0 or negative.
-func ExponentialBucketsRange(min, max float64, count int) []float64 {
- if count < 1 {
- panic("ExponentialBucketsRange count needs a positive count")
- }
- if min <= 0 {
- panic("ExponentialBucketsRange min needs to be greater than 0")
- }
-
- // Formula for exponential buckets.
- // max = min*growthFactor^(bucketCount-1)
-
- // We know max/min and highest bucket. Solve for growthFactor.
- growthFactor := math.Pow(max/min, 1.0/float64(count-1))
-
- // Now that we know growthFactor, solve for each bucket.
- buckets := make([]float64, count)
- for i := 1; i <= count; i++ {
- buckets[i-1] = min * math.Pow(growthFactor, float64(i-1))
- }
- return buckets
-}
-
-// HistogramOpts bundles the options for creating a Histogram metric. It is
-// mandatory to set Name to a non-empty string. All other fields are optional
-// and can safely be left at their zero value, although it is strongly
-// encouraged to set a Help string.
-type HistogramOpts struct {
- // Namespace, Subsystem, and Name are components of the fully-qualified
- // name of the Histogram (created by joining these components with
- // "_"). Only Name is mandatory, the others merely help structuring the
- // name. Note that the fully-qualified name of the Histogram must be a
- // valid Prometheus metric name.
- Namespace string
- Subsystem string
- Name string
-
- // Help provides information about this Histogram.
- //
- // Metrics with the same fully-qualified name must have the same Help
- // string.
- Help string
-
- // ConstLabels are used to attach fixed labels to this metric. Metrics
- // with the same fully-qualified name must have the same label names in
- // their ConstLabels.
- //
- // ConstLabels are only used rarely. In particular, do not use them to
- // attach the same labels to all your metrics. Those use cases are
- // better covered by target labels set by the scraping Prometheus
- // server, or by one specific metric (e.g. a build_info or a
- // machine_role metric). See also
- // https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels
- ConstLabels Labels
-
- // Buckets defines the buckets into which observations are counted. Each
- // element in the slice is the upper inclusive bound of a bucket. The
- // values must be sorted in strictly increasing order. There is no need
- // to add a highest bucket with +Inf bound, it will be added
- // implicitly. If Buckets is left as nil or set to a slice of length
- // zero, it is replaced by default buckets. The default buckets are
- // DefBuckets if no buckets for a native histogram (see below) are used,
- // otherwise the default is no buckets. (In other words, if you want to
- // use both regular buckets and buckets for a native histogram, you have
- // to define the regular buckets here explicitly.)
- Buckets []float64
-
- // If NativeHistogramBucketFactor is greater than one, so-called sparse
- // buckets are used (in addition to the regular buckets, if defined
- // above). A Histogram with sparse buckets will be ingested as a Native
- // Histogram by a Prometheus server with that feature enabled (requires
- // Prometheus v2.40+). Sparse buckets are exponential buckets covering
- // the whole float64 range (with the exception of the “zero” bucket, see
- // NativeHistogramZeroThreshold below). From any one bucket to the next,
- // the width of the bucket grows by a constant
- // factor. NativeHistogramBucketFactor provides an upper bound for this
- // factor (exception see below). The smaller
- // NativeHistogramBucketFactor, the more buckets will be used and thus
- // the more costly the histogram will become. A generally good trade-off
- // between cost and accuracy is a value of 1.1 (each bucket is at most
- // 10% wider than the previous one), which will result in each power of
- // two divided into 8 buckets (e.g. there will be 8 buckets between 1
- // and 2, same as between 2 and 4, and 4 and 8, etc.).
- //
- // Details about the actually used factor: The factor is calculated as
- // 2^(2^-n), where n is an integer number between (and including) -4 and
- // 8. n is chosen so that the resulting factor is the largest that is
- // still smaller or equal to NativeHistogramBucketFactor. Note that the
- // smallest possible factor is therefore approx. 1.00271 (i.e. 2^(2^-8)
- // ). If NativeHistogramBucketFactor is greater than 1 but smaller than
- // 2^(2^-8), then the actually used factor is still 2^(2^-8) even though
- // it is larger than the provided NativeHistogramBucketFactor.
- //
- // NOTE: Native Histograms are still an experimental feature. Their
- // behavior might still change without a major version
- // bump. Subsequently, all NativeHistogram... options here might still
- // change their behavior or name (or might completely disappear) without
- // a major version bump.
- NativeHistogramBucketFactor float64
- // All observations with an absolute value of less or equal
- // NativeHistogramZeroThreshold are accumulated into a “zero” bucket.
- // For best results, this should be close to a bucket boundary. This is
- // usually the case if picking a power of two. If
- // NativeHistogramZeroThreshold is left at zero,
- // DefNativeHistogramZeroThreshold is used as the threshold. To
- // configure a zero bucket with an actual threshold of zero (i.e. only
- // observations of precisely zero will go into the zero bucket), set
- // NativeHistogramZeroThreshold to the NativeHistogramZeroThresholdZero
- // constant (or any negative float value).
- NativeHistogramZeroThreshold float64
-
- // The next three fields define a strategy to limit the number of
- // populated sparse buckets. If NativeHistogramMaxBucketNumber is left
- // at zero, the number of buckets is not limited. (Note that this might
- // lead to unbounded memory consumption if the values observed by the
- // Histogram are sufficiently wide-spread. In particular, this could be
- // used as a DoS attack vector. Where the observed values depend on
- // external inputs, it is highly recommended to set a
- // NativeHistogramMaxBucketNumber.) Once the set
- // NativeHistogramMaxBucketNumber is exceeded, the following strategy is
- // enacted:
- // - First, if the last reset (or the creation) of the histogram is at
- // least NativeHistogramMinResetDuration ago, then the whole
- // histogram is reset to its initial state (including regular
- // buckets).
- // - If less time has passed, or if NativeHistogramMinResetDuration is
- // zero, no reset is performed. Instead, the zero threshold is
- // increased sufficiently to reduce the number of buckets to or below
- // NativeHistogramMaxBucketNumber, but not to more than
- // NativeHistogramMaxZeroThreshold. Thus, if
- // NativeHistogramMaxZeroThreshold is already at or below the current
- // zero threshold, nothing happens at this step.
- // - After that, if the number of buckets still exceeds
- // NativeHistogramMaxBucketNumber, the resolution of the histogram is
- // reduced by doubling the width of the sparse buckets (up to a
- // growth factor between one bucket to the next of 2^(2^4) = 65536,
- // see above).
- // - Any increased zero threshold or reduced resolution is reset back
- // to their original values once NativeHistogramMinResetDuration has
- // passed (since the last reset or the creation of the histogram).
- NativeHistogramMaxBucketNumber uint32
- NativeHistogramMinResetDuration time.Duration
- 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 func() time.Time
-
- // afterFunc is for testing purposes, by default it's time.AfterFunc.
- afterFunc func(time.Duration, func()) *time.Timer
-}
-
-// HistogramVecOpts bundles the options to create a HistogramVec metric.
-// It is mandatory to set HistogramOpts, see there for mandatory fields. VariableLabels
-// is optional and can safely be left to its default value.
-type HistogramVecOpts struct {
- HistogramOpts
-
- // VariableLabels are used to partition the metric vector by the given set
- // of labels. Each label value will be constrained with the optional Constraint
- // function, if provided.
- VariableLabels ConstrainableLabels
-}
-
-// NewHistogram creates a new Histogram based on the provided HistogramOpts. It
-// panics if the buckets in HistogramOpts are not in strictly increasing order.
-//
-// The returned implementation also implements ExemplarObserver. It is safe to
-// perform the corresponding type assertion. Exemplars are tracked separately
-// for each bucket.
-func NewHistogram(opts HistogramOpts) Histogram {
- return newHistogram(
- NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- nil,
- opts.ConstLabels,
- ),
- opts,
- )
-}
-
-func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogram {
- if len(desc.variableLabels.names) != len(labelValues) {
- panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.names, labelValues))
- }
-
- for _, n := range desc.variableLabels.names {
- if n == bucketLabel {
- panic(errBucketLabelNotAllowed)
- }
- }
- for _, lp := range desc.constLabelPairs {
- if lp.GetName() == bucketLabel {
- panic(errBucketLabelNotAllowed)
- }
- }
-
- if opts.now == nil {
- opts.now = time.Now
- }
- if opts.afterFunc == nil {
- opts.afterFunc = time.AfterFunc
- }
-
- h := &histogram{
- desc: desc,
- upperBounds: opts.Buckets,
- labelPairs: MakeLabelPairs(desc, labelValues),
- nativeHistogramMaxBuckets: opts.NativeHistogramMaxBucketNumber,
- nativeHistogramMaxZeroThreshold: opts.NativeHistogramMaxZeroThreshold,
- nativeHistogramMinResetDuration: opts.NativeHistogramMinResetDuration,
- lastResetTime: opts.now(),
- now: opts.now,
- afterFunc: opts.afterFunc,
- }
- if len(h.upperBounds) == 0 && opts.NativeHistogramBucketFactor <= 1 {
- h.upperBounds = DefBuckets
- }
- if opts.NativeHistogramBucketFactor <= 1 {
- h.nativeHistogramSchema = math.MinInt32 // To mark that there are no sparse buckets.
- } else {
- switch {
- case opts.NativeHistogramZeroThreshold > 0:
- h.nativeHistogramZeroThreshold = opts.NativeHistogramZeroThreshold
- case opts.NativeHistogramZeroThreshold == 0:
- h.nativeHistogramZeroThreshold = DefNativeHistogramZeroThreshold
- } // Leave h.nativeHistogramZeroThreshold at 0 otherwise.
- h.nativeHistogramSchema = pickSchema(opts.NativeHistogramBucketFactor)
- h.nativeExemplars = makeNativeExemplars(opts.NativeHistogramExemplarTTL, opts.NativeHistogramMaxExemplars)
- }
- for i, upperBound := range h.upperBounds {
- if i < len(h.upperBounds)-1 {
- if upperBound >= h.upperBounds[i+1] {
- panic(fmt.Errorf(
- "histogram buckets must be in increasing order: %f >= %f",
- upperBound, h.upperBounds[i+1],
- ))
- }
- } else {
- if math.IsInf(upperBound, +1) {
- // The +Inf bucket is implicit. Remove it here.
- h.upperBounds = h.upperBounds[:i]
- }
- }
- }
- // Finally we know the final length of h.upperBounds and can make buckets
- // for both counts as well as exemplars:
- h.counts[0] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))}
- atomic.StoreUint64(&h.counts[0].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold))
- atomic.StoreInt32(&h.counts[0].nativeHistogramSchema, h.nativeHistogramSchema)
- h.counts[1] = &histogramCounts{buckets: make([]uint64, len(h.upperBounds))}
- atomic.StoreUint64(&h.counts[1].nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold))
- atomic.StoreInt32(&h.counts[1].nativeHistogramSchema, h.nativeHistogramSchema)
- h.exemplars = make([]atomic.Value, len(h.upperBounds)+1)
-
- h.init(h) // Init self-collection.
- return h
-}
-
-type histogramCounts struct {
- // Order in this struct matters for the alignment required by atomic
- // operations, see http://golang.org/pkg/sync/atomic/#pkg-note-BUG
-
- // sumBits contains the bits of the float64 representing the sum of all
- // observations.
- sumBits uint64
- count uint64
-
- // nativeHistogramZeroBucket counts all (positive and negative)
- // observations in the zero bucket (with an absolute value less or equal
- // the current threshold, see next field.
- nativeHistogramZeroBucket uint64
- // nativeHistogramZeroThresholdBits is the bit pattern of the current
- // threshold for the zero bucket. It's initially equal to
- // nativeHistogramZeroThreshold but may change according to the bucket
- // count limitation strategy.
- nativeHistogramZeroThresholdBits uint64
- // nativeHistogramSchema may change over time according to the bucket
- // count limitation strategy and therefore has to be saved here.
- nativeHistogramSchema int32
- // Number of (positive and negative) sparse buckets.
- nativeHistogramBucketsNumber uint32
-
- // Regular buckets.
- buckets []uint64
-
- // The sparse buckets for native histograms are implemented with a
- // sync.Map for now. A dedicated data structure will likely be more
- // efficient. There are separate maps for negative and positive
- // observations. The map's value is an *int64, counting observations in
- // that bucket. (Note that we don't use uint64 as an int64 won't
- // overflow in practice, and working with signed numbers from the
- // beginning simplifies the handling of deltas.) The map's key is the
- // index of the bucket according to the used
- // nativeHistogramSchema. Index 0 is for an upper bound of 1.
- nativeHistogramBucketsPositive, nativeHistogramBucketsNegative sync.Map
-}
-
-// observe manages the parts of observe that only affects
-// histogramCounts. doSparse is true if sparse buckets should be done,
-// too.
-func (hc *histogramCounts) observe(v float64, bucket int, doSparse bool) {
- if bucket < len(hc.buckets) {
- atomic.AddUint64(&hc.buckets[bucket], 1)
- }
- atomicAddFloat(&hc.sumBits, v)
- if doSparse && !math.IsNaN(v) {
- var (
- key int
- schema = atomic.LoadInt32(&hc.nativeHistogramSchema)
- zeroThreshold = math.Float64frombits(atomic.LoadUint64(&hc.nativeHistogramZeroThresholdBits))
- bucketCreated, isInf bool
- )
- if math.IsInf(v, 0) {
- // Pretend v is MaxFloat64 but later increment key by one.
- if math.IsInf(v, +1) {
- v = math.MaxFloat64
- } else {
- v = -math.MaxFloat64
- }
- isInf = true
- }
- frac, exp := math.Frexp(math.Abs(v))
- if schema > 0 {
- bounds := nativeHistogramBounds[schema]
- key = sort.SearchFloat64s(bounds, frac) + (exp-1)*len(bounds)
- } else {
- key = exp
- if frac == 0.5 {
- key--
- }
- offset := (1 << -schema) - 1
- key = (key + offset) >> -schema
- }
- if isInf {
- key++
- }
- switch {
- case v > zeroThreshold:
- bucketCreated = addToBucket(&hc.nativeHistogramBucketsPositive, key, 1)
- case v < -zeroThreshold:
- bucketCreated = addToBucket(&hc.nativeHistogramBucketsNegative, key, 1)
- default:
- atomic.AddUint64(&hc.nativeHistogramZeroBucket, 1)
- }
- if bucketCreated {
- atomic.AddUint32(&hc.nativeHistogramBucketsNumber, 1)
- }
- }
- // Increment count last as we take it as a signal that the observation
- // is complete.
- atomic.AddUint64(&hc.count, 1)
-}
-
-type histogram struct {
- // countAndHotIdx enables lock-free writes with use of atomic updates.
- // The most significant bit is the hot index [0 or 1] of the count field
- // below. Observe calls update the hot one. All remaining bits count the
- // number of Observe calls. Observe starts by incrementing this counter,
- // and finish by incrementing the count field in the respective
- // histogramCounts, as a marker for completion.
- //
- // Calls of the Write method (which are non-mutating reads from the
- // perspective of the histogram) swap the hot–cold under the writeMtx
- // lock. A cooldown is awaited (while locked) by comparing the number of
- // observations with the initiation count. Once they match, then the
- // last observation on the now cool one has completed. All cold fields must
- // be merged into the new hot before releasing writeMtx.
- //
- // Fields with atomic access first! See alignment constraint:
- // http://golang.org/pkg/sync/atomic/#pkg-note-BUG
- countAndHotIdx uint64
-
- selfCollector
- desc *Desc
-
- // Only used in the Write method and for sparse bucket management.
- mtx sync.Mutex
-
- // Two counts, one is "hot" for lock-free observations, the other is
- // "cold" for writing out a dto.Metric. It has to be an array of
- // pointers to guarantee 64bit alignment of the histogramCounts, see
- // http://golang.org/pkg/sync/atomic/#pkg-note-BUG.
- counts [2]*histogramCounts
-
- upperBounds []float64
- labelPairs []*dto.LabelPair
- exemplars []atomic.Value // One more than buckets (to include +Inf), each a *dto.Exemplar.
- nativeHistogramSchema int32 // The initial schema. Set to math.MinInt32 if no sparse buckets are used.
- nativeHistogramZeroThreshold float64 // The initial zero threshold.
- nativeHistogramMaxZeroThreshold float64
- nativeHistogramMaxBuckets uint32
- nativeHistogramMinResetDuration time.Duration
- // lastResetTime is protected by mtx. It is also used as created timestamp.
- lastResetTime time.Time
- // resetScheduled is protected by mtx. It is true if a reset is
- // scheduled for a later time (when nativeHistogramMinResetDuration has
- // passed).
- resetScheduled bool
- nativeExemplars nativeExemplars
-
- // now is for testing purposes, by default it's time.Now.
- now func() time.Time
-
- // afterFunc is for testing purposes, by default it's time.AfterFunc.
- afterFunc func(time.Duration, func()) *time.Timer
-}
-
-func (h *histogram) Desc() *Desc {
- return h.desc
-}
-
-func (h *histogram) Observe(v float64) {
- 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) {
- i := h.findBucket(v)
- h.observe(v, i)
- h.updateExemplar(v, i, e)
-}
-
-func (h *histogram) Write(out *dto.Metric) error {
- // For simplicity, we protect this whole method by a mutex. It is not in
- // the hot path, i.e. Observe is called much more often than Write. The
- // complication of making Write lock-free isn't worth it, if possible at
- // all.
- h.mtx.Lock()
- defer h.mtx.Unlock()
-
- // Adding 1<<63 switches the hot index (from 0 to 1 or from 1 to 0)
- // without touching the count bits. See the struct comments for a full
- // description of the algorithm.
- n := atomic.AddUint64(&h.countAndHotIdx, 1<<63)
- // count is contained unchanged in the lower 63 bits.
- count := n & ((1 << 63) - 1)
- // The most significant bit tells us which counts is hot. The complement
- // is thus the cold one.
- hotCounts := h.counts[n>>63]
- coldCounts := h.counts[(^n)>>63]
-
- waitForCooldown(count, coldCounts)
-
- his := &dto.Histogram{
- Bucket: make([]*dto.Bucket, len(h.upperBounds)),
- SampleCount: proto.Uint64(count),
- SampleSum: proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.sumBits))),
- CreatedTimestamp: timestamppb.New(h.lastResetTime),
- }
- out.Histogram = his
- out.Label = h.labelPairs
-
- var cumCount uint64
- for i, upperBound := range h.upperBounds {
- cumCount += atomic.LoadUint64(&coldCounts.buckets[i])
- his.Bucket[i] = &dto.Bucket{
- CumulativeCount: proto.Uint64(cumCount),
- UpperBound: proto.Float64(upperBound),
- }
- if e := h.exemplars[i].Load(); e != nil {
- his.Bucket[i].Exemplar = e.(*dto.Exemplar)
- }
- }
- // If there is an exemplar for the +Inf bucket, we have to add that bucket explicitly.
- if e := h.exemplars[len(h.upperBounds)].Load(); e != nil {
- b := &dto.Bucket{
- CumulativeCount: proto.Uint64(count),
- UpperBound: proto.Float64(math.Inf(1)),
- Exemplar: e.(*dto.Exemplar),
- }
- his.Bucket = append(his.Bucket, b)
- }
- if h.nativeHistogramSchema > math.MinInt32 {
- his.ZeroThreshold = proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.nativeHistogramZeroThresholdBits)))
- his.Schema = proto.Int32(atomic.LoadInt32(&coldCounts.nativeHistogramSchema))
- zeroBucket := atomic.LoadUint64(&coldCounts.nativeHistogramZeroBucket)
-
- defer func() {
- coldCounts.nativeHistogramBucketsPositive.Range(addAndReset(&hotCounts.nativeHistogramBucketsPositive, &hotCounts.nativeHistogramBucketsNumber))
- coldCounts.nativeHistogramBucketsNegative.Range(addAndReset(&hotCounts.nativeHistogramBucketsNegative, &hotCounts.nativeHistogramBucketsNumber))
- }()
-
- his.ZeroCount = proto.Uint64(zeroBucket)
- his.NegativeSpan, his.NegativeDelta = makeBuckets(&coldCounts.nativeHistogramBucketsNegative)
- his.PositiveSpan, his.PositiveDelta = makeBuckets(&coldCounts.nativeHistogramBucketsPositive)
-
- // Add a no-op span to a histogram without observations and with
- // a zero threshold of zero. Otherwise, a native histogram would
- // look like a classic histogram to scrapers.
- if *his.ZeroThreshold == 0 && *his.ZeroCount == 0 && len(his.PositiveSpan) == 0 && len(his.NegativeSpan) == 0 {
- his.PositiveSpan = []*dto.BucketSpan{{
- Offset: proto.Int32(0),
- Length: proto.Uint32(0),
- }}
- }
-
- if h.nativeExemplars.isEnabled() {
- h.nativeExemplars.Lock()
- his.Exemplars = append(his.Exemplars, h.nativeExemplars.exemplars...)
- h.nativeExemplars.Unlock()
- }
-
- }
- addAndResetCounts(hotCounts, coldCounts)
- return nil
-}
-
-// findBucket returns the index of the bucket for the provided value, or
-// len(h.upperBounds) for the +Inf bucket.
-func (h *histogram) findBucket(v float64) int {
- // TODO(beorn7): For small numbers of buckets (<30), a linear search is
- // slightly faster than the binary search. If we really care, we could
- // switch from one search strategy to the other depending on the number
- // of buckets.
- //
- // Microbenchmarks (BenchmarkHistogramNoLabels):
- // 11 buckets: 38.3 ns/op linear - binary 48.7 ns/op
- // 100 buckets: 78.1 ns/op linear - binary 54.9 ns/op
- // 300 buckets: 154 ns/op linear - binary 61.6 ns/op
- return sort.SearchFloat64s(h.upperBounds, v)
-}
-
-// observe is the implementation for Observe without the findBucket part.
-func (h *histogram) observe(v float64, bucket int) {
- // Do not add to sparse buckets for NaN observations.
- doSparse := h.nativeHistogramSchema > math.MinInt32 && !math.IsNaN(v)
- // We increment h.countAndHotIdx so that the counter in the lower
- // 63 bits gets incremented. At the same time, we get the new value
- // back, which we can use to find the currently-hot counts.
- n := atomic.AddUint64(&h.countAndHotIdx, 1)
- hotCounts := h.counts[n>>63]
- hotCounts.observe(v, bucket, doSparse)
- if doSparse {
- h.limitBuckets(hotCounts, v, bucket)
- }
-}
-
-// limitBuckets applies a strategy to limit the number of populated sparse
-// buckets. It's generally best effort, and there are situations where the
-// number can go higher (if even the lowest resolution isn't enough to reduce
-// the number sufficiently, or if the provided counts aren't fully updated yet
-// by a concurrently happening Write call).
-func (h *histogram) limitBuckets(counts *histogramCounts, value float64, bucket int) {
- if h.nativeHistogramMaxBuckets == 0 {
- return // No limit configured.
- }
- if h.nativeHistogramMaxBuckets >= atomic.LoadUint32(&counts.nativeHistogramBucketsNumber) {
- return // Bucket limit not exceeded yet.
- }
-
- h.mtx.Lock()
- defer h.mtx.Unlock()
-
- // The hot counts might have been swapped just before we acquired the
- // lock. Re-fetch the hot counts first...
- n := atomic.LoadUint64(&h.countAndHotIdx)
- hotIdx := n >> 63
- coldIdx := (^n) >> 63
- hotCounts := h.counts[hotIdx]
- coldCounts := h.counts[coldIdx]
- // ...and then check again if we really have to reduce the bucket count.
- if h.nativeHistogramMaxBuckets >= atomic.LoadUint32(&hotCounts.nativeHistogramBucketsNumber) {
- return // Bucket limit not exceeded after all.
- }
- // Try the various strategies in order.
- if h.maybeReset(hotCounts, coldCounts, coldIdx, value, bucket) {
- return
- }
- // One of the other strategies will happen. To undo what they will do as
- // soon as enough time has passed to satisfy
- // h.nativeHistogramMinResetDuration, schedule a reset at the right time
- // if we haven't done so already.
- if h.nativeHistogramMinResetDuration > 0 && !h.resetScheduled {
- h.resetScheduled = true
- h.afterFunc(h.nativeHistogramMinResetDuration-h.now().Sub(h.lastResetTime), h.reset)
- }
-
- if h.maybeWidenZeroBucket(hotCounts, coldCounts) {
- return
- }
- h.doubleBucketWidth(hotCounts, coldCounts)
-}
-
-// maybeReset resets the whole histogram if at least
-// h.nativeHistogramMinResetDuration has been passed. It returns true if the
-// histogram has been reset. The caller must have locked h.mtx.
-func (h *histogram) maybeReset(
- hot, cold *histogramCounts, coldIdx uint64, value float64, bucket int,
-) bool {
- // We are using the possibly mocked h.now() rather than
- // time.Since(h.lastResetTime) to enable testing.
- if h.nativeHistogramMinResetDuration == 0 || // No reset configured.
- h.resetScheduled || // Do not interefere if a reset is already scheduled.
- h.now().Sub(h.lastResetTime) < h.nativeHistogramMinResetDuration {
- return false
- }
- // Completely reset coldCounts.
- h.resetCounts(cold)
- // Repeat the latest observation to not lose it completely.
- cold.observe(value, bucket, true)
- // Make coldCounts the new hot counts while resetting countAndHotIdx.
- n := atomic.SwapUint64(&h.countAndHotIdx, (coldIdx<<63)+1)
- count := n & ((1 << 63) - 1)
- waitForCooldown(count, hot)
- // Finally, reset the formerly hot counts, too.
- h.resetCounts(hot)
- h.lastResetTime = h.now()
- return true
-}
-
-// reset resets the whole histogram. It locks h.mtx itself, i.e. it has to be
-// called without having locked h.mtx.
-func (h *histogram) reset() {
- h.mtx.Lock()
- defer h.mtx.Unlock()
-
- n := atomic.LoadUint64(&h.countAndHotIdx)
- hotIdx := n >> 63
- coldIdx := (^n) >> 63
- hot := h.counts[hotIdx]
- cold := h.counts[coldIdx]
- // Completely reset coldCounts.
- h.resetCounts(cold)
- // Make coldCounts the new hot counts while resetting countAndHotIdx.
- n = atomic.SwapUint64(&h.countAndHotIdx, coldIdx<<63)
- count := n & ((1 << 63) - 1)
- waitForCooldown(count, hot)
- // Finally, reset the formerly hot counts, too.
- h.resetCounts(hot)
- h.lastResetTime = h.now()
- h.resetScheduled = false
-}
-
-// maybeWidenZeroBucket widens the zero bucket until it includes the existing
-// buckets closest to the zero bucket (which could be two, if an equidistant
-// negative and a positive bucket exists, but usually it's only one bucket to be
-// merged into the new wider zero bucket). h.nativeHistogramMaxZeroThreshold
-// limits how far the zero bucket can be extended, and if that's not enough to
-// include an existing bucket, the method returns false. The caller must have
-// locked h.mtx.
-func (h *histogram) maybeWidenZeroBucket(hot, cold *histogramCounts) bool {
- currentZeroThreshold := math.Float64frombits(atomic.LoadUint64(&hot.nativeHistogramZeroThresholdBits))
- if currentZeroThreshold >= h.nativeHistogramMaxZeroThreshold {
- return false
- }
- // Find the key of the bucket closest to zero.
- smallestKey := findSmallestKey(&hot.nativeHistogramBucketsPositive)
- smallestNegativeKey := findSmallestKey(&hot.nativeHistogramBucketsNegative)
- if smallestNegativeKey < smallestKey {
- smallestKey = smallestNegativeKey
- }
- if smallestKey == math.MaxInt32 {
- return false
- }
- newZeroThreshold := getLe(smallestKey, atomic.LoadInt32(&hot.nativeHistogramSchema))
- if newZeroThreshold > h.nativeHistogramMaxZeroThreshold {
- return false // New threshold would exceed the max threshold.
- }
- atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold))
- // Remove applicable buckets.
- if _, loaded := cold.nativeHistogramBucketsNegative.LoadAndDelete(smallestKey); loaded {
- atomicDecUint32(&cold.nativeHistogramBucketsNumber)
- }
- if _, loaded := cold.nativeHistogramBucketsPositive.LoadAndDelete(smallestKey); loaded {
- atomicDecUint32(&cold.nativeHistogramBucketsNumber)
- }
- // Make cold counts the new hot counts.
- n := atomic.AddUint64(&h.countAndHotIdx, 1<<63)
- count := n & ((1 << 63) - 1)
- // Swap the pointer names to represent the new roles and make
- // the rest less confusing.
- hot, cold = cold, hot
- waitForCooldown(count, cold)
- // Add all the now cold counts to the new hot counts...
- addAndResetCounts(hot, cold)
- // ...adjust the new zero threshold in the cold counts, too...
- atomic.StoreUint64(&cold.nativeHistogramZeroThresholdBits, math.Float64bits(newZeroThreshold))
- // ...and then merge the newly deleted buckets into the wider zero
- // bucket.
- mergeAndDeleteOrAddAndReset := func(hotBuckets, coldBuckets *sync.Map) func(k, v interface{}) bool {
- return func(k, v interface{}) bool {
- key := k.(int)
- bucket := v.(*int64)
- if key == smallestKey {
- // Merge into hot zero bucket...
- atomic.AddUint64(&hot.nativeHistogramZeroBucket, uint64(atomic.LoadInt64(bucket)))
- // ...and delete from cold counts.
- coldBuckets.Delete(key)
- atomicDecUint32(&cold.nativeHistogramBucketsNumber)
- } else {
- // Add to corresponding hot bucket...
- if addToBucket(hotBuckets, key, atomic.LoadInt64(bucket)) {
- atomic.AddUint32(&hot.nativeHistogramBucketsNumber, 1)
- }
- // ...and reset cold bucket.
- atomic.StoreInt64(bucket, 0)
- }
- return true
- }
- }
-
- cold.nativeHistogramBucketsPositive.Range(mergeAndDeleteOrAddAndReset(&hot.nativeHistogramBucketsPositive, &cold.nativeHistogramBucketsPositive))
- cold.nativeHistogramBucketsNegative.Range(mergeAndDeleteOrAddAndReset(&hot.nativeHistogramBucketsNegative, &cold.nativeHistogramBucketsNegative))
- return true
-}
-
-// doubleBucketWidth doubles the bucket width (by decrementing the schema
-// number). Note that very sparse buckets could lead to a low reduction of the
-// bucket count (or even no reduction at all). The method does nothing if the
-// schema is already -4.
-func (h *histogram) doubleBucketWidth(hot, cold *histogramCounts) {
- coldSchema := atomic.LoadInt32(&cold.nativeHistogramSchema)
- if coldSchema == -4 {
- return // Already at lowest resolution.
- }
- coldSchema--
- atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema)
- // Play it simple and just delete all cold buckets.
- atomic.StoreUint32(&cold.nativeHistogramBucketsNumber, 0)
- deleteSyncMap(&cold.nativeHistogramBucketsNegative)
- deleteSyncMap(&cold.nativeHistogramBucketsPositive)
- // Make coldCounts the new hot counts.
- n := atomic.AddUint64(&h.countAndHotIdx, 1<<63)
- count := n & ((1 << 63) - 1)
- // Swap the pointer names to represent the new roles and make
- // the rest less confusing.
- hot, cold = cold, hot
- waitForCooldown(count, cold)
- // Add all the now cold counts to the new hot counts...
- addAndResetCounts(hot, cold)
- // ...adjust the schema in the cold counts, too...
- atomic.StoreInt32(&cold.nativeHistogramSchema, coldSchema)
- // ...and then merge the cold buckets into the wider hot buckets.
- merge := func(hotBuckets *sync.Map) func(k, v interface{}) bool {
- return func(k, v interface{}) bool {
- key := k.(int)
- bucket := v.(*int64)
- // Adjust key to match the bucket to merge into.
- if key > 0 {
- key++
- }
- key /= 2
- // Add to corresponding hot bucket.
- if addToBucket(hotBuckets, key, atomic.LoadInt64(bucket)) {
- atomic.AddUint32(&hot.nativeHistogramBucketsNumber, 1)
- }
- return true
- }
- }
-
- cold.nativeHistogramBucketsPositive.Range(merge(&hot.nativeHistogramBucketsPositive))
- cold.nativeHistogramBucketsNegative.Range(merge(&hot.nativeHistogramBucketsNegative))
- // Play it simple again and just delete all cold buckets.
- atomic.StoreUint32(&cold.nativeHistogramBucketsNumber, 0)
- deleteSyncMap(&cold.nativeHistogramBucketsNegative)
- deleteSyncMap(&cold.nativeHistogramBucketsPositive)
-}
-
-func (h *histogram) resetCounts(counts *histogramCounts) {
- atomic.StoreUint64(&counts.sumBits, 0)
- atomic.StoreUint64(&counts.count, 0)
- atomic.StoreUint64(&counts.nativeHistogramZeroBucket, 0)
- atomic.StoreUint64(&counts.nativeHistogramZeroThresholdBits, math.Float64bits(h.nativeHistogramZeroThreshold))
- atomic.StoreInt32(&counts.nativeHistogramSchema, h.nativeHistogramSchema)
- atomic.StoreUint32(&counts.nativeHistogramBucketsNumber, 0)
- for i := range h.upperBounds {
- atomic.StoreUint64(&counts.buckets[i], 0)
- }
- deleteSyncMap(&counts.nativeHistogramBucketsNegative)
- deleteSyncMap(&counts.nativeHistogramBucketsPositive)
-}
-
-// updateExemplar replaces the exemplar for the provided classic bucket.
-// 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) {
- if l == nil {
- return
- }
- e, err := newExemplar(v, h.now(), l)
- if err != nil {
- panic(err)
- }
- 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
-// same Desc, but have different values for their variable labels. This is used
-// if you want to count the same thing partitioned by various dimensions
-// (e.g. HTTP request latencies, partitioned by status code and method). Create
-// instances with NewHistogramVec.
-type HistogramVec struct {
- *MetricVec
-}
-
-// NewHistogramVec creates a new HistogramVec based on the provided HistogramOpts and
-// partitioned by the given label names.
-func NewHistogramVec(opts HistogramOpts, labelNames []string) *HistogramVec {
- return V2.NewHistogramVec(HistogramVecOpts{
- HistogramOpts: opts,
- VariableLabels: UnconstrainedLabels(labelNames),
- })
-}
-
-// NewHistogramVec creates a new HistogramVec based on the provided HistogramVecOpts.
-func (v2) NewHistogramVec(opts HistogramVecOpts) *HistogramVec {
- desc := V2.NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- opts.VariableLabels,
- opts.ConstLabels,
- )
- return &HistogramVec{
- MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
- return newHistogram(desc, opts.HistogramOpts, lvs...)
- }),
- }
-}
-
-// GetMetricWithLabelValues returns the Histogram for the given slice of label
-// values (same order as the variable labels in Desc). If that combination of
-// label values is accessed for the first time, a new Histogram is created.
-//
-// It is possible to call this method without using the returned Histogram to only
-// create the new Histogram but leave it at its starting value, a Histogram without
-// any observations.
-//
-// Keeping the Histogram for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// Delete can be used to delete the Histogram from the HistogramVec. In that case, the
-// Histogram will still exist, but it will not be exported anymore, even if a
-// Histogram with the same label values is created later. See also the CounterVec
-// example.
-//
-// An error is returned if the number of label values is not the same as the
-// number of variable labels in Desc (minus any curried labels).
-//
-// Note that for more than one label value, this method is prone to mistakes
-// caused by an incorrect order of arguments. Consider GetMetricWith(Labels) as
-// an alternative to avoid that type of mistake. For higher label numbers, the
-// latter has a much more readable (albeit more verbose) syntax, but it comes
-// with a performance overhead (for creating and processing the Labels map).
-// See also the GaugeVec example.
-func (v *HistogramVec) GetMetricWithLabelValues(lvs ...string) (Observer, error) {
- metric, err := v.MetricVec.GetMetricWithLabelValues(lvs...)
- if metric != nil {
- return metric.(Observer), err
- }
- return nil, err
-}
-
-// GetMetricWith returns the Histogram for the given Labels map (the label names
-// must match those of the variable labels in Desc). If that label map is
-// accessed for the first time, a new Histogram is created. Implications of
-// creating a Histogram without using it and keeping the Histogram for later use
-// are the same as for GetMetricWithLabelValues.
-//
-// An error is returned if the number and names of the Labels are inconsistent
-// with those of the variable labels in Desc (minus any curried labels).
-//
-// This method is used for the same purpose as
-// GetMetricWithLabelValues(...string). See there for pros and cons of the two
-// methods.
-func (v *HistogramVec) GetMetricWith(labels Labels) (Observer, error) {
- metric, err := v.MetricVec.GetMetricWith(labels)
- if metric != nil {
- return metric.(Observer), err
- }
- return nil, err
-}
-
-// WithLabelValues works as GetMetricWithLabelValues, but panics where
-// GetMetricWithLabelValues would have returned an error. Not returning an
-// error allows shortcuts like
-//
-// myVec.WithLabelValues("404", "GET").Observe(42.21)
-func (v *HistogramVec) WithLabelValues(lvs ...string) Observer {
- h, err := v.GetMetricWithLabelValues(lvs...)
- if err != nil {
- panic(err)
- }
- return h
-}
-
-// With works as GetMetricWith but panics where GetMetricWithLabels would have
-// returned an error. Not returning an error allows shortcuts like
-//
-// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21)
-func (v *HistogramVec) With(labels Labels) Observer {
- h, err := v.GetMetricWith(labels)
- if err != nil {
- panic(err)
- }
- return h
-}
-
-// CurryWith returns a vector curried with the provided labels, i.e. the
-// returned vector has those labels pre-set for all labeled operations performed
-// on it. The cardinality of the curried vector is reduced accordingly. The
-// order of the remaining labels stays the same (just with the curried labels
-// taken out of the sequence – which is relevant for the
-// (GetMetric)WithLabelValues methods). It is possible to curry a curried
-// vector, but only with labels not yet used for currying before.
-//
-// The metrics contained in the HistogramVec are shared between the curried and
-// uncurried vectors. They are just accessed differently. Curried and uncurried
-// vectors behave identically in terms of collection. Only one must be
-// registered with a given registry (usually the uncurried version). The Reset
-// method deletes all metrics, even if called on a curried vector.
-func (v *HistogramVec) CurryWith(labels Labels) (ObserverVec, error) {
- vec, err := v.MetricVec.CurryWith(labels)
- if vec != nil {
- return &HistogramVec{vec}, err
- }
- return nil, err
-}
-
-// MustCurryWith works as CurryWith but panics where CurryWith would have
-// returned an error.
-func (v *HistogramVec) MustCurryWith(labels Labels) ObserverVec {
- vec, err := v.CurryWith(labels)
- if err != nil {
- panic(err)
- }
- return vec
-}
-
-type constHistogram struct {
- desc *Desc
- count uint64
- sum float64
- buckets map[float64]uint64
- labelPairs []*dto.LabelPair
- createdTs *timestamppb.Timestamp
-}
-
-func (h *constHistogram) Desc() *Desc {
- return h.desc
-}
-
-func (h *constHistogram) Write(out *dto.Metric) error {
- his := &dto.Histogram{
- CreatedTimestamp: h.createdTs,
- }
-
- buckets := make([]*dto.Bucket, 0, len(h.buckets))
-
- his.SampleCount = proto.Uint64(h.count)
- his.SampleSum = proto.Float64(h.sum)
- for upperBound, count := range h.buckets {
- buckets = append(buckets, &dto.Bucket{
- CumulativeCount: proto.Uint64(count),
- UpperBound: proto.Float64(upperBound),
- })
- }
-
- if len(buckets) > 0 {
- sort.Sort(buckSort(buckets))
- }
- his.Bucket = buckets
-
- out.Histogram = his
- out.Label = h.labelPairs
-
- return nil
-}
-
-// NewConstHistogram returns a metric representing a Prometheus histogram with
-// fixed values for the count, sum, and bucket counts. As those parameters
-// cannot be changed, the returned value does not implement the Histogram
-// interface (but only the Metric interface). Users of this package will not
-// have much use for it in regular operations. However, when implementing custom
-// Collectors, it is useful as a throw-away metric that is generated on the fly
-// to send it to Prometheus in the Collect method.
-//
-// buckets is a map of upper bounds to cumulative counts, excluding the +Inf
-// bucket. The +Inf bucket is implicit, and its value is equal to the provided count.
-//
-// NewConstHistogram returns an error if the length of labelValues is not
-// consistent with the variable labels in Desc or if Desc is invalid.
-func NewConstHistogram(
- desc *Desc,
- count uint64,
- sum float64,
- buckets map[float64]uint64,
- 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),
- }, nil
-}
-
-// MustNewConstHistogram is a version of NewConstHistogram that panics where
-// NewConstHistogram would have returned an error.
-func MustNewConstHistogram(
- desc *Desc,
- count uint64,
- sum float64,
- buckets map[float64]uint64,
- labelValues ...string,
-) Metric {
- m, err := NewConstHistogram(desc, count, sum, buckets, labelValues...)
- if err != nil {
- panic(err)
- }
- 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
-
-func (s buckSort) Len() int {
- return len(s)
-}
-
-func (s buckSort) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
-}
-
-func (s buckSort) Less(i, j int) bool {
- return s[i].GetUpperBound() < s[j].GetUpperBound()
-}
-
-// pickSchema returns the largest number n between -4 and 8 such that
-// 2^(2^-n) is less or equal the provided bucketFactor.
-//
-// Special cases:
-// - bucketFactor <= 1: panics.
-// - bucketFactor < 2^(2^-8) (but > 1): still returns 8.
-func pickSchema(bucketFactor float64) int32 {
- if bucketFactor <= 1 {
- panic(fmt.Errorf("bucketFactor %f is <=1", bucketFactor))
- }
- floor := math.Floor(math.Log2(math.Log2(bucketFactor)))
- switch {
- case floor <= -8:
- return 8
- case floor >= 4:
- return -4
- default:
- return -int32(floor)
- }
-}
-
-func makeBuckets(buckets *sync.Map) ([]*dto.BucketSpan, []int64) {
- var ii []int
- buckets.Range(func(k, v interface{}) bool {
- ii = append(ii, k.(int))
- return true
- })
- sort.Ints(ii)
-
- if len(ii) == 0 {
- return nil, nil
- }
-
- var (
- spans []*dto.BucketSpan
- deltas []int64
- prevCount int64
- nextI int
- )
-
- appendDelta := func(count int64) {
- *spans[len(spans)-1].Length++
- deltas = append(deltas, count-prevCount)
- prevCount = count
- }
-
- for n, i := range ii {
- v, _ := buckets.Load(i)
- count := atomic.LoadInt64(v.(*int64))
- // Multiple spans with only small gaps in between are probably
- // encoded more efficiently as one larger span with a few empty
- // buckets. Needs some research to find the sweet spot. For now,
- // we assume that gaps of one or two buckets should not create
- // a new span.
- iDelta := int32(i - nextI)
- if n == 0 || iDelta > 2 {
- // We have to create a new span, either because we are
- // at the very beginning, or because we have found a gap
- // of more than two buckets.
- spans = append(spans, &dto.BucketSpan{
- Offset: proto.Int32(iDelta),
- Length: proto.Uint32(0),
- })
- } else {
- // We have found a small gap (or no gap at all).
- // Insert empty buckets as needed.
- for j := int32(0); j < iDelta; j++ {
- appendDelta(0)
- }
- }
- appendDelta(count)
- nextI = i + 1
- }
- return spans, deltas
-}
-
-// addToBucket increments the sparse bucket at key by the provided amount. It
-// returns true if a new sparse bucket had to be created for that.
-func addToBucket(buckets *sync.Map, key int, increment int64) bool {
- if existingBucket, ok := buckets.Load(key); ok {
- // Fast path without allocation.
- atomic.AddInt64(existingBucket.(*int64), increment)
- return false
- }
- // Bucket doesn't exist yet. Slow path allocating new counter.
- newBucket := increment // TODO(beorn7): Check if this is sufficient to not let increment escape.
- if actualBucket, loaded := buckets.LoadOrStore(key, &newBucket); loaded {
- // The bucket was created concurrently in another goroutine.
- // Have to increment after all.
- atomic.AddInt64(actualBucket.(*int64), increment)
- return false
- }
- return true
-}
-
-// addAndReset returns a function to be used with sync.Map.Range of spare
-// buckets in coldCounts. It increments the buckets in the provided hotBuckets
-// according to the buckets ranged through. It then resets all buckets ranged
-// through to 0 (but leaves them in place so that they don't need to get
-// recreated on the next scrape).
-func addAndReset(hotBuckets *sync.Map, bucketNumber *uint32) func(k, v interface{}) bool {
- return func(k, v interface{}) bool {
- bucket := v.(*int64)
- if addToBucket(hotBuckets, k.(int), atomic.LoadInt64(bucket)) {
- atomic.AddUint32(bucketNumber, 1)
- }
- atomic.StoreInt64(bucket, 0)
- return true
- }
-}
-
-func deleteSyncMap(m *sync.Map) {
- m.Range(func(k, v interface{}) bool {
- m.Delete(k)
- return true
- })
-}
-
-func findSmallestKey(m *sync.Map) int {
- result := math.MaxInt32
- m.Range(func(k, v interface{}) bool {
- key := k.(int)
- if key < result {
- result = key
- }
- return true
- })
- return result
-}
-
-func getLe(key int, schema int32) float64 {
- // Here a bit of context about the behavior for the last bucket counting
- // regular numbers (called simply "last bucket" below) and the bucket
- // counting observations of ±Inf (called "inf bucket" below, with a key
- // one higher than that of the "last bucket"):
- //
- // If we apply the usual formula to the last bucket, its upper bound
- // would be calculated as +Inf. The reason is that the max possible
- // regular float64 number (math.MaxFloat64) doesn't coincide with one of
- // the calculated bucket boundaries. So the calculated boundary has to
- // be larger than math.MaxFloat64, and the only float64 larger than
- // math.MaxFloat64 is +Inf. However, we want to count actual
- // observations of ±Inf in the inf bucket. Therefore, we have to treat
- // the upper bound of the last bucket specially and set it to
- // math.MaxFloat64. (The upper bound of the inf bucket, with its key
- // being one higher than that of the last bucket, naturally comes out as
- // +Inf by the usual formula. So that's fine.)
- //
- // math.MaxFloat64 has a frac of 0.9999999999999999 and an exp of
- // 1024. If there were a float64 number following math.MaxFloat64, it
- // would have a frac of 1.0 and an exp of 1024, or equivalently a frac
- // of 0.5 and an exp of 1025. However, since frac must be smaller than
- // 1, and exp must be smaller than 1025, either representation overflows
- // a float64. (Which, in turn, is the reason that math.MaxFloat64 is the
- // largest possible float64. Q.E.D.) However, the formula for
- // calculating the upper bound from the idx and schema of the last
- // bucket results in precisely that. It is either frac=1.0 & exp=1024
- // (for schema < 0) or frac=0.5 & exp=1025 (for schema >=0). (This is,
- // by the way, a power of two where the exponent itself is a power of
- // two, 2¹⁰ in fact, which coinicides with a bucket boundary in all
- // schemas.) So these are the special cases we have to catch below.
- if schema < 0 {
- exp := key << -schema
- if exp == 1024 {
- // This is the last bucket before the overflow bucket
- // (for ±Inf observations). Return math.MaxFloat64 as
- // explained above.
- return math.MaxFloat64
- }
- return math.Ldexp(1, exp)
- }
-
- fracIdx := key & ((1 << schema) - 1)
- frac := nativeHistogramBounds[schema][fracIdx]
- exp := (key >> schema) + 1
- if frac == 0.5 && exp == 1025 {
- // This is the last bucket before the overflow bucket (for ±Inf
- // observations). Return math.MaxFloat64 as explained above.
- return math.MaxFloat64
- }
- return math.Ldexp(frac, exp)
-}
-
-// waitForCooldown returns after the count field in the provided histogramCounts
-// has reached the provided count value.
-func waitForCooldown(count uint64, counts *histogramCounts) {
- for count != atomic.LoadUint64(&counts.count) {
- runtime.Gosched() // Let observations get work done.
- }
-}
-
-// atomicAddFloat adds the provided float atomically to another float
-// represented by the bit pattern the bits pointer is pointing to.
-func atomicAddFloat(bits *uint64, v float64) {
- for {
- loadedBits := atomic.LoadUint64(bits)
- newBits := math.Float64bits(math.Float64frombits(loadedBits) + v)
- if atomic.CompareAndSwapUint64(bits, loadedBits, newBits) {
- break
- }
- }
-}
-
-// atomicDecUint32 atomically decrements the uint32 p points to. See
-// https://pkg.go.dev/sync/atomic#AddUint32 to understand how this is done.
-func atomicDecUint32(p *uint32) {
- atomic.AddUint32(p, ^uint32(0))
-}
-
-// addAndResetCounts adds certain fields (count, sum, conventional buckets, zero
-// bucket) from the cold counts to the corresponding fields in the hot
-// counts. Those fields are then reset to 0 in the cold counts.
-func addAndResetCounts(hot, cold *histogramCounts) {
- atomic.AddUint64(&hot.count, atomic.LoadUint64(&cold.count))
- atomic.StoreUint64(&cold.count, 0)
- coldSum := math.Float64frombits(atomic.LoadUint64(&cold.sumBits))
- atomicAddFloat(&hot.sumBits, coldSum)
- atomic.StoreUint64(&cold.sumBits, 0)
- for i := range hot.buckets {
- atomic.AddUint64(&hot.buckets[i], atomic.LoadUint64(&cold.buckets[i]))
- atomic.StoreUint64(&cold.buckets[i], 0)
- }
- atomic.AddUint64(&hot.nativeHistogramZeroBucket, atomic.LoadUint64(&cold.nativeHistogramZeroBucket))
- atomic.StoreUint64(&cold.nativeHistogramZeroBucket, 0)
-}
-
-type nativeExemplars struct {
- sync.Mutex
-
- // Time-to-live for exemplars, it is set to -1 if exemplars are disabled, that is NativeHistogramMaxExemplars is below 0.
- // The ttl is used on insertion to remove an exemplar that is older than ttl, if present.
- ttl time.Duration
-
- exemplars []*dto.Exemplar
-}
-
-func (n *nativeExemplars) isEnabled() bool {
- return n.ttl != -1
-}
-
-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
- ttl = -1
- }
-
- return nativeExemplars{
- ttl: ttl,
- exemplars: make([]*dto.Exemplar, 0, maxCount),
- }
-}
-
-func (n *nativeExemplars) addExemplar(e *dto.Exemplar) {
- if !n.isEnabled() {
- return
- }
-
- n.Lock()
- defer n.Unlock()
-
- // 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) {
- var nIdx int
- 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
- }
-
- if len(n.exemplars) == 1 {
- // When the number of exemplars is 1, then
- // replace the existing exemplar with the new exemplar.
- n.exemplars[0] = e
- return
- }
- // From this point on, the number of exemplars is greater than 1.
-
- // When the number of exemplars exceeds the limit, remove one exemplar.
- var (
- ot = time.Time{} // Oldest timestamp seen. Initial value doesn't matter as we replace it due to otIdx == -1 in the loop.
- otIdx = -1 // Index of the exemplar with the oldest timestamp.
-
- md = -1.0 // Logarithm of the delta of the closest pair of exemplars.
-
- // The insertion point of the new exemplar in the exemplars slice after insertion.
- // This is calculated purely based on the order of the exemplars by value.
- // nIdx == len(n.exemplars) means the new exemplar is to be inserted after the end.
- nIdx = -1
-
- // rIdx is ultimately the index for the exemplar that we are replacing with the new exemplar.
- // The aim is to keep a good spread of exemplars by value and not let them bunch up too much.
- // It is calculated in 3 steps:
- // 1. First we set rIdx to the index of the older exemplar within the closest pair by value.
- // That is the following will be true (on log scale):
- // either the exemplar pair on index (rIdx-1, rIdx) or (rIdx, rIdx+1) will have
- // the closest values to each other from all pairs.
- // For example, suppose the values are distributed like this:
- // |-----------x-------------x----------------x----x-----|
- // ^--rIdx as this is older.
- // Or like this:
- // |-----------x-------------x----------------x----x-----|
- // ^--rIdx as this is older.
- // 2. If there is an exemplar that expired, then we simple reset rIdx to that index.
- // 3. We check if by inserting the new exemplar we would create a closer pair at
- // (nIdx-1, nIdx) or (nIdx, nIdx+1) and set rIdx to nIdx-1 or nIdx accordingly to
- // keep the spread of exemplars by value; otherwise we keep rIdx as it is.
- rIdx = -1
- 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 nIdx == -1 && *e.Value <= *exemplar.Value {
- 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 {
- // The closest exemplar pair is at index: i-1, i.
- // Choose the exemplar with the older timestamp for replacement.
- md = diff
- if n.exemplars[i].Timestamp.AsTime().Before(n.exemplars[i-1].Timestamp.AsTime()) {
- rIdx = i
- } else {
- rIdx = 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)
- }
- // Here, we have the following relationships:
- // n.exemplars[nIdx-1].Value < e.Value (if nIdx > 0)
- // e.Value <= n.exemplars[nIdx].Value (if nIdx < len(n.exemplars))
-
- if otIdx != -1 && e.Timestamp.AsTime().Sub(ot) > n.ttl {
- // If the oldest exemplar has expired, then replace it with the new exemplar.
- 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 {
- // The value we are about to insert is closer to the previous exemplar at the insertion point than what we calculated before in rIdx.
- // v--rIdx
- // |-----------x-n-----------x----------------x----x-----|
- // nIdx-1--^ ^--new exemplar value
- // Do not make the spread worse, replace nIdx-1 and not rIdx.
- md = diff
- rIdx = nIdx - 1
- }
- }
- if nIdx < len(n.exemplars) {
- diff := math.Abs(math.Log(n.exemplars[nIdx].GetValue()) - elog)
- if diff < md {
- // The value we are about to insert is closer to the next exemplar at the insertion point than what we calculated before in rIdx.
- // v--rIdx
- // |-----------x-----------n-x----------------x----x-----|
- // new exemplar value--^ ^--nIdx
- // Do not make the spread worse, replace nIdx-1 and not rIdx.
- rIdx = nIdx
- }
- }
- }
-
- // 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:]...)...)...)
- }
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go b/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go
deleted file mode 100644
index 1ed5abe..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) 2015 Björn Rabenstein
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-// The code in this package is copy/paste to avoid a dependency. Hence this file
-// carries the copyright of the original repo.
-// https://github.com/beorn7/floats
-package internal
-
-import (
- "math"
-)
-
-// minNormalFloat64 is the smallest positive normal value of type float64.
-var minNormalFloat64 = math.Float64frombits(0x0010000000000000)
-
-// AlmostEqualFloat64 returns true if a and b are equal within a relative error
-// of epsilon. See http://floating-point-gui.de/errors/comparison/ for the
-// details of the applied method.
-func AlmostEqualFloat64(a, b, epsilon float64) bool {
- if a == b {
- return true
- }
- absA := math.Abs(a)
- absB := math.Abs(b)
- diff := math.Abs(a - b)
- if a == 0 || b == 0 || absA+absB < minNormalFloat64 {
- return diff < epsilon*minNormalFloat64
- }
- return diff/math.Min(absA+absB, math.MaxFloat64) < epsilon
-}
-
-// AlmostEqualFloat64s is the slice form of AlmostEqualFloat64.
-func AlmostEqualFloat64s(a, b []float64, epsilon float64) bool {
- if len(a) != len(b) {
- return false
- }
- for i := range a {
- if !AlmostEqualFloat64(a[i], b[i], epsilon) {
- return false
- }
- }
- return true
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go b/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go
deleted file mode 100644
index a595a20..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/internal/difflib.go
+++ /dev/null
@@ -1,654 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-// It provides tools to compare sequences of strings and generate textual diffs.
-//
-// Maintaining `GetUnifiedDiffString` here because original repository
-// (https://github.com/pmezard/go-difflib) is no longer maintained.
-package internal
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strings"
-)
-
-func min(a, b int) int {
- if a < b {
- return a
- }
- return b
-}
-
-func max(a, b int) int {
- if a > b {
- return a
- }
- return b
-}
-
-func calculateRatio(matches, length int) float64 {
- if length > 0 {
- return 2.0 * float64(matches) / float64(length)
- }
- return 1.0
-}
-
-type Match struct {
- A int
- B int
- Size int
-}
-
-type OpCode struct {
- Tag byte
- I1 int
- I2 int
- J1 int
- J2 int
-}
-
-// SequenceMatcher compares sequence of strings. The basic
-// algorithm predates, and is a little fancier than, an algorithm
-// published in the late 1980's by Ratcliff and Obershelp under the
-// hyperbolic name "gestalt pattern matching". The basic idea is to find
-// the longest contiguous matching subsequence that contains no "junk"
-// elements (R-O doesn't address junk). The same idea is then applied
-// recursively to the pieces of the sequences to the left and to the right
-// of the matching subsequence. This does not yield minimal edit
-// sequences, but does tend to yield matches that "look right" to people.
-//
-// SequenceMatcher tries to compute a "human-friendly diff" between two
-// sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the
-// longest *contiguous* & junk-free matching subsequence. That's what
-// catches peoples' eyes. The Windows(tm) windiff has another interesting
-// notion, pairing up elements that appear uniquely in each sequence.
-// That, and the method here, appear to yield more intuitive difference
-// reports than does diff. This method appears to be the least vulnerable
-// to synching up on blocks of "junk lines", though (like blank lines in
-// ordinary text files, or maybe "
" lines in HTML files). That may be
-// because this is the only method of the 3 that has a *concept* of
-// "junk" .
-//
-// Timing: Basic R-O is cubic time worst case and quadratic time expected
-// case. SequenceMatcher is quadratic time for the worst case and has
-// expected-case behavior dependent in a complicated way on how many
-// elements the sequences have in common; best case time is linear.
-type SequenceMatcher struct {
- a []string
- b []string
- b2j map[string][]int
- IsJunk func(string) bool
- autoJunk bool
- bJunk map[string]struct{}
- matchingBlocks []Match
- fullBCount map[string]int
- bPopular map[string]struct{}
- opCodes []OpCode
-}
-
-func NewMatcher(a, b []string) *SequenceMatcher {
- m := SequenceMatcher{autoJunk: true}
- m.SetSeqs(a, b)
- return &m
-}
-
-func NewMatcherWithJunk(a, b []string, autoJunk bool,
- isJunk func(string) bool,
-) *SequenceMatcher {
- m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk}
- m.SetSeqs(a, b)
- return &m
-}
-
-// Set two sequences to be compared.
-func (m *SequenceMatcher) SetSeqs(a, b []string) {
- m.SetSeq1(a)
- m.SetSeq2(b)
-}
-
-// Set the first sequence to be compared. The second sequence to be compared is
-// not changed.
-//
-// SequenceMatcher computes and caches detailed information about the second
-// sequence, so if you want to compare one sequence S against many sequences,
-// use .SetSeq2(s) once and call .SetSeq1(x) repeatedly for each of the other
-// sequences.
-//
-// See also SetSeqs() and SetSeq2().
-func (m *SequenceMatcher) SetSeq1(a []string) {
- if &a == &m.a {
- return
- }
- m.a = a
- m.matchingBlocks = nil
- m.opCodes = nil
-}
-
-// Set the second sequence to be compared. The first sequence to be compared is
-// not changed.
-func (m *SequenceMatcher) SetSeq2(b []string) {
- if &b == &m.b {
- return
- }
- m.b = b
- m.matchingBlocks = nil
- m.opCodes = nil
- m.fullBCount = nil
- m.chainB()
-}
-
-func (m *SequenceMatcher) chainB() {
- // Populate line -> index mapping
- b2j := map[string][]int{}
- for i, s := range m.b {
- indices := b2j[s]
- indices = append(indices, i)
- b2j[s] = indices
- }
-
- // Purge junk elements
- m.bJunk = map[string]struct{}{}
- if m.IsJunk != nil {
- junk := m.bJunk
- for s := range b2j {
- if m.IsJunk(s) {
- junk[s] = struct{}{}
- }
- }
- for s := range junk {
- delete(b2j, s)
- }
- }
-
- // Purge remaining popular elements
- popular := map[string]struct{}{}
- n := len(m.b)
- if m.autoJunk && n >= 200 {
- ntest := n/100 + 1
- for s, indices := range b2j {
- if len(indices) > ntest {
- popular[s] = struct{}{}
- }
- }
- for s := range popular {
- delete(b2j, s)
- }
- }
- m.bPopular = popular
- m.b2j = b2j
-}
-
-func (m *SequenceMatcher) isBJunk(s string) bool {
- _, ok := m.bJunk[s]
- return ok
-}
-
-// Find longest matching block in a[alo:ahi] and b[blo:bhi].
-//
-// If IsJunk is not defined:
-//
-// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
-//
-// alo <= i <= i+k <= ahi
-// blo <= j <= j+k <= bhi
-//
-// and for all (i',j',k') meeting those conditions,
-//
-// k >= k'
-// i <= i'
-// and if i == i', j <= j'
-//
-// In other words, of all maximal matching blocks, return one that
-// starts earliest in a, and of all those maximal matching blocks that
-// start earliest in a, return the one that starts earliest in b.
-//
-// If IsJunk is defined, first the longest matching block is
-// determined as above, but with the additional restriction that no
-// junk element appears in the block. Then that block is extended as
-// far as possible by matching (only) junk elements on both sides. So
-// the resulting block never matches on junk except as identical junk
-// happens to be adjacent to an "interesting" match.
-//
-// If no blocks match, return (alo, blo, 0).
-func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match {
- // CAUTION: stripping common prefix or suffix would be incorrect.
- // E.g.,
- // ab
- // acab
- // Longest matching block is "ab", but if common prefix is
- // stripped, it's "a" (tied with "b"). UNIX(tm) diff does so
- // strip, so ends up claiming that ab is changed to acab by
- // inserting "ca" in the middle. That's minimal but unintuitive:
- // "it's obvious" that someone inserted "ac" at the front.
- // Windiff ends up at the same place as diff, but by pairing up
- // the unique 'b's and then matching the first two 'a's.
- besti, bestj, bestsize := alo, blo, 0
-
- // find longest junk-free match
- // during an iteration of the loop, j2len[j] = length of longest
- // junk-free match ending with a[i-1] and b[j]
- j2len := map[int]int{}
- for i := alo; i != ahi; i++ {
- // look at all instances of a[i] in b; note that because
- // b2j has no junk keys, the loop is skipped if a[i] is junk
- newj2len := map[int]int{}
- for _, j := range m.b2j[m.a[i]] {
- // a[i] matches b[j]
- if j < blo {
- continue
- }
- if j >= bhi {
- break
- }
- k := j2len[j-1] + 1
- newj2len[j] = k
- if k > bestsize {
- besti, bestj, bestsize = i-k+1, j-k+1, k
- }
- }
- j2len = newj2len
- }
-
- // Extend the best by non-junk elements on each end. In particular,
- // "popular" non-junk elements aren't in b2j, which greatly speeds
- // the inner loop above, but also means "the best" match so far
- // doesn't contain any junk *or* popular non-junk elements.
- for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) &&
- m.a[besti-1] == m.b[bestj-1] {
- besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
- }
- for besti+bestsize < ahi && bestj+bestsize < bhi &&
- !m.isBJunk(m.b[bestj+bestsize]) &&
- m.a[besti+bestsize] == m.b[bestj+bestsize] {
- bestsize++
- }
-
- // Now that we have a wholly interesting match (albeit possibly
- // empty!), we may as well suck up the matching junk on each
- // side of it too. Can't think of a good reason not to, and it
- // saves post-processing the (possibly considerable) expense of
- // figuring out what to do with it. In the case of an empty
- // interesting match, this is clearly the right thing to do,
- // because no other kind of match is possible in the regions.
- for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) &&
- m.a[besti-1] == m.b[bestj-1] {
- besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
- }
- for besti+bestsize < ahi && bestj+bestsize < bhi &&
- m.isBJunk(m.b[bestj+bestsize]) &&
- m.a[besti+bestsize] == m.b[bestj+bestsize] {
- bestsize++
- }
-
- return Match{A: besti, B: bestj, Size: bestsize}
-}
-
-// Return list of triples describing matching subsequences.
-//
-// Each triple is of the form (i, j, n), and means that
-// a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in
-// i and in j. It's also guaranteed that if (i, j, n) and (i', j', n') are
-// adjacent triples in the list, and the second is not the last triple in the
-// list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe
-// adjacent equal blocks.
-//
-// The last triple is a dummy, (len(a), len(b), 0), and is the only
-// triple with n==0.
-func (m *SequenceMatcher) GetMatchingBlocks() []Match {
- if m.matchingBlocks != nil {
- return m.matchingBlocks
- }
-
- var matchBlocks func(alo, ahi, blo, bhi int, matched []Match) []Match
- matchBlocks = func(alo, ahi, blo, bhi int, matched []Match) []Match {
- match := m.findLongestMatch(alo, ahi, blo, bhi)
- i, j, k := match.A, match.B, match.Size
- if match.Size > 0 {
- if alo < i && blo < j {
- matched = matchBlocks(alo, i, blo, j, matched)
- }
- matched = append(matched, match)
- if i+k < ahi && j+k < bhi {
- matched = matchBlocks(i+k, ahi, j+k, bhi, matched)
- }
- }
- return matched
- }
- matched := matchBlocks(0, len(m.a), 0, len(m.b), nil)
-
- // It's possible that we have adjacent equal blocks in the
- // matching_blocks list now.
- nonAdjacent := []Match{}
- i1, j1, k1 := 0, 0, 0
- for _, b := range matched {
- // Is this block adjacent to i1, j1, k1?
- i2, j2, k2 := b.A, b.B, b.Size
- if i1+k1 == i2 && j1+k1 == j2 {
- // Yes, so collapse them -- this just increases the length of
- // the first block by the length of the second, and the first
- // block so lengthened remains the block to compare against.
- k1 += k2
- } else {
- // Not adjacent. Remember the first block (k1==0 means it's
- // the dummy we started with), and make the second block the
- // new block to compare against.
- if k1 > 0 {
- nonAdjacent = append(nonAdjacent, Match{i1, j1, k1})
- }
- i1, j1, k1 = i2, j2, k2
- }
- }
- if k1 > 0 {
- nonAdjacent = append(nonAdjacent, Match{i1, j1, k1})
- }
-
- nonAdjacent = append(nonAdjacent, Match{len(m.a), len(m.b), 0})
- m.matchingBlocks = nonAdjacent
- return m.matchingBlocks
-}
-
-// Return list of 5-tuples describing how to turn a into b.
-//
-// Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple
-// has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
-// tuple preceding it, and likewise for j1 == the previous j2.
-//
-// The tags are characters, with these meanings:
-//
-// 'r' (replace): a[i1:i2] should be replaced by b[j1:j2]
-//
-// 'd' (delete): a[i1:i2] should be deleted, j1==j2 in this case.
-//
-// 'i' (insert): b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case.
-//
-// 'e' (equal): a[i1:i2] == b[j1:j2]
-func (m *SequenceMatcher) GetOpCodes() []OpCode {
- if m.opCodes != nil {
- return m.opCodes
- }
- i, j := 0, 0
- matching := m.GetMatchingBlocks()
- opCodes := make([]OpCode, 0, len(matching))
- for _, m := range matching {
- // invariant: we've pumped out correct diffs to change
- // a[:i] into b[:j], and the next matching block is
- // a[ai:ai+size] == b[bj:bj+size]. So we need to pump
- // out a diff to change a[i:ai] into b[j:bj], pump out
- // the matching block, and move (i,j) beyond the match
- ai, bj, size := m.A, m.B, m.Size
- tag := byte(0)
- if i < ai && j < bj {
- tag = 'r'
- } else if i < ai {
- tag = 'd'
- } else if j < bj {
- tag = 'i'
- }
- if tag > 0 {
- opCodes = append(opCodes, OpCode{tag, i, ai, j, bj})
- }
- i, j = ai+size, bj+size
- // the list of matching blocks is terminated by a
- // sentinel with size 0
- if size > 0 {
- opCodes = append(opCodes, OpCode{'e', ai, i, bj, j})
- }
- }
- m.opCodes = opCodes
- return m.opCodes
-}
-
-// Isolate change clusters by eliminating ranges with no changes.
-//
-// Return a generator of groups with up to n lines of context.
-// Each group is in the same format as returned by GetOpCodes().
-func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
- if n < 0 {
- n = 3
- }
- codes := m.GetOpCodes()
- if len(codes) == 0 {
- codes = []OpCode{{'e', 0, 1, 0, 1}}
- }
- // Fixup leading and trailing groups if they show no changes.
- if codes[0].Tag == 'e' {
- c := codes[0]
- i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
- codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2}
- }
- if codes[len(codes)-1].Tag == 'e' {
- c := codes[len(codes)-1]
- i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
- codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)}
- }
- nn := n + n
- groups := [][]OpCode{}
- group := []OpCode{}
- for _, c := range codes {
- i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
- // End the current group and start a new one whenever
- // there is a large range with no changes.
- if c.Tag == 'e' && i2-i1 > nn {
- group = append(group, OpCode{
- c.Tag, i1, min(i2, i1+n),
- j1, min(j2, j1+n),
- })
- groups = append(groups, group)
- group = []OpCode{}
- i1, j1 = max(i1, i2-n), max(j1, j2-n)
- }
- group = append(group, OpCode{c.Tag, i1, i2, j1, j2})
- }
- if len(group) > 0 && !(len(group) == 1 && group[0].Tag == 'e') {
- groups = append(groups, group)
- }
- return groups
-}
-
-// Return a measure of the sequences' similarity (float in [0,1]).
-//
-// Where T is the total number of elements in both sequences, and
-// M is the number of matches, this is 2.0*M / T.
-// Note that this is 1 if the sequences are identical, and 0 if
-// they have nothing in common.
-//
-// .Ratio() is expensive to compute if you haven't already computed
-// .GetMatchingBlocks() or .GetOpCodes(), in which case you may
-// want to try .QuickRatio() or .RealQuickRation() first to get an
-// upper bound.
-func (m *SequenceMatcher) Ratio() float64 {
- matches := 0
- for _, m := range m.GetMatchingBlocks() {
- matches += m.Size
- }
- return calculateRatio(matches, len(m.a)+len(m.b))
-}
-
-// Return an upper bound on ratio() relatively quickly.
-//
-// This isn't defined beyond that it is an upper bound on .Ratio(), and
-// is faster to compute.
-func (m *SequenceMatcher) QuickRatio() float64 {
- // viewing a and b as multisets, set matches to the cardinality
- // of their intersection; this counts the number of matches
- // without regard to order, so is clearly an upper bound
- if m.fullBCount == nil {
- m.fullBCount = map[string]int{}
- for _, s := range m.b {
- m.fullBCount[s]++
- }
- }
-
- // avail[x] is the number of times x appears in 'b' less the
- // number of times we've seen it in 'a' so far ... kinda
- avail := map[string]int{}
- matches := 0
- for _, s := range m.a {
- n, ok := avail[s]
- if !ok {
- n = m.fullBCount[s]
- }
- avail[s] = n - 1
- if n > 0 {
- matches++
- }
- }
- return calculateRatio(matches, len(m.a)+len(m.b))
-}
-
-// Return an upper bound on ratio() very quickly.
-//
-// This isn't defined beyond that it is an upper bound on .Ratio(), and
-// is faster to compute than either .Ratio() or .QuickRatio().
-func (m *SequenceMatcher) RealQuickRatio() float64 {
- la, lb := len(m.a), len(m.b)
- return calculateRatio(min(la, lb), la+lb)
-}
-
-// Convert range to the "ed" format
-func formatRangeUnified(start, stop int) string {
- // Per the diff spec at http://www.unix.org/single_unix_specification/
- beginning := start + 1 // lines start numbering with one
- length := stop - start
- if length == 1 {
- return fmt.Sprintf("%d", beginning)
- }
- if length == 0 {
- beginning-- // empty ranges begin at line just before the range
- }
- return fmt.Sprintf("%d,%d", beginning, length)
-}
-
-// Unified diff parameters
-type UnifiedDiff struct {
- A []string // First sequence lines
- FromFile string // First file name
- FromDate string // First file time
- B []string // Second sequence lines
- ToFile string // Second file name
- ToDate string // Second file time
- Eol string // Headers end of line, defaults to LF
- Context int // Number of context lines
-}
-
-// Compare two sequences of lines; generate the delta as a unified diff.
-//
-// Unified diffs are a compact way of showing line changes and a few
-// lines of context. The number of context lines is set by 'n' which
-// defaults to three.
-//
-// By default, the diff control lines (those with ---, +++, or @@) are
-// created with a trailing newline. This is helpful so that inputs
-// created from file.readlines() result in diffs that are suitable for
-// file.writelines() since both the inputs and outputs have trailing
-// newlines.
-//
-// For inputs that do not have trailing newlines, set the lineterm
-// argument to "" so that the output will be uniformly newline free.
-//
-// The unidiff format normally has a header for filenames and modification
-// times. Any or all of these may be specified using strings for
-// 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
-// The modification times are normally expressed in the ISO 8601 format.
-func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error {
- buf := bufio.NewWriter(writer)
- defer buf.Flush()
- wf := func(format string, args ...interface{}) error {
- _, err := buf.WriteString(fmt.Sprintf(format, args...))
- return err
- }
- ws := func(s string) error {
- _, err := buf.WriteString(s)
- return err
- }
-
- if len(diff.Eol) == 0 {
- diff.Eol = "\n"
- }
-
- started := false
- m := NewMatcher(diff.A, diff.B)
- for _, g := range m.GetGroupedOpCodes(diff.Context) {
- if !started {
- started = true
- fromDate := ""
- if len(diff.FromDate) > 0 {
- fromDate = "\t" + diff.FromDate
- }
- toDate := ""
- if len(diff.ToDate) > 0 {
- toDate = "\t" + diff.ToDate
- }
- if diff.FromFile != "" || diff.ToFile != "" {
- err := wf("--- %s%s%s", diff.FromFile, fromDate, diff.Eol)
- if err != nil {
- return err
- }
- err = wf("+++ %s%s%s", diff.ToFile, toDate, diff.Eol)
- if err != nil {
- return err
- }
- }
- }
- first, last := g[0], g[len(g)-1]
- range1 := formatRangeUnified(first.I1, last.I2)
- range2 := formatRangeUnified(first.J1, last.J2)
- if err := wf("@@ -%s +%s @@%s", range1, range2, diff.Eol); err != nil {
- return err
- }
- for _, c := range g {
- i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
- if c.Tag == 'e' {
- for _, line := range diff.A[i1:i2] {
- if err := ws(" " + line); err != nil {
- return err
- }
- }
- continue
- }
- if c.Tag == 'r' || c.Tag == 'd' {
- for _, line := range diff.A[i1:i2] {
- if err := ws("-" + line); err != nil {
- return err
- }
- }
- }
- if c.Tag == 'r' || c.Tag == 'i' {
- for _, line := range diff.B[j1:j2] {
- if err := ws("+" + line); err != nil {
- return err
- }
- }
- }
- }
- }
- return nil
-}
-
-// Like WriteUnifiedDiff but returns the diff a string.
-func GetUnifiedDiffString(diff UnifiedDiff) (string, error) {
- w := &bytes.Buffer{}
- err := WriteUnifiedDiff(w, diff)
- return w.String(), err
-}
-
-// Split a string on "\n" while preserving them. The output can be used
-// as input for UnifiedDiff and ContextDiff structures.
-func SplitLines(s string) []string {
- lines := strings.SplitAfter(s, "\n")
- lines[len(lines)-1] += "\n"
- return lines
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/internal/go_collector_options.go b/vendor/github.com/prometheus/client_golang/prometheus/internal/go_collector_options.go
deleted file mode 100644
index a4fa6ea..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/internal/go_collector_options.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2021 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package internal
-
-import "regexp"
-
-type GoCollectorRule struct {
- Matcher *regexp.Regexp
- Deny bool
-}
-
-// GoCollectorOptions should not be used be directly by anything, except `collectors` package.
-// Use it via collectors package instead. See issue
-// https://github.com/prometheus/client_golang/issues/1030.
-//
-// This is internal, so external users only can use it via `collector.WithGoCollector*` methods
-type GoCollectorOptions struct {
- DisableMemStatsLikeMetrics bool
- RuntimeMetricSumForHist map[string]string
- RuntimeMetricRules []GoCollectorRule
-}
-
-var GoCollectorDefaultRuntimeMetrics = regexp.MustCompile(`/gc/gogc:percent|/gc/gomemlimit:bytes|/sched/gomaxprocs:threads`)
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/internal/go_runtime_metrics.go b/vendor/github.com/prometheus/client_golang/prometheus/internal/go_runtime_metrics.go
deleted file mode 100644
index 97d17d6..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/internal/go_runtime_metrics.go
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2021 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build go1.17
-// +build go1.17
-
-package internal
-
-import (
- "math"
- "path"
- "runtime/metrics"
- "strings"
-
- "github.com/prometheus/common/model"
-)
-
-// RuntimeMetricsToProm produces a Prometheus metric name from a runtime/metrics
-// metric description and validates whether the metric is suitable for integration
-// with Prometheus.
-//
-// Returns false if a name could not be produced, or if Prometheus does not understand
-// the runtime/metrics Kind.
-//
-// Note that the main reason a name couldn't be produced is if the runtime/metrics
-// package exports a name with characters outside the valid Prometheus metric name
-// character set. This is theoretically possible, but should never happen in practice.
-// Still, don't rely on it.
-func RuntimeMetricsToProm(d *metrics.Description) (string, string, string, bool) {
- namespace := "go"
-
- comp := strings.SplitN(d.Name, ":", 2)
- key := comp[0]
- unit := comp[1]
-
- // The last path element in the key is the name,
- // the rest is the subsystem.
- subsystem := path.Dir(key[1:] /* remove leading / */)
- name := path.Base(key)
-
- // subsystem is translated by replacing all / and - with _.
- subsystem = strings.ReplaceAll(subsystem, "/", "_")
- subsystem = strings.ReplaceAll(subsystem, "-", "_")
-
- // unit is translated assuming that the unit contains no
- // non-ASCII characters.
- unit = strings.ReplaceAll(unit, "-", "_")
- unit = strings.ReplaceAll(unit, "*", "_")
- unit = strings.ReplaceAll(unit, "/", "_per_")
-
- // name has - replaced with _ and is concatenated with the unit and
- // other data.
- name = strings.ReplaceAll(name, "-", "_")
- name += "_" + unit
- if d.Cumulative && d.Kind != metrics.KindFloat64Histogram {
- name += "_total"
- }
-
- valid := model.IsValidMetricName(model.LabelValue(namespace + "_" + subsystem + "_" + name))
- switch d.Kind {
- case metrics.KindUint64:
- case metrics.KindFloat64:
- case metrics.KindFloat64Histogram:
- default:
- valid = false
- }
- return namespace, subsystem, name, valid
-}
-
-// RuntimeMetricsBucketsForUnit takes a set of buckets obtained for a runtime/metrics histogram
-// type (so, lower-bound inclusive) and a unit from a runtime/metrics name, and produces
-// a reduced set of buckets. This function always removes any -Inf bucket as it's represented
-// as the bottom-most upper-bound inclusive bucket in Prometheus.
-func RuntimeMetricsBucketsForUnit(buckets []float64, unit string) []float64 {
- switch unit {
- case "bytes":
- // Re-bucket as powers of 2.
- return reBucketExp(buckets, 2)
- case "seconds":
- // Re-bucket as powers of 10 and then merge all buckets greater
- // than 1 second into the +Inf bucket.
- b := reBucketExp(buckets, 10)
- for i := range b {
- if b[i] <= 1 {
- continue
- }
- b[i] = math.Inf(1)
- b = b[:i+1]
- break
- }
- return b
- }
- return buckets
-}
-
-// reBucketExp takes a list of bucket boundaries (lower bound inclusive) and
-// downsamples the buckets to those a multiple of base apart. The end result
-// is a roughly exponential (in many cases, perfectly exponential) bucketing
-// scheme.
-func reBucketExp(buckets []float64, base float64) []float64 {
- bucket := buckets[0]
- var newBuckets []float64
- // We may see a -Inf here, in which case, add it and skip it
- // since we risk producing NaNs otherwise.
- //
- // We need to preserve -Inf values to maintain runtime/metrics
- // conventions. We'll strip it out later.
- if bucket == math.Inf(-1) {
- newBuckets = append(newBuckets, bucket)
- buckets = buckets[1:]
- bucket = buckets[0]
- }
- // From now on, bucket should always have a non-Inf value because
- // Infs are only ever at the ends of the bucket lists, so
- // arithmetic operations on it are non-NaN.
- for i := 1; i < len(buckets); i++ {
- if bucket >= 0 && buckets[i] < bucket*base {
- // The next bucket we want to include is at least bucket*base.
- continue
- } else if bucket < 0 && buckets[i] < bucket/base {
- // In this case the bucket we're targeting is negative, and since
- // we're ascending through buckets here, we need to divide to get
- // closer to zero exponentially.
- continue
- }
- // The +Inf bucket will always be the last one, and we'll always
- // end up including it here because bucket
- newBuckets = append(newBuckets, bucket)
- bucket = buckets[i]
- }
- return append(newBuckets, bucket)
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/internal/metric.go b/vendor/github.com/prometheus/client_golang/prometheus/internal/metric.go
deleted file mode 100644
index 6515c11..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/internal/metric.go
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package internal
-
-import (
- "sort"
-
- dto "github.com/prometheus/client_model/go"
-)
-
-// LabelPairSorter implements sort.Interface. It is used to sort a slice of
-// dto.LabelPair pointers.
-type LabelPairSorter []*dto.LabelPair
-
-func (s LabelPairSorter) Len() int {
- return len(s)
-}
-
-func (s LabelPairSorter) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
-}
-
-func (s LabelPairSorter) Less(i, j int) bool {
- return s[i].GetName() < s[j].GetName()
-}
-
-// MetricSorter is a sortable slice of *dto.Metric.
-type MetricSorter []*dto.Metric
-
-func (s MetricSorter) Len() int {
- return len(s)
-}
-
-func (s MetricSorter) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
-}
-
-func (s MetricSorter) Less(i, j int) bool {
- if len(s[i].Label) != len(s[j].Label) {
- // This should not happen. The metrics are
- // inconsistent. However, we have to deal with the fact, as
- // people might use custom collectors or metric family injection
- // to create inconsistent metrics. So let's simply compare the
- // number of labels in this case. That will still yield
- // reproducible sorting.
- return len(s[i].Label) < len(s[j].Label)
- }
- for n, lp := range s[i].Label {
- vi := lp.GetValue()
- vj := s[j].Label[n].GetValue()
- if vi != vj {
- return vi < vj
- }
- }
-
- // We should never arrive here. Multiple metrics with the same
- // label set in the same scrape will lead to undefined ingestion
- // behavior. However, as above, we have to provide stable sorting
- // here, even for inconsistent metrics. So sort equal metrics
- // by their timestamp, with missing timestamps (implying "now")
- // coming last.
- if s[i].TimestampMs == nil {
- return false
- }
- if s[j].TimestampMs == nil {
- return true
- }
- return s[i].GetTimestampMs() < s[j].GetTimestampMs()
-}
-
-// NormalizeMetricFamilies returns a MetricFamily slice with empty
-// MetricFamilies pruned and the remaining MetricFamilies sorted by name within
-// the slice, with the contained Metrics sorted within each MetricFamily.
-func NormalizeMetricFamilies(metricFamiliesByName map[string]*dto.MetricFamily) []*dto.MetricFamily {
- for _, mf := range metricFamiliesByName {
- sort.Sort(MetricSorter(mf.Metric))
- }
- names := make([]string, 0, len(metricFamiliesByName))
- for name, mf := range metricFamiliesByName {
- if len(mf.Metric) > 0 {
- names = append(names, name)
- }
- }
- sort.Strings(names)
- result := make([]*dto.MetricFamily, 0, len(names))
- for _, name := range names {
- result = append(result, metricFamiliesByName[name])
- }
- return result
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/labels.go b/vendor/github.com/prometheus/client_golang/prometheus/labels.go
deleted file mode 100644
index c21911f..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/labels.go
+++ /dev/null
@@ -1,188 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "errors"
- "fmt"
- "strings"
- "unicode/utf8"
-
- "github.com/prometheus/common/model"
-)
-
-// Labels represents a collection of label name -> value mappings. This type is
-// commonly used with the With(Labels) and GetMetricWith(Labels) methods of
-// metric vector Collectors, e.g.:
-//
-// myVec.With(Labels{"code": "404", "method": "GET"}).Add(42)
-//
-// The other use-case is the specification of constant label pairs in Opts or to
-// create a Desc.
-type Labels map[string]string
-
-// LabelConstraint normalizes label values.
-type LabelConstraint func(string) string
-
-// ConstrainedLabels represents a label name and its constrain function
-// to normalize label values. This type is commonly used when constructing
-// metric vector Collectors.
-type ConstrainedLabel struct {
- Name string
- Constraint LabelConstraint
-}
-
-// ConstrainableLabels is an interface that allows creating of labels that can
-// be optionally constrained.
-//
-// prometheus.V2().NewCounterVec(CounterVecOpts{
-// CounterOpts: {...}, // Usual CounterOpts fields
-// VariableLabels: []ConstrainedLabels{
-// {Name: "A"},
-// {Name: "B", Constraint: func(v string) string { ... }},
-// },
-// })
-type ConstrainableLabels interface {
- compile() *compiledLabels
- labelNames() []string
-}
-
-// ConstrainedLabels represents a collection of label name -> constrain function
-// to normalize label values. This type is commonly used when constructing
-// metric vector Collectors.
-type ConstrainedLabels []ConstrainedLabel
-
-func (cls ConstrainedLabels) compile() *compiledLabels {
- compiled := &compiledLabels{
- names: make([]string, len(cls)),
- labelConstraints: map[string]LabelConstraint{},
- }
-
- for i, label := range cls {
- compiled.names[i] = label.Name
- if label.Constraint != nil {
- compiled.labelConstraints[label.Name] = label.Constraint
- }
- }
-
- return compiled
-}
-
-func (cls ConstrainedLabels) labelNames() []string {
- names := make([]string, len(cls))
- for i, label := range cls {
- names[i] = label.Name
- }
- return names
-}
-
-// UnconstrainedLabels represents collection of label without any constraint on
-// their value. Thus, it is simply a collection of label names.
-//
-// UnconstrainedLabels([]string{ "A", "B" })
-//
-// is equivalent to
-//
-// ConstrainedLabels {
-// { Name: "A" },
-// { Name: "B" },
-// }
-type UnconstrainedLabels []string
-
-func (uls UnconstrainedLabels) compile() *compiledLabels {
- return &compiledLabels{
- names: uls,
- }
-}
-
-func (uls UnconstrainedLabels) labelNames() []string {
- return uls
-}
-
-type compiledLabels struct {
- names []string
- labelConstraints map[string]LabelConstraint
-}
-
-func (cls *compiledLabels) compile() *compiledLabels {
- return cls
-}
-
-func (cls *compiledLabels) labelNames() []string {
- return cls.names
-}
-
-func (cls *compiledLabels) constrain(labelName, value string) string {
- if fn, ok := cls.labelConstraints[labelName]; ok && fn != nil {
- return fn(value)
- }
- return value
-}
-
-// reservedLabelPrefix is a prefix which is not legal in user-supplied
-// label names.
-const reservedLabelPrefix = "__"
-
-var errInconsistentCardinality = errors.New("inconsistent label cardinality")
-
-func makeInconsistentCardinalityError(fqName string, labels, labelValues []string) error {
- return fmt.Errorf(
- "%w: %q has %d variable labels named %q but %d values %q were provided",
- errInconsistentCardinality, fqName,
- len(labels), labels,
- len(labelValues), labelValues,
- )
-}
-
-func validateValuesInLabels(labels Labels, expectedNumberOfValues int) error {
- if len(labels) != expectedNumberOfValues {
- return fmt.Errorf(
- "%w: expected %d label values but got %d in %#v",
- errInconsistentCardinality, expectedNumberOfValues,
- len(labels), labels,
- )
- }
-
- for name, val := range labels {
- if !utf8.ValidString(val) {
- return fmt.Errorf("label %s: value %q is not valid UTF-8", name, val)
- }
- }
-
- return nil
-}
-
-func validateLabelValues(vals []string, expectedNumberOfValues int) error {
- if len(vals) != expectedNumberOfValues {
- // The call below makes vals escape, copy them to avoid that.
- vals := append([]string(nil), vals...)
- return fmt.Errorf(
- "%w: expected %d label values but got %d in %#v",
- errInconsistentCardinality, expectedNumberOfValues,
- len(vals), vals,
- )
- }
-
- for _, val := range vals {
- if !utf8.ValidString(val) {
- return fmt.Errorf("label value %q is not valid UTF-8", val)
- }
- }
-
- return nil
-}
-
-func checkLabelName(l string) bool {
- return model.LabelName(l).IsValid() && !strings.HasPrefix(l, reservedLabelPrefix)
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/metric.go b/vendor/github.com/prometheus/client_golang/prometheus/metric.go
deleted file mode 100644
index 9d9b81a..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/metric.go
+++ /dev/null
@@ -1,257 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "errors"
- "math"
- "sort"
- "strings"
- "time"
-
- dto "github.com/prometheus/client_model/go"
- "github.com/prometheus/common/model"
- "google.golang.org/protobuf/proto"
-)
-
-var separatorByteSlice = []byte{model.SeparatorByte} // For convenient use with xxhash.
-
-// A Metric models a single sample value with its meta data being exported to
-// Prometheus. Implementations of Metric in this package are Gauge, Counter,
-// Histogram, Summary, and Untyped.
-type Metric interface {
- // Desc returns the descriptor for the Metric. This method idempotently
- // returns the same descriptor throughout the lifetime of the
- // Metric. The returned descriptor is immutable by contract. A Metric
- // unable to describe itself must return an invalid descriptor (created
- // with NewInvalidDesc).
- Desc() *Desc
- // Write encodes the Metric into a "Metric" Protocol Buffer data
- // transmission object.
- //
- // Metric implementations must observe concurrency safety as reads of
- // this metric may occur at any time, and any blocking occurs at the
- // expense of total performance of rendering all registered
- // metrics. Ideally, Metric implementations should support concurrent
- // readers.
- //
- // While populating dto.Metric, it is the responsibility of the
- // implementation to ensure validity of the Metric protobuf (like valid
- // UTF-8 strings or syntactically valid metric and label names). It is
- // recommended to sort labels lexicographically. Callers of Write should
- // still make sure of sorting if they depend on it.
- Write(*dto.Metric) error
- // TODO(beorn7): The original rationale of passing in a pre-allocated
- // dto.Metric protobuf to save allocations has disappeared. The
- // signature of this method should be changed to "Write() (*dto.Metric,
- // error)".
-}
-
-// Opts bundles the options for creating most Metric types. Each metric
-// implementation XXX has its own XXXOpts type, but in most cases, it is just
-// an alias of this type (which might change when the requirement arises.)
-//
-// It is mandatory to set Name to a non-empty string. All other fields are
-// optional and can safely be left at their zero value, although it is strongly
-// encouraged to set a Help string.
-type Opts struct {
- // Namespace, Subsystem, and Name are components of the fully-qualified
- // name of the Metric (created by joining these components with
- // "_"). Only Name is mandatory, the others merely help structuring the
- // name. Note that the fully-qualified name of the metric must be a
- // valid Prometheus metric name.
- Namespace string
- Subsystem string
- Name string
-
- // Help provides information about this metric.
- //
- // Metrics with the same fully-qualified name must have the same Help
- // string.
- Help string
-
- // ConstLabels are used to attach fixed labels to this metric. Metrics
- // with the same fully-qualified name must have the same label names in
- // their ConstLabels.
- //
- // ConstLabels are only used rarely. In particular, do not use them to
- // attach the same labels to all your metrics. Those use cases are
- // better covered by target labels set by the scraping Prometheus
- // server, or by one specific metric (e.g. a build_info or a
- // machine_role metric). See also
- // https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels
- ConstLabels Labels
-
- // now is for testing purposes, by default it's time.Now.
- now func() time.Time
-}
-
-// BuildFQName joins the given three name components by "_". Empty name
-// components are ignored. If the name parameter itself is empty, an empty
-// string is returned, no matter what. Metric implementations included in this
-// library use this function internally to generate the fully-qualified metric
-// name from the name component in their Opts. Users of the library will only
-// need this function if they implement their own Metric or instantiate a Desc
-// (with NewDesc) directly.
-func BuildFQName(namespace, subsystem, name string) string {
- if name == "" {
- return ""
- }
- switch {
- case namespace != "" && subsystem != "":
- return strings.Join([]string{namespace, subsystem, name}, "_")
- case namespace != "":
- return strings.Join([]string{namespace, name}, "_")
- case subsystem != "":
- return strings.Join([]string{subsystem, name}, "_")
- }
- return name
-}
-
-type invalidMetric struct {
- desc *Desc
- err error
-}
-
-// NewInvalidMetric returns a metric whose Write method always returns the
-// provided error. It is useful if a Collector finds itself unable to collect
-// a metric and wishes to report an error to the registry.
-func NewInvalidMetric(desc *Desc, err error) Metric {
- return &invalidMetric{desc, err}
-}
-
-func (m *invalidMetric) Desc() *Desc { return m.desc }
-
-func (m *invalidMetric) Write(*dto.Metric) error { return m.err }
-
-type timestampedMetric struct {
- Metric
- t time.Time
-}
-
-func (m timestampedMetric) Write(pb *dto.Metric) error {
- e := m.Metric.Write(pb)
- pb.TimestampMs = proto.Int64(m.t.Unix()*1000 + int64(m.t.Nanosecond()/1000000))
- return e
-}
-
-// NewMetricWithTimestamp returns a new Metric wrapping the provided Metric in a
-// way that it has an explicit timestamp set to the provided Time. This is only
-// useful in rare cases as the timestamp of a Prometheus metric should usually
-// be set by the Prometheus server during scraping. Exceptions include mirroring
-// metrics with given timestamps from other metric
-// sources.
-//
-// NewMetricWithTimestamp works best with MustNewConstMetric,
-// MustNewConstHistogram, and MustNewConstSummary, see example.
-//
-// Currently, the exposition formats used by Prometheus are limited to
-// millisecond resolution. Thus, the provided time will be rounded down to the
-// next full millisecond value.
-func NewMetricWithTimestamp(t time.Time, m Metric) Metric {
- return timestampedMetric{Metric: m, t: t}
-}
-
-type withExemplarsMetric struct {
- Metric
-
- exemplars []*dto.Exemplar
-}
-
-func (m *withExemplarsMetric) Write(pb *dto.Metric) error {
- if err := m.Metric.Write(pb); err != nil {
- return err
- }
-
- switch {
- case pb.Counter != nil:
- pb.Counter.Exemplar = m.exemplars[len(m.exemplars)-1]
- case pb.Histogram != nil:
- for _, e := range m.exemplars {
- // pb.Histogram.Bucket are sorted by UpperBound.
- i := sort.Search(len(pb.Histogram.Bucket), func(i int) bool {
- return pb.Histogram.Bucket[i].GetUpperBound() >= e.GetValue()
- })
- if i < len(pb.Histogram.Bucket) {
- pb.Histogram.Bucket[i].Exemplar = e
- } else {
- // The +Inf bucket should be explicitly added if there is an exemplar for it, similar to non-const histogram logic in https://github.com/prometheus/client_golang/blob/main/prometheus/histogram.go#L357-L365.
- b := &dto.Bucket{
- CumulativeCount: proto.Uint64(pb.Histogram.GetSampleCount()),
- UpperBound: proto.Float64(math.Inf(1)),
- Exemplar: e,
- }
- pb.Histogram.Bucket = append(pb.Histogram.Bucket, b)
- }
- }
- default:
- // TODO(bwplotka): Implement Gauge?
- return errors.New("cannot inject exemplar into Gauge, Summary or Untyped")
- }
-
- return nil
-}
-
-// Exemplar is easier to use, user-facing representation of *dto.Exemplar.
-type Exemplar struct {
- Value float64
- Labels Labels
- // Optional.
- // Default value (time.Time{}) indicates its empty, which should be
- // understood as time.Now() time at the moment of creation of metric.
- Timestamp time.Time
-}
-
-// NewMetricWithExemplars returns a new Metric wrapping the provided Metric with given
-// exemplars. Exemplars are validated.
-//
-// Only last applicable exemplar is injected from the list.
-// For example for Counter it means last exemplar is injected.
-// For Histogram, it means last applicable exemplar for each bucket is injected.
-//
-// NewMetricWithExemplars works best with MustNewConstMetric and
-// MustNewConstHistogram, see example.
-func NewMetricWithExemplars(m Metric, exemplars ...Exemplar) (Metric, error) {
- if len(exemplars) == 0 {
- return nil, errors.New("no exemplar was passed for NewMetricWithExemplars")
- }
-
- var (
- now = time.Now()
- exs = make([]*dto.Exemplar, len(exemplars))
- err error
- )
- for i, e := range exemplars {
- ts := e.Timestamp
- if ts.IsZero() {
- ts = now
- }
- exs[i], err = newExemplar(e.Value, ts, e.Labels)
- if err != nil {
- return nil, err
- }
- }
-
- return &withExemplarsMetric{Metric: m, exemplars: exs}, nil
-}
-
-// MustNewMetricWithExemplars is a version of NewMetricWithExemplars that panics where
-// NewMetricWithExemplars would have returned an error.
-func MustNewMetricWithExemplars(m Metric, exemplars ...Exemplar) Metric {
- ret, err := NewMetricWithExemplars(m, exemplars...)
- if err != nil {
- panic(err)
- }
- return ret
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/num_threads.go b/vendor/github.com/prometheus/client_golang/prometheus/num_threads.go
deleted file mode 100644
index 7c12b21..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/num_threads.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !js || wasm
-// +build !js wasm
-
-package prometheus
-
-import "runtime"
-
-// getRuntimeNumThreads returns the number of open OS threads.
-func getRuntimeNumThreads() float64 {
- n, _ := runtime.ThreadCreateProfile(nil)
- return float64(n)
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/num_threads_gopherjs.go b/vendor/github.com/prometheus/client_golang/prometheus/num_threads_gopherjs.go
deleted file mode 100644
index 7348df0..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/num_threads_gopherjs.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build js && !wasm
-// +build js,!wasm
-
-package prometheus
-
-// getRuntimeNumThreads returns the number of open OS threads.
-func getRuntimeNumThreads() float64 {
- return 1
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/observer.go b/vendor/github.com/prometheus/client_golang/prometheus/observer.go
deleted file mode 100644
index 03773b2..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/observer.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2017 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-// Observer is the interface that wraps the Observe method, which is used by
-// Histogram and Summary to add observations.
-type Observer interface {
- Observe(float64)
-}
-
-// The ObserverFunc type is an adapter to allow the use of ordinary
-// functions as Observers. If f is a function with the appropriate
-// signature, ObserverFunc(f) is an Observer that calls f.
-//
-// This adapter is usually used in connection with the Timer type, and there are
-// two general use cases:
-//
-// The most common one is to use a Gauge as the Observer for a Timer.
-// See the "Gauge" Timer example.
-//
-// The more advanced use case is to create a function that dynamically decides
-// which Observer to use for observing the duration. See the "Complex" Timer
-// example.
-type ObserverFunc func(float64)
-
-// Observe calls f(value). It implements Observer.
-func (f ObserverFunc) Observe(value float64) {
- f(value)
-}
-
-// ObserverVec is an interface implemented by `HistogramVec` and `SummaryVec`.
-type ObserverVec interface {
- GetMetricWith(Labels) (Observer, error)
- GetMetricWithLabelValues(lvs ...string) (Observer, error)
- With(Labels) Observer
- WithLabelValues(...string) Observer
- CurryWith(Labels) (ObserverVec, error)
- MustCurryWith(Labels) ObserverVec
-
- Collector
-}
-
-// ExemplarObserver is implemented by Observers that offer the option of
-// observing a value together with an exemplar. Its ObserveWithExemplar method
-// works like the Observe method of an Observer but also replaces the currently
-// saved exemplar (if any) with a new one, created from the provided value, the
-// current time as timestamp, and the provided Labels. Empty Labels will lead to
-// a valid (label-less) exemplar. But if Labels is nil, the current exemplar is
-// left in place. ObserveWithExemplar panics if any of the provided labels are
-// invalid or if the provided labels contain more than 128 runes in total.
-type ExemplarObserver interface {
- ObserveWithExemplar(value float64, exemplar Labels)
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
deleted file mode 100644
index 62a4e7a..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "errors"
- "fmt"
- "os"
- "strconv"
- "strings"
-)
-
-type processCollector struct {
- collectFn func(chan<- Metric)
- pidFn func() (int, error)
- reportErrors bool
- cpuTotal *Desc
- openFDs, maxFDs *Desc
- vsize, maxVsize *Desc
- rss *Desc
- startTime *Desc
- inBytes, outBytes *Desc
-}
-
-// ProcessCollectorOpts defines the behavior of a process metrics collector
-// created with NewProcessCollector.
-type ProcessCollectorOpts struct {
- // PidFn returns the PID of the process the collector collects metrics
- // for. It is called upon each collection. By default, the PID of the
- // current process is used, as determined on construction time by
- // calling os.Getpid().
- PidFn func() (int, error)
- // If non-empty, each of the collected metrics is prefixed by the
- // provided string and an underscore ("_").
- Namespace string
- // If true, any error encountered during collection is reported as an
- // invalid metric (see NewInvalidMetric). Otherwise, errors are ignored
- // and the collected metrics will be incomplete. (Possibly, no metrics
- // will be collected at all.) While that's usually not desired, it is
- // appropriate for the common "mix-in" of process metrics, where process
- // metrics are nice to have, but failing to collect them should not
- // disrupt the collection of the remaining metrics.
- ReportErrors bool
-}
-
-// NewProcessCollector is the obsolete version of collectors.NewProcessCollector.
-// See there for documentation.
-//
-// Deprecated: Use collectors.NewProcessCollector instead.
-func NewProcessCollector(opts ProcessCollectorOpts) Collector {
- ns := ""
- if len(opts.Namespace) > 0 {
- ns = opts.Namespace + "_"
- }
-
- c := &processCollector{
- reportErrors: opts.ReportErrors,
- cpuTotal: NewDesc(
- ns+"process_cpu_seconds_total",
- "Total user and system CPU time spent in seconds.",
- nil, nil,
- ),
- openFDs: NewDesc(
- ns+"process_open_fds",
- "Number of open file descriptors.",
- nil, nil,
- ),
- maxFDs: NewDesc(
- ns+"process_max_fds",
- "Maximum number of open file descriptors.",
- nil, nil,
- ),
- vsize: NewDesc(
- ns+"process_virtual_memory_bytes",
- "Virtual memory size in bytes.",
- nil, nil,
- ),
- maxVsize: NewDesc(
- ns+"process_virtual_memory_max_bytes",
- "Maximum amount of virtual memory available in bytes.",
- nil, nil,
- ),
- rss: NewDesc(
- ns+"process_resident_memory_bytes",
- "Resident memory size in bytes.",
- nil, nil,
- ),
- startTime: NewDesc(
- ns+"process_start_time_seconds",
- "Start time of the process since unix epoch in seconds.",
- 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 {
- c.pidFn = getPIDFn()
- } else {
- c.pidFn = opts.PidFn
- }
-
- // Set up process metric collection if supported by the runtime.
- if canCollectProcess() {
- c.collectFn = c.processCollect
- } else {
- c.collectFn = func(ch chan<- Metric) {
- c.reportError(ch, nil, errors.New("process metrics not supported on this platform"))
- }
- }
-
- return c
-}
-
-// Describe returns all descriptions of the collector.
-func (c *processCollector) Describe(ch chan<- *Desc) {
- ch <- c.cpuTotal
- ch <- c.openFDs
- ch <- c.maxFDs
- ch <- c.vsize
- ch <- c.maxVsize
- ch <- c.rss
- ch <- c.startTime
- ch <- c.inBytes
- ch <- c.outBytes
-}
-
-// Collect returns the current state of all metrics of the collector.
-func (c *processCollector) Collect(ch chan<- Metric) {
- c.collectFn(ch)
-}
-
-func (c *processCollector) reportError(ch chan<- Metric, desc *Desc, err error) {
- if !c.reportErrors {
- return
- }
- if desc == nil {
- desc = NewInvalidDesc(err)
- }
- ch <- NewInvalidMetric(desc, err)
-}
-
-// NewPidFileFn returns a function that retrieves a pid from the specified file.
-// It is meant to be used for the PidFn field in ProcessCollectorOpts.
-func NewPidFileFn(pidFilePath string) func() (int, error) {
- return func() (int, error) {
- content, err := os.ReadFile(pidFilePath)
- if err != nil {
- return 0, fmt.Errorf("can't read pid file %q: %w", pidFilePath, err)
- }
- pid, err := strconv.Atoi(strings.TrimSpace(string(content)))
- if err != nil {
- return 0, fmt.Errorf("can't parse pid file %q: %w", pidFilePath, err)
- }
-
- return pid, nil
- }
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_js.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector_js.go
deleted file mode 100644
index b1e363d..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_js.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build js
-// +build js
-
-package prometheus
-
-func canCollectProcess() bool {
- return false
-}
-
-func (c *processCollector) processCollect(ch chan<- Metric) {
- // noop on this platform
- return
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
deleted file mode 100644
index 14d56d2..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !windows && !js && !wasip1
-// +build !windows,!js,!wasip1
-
-package prometheus
-
-import (
- "github.com/prometheus/procfs"
-)
-
-func canCollectProcess() bool {
- _, err := procfs.NewDefaultFS()
- return err == nil
-}
-
-func (c *processCollector) processCollect(ch chan<- Metric) {
- pid, err := c.pidFn()
- if err != nil {
- c.reportError(ch, nil, err)
- return
- }
-
- p, err := procfs.NewProc(pid)
- if err != nil {
- c.reportError(ch, nil, err)
- return
- }
-
- if stat, err := p.Stat(); err == nil {
- ch <- MustNewConstMetric(c.cpuTotal, CounterValue, stat.CPUTime())
- ch <- MustNewConstMetric(c.vsize, GaugeValue, float64(stat.VirtualMemory()))
- ch <- MustNewConstMetric(c.rss, GaugeValue, float64(stat.ResidentMemory()))
- if startTime, err := stat.StartTime(); err == nil {
- ch <- MustNewConstMetric(c.startTime, GaugeValue, startTime)
- } else {
- c.reportError(ch, c.startTime, err)
- }
- } else {
- c.reportError(ch, nil, err)
- }
-
- if fds, err := p.FileDescriptorsLen(); err == nil {
- ch <- MustNewConstMetric(c.openFDs, GaugeValue, float64(fds))
- } else {
- c.reportError(ch, c.openFDs, err)
- }
-
- if limits, err := p.Limits(); err == nil {
- ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(limits.OpenFiles))
- ch <- MustNewConstMetric(c.maxVsize, GaugeValue, float64(limits.AddressSpace))
- } else {
- 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)
- }
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_wasip1.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector_wasip1.go
deleted file mode 100644
index d8d9a6d..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_wasip1.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2023 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build wasip1
-// +build wasip1
-
-package prometheus
-
-func canCollectProcess() bool {
- return false
-}
-
-func (*processCollector) processCollect(chan<- Metric) {
- // noop on this platform
- return
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go b/vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go
deleted file mode 100644
index f973398..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "syscall"
- "unsafe"
-
- "golang.org/x/sys/windows"
-)
-
-func canCollectProcess() bool {
- return true
-}
-
-var (
- modpsapi = syscall.NewLazyDLL("psapi.dll")
- modkernel32 = syscall.NewLazyDLL("kernel32.dll")
-
- procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo")
- procGetProcessHandleCount = modkernel32.NewProc("GetProcessHandleCount")
-)
-
-type processMemoryCounters struct {
- // System interface description
- // https://docs.microsoft.com/en-us/windows/desktop/api/psapi/ns-psapi-process_memory_counters_ex
-
- // Refer to the Golang internal implementation
- // https://golang.org/src/internal/syscall/windows/psapi_windows.go
- _ uint32
- PageFaultCount uint32
- PeakWorkingSetSize uintptr
- WorkingSetSize uintptr
- QuotaPeakPagedPoolUsage uintptr
- QuotaPagedPoolUsage uintptr
- QuotaPeakNonPagedPoolUsage uintptr
- QuotaNonPagedPoolUsage uintptr
- PagefileUsage uintptr
- PeakPagefileUsage uintptr
- PrivateUsage uintptr
-}
-
-func getProcessMemoryInfo(handle windows.Handle) (processMemoryCounters, error) {
- mem := processMemoryCounters{}
- r1, _, err := procGetProcessMemoryInfo.Call(
- uintptr(handle),
- uintptr(unsafe.Pointer(&mem)),
- uintptr(unsafe.Sizeof(mem)),
- )
- if r1 != 1 {
- return mem, err
- } else {
- return mem, nil
- }
-}
-
-func getProcessHandleCount(handle windows.Handle) (uint32, error) {
- var count uint32
- r1, _, err := procGetProcessHandleCount.Call(
- uintptr(handle),
- uintptr(unsafe.Pointer(&count)),
- )
- if r1 != 1 {
- return 0, err
- } else {
- return count, nil
- }
-}
-
-func (c *processCollector) processCollect(ch chan<- Metric) {
- h, err := windows.GetCurrentProcess()
- if err != nil {
- c.reportError(ch, nil, err)
- return
- }
-
- var startTime, exitTime, kernelTime, userTime windows.Filetime
- err = windows.GetProcessTimes(h, &startTime, &exitTime, &kernelTime, &userTime)
- if err != nil {
- c.reportError(ch, nil, err)
- return
- }
- ch <- MustNewConstMetric(c.startTime, GaugeValue, float64(startTime.Nanoseconds()/1e9))
- ch <- MustNewConstMetric(c.cpuTotal, CounterValue, fileTimeToSeconds(kernelTime)+fileTimeToSeconds(userTime))
-
- mem, err := getProcessMemoryInfo(h)
- if err != nil {
- c.reportError(ch, nil, err)
- return
- }
- ch <- MustNewConstMetric(c.vsize, GaugeValue, float64(mem.PrivateUsage))
- ch <- MustNewConstMetric(c.rss, GaugeValue, float64(mem.WorkingSetSize))
-
- handles, err := getProcessHandleCount(h)
- if err != nil {
- c.reportError(ch, nil, err)
- return
- }
- ch <- MustNewConstMetric(c.openFDs, GaugeValue, float64(handles))
- ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(16*1024*1024)) // Windows has a hard-coded max limit, not per-process.
-}
-
-func fileTimeToSeconds(ft windows.Filetime) float64 {
- return float64(uint64(ft.HighDateTime)<<32+uint64(ft.LowDateTime)) / 1e7
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/promauto/auto.go b/vendor/github.com/prometheus/client_golang/prometheus/promauto/auto.go
deleted file mode 100644
index 58f9659..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/promauto/auto.go
+++ /dev/null
@@ -1,376 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package promauto provides alternative constructors for the fundamental
-// Prometheus metric types and their …Vec and …Func variants. The difference to
-// their counterparts in the prometheus package is that the promauto
-// constructors register the Collectors with a registry before returning them.
-// There are two sets of constructors. The constructors in the first set are
-// top-level functions, while the constructors in the other set are methods of
-// the Factory type. The top-level functions return Collectors registered with
-// the global registry (prometheus.DefaultRegisterer), while the methods return
-// Collectors registered with the registry the Factory was constructed with. All
-// constructors panic if the registration fails.
-//
-// The following example is a complete program to create a histogram of normally
-// distributed random numbers from the math/rand package:
-//
-// package main
-//
-// import (
-// "math/rand"
-// "net/http"
-//
-// "github.com/prometheus/client_golang/prometheus"
-// "github.com/prometheus/client_golang/prometheus/promauto"
-// "github.com/prometheus/client_golang/prometheus/promhttp"
-// )
-//
-// var histogram = promauto.NewHistogram(prometheus.HistogramOpts{
-// Name: "random_numbers",
-// Help: "A histogram of normally distributed random numbers.",
-// Buckets: prometheus.LinearBuckets(-3, .1, 61),
-// })
-//
-// func Random() {
-// for {
-// histogram.Observe(rand.NormFloat64())
-// }
-// }
-//
-// func main() {
-// go Random()
-// http.Handle("/metrics", promhttp.Handler())
-// http.ListenAndServe(":1971", nil)
-// }
-//
-// Prometheus's version of a minimal hello-world program:
-//
-// package main
-//
-// import (
-// "fmt"
-// "net/http"
-//
-// "github.com/prometheus/client_golang/prometheus"
-// "github.com/prometheus/client_golang/prometheus/promauto"
-// "github.com/prometheus/client_golang/prometheus/promhttp"
-// )
-//
-// func main() {
-// http.Handle("/", promhttp.InstrumentHandlerCounter(
-// promauto.NewCounterVec(
-// prometheus.CounterOpts{
-// Name: "hello_requests_total",
-// Help: "Total number of hello-world requests by HTTP code.",
-// },
-// []string{"code"},
-// ),
-// http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-// fmt.Fprint(w, "Hello, world!")
-// }),
-// ))
-// http.Handle("/metrics", promhttp.Handler())
-// http.ListenAndServe(":1971", nil)
-// }
-//
-// A Factory is created with the With(prometheus.Registerer) function, which
-// enables two usage patterns. With(prometheus.Registerer) can be called once per
-// line:
-//
-// var (
-// reg = prometheus.NewRegistry()
-// randomNumbers = promauto.With(reg).NewHistogram(prometheus.HistogramOpts{
-// Name: "random_numbers",
-// Help: "A histogram of normally distributed random numbers.",
-// Buckets: prometheus.LinearBuckets(-3, .1, 61),
-// })
-// requestCount = promauto.With(reg).NewCounterVec(
-// prometheus.CounterOpts{
-// Name: "http_requests_total",
-// Help: "Total number of HTTP requests by status code and method.",
-// },
-// []string{"code", "method"},
-// )
-// )
-//
-// Or it can be used to create a Factory once to be used multiple times:
-//
-// var (
-// reg = prometheus.NewRegistry()
-// factory = promauto.With(reg)
-// randomNumbers = factory.NewHistogram(prometheus.HistogramOpts{
-// Name: "random_numbers",
-// Help: "A histogram of normally distributed random numbers.",
-// Buckets: prometheus.LinearBuckets(-3, .1, 61),
-// })
-// requestCount = factory.NewCounterVec(
-// prometheus.CounterOpts{
-// Name: "http_requests_total",
-// Help: "Total number of HTTP requests by status code and method.",
-// },
-// []string{"code", "method"},
-// )
-// )
-//
-// This appears very handy. So why are these constructors locked away in a
-// separate package?
-//
-// The main problem is that registration may fail, e.g. if a metric inconsistent
-// with or equal to the newly to be registered one is already registered.
-// Therefore, the Register method in the prometheus.Registerer interface returns
-// an error, and the same is the case for the top-level prometheus.Register
-// function that registers with the global registry. The prometheus package also
-// provides MustRegister versions for both. They panic if the registration
-// fails, and they clearly call this out by using the Must… idiom. Panicking is
-// problematic in this case because it doesn't just happen on input provided by
-// the caller that is invalid on its own. Things are a bit more subtle here:
-// Metric creation and registration tend to be spread widely over the
-// codebase. It can easily happen that an incompatible metric is added to an
-// unrelated part of the code, and suddenly code that used to work perfectly
-// fine starts to panic (provided that the registration of the newly added
-// metric happens before the registration of the previously existing
-// metric). This may come as an even bigger surprise with the global registry,
-// where simply importing another package can trigger a panic (if the newly
-// imported package registers metrics in its init function). At least, in the
-// prometheus package, creation of metrics and other collectors is separate from
-// registration. You first create the metric, and then you decide explicitly if
-// you want to register it with a local or the global registry, and if you want
-// to handle the error or risk a panic. With the constructors in the promauto
-// package, registration is automatic, and if it fails, it will always
-// panic. Furthermore, the constructors will often be called in the var section
-// of a file, which means that panicking will happen as a side effect of merely
-// importing a package.
-//
-// A separate package allows conservative users to entirely ignore it. And
-// whoever wants to use it will do so explicitly, with an opportunity to read
-// this warning.
-//
-// Enjoy promauto responsibly!
-package promauto
-
-import "github.com/prometheus/client_golang/prometheus"
-
-// NewCounter works like the function of the same name in the prometheus package
-// but it automatically registers the Counter with the
-// prometheus.DefaultRegisterer. If the registration fails, NewCounter panics.
-func NewCounter(opts prometheus.CounterOpts) prometheus.Counter {
- return With(prometheus.DefaultRegisterer).NewCounter(opts)
-}
-
-// NewCounterVec works like the function of the same name in the prometheus
-// package but it automatically registers the CounterVec with the
-// prometheus.DefaultRegisterer. If the registration fails, NewCounterVec
-// panics.
-func NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec {
- return With(prometheus.DefaultRegisterer).NewCounterVec(opts, labelNames)
-}
-
-// NewCounterFunc works like the function of the same name in the prometheus
-// package but it automatically registers the CounterFunc with the
-// prometheus.DefaultRegisterer. If the registration fails, NewCounterFunc
-// panics.
-func NewCounterFunc(opts prometheus.CounterOpts, function func() float64) prometheus.CounterFunc {
- return With(prometheus.DefaultRegisterer).NewCounterFunc(opts, function)
-}
-
-// NewGauge works like the function of the same name in the prometheus package
-// but it automatically registers the Gauge with the
-// prometheus.DefaultRegisterer. If the registration fails, NewGauge panics.
-func NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge {
- return With(prometheus.DefaultRegisterer).NewGauge(opts)
-}
-
-// NewGaugeVec works like the function of the same name in the prometheus
-// package but it automatically registers the GaugeVec with the
-// prometheus.DefaultRegisterer. If the registration fails, NewGaugeVec panics.
-func NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec {
- return With(prometheus.DefaultRegisterer).NewGaugeVec(opts, labelNames)
-}
-
-// NewGaugeFunc works like the function of the same name in the prometheus
-// package but it automatically registers the GaugeFunc with the
-// prometheus.DefaultRegisterer. If the registration fails, NewGaugeFunc panics.
-func NewGaugeFunc(opts prometheus.GaugeOpts, function func() float64) prometheus.GaugeFunc {
- return With(prometheus.DefaultRegisterer).NewGaugeFunc(opts, function)
-}
-
-// NewSummary works like the function of the same name in the prometheus package
-// but it automatically registers the Summary with the
-// prometheus.DefaultRegisterer. If the registration fails, NewSummary panics.
-func NewSummary(opts prometheus.SummaryOpts) prometheus.Summary {
- return With(prometheus.DefaultRegisterer).NewSummary(opts)
-}
-
-// NewSummaryVec works like the function of the same name in the prometheus
-// package but it automatically registers the SummaryVec with the
-// prometheus.DefaultRegisterer. If the registration fails, NewSummaryVec
-// panics.
-func NewSummaryVec(opts prometheus.SummaryOpts, labelNames []string) *prometheus.SummaryVec {
- return With(prometheus.DefaultRegisterer).NewSummaryVec(opts, labelNames)
-}
-
-// NewHistogram works like the function of the same name in the prometheus
-// package but it automatically registers the Histogram with the
-// prometheus.DefaultRegisterer. If the registration fails, NewHistogram panics.
-func NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram {
- return With(prometheus.DefaultRegisterer).NewHistogram(opts)
-}
-
-// NewHistogramVec works like the function of the same name in the prometheus
-// package but it automatically registers the HistogramVec with the
-// prometheus.DefaultRegisterer. If the registration fails, NewHistogramVec
-// panics.
-func NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec {
- return With(prometheus.DefaultRegisterer).NewHistogramVec(opts, labelNames)
-}
-
-// NewUntypedFunc works like the function of the same name in the prometheus
-// package but it automatically registers the UntypedFunc with the
-// prometheus.DefaultRegisterer. If the registration fails, NewUntypedFunc
-// panics.
-func NewUntypedFunc(opts prometheus.UntypedOpts, function func() float64) prometheus.UntypedFunc {
- return With(prometheus.DefaultRegisterer).NewUntypedFunc(opts, function)
-}
-
-// Factory provides factory methods to create Collectors that are automatically
-// registered with a Registerer. Create a Factory with the With function,
-// providing a Registerer to auto-register created Collectors with. The zero
-// value of a Factory creates Collectors that are not registered with any
-// Registerer. All methods of the Factory panic if the registration fails.
-type Factory struct {
- r prometheus.Registerer
-}
-
-// With creates a Factory using the provided Registerer for registration of the
-// created Collectors. If the provided Registerer is nil, the returned Factory
-// creates Collectors that are not registered with any Registerer.
-func With(r prometheus.Registerer) Factory { return Factory{r} }
-
-// NewCounter works like the function of the same name in the prometheus package
-// but it automatically registers the Counter with the Factory's Registerer.
-func (f Factory) NewCounter(opts prometheus.CounterOpts) prometheus.Counter {
- c := prometheus.NewCounter(opts)
- if f.r != nil {
- f.r.MustRegister(c)
- }
- return c
-}
-
-// NewCounterVec works like the function of the same name in the prometheus
-// package but it automatically registers the CounterVec with the Factory's
-// Registerer.
-func (f Factory) NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec {
- c := prometheus.NewCounterVec(opts, labelNames)
- if f.r != nil {
- f.r.MustRegister(c)
- }
- return c
-}
-
-// NewCounterFunc works like the function of the same name in the prometheus
-// package but it automatically registers the CounterFunc with the Factory's
-// Registerer.
-func (f Factory) NewCounterFunc(opts prometheus.CounterOpts, function func() float64) prometheus.CounterFunc {
- c := prometheus.NewCounterFunc(opts, function)
- if f.r != nil {
- f.r.MustRegister(c)
- }
- return c
-}
-
-// NewGauge works like the function of the same name in the prometheus package
-// but it automatically registers the Gauge with the Factory's Registerer.
-func (f Factory) NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge {
- g := prometheus.NewGauge(opts)
- if f.r != nil {
- f.r.MustRegister(g)
- }
- return g
-}
-
-// NewGaugeVec works like the function of the same name in the prometheus
-// package but it automatically registers the GaugeVec with the Factory's
-// Registerer.
-func (f Factory) NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec {
- g := prometheus.NewGaugeVec(opts, labelNames)
- if f.r != nil {
- f.r.MustRegister(g)
- }
- return g
-}
-
-// NewGaugeFunc works like the function of the same name in the prometheus
-// package but it automatically registers the GaugeFunc with the Factory's
-// Registerer.
-func (f Factory) NewGaugeFunc(opts prometheus.GaugeOpts, function func() float64) prometheus.GaugeFunc {
- g := prometheus.NewGaugeFunc(opts, function)
- if f.r != nil {
- f.r.MustRegister(g)
- }
- return g
-}
-
-// NewSummary works like the function of the same name in the prometheus package
-// but it automatically registers the Summary with the Factory's Registerer.
-func (f Factory) NewSummary(opts prometheus.SummaryOpts) prometheus.Summary {
- s := prometheus.NewSummary(opts)
- if f.r != nil {
- f.r.MustRegister(s)
- }
- return s
-}
-
-// NewSummaryVec works like the function of the same name in the prometheus
-// package but it automatically registers the SummaryVec with the Factory's
-// Registerer.
-func (f Factory) NewSummaryVec(opts prometheus.SummaryOpts, labelNames []string) *prometheus.SummaryVec {
- s := prometheus.NewSummaryVec(opts, labelNames)
- if f.r != nil {
- f.r.MustRegister(s)
- }
- return s
-}
-
-// NewHistogram works like the function of the same name in the prometheus
-// package but it automatically registers the Histogram with the Factory's
-// Registerer.
-func (f Factory) NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram {
- h := prometheus.NewHistogram(opts)
- if f.r != nil {
- f.r.MustRegister(h)
- }
- return h
-}
-
-// NewHistogramVec works like the function of the same name in the prometheus
-// package but it automatically registers the HistogramVec with the Factory's
-// Registerer.
-func (f Factory) NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec {
- h := prometheus.NewHistogramVec(opts, labelNames)
- if f.r != nil {
- f.r.MustRegister(h)
- }
- return h
-}
-
-// NewUntypedFunc works like the function of the same name in the prometheus
-// package but it automatically registers the UntypedFunc with the Factory's
-// Registerer.
-func (f Factory) NewUntypedFunc(opts prometheus.UntypedOpts, function func() float64) prometheus.UntypedFunc {
- u := prometheus.NewUntypedFunc(opts, function)
- if f.r != nil {
- f.r.MustRegister(u)
- }
- return u
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/vendor/github.com/prometheus/client_golang/prometheus/registry.go
deleted file mode 100644
index c6fd2f5..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/registry.go
+++ /dev/null
@@ -1,1076 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "bytes"
- "errors"
- "fmt"
- "os"
- "path/filepath"
- "runtime"
- "sort"
- "strconv"
- "strings"
- "sync"
- "unicode/utf8"
-
- "github.com/prometheus/client_golang/prometheus/internal"
-
- "github.com/cespare/xxhash/v2"
- dto "github.com/prometheus/client_model/go"
- "github.com/prometheus/common/expfmt"
- "google.golang.org/protobuf/proto"
-)
-
-const (
- // Capacity for the channel to collect metrics and descriptors.
- capMetricChan = 1000
- capDescChan = 10
-)
-
-// DefaultRegisterer and DefaultGatherer are the implementations of the
-// Registerer and Gatherer interface a number of convenience functions in this
-// package act on. Initially, both variables point to the same Registry, which
-// has a process collector (currently on Linux only, see NewProcessCollector)
-// and a Go collector (see NewGoCollector, in particular the note about
-// stop-the-world implication with Go versions older than 1.9) already
-// registered. This approach to keep default instances as global state mirrors
-// the approach of other packages in the Go standard library. Note that there
-// are caveats. Change the variables with caution and only if you understand the
-// consequences. Users who want to avoid global state altogether should not use
-// the convenience functions and act on custom instances instead.
-var (
- defaultRegistry = NewRegistry()
- DefaultRegisterer Registerer = defaultRegistry
- DefaultGatherer Gatherer = defaultRegistry
-)
-
-func init() {
- MustRegister(NewProcessCollector(ProcessCollectorOpts{}))
- MustRegister(NewGoCollector())
-}
-
-// NewRegistry creates a new vanilla Registry without any Collectors
-// pre-registered.
-func NewRegistry() *Registry {
- return &Registry{
- collectorsByID: map[uint64]Collector{},
- descIDs: map[uint64]struct{}{},
- dimHashesByName: map[string]uint64{},
- }
-}
-
-// NewPedanticRegistry returns a registry that checks during collection if each
-// collected Metric is consistent with its reported Desc, and if the Desc has
-// actually been registered with the registry. Unchecked Collectors (those whose
-// Describe method does not yield any descriptors) are excluded from the check.
-//
-// Usually, a Registry will be happy as long as the union of all collected
-// Metrics is consistent and valid even if some metrics are not consistent with
-// their own Desc or a Desc provided by their registered Collector. Well-behaved
-// Collectors and Metrics will only provide consistent Descs. This Registry is
-// useful to test the implementation of Collectors and Metrics.
-func NewPedanticRegistry() *Registry {
- r := NewRegistry()
- r.pedanticChecksEnabled = true
- return r
-}
-
-// Registerer is the interface for the part of a registry in charge of
-// registering and unregistering. Users of custom registries should use
-// Registerer as type for registration purposes (rather than the Registry type
-// directly). In that way, they are free to use custom Registerer implementation
-// (e.g. for testing purposes).
-type Registerer interface {
- // Register registers a new Collector to be included in metrics
- // collection. It returns an error if the descriptors provided by the
- // Collector are invalid or if they — in combination with descriptors of
- // already registered Collectors — do not fulfill the consistency and
- // uniqueness criteria described in the documentation of metric.Desc.
- //
- // If the provided Collector is equal to a Collector already registered
- // (which includes the case of re-registering the same Collector), the
- // returned error is an instance of AlreadyRegisteredError, which
- // contains the previously registered Collector.
- //
- // A Collector whose Describe method does not yield any Desc is treated
- // as unchecked. Registration will always succeed. No check for
- // re-registering (see previous paragraph) is performed. Thus, the
- // caller is responsible for not double-registering the same unchecked
- // Collector, and for providing a Collector that will not cause
- // inconsistent metrics on collection. (This would lead to scrape
- // errors.)
- Register(Collector) error
- // MustRegister works like Register but registers any number of
- // Collectors and panics upon the first registration that causes an
- // error.
- MustRegister(...Collector)
- // Unregister unregisters the Collector that equals the Collector passed
- // in as an argument. (Two Collectors are considered equal if their
- // Describe method yields the same set of descriptors.) The function
- // returns whether a Collector was unregistered. Note that an unchecked
- // Collector cannot be unregistered (as its Describe method does not
- // yield any descriptor).
- //
- // Note that even after unregistering, it will not be possible to
- // register a new Collector that is inconsistent with the unregistered
- // Collector, e.g. a Collector collecting metrics with the same name but
- // a different help string. The rationale here is that the same registry
- // instance must only collect consistent metrics throughout its
- // lifetime.
- Unregister(Collector) bool
-}
-
-// Gatherer is the interface for the part of a registry in charge of gathering
-// the collected metrics into a number of MetricFamilies. The Gatherer interface
-// comes with the same general implication as described for the Registerer
-// interface.
-type Gatherer interface {
- // Gather calls the Collect method of the registered Collectors and then
- // gathers the collected metrics into a lexicographically sorted slice
- // of uniquely named MetricFamily protobufs. Gather ensures that the
- // returned slice is valid and self-consistent so that it can be used
- // for valid exposition. As an exception to the strict consistency
- // requirements described for metric.Desc, Gather will tolerate
- // different sets of label names for metrics of the same metric family.
- //
- // Even if an error occurs, Gather attempts to gather as many metrics as
- // possible. Hence, if a non-nil error is returned, the returned
- // MetricFamily slice could be nil (in case of a fatal error that
- // prevented any meaningful metric collection) or contain a number of
- // MetricFamily protobufs, some of which might be incomplete, and some
- // might be missing altogether. The returned error (which might be a
- // MultiError) explains the details. Note that this is mostly useful for
- // debugging purposes. If the gathered protobufs are to be used for
- // exposition in actual monitoring, it is almost always better to not
- // expose an incomplete result and instead disregard the returned
- // MetricFamily protobufs in case the returned error is non-nil.
- Gather() ([]*dto.MetricFamily, error)
-}
-
-// Register registers the provided Collector with the DefaultRegisterer.
-//
-// Register is a shortcut for DefaultRegisterer.Register(c). See there for more
-// details.
-func Register(c Collector) error {
- return DefaultRegisterer.Register(c)
-}
-
-// MustRegister registers the provided Collectors with the DefaultRegisterer and
-// panics if any error occurs.
-//
-// MustRegister is a shortcut for DefaultRegisterer.MustRegister(cs...). See
-// there for more details.
-func MustRegister(cs ...Collector) {
- DefaultRegisterer.MustRegister(cs...)
-}
-
-// Unregister removes the registration of the provided Collector from the
-// DefaultRegisterer.
-//
-// Unregister is a shortcut for DefaultRegisterer.Unregister(c). See there for
-// more details.
-func Unregister(c Collector) bool {
- return DefaultRegisterer.Unregister(c)
-}
-
-// GathererFunc turns a function into a Gatherer.
-type GathererFunc func() ([]*dto.MetricFamily, error)
-
-// Gather implements Gatherer.
-func (gf GathererFunc) Gather() ([]*dto.MetricFamily, error) {
- return gf()
-}
-
-// AlreadyRegisteredError is returned by the Register method if the Collector to
-// be registered has already been registered before, or a different Collector
-// that collects the same metrics has been registered before. Registration fails
-// in that case, but you can detect from the kind of error what has
-// happened. The error contains fields for the existing Collector and the
-// (rejected) new Collector that equals the existing one. This can be used to
-// find out if an equal Collector has been registered before and switch over to
-// using the old one, as demonstrated in the example.
-type AlreadyRegisteredError struct {
- ExistingCollector, NewCollector Collector
-}
-
-func (err AlreadyRegisteredError) Error() string {
- return "duplicate metrics collector registration attempted"
-}
-
-// MultiError is a slice of errors implementing the error interface. It is used
-// by a Gatherer to report multiple errors during MetricFamily gathering.
-type MultiError []error
-
-// Error formats the contained errors as a bullet point list, preceded by the
-// total number of errors. Note that this results in a multi-line string.
-func (errs MultiError) Error() string {
- if len(errs) == 0 {
- return ""
- }
- buf := &bytes.Buffer{}
- fmt.Fprintf(buf, "%d error(s) occurred:", len(errs))
- for _, err := range errs {
- fmt.Fprintf(buf, "\n* %s", err)
- }
- return buf.String()
-}
-
-// Append appends the provided error if it is not nil.
-func (errs *MultiError) Append(err error) {
- if err != nil {
- *errs = append(*errs, err)
- }
-}
-
-// MaybeUnwrap returns nil if len(errs) is 0. It returns the first and only
-// contained error as error if len(errs is 1). In all other cases, it returns
-// the MultiError directly. This is helpful for returning a MultiError in a way
-// that only uses the MultiError if needed.
-func (errs MultiError) MaybeUnwrap() error {
- switch len(errs) {
- case 0:
- return nil
- case 1:
- return errs[0]
- default:
- return errs
- }
-}
-
-// Registry registers Prometheus collectors, collects their metrics, and gathers
-// them into MetricFamilies for exposition. It implements Registerer, Gatherer,
-// and Collector. The zero value is not usable. Create instances with
-// NewRegistry or NewPedanticRegistry.
-//
-// Registry implements Collector to allow it to be used for creating groups of
-// metrics. See the Grouping example for how this can be done.
-type Registry struct {
- mtx sync.RWMutex
- collectorsByID map[uint64]Collector // ID is a hash of the descIDs.
- descIDs map[uint64]struct{}
- dimHashesByName map[string]uint64
- uncheckedCollectors []Collector
- pedanticChecksEnabled bool
-}
-
-// Register implements Registerer.
-func (r *Registry) Register(c Collector) error {
- var (
- descChan = make(chan *Desc, capDescChan)
- newDescIDs = map[uint64]struct{}{}
- newDimHashesByName = map[string]uint64{}
- collectorID uint64 // All desc IDs XOR'd together.
- duplicateDescErr error
- )
- go func() {
- c.Describe(descChan)
- close(descChan)
- }()
- r.mtx.Lock()
- defer func() {
- // Drain channel in case of premature return to not leak a goroutine.
- for range descChan {
- }
- r.mtx.Unlock()
- }()
- // Conduct various tests...
- for desc := range descChan {
-
- // Is the descriptor valid at all?
- if desc.err != nil {
- return fmt.Errorf("descriptor %s is invalid: %w", desc, desc.err)
- }
-
- // Is the descID unique?
- // (In other words: Is the fqName + constLabel combination unique?)
- if _, exists := r.descIDs[desc.id]; exists {
- duplicateDescErr = fmt.Errorf("descriptor %s already exists with the same fully-qualified name and const label values", desc)
- }
- // If it is not a duplicate desc in this collector, XOR it to
- // the collectorID. (We allow duplicate descs within the same
- // collector, but their existence must be a no-op.)
- if _, exists := newDescIDs[desc.id]; !exists {
- newDescIDs[desc.id] = struct{}{}
- collectorID ^= desc.id
- }
-
- // Are all the label names and the help string consistent with
- // previous descriptors of the same name?
- // First check existing descriptors...
- if dimHash, exists := r.dimHashesByName[desc.fqName]; exists {
- 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)
- }
- 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)
- }
- continue
- }
- newDimHashesByName[desc.fqName] = desc.dimHash
- }
- // A Collector yielding no Desc at all is considered unchecked.
- if len(newDescIDs) == 0 {
- r.uncheckedCollectors = append(r.uncheckedCollectors, c)
- return nil
- }
- if existing, exists := r.collectorsByID[collectorID]; exists {
- switch e := existing.(type) {
- case *wrappingCollector:
- return AlreadyRegisteredError{
- ExistingCollector: e.unwrapRecursively(),
- NewCollector: c,
- }
- default:
- return AlreadyRegisteredError{
- ExistingCollector: e,
- NewCollector: c,
- }
- }
- }
- // If the collectorID is new, but at least one of the descs existed
- // before, we are in trouble.
- if duplicateDescErr != nil {
- return duplicateDescErr
- }
-
- // Only after all tests have passed, actually register.
- r.collectorsByID[collectorID] = c
- for hash := range newDescIDs {
- r.descIDs[hash] = struct{}{}
- }
- for name, dimHash := range newDimHashesByName {
- r.dimHashesByName[name] = dimHash
- }
- return nil
-}
-
-// Unregister implements Registerer.
-func (r *Registry) Unregister(c Collector) bool {
- var (
- descChan = make(chan *Desc, capDescChan)
- descIDs = map[uint64]struct{}{}
- collectorID uint64 // All desc IDs XOR'd together.
- )
- go func() {
- c.Describe(descChan)
- close(descChan)
- }()
- for desc := range descChan {
- if _, exists := descIDs[desc.id]; !exists {
- collectorID ^= desc.id
- descIDs[desc.id] = struct{}{}
- }
- }
-
- r.mtx.RLock()
- if _, exists := r.collectorsByID[collectorID]; !exists {
- r.mtx.RUnlock()
- return false
- }
- r.mtx.RUnlock()
-
- r.mtx.Lock()
- defer r.mtx.Unlock()
-
- delete(r.collectorsByID, collectorID)
- for id := range descIDs {
- delete(r.descIDs, id)
- }
- // dimHashesByName is left untouched as those must be consistent
- // throughout the lifetime of a program.
- return true
-}
-
-// MustRegister implements Registerer.
-func (r *Registry) MustRegister(cs ...Collector) {
- for _, c := range cs {
- if err := r.Register(c); err != nil {
- panic(err)
- }
- }
-}
-
-// Gather implements Gatherer.
-func (r *Registry) Gather() ([]*dto.MetricFamily, error) {
- r.mtx.RLock()
-
- if len(r.collectorsByID) == 0 && len(r.uncheckedCollectors) == 0 {
- // Fast path.
- r.mtx.RUnlock()
- return nil, nil
- }
-
- var (
- checkedMetricChan = make(chan Metric, capMetricChan)
- uncheckedMetricChan = make(chan Metric, capMetricChan)
- metricHashes = map[uint64]struct{}{}
- wg sync.WaitGroup
- errs MultiError // The collected errors to return in the end.
- registeredDescIDs map[uint64]struct{} // Only used for pedantic checks
- )
-
- goroutineBudget := len(r.collectorsByID) + len(r.uncheckedCollectors)
- metricFamiliesByName := make(map[string]*dto.MetricFamily, len(r.dimHashesByName))
- checkedCollectors := make(chan Collector, len(r.collectorsByID))
- uncheckedCollectors := make(chan Collector, len(r.uncheckedCollectors))
- for _, collector := range r.collectorsByID {
- checkedCollectors <- collector
- }
- for _, collector := range r.uncheckedCollectors {
- uncheckedCollectors <- collector
- }
- // In case pedantic checks are enabled, we have to copy the map before
- // giving up the RLock.
- if r.pedanticChecksEnabled {
- registeredDescIDs = make(map[uint64]struct{}, len(r.descIDs))
- for id := range r.descIDs {
- registeredDescIDs[id] = struct{}{}
- }
- }
- r.mtx.RUnlock()
-
- wg.Add(goroutineBudget)
-
- collectWorker := func() {
- for {
- select {
- case collector := <-checkedCollectors:
- collector.Collect(checkedMetricChan)
- case collector := <-uncheckedCollectors:
- collector.Collect(uncheckedMetricChan)
- default:
- return
- }
- wg.Done()
- }
- }
-
- // Start the first worker now to make sure at least one is running.
- go collectWorker()
- goroutineBudget--
-
- // Close checkedMetricChan and uncheckedMetricChan once all collectors
- // are collected.
- go func() {
- wg.Wait()
- close(checkedMetricChan)
- close(uncheckedMetricChan)
- }()
-
- // Drain checkedMetricChan and uncheckedMetricChan in case of premature return.
- defer func() {
- if checkedMetricChan != nil {
- for range checkedMetricChan {
- }
- }
- if uncheckedMetricChan != nil {
- for range uncheckedMetricChan {
- }
- }
- }()
-
- // Copy the channel references so we can nil them out later to remove
- // them from the select statements below.
- cmc := checkedMetricChan
- umc := uncheckedMetricChan
-
- for {
- select {
- case metric, ok := <-cmc:
- if !ok {
- cmc = nil
- break
- }
- errs.Append(processMetric(
- metric, metricFamiliesByName,
- metricHashes,
- registeredDescIDs,
- ))
- case metric, ok := <-umc:
- if !ok {
- umc = nil
- break
- }
- errs.Append(processMetric(
- metric, metricFamiliesByName,
- metricHashes,
- nil,
- ))
- default:
- if goroutineBudget <= 0 || len(checkedCollectors)+len(uncheckedCollectors) == 0 {
- // All collectors are already being worked on or
- // we have already as many goroutines started as
- // there are collectors. Do the same as above,
- // just without the default.
- select {
- case metric, ok := <-cmc:
- if !ok {
- cmc = nil
- break
- }
- errs.Append(processMetric(
- metric, metricFamiliesByName,
- metricHashes,
- registeredDescIDs,
- ))
- case metric, ok := <-umc:
- if !ok {
- umc = nil
- break
- }
- errs.Append(processMetric(
- metric, metricFamiliesByName,
- metricHashes,
- nil,
- ))
- }
- break
- }
- // Start more workers.
- go collectWorker()
- goroutineBudget--
- runtime.Gosched()
- }
- // Once both checkedMetricChan and uncheckedMetricChan are closed
- // and drained, the contraption above will nil out cmc and umc,
- // and then we can leave the collect loop here.
- if cmc == nil && umc == nil {
- break
- }
- }
- return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap()
-}
-
-// Describe implements Collector.
-func (r *Registry) Describe(ch chan<- *Desc) {
- r.mtx.RLock()
- defer r.mtx.RUnlock()
-
- // Only report the checked Collectors; unchecked collectors don't report any
- // Desc.
- for _, c := range r.collectorsByID {
- c.Describe(ch)
- }
-}
-
-// Collect implements Collector.
-func (r *Registry) Collect(ch chan<- Metric) {
- r.mtx.RLock()
- defer r.mtx.RUnlock()
-
- for _, c := range r.collectorsByID {
- c.Collect(ch)
- }
- for _, c := range r.uncheckedCollectors {
- c.Collect(ch)
- }
-}
-
-// WriteToTextfile calls Gather on the provided Gatherer, encodes the result in the
-// Prometheus text format, and writes it to a temporary file. Upon success, the
-// temporary file is renamed to the provided filename.
-//
-// This is intended for use with the textfile collector of the node exporter.
-// Note that the node exporter expects the filename to be suffixed with ".prom".
-func WriteToTextfile(filename string, g Gatherer) error {
- tmp, err := os.CreateTemp(filepath.Dir(filename), filepath.Base(filename))
- if err != nil {
- return err
- }
- defer os.Remove(tmp.Name())
-
- mfs, err := g.Gather()
- if err != nil {
- return err
- }
- for _, mf := range mfs {
- if _, err := expfmt.MetricFamilyToText(tmp, mf); err != nil {
- return err
- }
- }
- if err := tmp.Close(); err != nil {
- return err
- }
-
- if err := os.Chmod(tmp.Name(), 0o644); err != nil {
- return err
- }
- return os.Rename(tmp.Name(), filename)
-}
-
-// processMetric is an internal helper method only used by the Gather method.
-func processMetric(
- metric Metric,
- metricFamiliesByName map[string]*dto.MetricFamily,
- metricHashes map[uint64]struct{},
- registeredDescIDs map[uint64]struct{},
-) error {
- desc := metric.Desc()
- // Wrapped metrics collected by an unchecked Collector can have an
- // invalid Desc.
- if desc.err != nil {
- return desc.err
- }
- dtoMetric := &dto.Metric{}
- if err := metric.Write(dtoMetric); err != nil {
- return fmt.Errorf("error collecting metric %v: %w", desc, err)
- }
- metricFamily, ok := metricFamiliesByName[desc.fqName]
- if ok { // Existing name.
- if metricFamily.GetHelp() != desc.help {
- return fmt.Errorf(
- "collected metric %s %s has help %q but should have %q",
- desc.fqName, dtoMetric, desc.help, metricFamily.GetHelp(),
- )
- }
- // TODO(beorn7): Simplify switch once Desc has type.
- switch metricFamily.GetType() {
- case dto.MetricType_COUNTER:
- if dtoMetric.Counter == nil {
- return fmt.Errorf(
- "collected metric %s %s should be a Counter",
- desc.fqName, dtoMetric,
- )
- }
- case dto.MetricType_GAUGE:
- if dtoMetric.Gauge == nil {
- return fmt.Errorf(
- "collected metric %s %s should be a Gauge",
- desc.fqName, dtoMetric,
- )
- }
- case dto.MetricType_SUMMARY:
- if dtoMetric.Summary == nil {
- return fmt.Errorf(
- "collected metric %s %s should be a Summary",
- desc.fqName, dtoMetric,
- )
- }
- case dto.MetricType_UNTYPED:
- if dtoMetric.Untyped == nil {
- return fmt.Errorf(
- "collected metric %s %s should be Untyped",
- desc.fqName, dtoMetric,
- )
- }
- case dto.MetricType_HISTOGRAM:
- if dtoMetric.Histogram == nil {
- return fmt.Errorf(
- "collected metric %s %s should be a Histogram",
- desc.fqName, dtoMetric,
- )
- }
- default:
- panic("encountered MetricFamily with invalid type")
- }
- } else { // New name.
- metricFamily = &dto.MetricFamily{}
- metricFamily.Name = proto.String(desc.fqName)
- metricFamily.Help = proto.String(desc.help)
- // TODO(beorn7): Simplify switch once Desc has type.
- switch {
- case dtoMetric.Gauge != nil:
- metricFamily.Type = dto.MetricType_GAUGE.Enum()
- case dtoMetric.Counter != nil:
- metricFamily.Type = dto.MetricType_COUNTER.Enum()
- case dtoMetric.Summary != nil:
- metricFamily.Type = dto.MetricType_SUMMARY.Enum()
- case dtoMetric.Untyped != nil:
- metricFamily.Type = dto.MetricType_UNTYPED.Enum()
- case dtoMetric.Histogram != nil:
- metricFamily.Type = dto.MetricType_HISTOGRAM.Enum()
- default:
- return fmt.Errorf("empty metric collected: %s", dtoMetric)
- }
- if err := checkSuffixCollisions(metricFamily, metricFamiliesByName); err != nil {
- return err
- }
- metricFamiliesByName[desc.fqName] = metricFamily
- }
- if err := checkMetricConsistency(metricFamily, dtoMetric, metricHashes); err != nil {
- return err
- }
- if registeredDescIDs != nil {
- // Is the desc registered at all?
- if _, exist := registeredDescIDs[desc.id]; !exist {
- return fmt.Errorf(
- "collected metric %s %s with unregistered descriptor %s",
- metricFamily.GetName(), dtoMetric, desc,
- )
- }
- if err := checkDescConsistency(metricFamily, dtoMetric, desc); err != nil {
- return err
- }
- }
- metricFamily.Metric = append(metricFamily.Metric, dtoMetric)
- return nil
-}
-
-// Gatherers is a slice of Gatherer instances that implements the Gatherer
-// interface itself. Its Gather method calls Gather on all Gatherers in the
-// slice in order and returns the merged results. Errors returned from the
-// Gather calls are all returned in a flattened MultiError. Duplicate and
-// inconsistent Metrics are skipped (first occurrence in slice order wins) and
-// reported in the returned error.
-//
-// Gatherers can be used to merge the Gather results from multiple
-// Registries. It also provides a way to directly inject existing MetricFamily
-// protobufs into the gathering by creating a custom Gatherer with a Gather
-// method that simply returns the existing MetricFamily protobufs. Note that no
-// registration is involved (in contrast to Collector registration), so
-// obviously registration-time checks cannot happen. Any inconsistencies between
-// the gathered MetricFamilies are reported as errors by the Gather method, and
-// inconsistent Metrics are dropped. Invalid parts of the MetricFamilies
-// (e.g. syntactically invalid metric or label names) will go undetected.
-type Gatherers []Gatherer
-
-// Gather implements Gatherer.
-func (gs Gatherers) Gather() ([]*dto.MetricFamily, error) {
- var (
- metricFamiliesByName = map[string]*dto.MetricFamily{}
- metricHashes = map[uint64]struct{}{}
- errs MultiError // The collected errors to return in the end.
- )
-
- for i, g := range gs {
- mfs, err := g.Gather()
- if err != nil {
- multiErr := MultiError{}
- if errors.As(err, &multiErr) {
- for _, err := range multiErr {
- errs = append(errs, fmt.Errorf("[from Gatherer #%d] %w", i+1, err))
- }
- } else {
- errs = append(errs, fmt.Errorf("[from Gatherer #%d] %w", i+1, err))
- }
- }
- for _, mf := range mfs {
- existingMF, exists := metricFamiliesByName[mf.GetName()]
- if exists {
- if existingMF.GetHelp() != mf.GetHelp() {
- errs = append(errs, fmt.Errorf(
- "gathered metric family %s has help %q but should have %q",
- mf.GetName(), mf.GetHelp(), existingMF.GetHelp(),
- ))
- continue
- }
- if existingMF.GetType() != mf.GetType() {
- errs = append(errs, fmt.Errorf(
- "gathered metric family %s has type %s but should have %s",
- mf.GetName(), mf.GetType(), existingMF.GetType(),
- ))
- continue
- }
- } else {
- existingMF = &dto.MetricFamily{}
- existingMF.Name = mf.Name
- existingMF.Help = mf.Help
- existingMF.Type = mf.Type
- if err := checkSuffixCollisions(existingMF, metricFamiliesByName); err != nil {
- errs = append(errs, err)
- continue
- }
- metricFamiliesByName[mf.GetName()] = existingMF
- }
- for _, m := range mf.Metric {
- if err := checkMetricConsistency(existingMF, m, metricHashes); err != nil {
- errs = append(errs, err)
- continue
- }
- existingMF.Metric = append(existingMF.Metric, m)
- }
- }
- }
- return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap()
-}
-
-// checkSuffixCollisions checks for collisions with the “magic” suffixes the
-// Prometheus text format and the internal metric representation of the
-// Prometheus server add while flattening Summaries and Histograms.
-func checkSuffixCollisions(mf *dto.MetricFamily, mfs map[string]*dto.MetricFamily) error {
- var (
- newName = mf.GetName()
- newType = mf.GetType()
- newNameWithoutSuffix = ""
- )
- switch {
- case strings.HasSuffix(newName, "_count"):
- newNameWithoutSuffix = newName[:len(newName)-6]
- case strings.HasSuffix(newName, "_sum"):
- newNameWithoutSuffix = newName[:len(newName)-4]
- case strings.HasSuffix(newName, "_bucket"):
- newNameWithoutSuffix = newName[:len(newName)-7]
- }
- if newNameWithoutSuffix != "" {
- if existingMF, ok := mfs[newNameWithoutSuffix]; ok {
- switch existingMF.GetType() {
- case dto.MetricType_SUMMARY:
- if !strings.HasSuffix(newName, "_bucket") {
- return fmt.Errorf(
- "collected metric named %q collides with previously collected summary named %q",
- newName, newNameWithoutSuffix,
- )
- }
- case dto.MetricType_HISTOGRAM:
- return fmt.Errorf(
- "collected metric named %q collides with previously collected histogram named %q",
- newName, newNameWithoutSuffix,
- )
- }
- }
- }
- if newType == dto.MetricType_SUMMARY || newType == dto.MetricType_HISTOGRAM {
- if _, ok := mfs[newName+"_count"]; ok {
- return fmt.Errorf(
- "collected histogram or summary named %q collides with previously collected metric named %q",
- newName, newName+"_count",
- )
- }
- if _, ok := mfs[newName+"_sum"]; ok {
- return fmt.Errorf(
- "collected histogram or summary named %q collides with previously collected metric named %q",
- newName, newName+"_sum",
- )
- }
- }
- if newType == dto.MetricType_HISTOGRAM {
- if _, ok := mfs[newName+"_bucket"]; ok {
- return fmt.Errorf(
- "collected histogram named %q collides with previously collected metric named %q",
- newName, newName+"_bucket",
- )
- }
- }
- return nil
-}
-
-// checkMetricConsistency checks if the provided Metric is consistent with the
-// provided MetricFamily. It also hashes the Metric labels and the MetricFamily
-// name. If the resulting hash is already in the provided metricHashes, an error
-// is returned. If not, it is added to metricHashes.
-func checkMetricConsistency(
- metricFamily *dto.MetricFamily,
- dtoMetric *dto.Metric,
- metricHashes map[uint64]struct{},
-) error {
- name := metricFamily.GetName()
-
- // Type consistency with metric family.
- if metricFamily.GetType() == dto.MetricType_GAUGE && dtoMetric.Gauge == nil ||
- metricFamily.GetType() == dto.MetricType_COUNTER && dtoMetric.Counter == nil ||
- metricFamily.GetType() == dto.MetricType_SUMMARY && dtoMetric.Summary == nil ||
- metricFamily.GetType() == dto.MetricType_HISTOGRAM && dtoMetric.Histogram == nil ||
- metricFamily.GetType() == dto.MetricType_UNTYPED && dtoMetric.Untyped == nil {
- return fmt.Errorf(
- "collected metric %q { %s} is not a %s",
- name, dtoMetric, metricFamily.GetType(),
- )
- }
-
- previousLabelName := ""
- for _, labelPair := range dtoMetric.GetLabel() {
- labelName := labelPair.GetName()
- if labelName == previousLabelName {
- return fmt.Errorf(
- "collected metric %q { %s} has two or more labels with the same name: %s",
- name, dtoMetric, labelName,
- )
- }
- if !checkLabelName(labelName) {
- return fmt.Errorf(
- "collected metric %q { %s} has a label with an invalid name: %s",
- name, dtoMetric, labelName,
- )
- }
- if dtoMetric.Summary != nil && labelName == quantileLabel {
- return fmt.Errorf(
- "collected metric %q { %s} must not have an explicit %q label",
- name, dtoMetric, quantileLabel,
- )
- }
- if !utf8.ValidString(labelPair.GetValue()) {
- return fmt.Errorf(
- "collected metric %q { %s} has a label named %q whose value is not utf8: %#v",
- name, dtoMetric, labelName, labelPair.GetValue())
- }
- previousLabelName = labelName
- }
-
- // Is the metric unique (i.e. no other metric with the same name and the same labels)?
- h := xxhash.New()
- h.WriteString(name)
- h.Write(separatorByteSlice)
- // Make sure label pairs are sorted. We depend on it for the consistency
- // check.
- if !sort.IsSorted(internal.LabelPairSorter(dtoMetric.Label)) {
- // We cannot sort dtoMetric.Label in place as it is immutable by contract.
- copiedLabels := make([]*dto.LabelPair, len(dtoMetric.Label))
- copy(copiedLabels, dtoMetric.Label)
- sort.Sort(internal.LabelPairSorter(copiedLabels))
- dtoMetric.Label = copiedLabels
- }
- for _, lp := range dtoMetric.Label {
- h.WriteString(lp.GetName())
- h.Write(separatorByteSlice)
- h.WriteString(lp.GetValue())
- h.Write(separatorByteSlice)
- }
- if dtoMetric.TimestampMs != nil {
- h.WriteString(strconv.FormatInt(*(dtoMetric.TimestampMs), 10))
- h.Write(separatorByteSlice)
- }
- hSum := h.Sum64()
- if _, exists := metricHashes[hSum]; exists {
- return fmt.Errorf(
- "collected metric %q { %s} was collected before with the same name and label values",
- name, dtoMetric,
- )
- }
- metricHashes[hSum] = struct{}{}
- return nil
-}
-
-func checkDescConsistency(
- metricFamily *dto.MetricFamily,
- dtoMetric *dto.Metric,
- desc *Desc,
-) error {
- // Desc help consistency with metric family help.
- if metricFamily.GetHelp() != desc.help {
- return fmt.Errorf(
- "collected metric %s %s has help %q but should have %q",
- metricFamily.GetName(), dtoMetric, metricFamily.GetHelp(), desc.help,
- )
- }
-
- // Is the desc consistent with the content of the metric?
- lpsFromDesc := make([]*dto.LabelPair, len(desc.constLabelPairs), len(dtoMetric.Label))
- copy(lpsFromDesc, desc.constLabelPairs)
- for _, l := range desc.variableLabels.names {
- lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{
- Name: proto.String(l),
- })
- }
- if len(lpsFromDesc) != len(dtoMetric.Label) {
- return fmt.Errorf(
- "labels in collected metric %s %s are inconsistent with descriptor %s",
- metricFamily.GetName(), dtoMetric, desc,
- )
- }
- sort.Sort(internal.LabelPairSorter(lpsFromDesc))
- for i, lpFromDesc := range lpsFromDesc {
- lpFromMetric := dtoMetric.Label[i]
- if lpFromDesc.GetName() != lpFromMetric.GetName() ||
- lpFromDesc.Value != nil && lpFromDesc.GetValue() != lpFromMetric.GetValue() {
- return fmt.Errorf(
- "labels in collected metric %s %s are inconsistent with descriptor %s",
- metricFamily.GetName(), dtoMetric, desc,
- )
- }
- }
- return nil
-}
-
-var _ TransactionalGatherer = &MultiTRegistry{}
-
-// MultiTRegistry is a TransactionalGatherer that joins gathered metrics from multiple
-// transactional gatherers.
-//
-// It is caller responsibility to ensure two registries have mutually exclusive metric families,
-// no deduplication will happen.
-type MultiTRegistry struct {
- tGatherers []TransactionalGatherer
-}
-
-// NewMultiTRegistry creates MultiTRegistry.
-func NewMultiTRegistry(tGatherers ...TransactionalGatherer) *MultiTRegistry {
- return &MultiTRegistry{
- tGatherers: tGatherers,
- }
-}
-
-// Gather implements TransactionalGatherer interface.
-func (r *MultiTRegistry) Gather() (mfs []*dto.MetricFamily, done func(), err error) {
- errs := MultiError{}
-
- dFns := make([]func(), 0, len(r.tGatherers))
- // TODO(bwplotka): Implement concurrency for those?
- for _, g := range r.tGatherers {
- // TODO(bwplotka): Check for duplicates?
- m, d, err := g.Gather()
- errs.Append(err)
-
- mfs = append(mfs, m...)
- dFns = append(dFns, d)
- }
-
- // TODO(bwplotka): Consider sort in place, given metric family in gather is sorted already.
- sort.Slice(mfs, func(i, j int) bool {
- return *mfs[i].Name < *mfs[j].Name
- })
- return mfs, func() {
- for _, d := range dFns {
- d()
- }
- }, errs.MaybeUnwrap()
-}
-
-// TransactionalGatherer represents transactional gatherer that can be triggered to notify gatherer that memory
-// used by metric family is no longer used by a caller. This allows implementations with cache.
-type TransactionalGatherer interface {
- // Gather returns metrics in a lexicographically sorted slice
- // of uniquely named MetricFamily protobufs. Gather ensures that the
- // returned slice is valid and self-consistent so that it can be used
- // for valid exposition. As an exception to the strict consistency
- // requirements described for metric.Desc, Gather will tolerate
- // different sets of label names for metrics of the same metric family.
- //
- // Even if an error occurs, Gather attempts to gather as many metrics as
- // possible. Hence, if a non-nil error is returned, the returned
- // MetricFamily slice could be nil (in case of a fatal error that
- // prevented any meaningful metric collection) or contain a number of
- // MetricFamily protobufs, some of which might be incomplete, and some
- // might be missing altogether. The returned error (which might be a
- // MultiError) explains the details. Note that this is mostly useful for
- // debugging purposes. If the gathered protobufs are to be used for
- // exposition in actual monitoring, it is almost always better to not
- // expose an incomplete result and instead disregard the returned
- // MetricFamily protobufs in case the returned error is non-nil.
- //
- // Important: done is expected to be triggered (even if the error occurs!)
- // once caller does not need returned slice of dto.MetricFamily.
- Gather() (_ []*dto.MetricFamily, done func(), err error)
-}
-
-// ToTransactionalGatherer transforms Gatherer to transactional one with noop as done function.
-func ToTransactionalGatherer(g Gatherer) TransactionalGatherer {
- return &noTransactionGatherer{g: g}
-}
-
-type noTransactionGatherer struct {
- g Gatherer
-}
-
-// Gather implements TransactionalGatherer interface.
-func (g *noTransactionGatherer) Gather() (_ []*dto.MetricFamily, done func(), err error) {
- mfs, err := g.g.Gather()
- return mfs, func() {}, err
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/summary.go b/vendor/github.com/prometheus/client_golang/prometheus/summary.go
deleted file mode 100644
index 1ab0e47..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/summary.go
+++ /dev/null
@@ -1,827 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "fmt"
- "math"
- "runtime"
- "sort"
- "sync"
- "sync/atomic"
- "time"
-
- dto "github.com/prometheus/client_model/go"
-
- "github.com/beorn7/perks/quantile"
- "google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/types/known/timestamppb"
-)
-
-// quantileLabel is used for the label that defines the quantile in a
-// summary.
-const quantileLabel = "quantile"
-
-// A Summary captures individual observations from an event or sample stream and
-// summarizes them in a manner similar to traditional summary statistics: 1. sum
-// of observations, 2. observation count, 3. rank estimations.
-//
-// A typical use-case is the observation of request latencies. By default, a
-// Summary provides the median, the 90th and the 99th percentile of the latency
-// as rank estimations. However, the default behavior will change in the
-// upcoming v1.0.0 of the library. There will be no rank estimations at all by
-// default. For a sane transition, it is recommended to set the desired rank
-// estimations explicitly.
-//
-// Note that the rank estimations cannot be aggregated in a meaningful way with
-// the Prometheus query language (i.e. you cannot average or add them). If you
-// need aggregatable quantiles (e.g. you want the 99th percentile latency of all
-// queries served across all instances of a service), consider the Histogram
-// metric type. See the Prometheus documentation for more details.
-//
-// To create Summary instances, use NewSummary.
-type Summary interface {
- Metric
- Collector
-
- // Observe adds a single observation to the summary. Observations are
- // usually positive or zero. Negative observations are accepted but
- // prevent current versions of Prometheus from properly detecting
- // counter resets in the sum of observations. See
- // https://prometheus.io/docs/practices/histograms/#count-and-sum-of-observations
- // for details.
- Observe(float64)
-}
-
-var errQuantileLabelNotAllowed = fmt.Errorf(
- "%q is not allowed as label name in summaries", quantileLabel,
-)
-
-// Default values for SummaryOpts.
-const (
- // DefMaxAge is the default duration for which observations stay
- // relevant.
- DefMaxAge time.Duration = 10 * time.Minute
- // DefAgeBuckets is the default number of buckets used to calculate the
- // age of observations.
- DefAgeBuckets = 5
- // DefBufCap is the standard buffer size for collecting Summary observations.
- DefBufCap = 500
-)
-
-// SummaryOpts bundles the options for creating a Summary metric. It is
-// mandatory to set Name to a non-empty string. While all other fields are
-// optional and can safely be left at their zero value, it is recommended to set
-// a help string and to explicitly set the Objectives field to the desired value
-// as the default value will change in the upcoming v1.0.0 of the library.
-type SummaryOpts struct {
- // Namespace, Subsystem, and Name are components of the fully-qualified
- // name of the Summary (created by joining these components with
- // "_"). Only Name is mandatory, the others merely help structuring the
- // name. Note that the fully-qualified name of the Summary must be a
- // valid Prometheus metric name.
- Namespace string
- Subsystem string
- Name string
-
- // Help provides information about this Summary.
- //
- // Metrics with the same fully-qualified name must have the same Help
- // string.
- Help string
-
- // ConstLabels are used to attach fixed labels to this metric. Metrics
- // with the same fully-qualified name must have the same label names in
- // their ConstLabels.
- //
- // Due to the way a Summary is represented in the Prometheus text format
- // and how it is handled by the Prometheus server internally, “quantile”
- // is an illegal label name. Construction of a Summary or SummaryVec
- // will panic if this label name is used in ConstLabels.
- //
- // ConstLabels are only used rarely. In particular, do not use them to
- // attach the same labels to all your metrics. Those use cases are
- // better covered by target labels set by the scraping Prometheus
- // server, or by one specific metric (e.g. a build_info or a
- // machine_role metric). See also
- // https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels
- ConstLabels Labels
-
- // Objectives defines the quantile rank estimates with their respective
- // absolute error. If Objectives[q] = e, then the value reported for q
- // will be the φ-quantile value for some φ between q-e and q+e. The
- // default value is an empty map, resulting in a summary without
- // quantiles.
- Objectives map[float64]float64
-
- // MaxAge defines the duration for which an observation stays relevant
- // for the summary. Only applies to pre-calculated quantiles, does not
- // apply to _sum and _count. Must be positive. The default value is
- // DefMaxAge.
- MaxAge time.Duration
-
- // AgeBuckets is the number of buckets used to exclude observations that
- // are older than MaxAge from the summary. A higher number has a
- // resource penalty, so only increase it if the higher resolution is
- // really required. For very high observation rates, you might want to
- // reduce the number of age buckets. With only one age bucket, you will
- // effectively see a complete reset of the summary each time MaxAge has
- // passed. The default value is DefAgeBuckets.
- AgeBuckets uint32
-
- // BufCap defines the default sample stream buffer size. The default
- // value of DefBufCap should suffice for most uses. If there is a need
- // to increase the value, a multiple of 500 is recommended (because that
- // is the internal buffer size of the underlying package
- // "github.com/bmizerany/perks/quantile").
- BufCap uint32
-
- // now is for testing purposes, by default it's time.Now.
- now func() time.Time
-}
-
-// SummaryVecOpts bundles the options to create a SummaryVec metric.
-// It is mandatory to set SummaryOpts, see there for mandatory fields. VariableLabels
-// is optional and can safely be left to its default value.
-type SummaryVecOpts struct {
- SummaryOpts
-
- // VariableLabels are used to partition the metric vector by the given set
- // of labels. Each label value will be constrained with the optional Constraint
- // function, if provided.
- VariableLabels ConstrainableLabels
-}
-
-// Problem with the sliding-window decay algorithm... The Merge method of
-// perk/quantile is actually not working as advertised - and it might be
-// unfixable, as the underlying algorithm is apparently not capable of merging
-// summaries in the first place. To avoid using Merge, we are currently adding
-// observations to _each_ age bucket, i.e. the effort to add a sample is
-// essentially multiplied by the number of age buckets. When rotating age
-// buckets, we empty the previous head stream. On scrape time, we simply take
-// the quantiles from the head stream (no merging required). Result: More effort
-// on observation time, less effort on scrape time, which is exactly the
-// opposite of what we try to accomplish, but at least the results are correct.
-//
-// The quite elegant previous contraption to merge the age buckets efficiently
-// on scrape time (see code up commit 6b9530d72ea715f0ba612c0120e6e09fbf1d49d0)
-// can't be used anymore.
-
-// NewSummary creates a new Summary based on the provided SummaryOpts.
-func NewSummary(opts SummaryOpts) Summary {
- return newSummary(
- NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- nil,
- opts.ConstLabels,
- ),
- opts,
- )
-}
-
-func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
- if len(desc.variableLabels.names) != len(labelValues) {
- panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.names, labelValues))
- }
-
- for _, n := range desc.variableLabels.names {
- if n == quantileLabel {
- panic(errQuantileLabelNotAllowed)
- }
- }
- for _, lp := range desc.constLabelPairs {
- if lp.GetName() == quantileLabel {
- panic(errQuantileLabelNotAllowed)
- }
- }
-
- if opts.Objectives == nil {
- opts.Objectives = map[float64]float64{}
- }
-
- if opts.MaxAge < 0 {
- panic(fmt.Errorf("illegal max age MaxAge=%v", opts.MaxAge))
- }
- if opts.MaxAge == 0 {
- opts.MaxAge = DefMaxAge
- }
-
- if opts.AgeBuckets == 0 {
- opts.AgeBuckets = DefAgeBuckets
- }
-
- if opts.BufCap == 0 {
- opts.BufCap = DefBufCap
- }
-
- if opts.now == nil {
- opts.now = time.Now
- }
- if len(opts.Objectives) == 0 {
- // Use the lock-free implementation of a Summary without objectives.
- s := &noObjectivesSummary{
- desc: desc,
- labelPairs: MakeLabelPairs(desc, labelValues),
- counts: [2]*summaryCounts{{}, {}},
- }
- s.init(s) // Init self-collection.
- s.createdTs = timestamppb.New(opts.now())
- return s
- }
-
- s := &summary{
- desc: desc,
-
- objectives: opts.Objectives,
- sortedObjectives: make([]float64, 0, len(opts.Objectives)),
-
- labelPairs: MakeLabelPairs(desc, labelValues),
-
- hotBuf: make([]float64, 0, opts.BufCap),
- coldBuf: make([]float64, 0, opts.BufCap),
- streamDuration: opts.MaxAge / time.Duration(opts.AgeBuckets),
- }
- s.headStreamExpTime = opts.now().Add(s.streamDuration)
- s.hotBufExpTime = s.headStreamExpTime
-
- for i := uint32(0); i < opts.AgeBuckets; i++ {
- s.streams = append(s.streams, s.newStream())
- }
- s.headStream = s.streams[0]
-
- for qu := range s.objectives {
- s.sortedObjectives = append(s.sortedObjectives, qu)
- }
- sort.Float64s(s.sortedObjectives)
-
- s.init(s) // Init self-collection.
- s.createdTs = timestamppb.New(opts.now())
- return s
-}
-
-type summary struct {
- selfCollector
-
- bufMtx sync.Mutex // Protects hotBuf and hotBufExpTime.
- mtx sync.Mutex // Protects every other moving part.
- // Lock bufMtx before mtx if both are needed.
-
- desc *Desc
-
- objectives map[float64]float64
- sortedObjectives []float64
-
- labelPairs []*dto.LabelPair
-
- sum float64
- cnt uint64
-
- hotBuf, coldBuf []float64
-
- streams []*quantile.Stream
- streamDuration time.Duration
- headStream *quantile.Stream
- headStreamIdx int
- headStreamExpTime, hotBufExpTime time.Time
-
- createdTs *timestamppb.Timestamp
-}
-
-func (s *summary) Desc() *Desc {
- return s.desc
-}
-
-func (s *summary) Observe(v float64) {
- s.bufMtx.Lock()
- defer s.bufMtx.Unlock()
-
- now := time.Now()
- if now.After(s.hotBufExpTime) {
- s.asyncFlush(now)
- }
- s.hotBuf = append(s.hotBuf, v)
- if len(s.hotBuf) == cap(s.hotBuf) {
- s.asyncFlush(now)
- }
-}
-
-func (s *summary) Write(out *dto.Metric) error {
- sum := &dto.Summary{
- CreatedTimestamp: s.createdTs,
- }
- qs := make([]*dto.Quantile, 0, len(s.objectives))
-
- s.bufMtx.Lock()
- s.mtx.Lock()
- // Swap bufs even if hotBuf is empty to set new hotBufExpTime.
- s.swapBufs(time.Now())
- s.bufMtx.Unlock()
-
- s.flushColdBuf()
- sum.SampleCount = proto.Uint64(s.cnt)
- sum.SampleSum = proto.Float64(s.sum)
-
- for _, rank := range s.sortedObjectives {
- var q float64
- if s.headStream.Count() == 0 {
- q = math.NaN()
- } else {
- q = s.headStream.Query(rank)
- }
- qs = append(qs, &dto.Quantile{
- Quantile: proto.Float64(rank),
- Value: proto.Float64(q),
- })
- }
-
- s.mtx.Unlock()
-
- if len(qs) > 0 {
- sort.Sort(quantSort(qs))
- }
- sum.Quantile = qs
-
- out.Summary = sum
- out.Label = s.labelPairs
- return nil
-}
-
-func (s *summary) newStream() *quantile.Stream {
- return quantile.NewTargeted(s.objectives)
-}
-
-// asyncFlush needs bufMtx locked.
-func (s *summary) asyncFlush(now time.Time) {
- s.mtx.Lock()
- s.swapBufs(now)
-
- // Unblock the original goroutine that was responsible for the mutation
- // that triggered the compaction. But hold onto the global non-buffer
- // state mutex until the operation finishes.
- go func() {
- s.flushColdBuf()
- s.mtx.Unlock()
- }()
-}
-
-// rotateStreams needs mtx AND bufMtx locked.
-func (s *summary) maybeRotateStreams() {
- for !s.hotBufExpTime.Equal(s.headStreamExpTime) {
- s.headStream.Reset()
- s.headStreamIdx++
- if s.headStreamIdx >= len(s.streams) {
- s.headStreamIdx = 0
- }
- s.headStream = s.streams[s.headStreamIdx]
- s.headStreamExpTime = s.headStreamExpTime.Add(s.streamDuration)
- }
-}
-
-// flushColdBuf needs mtx locked.
-func (s *summary) flushColdBuf() {
- for _, v := range s.coldBuf {
- for _, stream := range s.streams {
- stream.Insert(v)
- }
- s.cnt++
- s.sum += v
- }
- s.coldBuf = s.coldBuf[0:0]
- s.maybeRotateStreams()
-}
-
-// swapBufs needs mtx AND bufMtx locked, coldBuf must be empty.
-func (s *summary) swapBufs(now time.Time) {
- if len(s.coldBuf) != 0 {
- panic("coldBuf is not empty")
- }
- s.hotBuf, s.coldBuf = s.coldBuf, s.hotBuf
- // hotBuf is now empty and gets new expiration set.
- for now.After(s.hotBufExpTime) {
- s.hotBufExpTime = s.hotBufExpTime.Add(s.streamDuration)
- }
-}
-
-type summaryCounts struct {
- // sumBits contains the bits of the float64 representing the sum of all
- // observations. sumBits and count have to go first in the struct to
- // guarantee alignment for atomic operations.
- // http://golang.org/pkg/sync/atomic/#pkg-note-BUG
- sumBits uint64
- count uint64
-}
-
-type noObjectivesSummary struct {
- // countAndHotIdx enables lock-free writes with use of atomic updates.
- // The most significant bit is the hot index [0 or 1] of the count field
- // below. Observe calls update the hot one. All remaining bits count the
- // number of Observe calls. Observe starts by incrementing this counter,
- // and finish by incrementing the count field in the respective
- // summaryCounts, as a marker for completion.
- //
- // Calls of the Write method (which are non-mutating reads from the
- // perspective of the summary) swap the hot–cold under the writeMtx
- // lock. A cooldown is awaited (while locked) by comparing the number of
- // observations with the initiation count. Once they match, then the
- // last observation on the now cool one has completed. All cool fields must
- // be merged into the new hot before releasing writeMtx.
-
- // Fields with atomic access first! See alignment constraint:
- // http://golang.org/pkg/sync/atomic/#pkg-note-BUG
- countAndHotIdx uint64
-
- selfCollector
- desc *Desc
- writeMtx sync.Mutex // Only used in the Write method.
-
- // Two counts, one is "hot" for lock-free observations, the other is
- // "cold" for writing out a dto.Metric. It has to be an array of
- // pointers to guarantee 64bit alignment of the histogramCounts, see
- // http://golang.org/pkg/sync/atomic/#pkg-note-BUG.
- counts [2]*summaryCounts
-
- labelPairs []*dto.LabelPair
-
- createdTs *timestamppb.Timestamp
-}
-
-func (s *noObjectivesSummary) Desc() *Desc {
- return s.desc
-}
-
-func (s *noObjectivesSummary) Observe(v float64) {
- // We increment h.countAndHotIdx so that the counter in the lower
- // 63 bits gets incremented. At the same time, we get the new value
- // back, which we can use to find the currently-hot counts.
- n := atomic.AddUint64(&s.countAndHotIdx, 1)
- hotCounts := s.counts[n>>63]
-
- for {
- oldBits := atomic.LoadUint64(&hotCounts.sumBits)
- newBits := math.Float64bits(math.Float64frombits(oldBits) + v)
- if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) {
- break
- }
- }
- // Increment count last as we take it as a signal that the observation
- // is complete.
- atomic.AddUint64(&hotCounts.count, 1)
-}
-
-func (s *noObjectivesSummary) Write(out *dto.Metric) error {
- // For simplicity, we protect this whole method by a mutex. It is not in
- // the hot path, i.e. Observe is called much more often than Write. The
- // complication of making Write lock-free isn't worth it, if possible at
- // all.
- s.writeMtx.Lock()
- defer s.writeMtx.Unlock()
-
- // Adding 1<<63 switches the hot index (from 0 to 1 or from 1 to 0)
- // without touching the count bits. See the struct comments for a full
- // description of the algorithm.
- n := atomic.AddUint64(&s.countAndHotIdx, 1<<63)
- // count is contained unchanged in the lower 63 bits.
- count := n & ((1 << 63) - 1)
- // The most significant bit tells us which counts is hot. The complement
- // is thus the cold one.
- hotCounts := s.counts[n>>63]
- coldCounts := s.counts[(^n)>>63]
-
- // Await cooldown.
- for count != atomic.LoadUint64(&coldCounts.count) {
- runtime.Gosched() // Let observations get work done.
- }
-
- sum := &dto.Summary{
- SampleCount: proto.Uint64(count),
- SampleSum: proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.sumBits))),
- CreatedTimestamp: s.createdTs,
- }
-
- out.Summary = sum
- out.Label = s.labelPairs
-
- // Finally add all the cold counts to the new hot counts and reset the cold counts.
- atomic.AddUint64(&hotCounts.count, count)
- atomic.StoreUint64(&coldCounts.count, 0)
- for {
- oldBits := atomic.LoadUint64(&hotCounts.sumBits)
- newBits := math.Float64bits(math.Float64frombits(oldBits) + sum.GetSampleSum())
- if atomic.CompareAndSwapUint64(&hotCounts.sumBits, oldBits, newBits) {
- atomic.StoreUint64(&coldCounts.sumBits, 0)
- break
- }
- }
- return nil
-}
-
-type quantSort []*dto.Quantile
-
-func (s quantSort) Len() int {
- return len(s)
-}
-
-func (s quantSort) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
-}
-
-func (s quantSort) Less(i, j int) bool {
- return s[i].GetQuantile() < s[j].GetQuantile()
-}
-
-// SummaryVec is a Collector that bundles a set of Summaries that all share the
-// same Desc, but have different values for their variable labels. This is used
-// if you want to count the same thing partitioned by various dimensions
-// (e.g. HTTP request latencies, partitioned by status code and method). Create
-// instances with NewSummaryVec.
-type SummaryVec struct {
- *MetricVec
-}
-
-// NewSummaryVec creates a new SummaryVec based on the provided SummaryOpts and
-// partitioned by the given label names.
-//
-// Due to the way a Summary is represented in the Prometheus text format and how
-// it is handled by the Prometheus server internally, “quantile” is an illegal
-// label name. NewSummaryVec will panic if this label name is used.
-func NewSummaryVec(opts SummaryOpts, labelNames []string) *SummaryVec {
- return V2.NewSummaryVec(SummaryVecOpts{
- SummaryOpts: opts,
- VariableLabels: UnconstrainedLabels(labelNames),
- })
-}
-
-// NewSummaryVec creates a new SummaryVec based on the provided SummaryVecOpts.
-func (v2) NewSummaryVec(opts SummaryVecOpts) *SummaryVec {
- for _, ln := range opts.VariableLabels.labelNames() {
- if ln == quantileLabel {
- panic(errQuantileLabelNotAllowed)
- }
- }
- desc := V2.NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- opts.VariableLabels,
- opts.ConstLabels,
- )
- return &SummaryVec{
- MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
- return newSummary(desc, opts.SummaryOpts, lvs...)
- }),
- }
-}
-
-// GetMetricWithLabelValues returns the Summary for the given slice of label
-// values (same order as the variable labels in Desc). If that combination of
-// label values is accessed for the first time, a new Summary is created.
-//
-// It is possible to call this method without using the returned Summary to only
-// create the new Summary but leave it at its starting value, a Summary without
-// any observations.
-//
-// Keeping the Summary for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// Delete can be used to delete the Summary from the SummaryVec. In that case,
-// the Summary will still exist, but it will not be exported anymore, even if a
-// Summary with the same label values is created later. See also the CounterVec
-// example.
-//
-// An error is returned if the number of label values is not the same as the
-// number of variable labels in Desc (minus any curried labels).
-//
-// Note that for more than one label value, this method is prone to mistakes
-// caused by an incorrect order of arguments. Consider GetMetricWith(Labels) as
-// an alternative to avoid that type of mistake. For higher label numbers, the
-// latter has a much more readable (albeit more verbose) syntax, but it comes
-// with a performance overhead (for creating and processing the Labels map).
-// See also the GaugeVec example.
-func (v *SummaryVec) GetMetricWithLabelValues(lvs ...string) (Observer, error) {
- metric, err := v.MetricVec.GetMetricWithLabelValues(lvs...)
- if metric != nil {
- return metric.(Observer), err
- }
- return nil, err
-}
-
-// GetMetricWith returns the Summary for the given Labels map (the label names
-// must match those of the variable labels in Desc). If that label map is
-// accessed for the first time, a new Summary is created. Implications of
-// creating a Summary without using it and keeping the Summary for later use are
-// the same as for GetMetricWithLabelValues.
-//
-// An error is returned if the number and names of the Labels are inconsistent
-// with those of the variable labels in Desc (minus any curried labels).
-//
-// This method is used for the same purpose as
-// GetMetricWithLabelValues(...string). See there for pros and cons of the two
-// methods.
-func (v *SummaryVec) GetMetricWith(labels Labels) (Observer, error) {
- metric, err := v.MetricVec.GetMetricWith(labels)
- if metric != nil {
- return metric.(Observer), err
- }
- return nil, err
-}
-
-// WithLabelValues works as GetMetricWithLabelValues, but panics where
-// GetMetricWithLabelValues would have returned an error. Not returning an
-// error allows shortcuts like
-//
-// myVec.WithLabelValues("404", "GET").Observe(42.21)
-func (v *SummaryVec) WithLabelValues(lvs ...string) Observer {
- s, err := v.GetMetricWithLabelValues(lvs...)
- if err != nil {
- panic(err)
- }
- return s
-}
-
-// With works as GetMetricWith, but panics where GetMetricWithLabels would have
-// returned an error. Not returning an error allows shortcuts like
-//
-// myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21)
-func (v *SummaryVec) With(labels Labels) Observer {
- s, err := v.GetMetricWith(labels)
- if err != nil {
- panic(err)
- }
- return s
-}
-
-// CurryWith returns a vector curried with the provided labels, i.e. the
-// returned vector has those labels pre-set for all labeled operations performed
-// on it. The cardinality of the curried vector is reduced accordingly. The
-// order of the remaining labels stays the same (just with the curried labels
-// taken out of the sequence – which is relevant for the
-// (GetMetric)WithLabelValues methods). It is possible to curry a curried
-// vector, but only with labels not yet used for currying before.
-//
-// The metrics contained in the SummaryVec are shared between the curried and
-// uncurried vectors. They are just accessed differently. Curried and uncurried
-// vectors behave identically in terms of collection. Only one must be
-// registered with a given registry (usually the uncurried version). The Reset
-// method deletes all metrics, even if called on a curried vector.
-func (v *SummaryVec) CurryWith(labels Labels) (ObserverVec, error) {
- vec, err := v.MetricVec.CurryWith(labels)
- if vec != nil {
- return &SummaryVec{vec}, err
- }
- return nil, err
-}
-
-// MustCurryWith works as CurryWith but panics where CurryWith would have
-// returned an error.
-func (v *SummaryVec) MustCurryWith(labels Labels) ObserverVec {
- vec, err := v.CurryWith(labels)
- if err != nil {
- panic(err)
- }
- return vec
-}
-
-type constSummary struct {
- desc *Desc
- count uint64
- sum float64
- quantiles map[float64]float64
- labelPairs []*dto.LabelPair
- createdTs *timestamppb.Timestamp
-}
-
-func (s *constSummary) Desc() *Desc {
- return s.desc
-}
-
-func (s *constSummary) Write(out *dto.Metric) error {
- sum := &dto.Summary{
- CreatedTimestamp: s.createdTs,
- }
- qs := make([]*dto.Quantile, 0, len(s.quantiles))
-
- sum.SampleCount = proto.Uint64(s.count)
- sum.SampleSum = proto.Float64(s.sum)
-
- for rank, q := range s.quantiles {
- qs = append(qs, &dto.Quantile{
- Quantile: proto.Float64(rank),
- Value: proto.Float64(q),
- })
- }
-
- if len(qs) > 0 {
- sort.Sort(quantSort(qs))
- }
- sum.Quantile = qs
-
- out.Summary = sum
- out.Label = s.labelPairs
-
- return nil
-}
-
-// NewConstSummary returns a metric representing a Prometheus summary with fixed
-// values for the count, sum, and quantiles. As those parameters cannot be
-// changed, the returned value does not implement the Summary interface (but
-// only the Metric interface). Users of this package will not have much use for
-// it in regular operations. However, when implementing custom Collectors, it is
-// useful as a throw-away metric that is generated on the fly to send it to
-// Prometheus in the Collect method.
-//
-// quantiles maps ranks to quantile values. For example, a median latency of
-// 0.23s and a 99th percentile latency of 0.56s would be expressed as:
-//
-// map[float64]float64{0.5: 0.23, 0.99: 0.56}
-//
-// NewConstSummary returns an error if the length of labelValues is not
-// consistent with the variable labels in Desc or if Desc is invalid.
-func NewConstSummary(
- desc *Desc,
- count uint64,
- sum float64,
- quantiles map[float64]float64,
- 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),
- }, nil
-}
-
-// MustNewConstSummary is a version of NewConstSummary that panics where
-// NewConstMetric would have returned an error.
-func MustNewConstSummary(
- desc *Desc,
- count uint64,
- sum float64,
- quantiles map[float64]float64,
- labelValues ...string,
-) Metric {
- m, err := NewConstSummary(desc, count, sum, quantiles, labelValues...)
- if err != nil {
- panic(err)
- }
- 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
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/timer.go b/vendor/github.com/prometheus/client_golang/prometheus/timer.go
deleted file mode 100644
index 52344fe..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/timer.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2016 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import "time"
-
-// Timer is a helper type to time functions. Use NewTimer to create new
-// instances.
-type Timer struct {
- begin time.Time
- observer Observer
-}
-
-// NewTimer creates a new Timer. The provided Observer is used to observe a
-// duration in seconds. If the Observer implements ExemplarObserver, passing exemplar
-// later on will be also supported.
-// Timer is usually used to time a function call in the
-// following way:
-//
-// func TimeMe() {
-// timer := NewTimer(myHistogram)
-// defer timer.ObserveDuration()
-// // Do actual work.
-// }
-//
-// or
-//
-// func TimeMeWithExemplar() {
-// timer := NewTimer(myHistogram)
-// defer timer.ObserveDurationWithExemplar(exemplar)
-// // Do actual work.
-// }
-func NewTimer(o Observer) *Timer {
- return &Timer{
- begin: time.Now(),
- observer: o,
- }
-}
-
-// ObserveDuration records the duration passed since the Timer was created with
-// NewTimer. It calls the Observe method of the Observer provided during
-// construction with the duration in seconds as an argument. The observed
-// duration is also returned. ObserveDuration is usually called with a defer
-// statement.
-//
-// Note that this method is only guaranteed to never observe negative durations
-// if used with Go1.9+.
-func (t *Timer) ObserveDuration() time.Duration {
- d := time.Since(t.begin)
- if t.observer != nil {
- t.observer.Observe(d.Seconds())
- }
- return d
-}
-
-// ObserveDurationWithExemplar is like ObserveDuration, but it will also
-// observe exemplar with the duration unless exemplar is nil or provided Observer can't
-// be casted to ExemplarObserver.
-func (t *Timer) ObserveDurationWithExemplar(exemplar Labels) time.Duration {
- d := time.Since(t.begin)
- eo, ok := t.observer.(ExemplarObserver)
- if ok && exemplar != nil {
- eo.ObserveWithExemplar(d.Seconds(), exemplar)
- return d
- }
- if t.observer != nil {
- t.observer.Observe(d.Seconds())
- }
- return d
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/untyped.go b/vendor/github.com/prometheus/client_golang/prometheus/untyped.go
deleted file mode 100644
index 0f9ce63..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/untyped.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-// UntypedOpts is an alias for Opts. See there for doc comments.
-type UntypedOpts Opts
-
-// UntypedFunc works like GaugeFunc but the collected metric is of type
-// "Untyped". UntypedFunc is useful to mirror an external metric of unknown
-// type.
-//
-// To create UntypedFunc instances, use NewUntypedFunc.
-type UntypedFunc interface {
- Metric
- Collector
-}
-
-// NewUntypedFunc creates a new UntypedFunc based on the provided
-// UntypedOpts. The value reported is determined by calling the given function
-// from within the Write method. Take into account that metric collection may
-// happen concurrently. If that results in concurrent calls to Write, like in
-// the case where an UntypedFunc is directly registered with Prometheus, the
-// provided function must be concurrency-safe.
-func NewUntypedFunc(opts UntypedOpts, function func() float64) UntypedFunc {
- return newValueFunc(NewDesc(
- BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
- opts.Help,
- nil,
- opts.ConstLabels,
- ), UntypedValue, function)
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/value.go b/vendor/github.com/prometheus/client_golang/prometheus/value.go
deleted file mode 100644
index cc23011..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/value.go
+++ /dev/null
@@ -1,274 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "errors"
- "fmt"
- "sort"
- "time"
- "unicode/utf8"
-
- "github.com/prometheus/client_golang/prometheus/internal"
-
- dto "github.com/prometheus/client_model/go"
- "google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/types/known/timestamppb"
-)
-
-// ValueType is an enumeration of metric types that represent a simple value.
-type ValueType int
-
-// Possible values for the ValueType enum. Use UntypedValue to mark a metric
-// with an unknown type.
-const (
- _ ValueType = iota
- CounterValue
- GaugeValue
- UntypedValue
-)
-
-var (
- CounterMetricTypePtr = func() *dto.MetricType { d := dto.MetricType_COUNTER; return &d }()
- GaugeMetricTypePtr = func() *dto.MetricType { d := dto.MetricType_GAUGE; return &d }()
- UntypedMetricTypePtr = func() *dto.MetricType { d := dto.MetricType_UNTYPED; return &d }()
-)
-
-func (v ValueType) ToDTO() *dto.MetricType {
- switch v {
- case CounterValue:
- return CounterMetricTypePtr
- case GaugeValue:
- return GaugeMetricTypePtr
- default:
- return UntypedMetricTypePtr
- }
-}
-
-// valueFunc is a generic metric for simple values retrieved on collect time
-// from a function. It implements Metric and Collector. Its effective type is
-// determined by ValueType. This is a low-level building block used by the
-// library to back the implementations of CounterFunc, GaugeFunc, and
-// UntypedFunc.
-type valueFunc struct {
- selfCollector
-
- desc *Desc
- valType ValueType
- function func() float64
- labelPairs []*dto.LabelPair
-}
-
-// newValueFunc returns a newly allocated valueFunc with the given Desc and
-// ValueType. The value reported is determined by calling the given function
-// from within the Write method. Take into account that metric collection may
-// happen concurrently. If that results in concurrent calls to Write, like in
-// the case where a valueFunc is directly registered with Prometheus, the
-// provided function must be concurrency-safe.
-func newValueFunc(desc *Desc, valueType ValueType, function func() float64) *valueFunc {
- result := &valueFunc{
- desc: desc,
- valType: valueType,
- function: function,
- labelPairs: MakeLabelPairs(desc, nil),
- }
- result.init(result)
- return result
-}
-
-func (v *valueFunc) Desc() *Desc {
- return v.desc
-}
-
-func (v *valueFunc) Write(out *dto.Metric) error {
- return populateMetric(v.valType, v.function(), v.labelPairs, nil, out, nil)
-}
-
-// NewConstMetric returns a metric with one fixed value that cannot be
-// changed. Users of this package will not have much use for it in regular
-// operations. However, when implementing custom Collectors, it is useful as a
-// throw-away metric that is generated on the fly to send it to Prometheus in
-// the Collect method. NewConstMetric returns an error if the length of
-// labelValues is not consistent with the variable labels in Desc or if Desc is
-// invalid.
-func NewConstMetric(desc *Desc, valueType ValueType, value float64, 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
- }
-
- metric := &dto.Metric{}
- if err := populateMetric(valueType, value, MakeLabelPairs(desc, labelValues), nil, metric, nil); err != nil {
- return nil, err
- }
-
- return &constMetric{
- desc: desc,
- metric: metric,
- }, nil
-}
-
-// MustNewConstMetric is a version of NewConstMetric that panics where
-// NewConstMetric would have returned an error.
-func MustNewConstMetric(desc *Desc, valueType ValueType, value float64, labelValues ...string) Metric {
- m, err := NewConstMetric(desc, valueType, value, labelValues...)
- if err != nil {
- panic(err)
- }
- return m
-}
-
-// NewConstMetricWithCreatedTimestamp does the same thing as NewConstMetric, but generates Counters
-// with created timestamp set and returns an error for other metric types.
-func NewConstMetricWithCreatedTimestamp(desc *Desc, valueType ValueType, value 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
- }
- switch valueType {
- case CounterValue:
- break
- default:
- return nil, errors.New("created timestamps are only supported for counters")
- }
-
- metric := &dto.Metric{}
- if err := populateMetric(valueType, value, MakeLabelPairs(desc, labelValues), nil, metric, timestamppb.New(ct)); err != nil {
- return nil, err
- }
-
- return &constMetric{
- desc: desc,
- metric: metric,
- }, nil
-}
-
-// MustNewConstMetricWithCreatedTimestamp is a version of NewConstMetricWithCreatedTimestamp that panics where
-// NewConstMetricWithCreatedTimestamp would have returned an error.
-func MustNewConstMetricWithCreatedTimestamp(desc *Desc, valueType ValueType, value float64, ct time.Time, labelValues ...string) Metric {
- m, err := NewConstMetricWithCreatedTimestamp(desc, valueType, value, ct, labelValues...)
- if err != nil {
- panic(err)
- }
- return m
-}
-
-type constMetric struct {
- desc *Desc
- metric *dto.Metric
-}
-
-func (m *constMetric) Desc() *Desc {
- return m.desc
-}
-
-func (m *constMetric) Write(out *dto.Metric) error {
- out.Label = m.metric.Label
- out.Counter = m.metric.Counter
- out.Gauge = m.metric.Gauge
- out.Untyped = m.metric.Untyped
- return nil
-}
-
-func populateMetric(
- t ValueType,
- v float64,
- labelPairs []*dto.LabelPair,
- e *dto.Exemplar,
- m *dto.Metric,
- ct *timestamppb.Timestamp,
-) error {
- m.Label = labelPairs
- switch t {
- case CounterValue:
- m.Counter = &dto.Counter{Value: proto.Float64(v), Exemplar: e, CreatedTimestamp: ct}
- case GaugeValue:
- m.Gauge = &dto.Gauge{Value: proto.Float64(v)}
- case UntypedValue:
- m.Untyped = &dto.Untyped{Value: proto.Float64(v)}
- default:
- return fmt.Errorf("encountered unknown type %v", t)
- }
- return nil
-}
-
-// MakeLabelPairs is a helper function to create protobuf LabelPairs from the
-// variable and constant labels in the provided Desc. The values for the
-// variable labels are defined by the labelValues slice, which must be in the
-// same order as the corresponding variable labels in the Desc.
-//
-// This function is only needed for custom Metric implementations. See MetricVec
-// example.
-func MakeLabelPairs(desc *Desc, labelValues []string) []*dto.LabelPair {
- totalLen := len(desc.variableLabels.names) + len(desc.constLabelPairs)
- if totalLen == 0 {
- // Super fast path.
- return nil
- }
- if len(desc.variableLabels.names) == 0 {
- // Moderately fast path.
- return desc.constLabelPairs
- }
- labelPairs := make([]*dto.LabelPair, 0, totalLen)
- for i, l := range desc.variableLabels.names {
- labelPairs = append(labelPairs, &dto.LabelPair{
- Name: proto.String(l),
- Value: proto.String(labelValues[i]),
- })
- }
- labelPairs = append(labelPairs, desc.constLabelPairs...)
- sort.Sort(internal.LabelPairSorter(labelPairs))
- return labelPairs
-}
-
-// ExemplarMaxRunes is the max total number of runes allowed in exemplar labels.
-const ExemplarMaxRunes = 128
-
-// newExemplar creates a new dto.Exemplar from the provided values. An error is
-// returned if any of the label names or values are invalid or if the total
-// number of runes in the label names and values exceeds ExemplarMaxRunes.
-func newExemplar(value float64, ts time.Time, l Labels) (*dto.Exemplar, error) {
- e := &dto.Exemplar{}
- e.Value = proto.Float64(value)
- tsProto := timestamppb.New(ts)
- if err := tsProto.CheckValid(); err != nil {
- return nil, err
- }
- e.Timestamp = tsProto
- labelPairs := make([]*dto.LabelPair, 0, len(l))
- var runes int
- for name, value := range l {
- if !checkLabelName(name) {
- return nil, fmt.Errorf("exemplar label name %q is invalid", name)
- }
- runes += utf8.RuneCountInString(name)
- if !utf8.ValidString(value) {
- return nil, fmt.Errorf("exemplar label value %q is not valid UTF-8", value)
- }
- runes += utf8.RuneCountInString(value)
- labelPairs = append(labelPairs, &dto.LabelPair{
- Name: proto.String(name),
- Value: proto.String(value),
- })
- }
- if runes > ExemplarMaxRunes {
- return nil, fmt.Errorf("exemplar labels have %d runes, exceeding the limit of %d", runes, ExemplarMaxRunes)
- }
- e.Label = labelPairs
- return e, nil
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/vec.go b/vendor/github.com/prometheus/client_golang/prometheus/vec.go
deleted file mode 100644
index 2c808ee..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/vec.go
+++ /dev/null
@@ -1,709 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "fmt"
- "sync"
-
- "github.com/prometheus/common/model"
-)
-
-// MetricVec is a Collector to bundle metrics of the same name that differ in
-// their label values. MetricVec is not used directly but as a building block
-// for implementations of vectors of a given metric type, like GaugeVec,
-// CounterVec, SummaryVec, and HistogramVec. It is exported so that it can be
-// used for custom Metric implementations.
-//
-// To create a FooVec for custom Metric Foo, embed a pointer to MetricVec in
-// FooVec and initialize it with NewMetricVec. Implement wrappers for
-// GetMetricWithLabelValues and GetMetricWith that return (Foo, error) rather
-// than (Metric, error). Similarly, create a wrapper for CurryWith that returns
-// (*FooVec, error) rather than (*MetricVec, error). It is recommended to also
-// add the convenience methods WithLabelValues, With, and MustCurryWith, which
-// panic instead of returning errors. See also the MetricVec example.
-type MetricVec struct {
- *metricMap
-
- curry []curriedLabelValue
-
- // hashAdd and hashAddByte can be replaced for testing collision handling.
- hashAdd func(h uint64, s string) uint64
- hashAddByte func(h uint64, b byte) uint64
-}
-
-// NewMetricVec returns an initialized metricVec.
-func NewMetricVec(desc *Desc, newMetric func(lvs ...string) Metric) *MetricVec {
- return &MetricVec{
- metricMap: &metricMap{
- metrics: map[uint64][]metricWithLabelValues{},
- desc: desc,
- newMetric: newMetric,
- },
- hashAdd: hashAdd,
- hashAddByte: hashAddByte,
- }
-}
-
-// DeleteLabelValues removes the metric where the variable labels are the same
-// as those passed in as labels (same order as the VariableLabels in Desc). It
-// returns true if a metric was deleted.
-//
-// It is not an error if the number of label values is not the same as the
-// number of VariableLabels in Desc. However, such inconsistent label count can
-// never match an actual metric, so the method will always return false in that
-// case.
-//
-// Note that for more than one label value, this method is prone to mistakes
-// caused by an incorrect order of arguments. Consider Delete(Labels) as an
-// alternative to avoid that type of mistake. For higher label numbers, the
-// latter has a much more readable (albeit more verbose) syntax, but it comes
-// with a performance overhead (for creating and processing the Labels map).
-// See also the CounterVec example.
-func (m *MetricVec) DeleteLabelValues(lvs ...string) bool {
- lvs = constrainLabelValues(m.desc, lvs, m.curry)
-
- h, err := m.hashLabelValues(lvs)
- if err != nil {
- return false
- }
-
- return m.metricMap.deleteByHashWithLabelValues(h, lvs, m.curry)
-}
-
-// Delete deletes the metric where the variable labels are the same as those
-// passed in as labels. It returns true if a metric was deleted.
-//
-// It is not an error if the number and names of the Labels are inconsistent
-// with those of the VariableLabels in Desc. However, such inconsistent Labels
-// can never match an actual metric, so the method will always return false in
-// that case.
-//
-// This method is used for the same purpose as DeleteLabelValues(...string). See
-// there for pros and cons of the two methods.
-func (m *MetricVec) Delete(labels Labels) bool {
- labels, closer := constrainLabels(m.desc, labels)
- defer closer()
-
- h, err := m.hashLabels(labels)
- if err != nil {
- return false
- }
-
- return m.metricMap.deleteByHashWithLabels(h, labels, m.curry)
-}
-
-// DeletePartialMatch deletes all metrics where the variable labels contain all of those
-// passed in as labels. The order of the labels does not matter.
-// It returns the number of metrics deleted.
-//
-// Note that curried labels will never be matched if deleting from the curried vector.
-// To match curried labels with DeletePartialMatch, it must be called on the base vector.
-func (m *MetricVec) DeletePartialMatch(labels Labels) int {
- labels, closer := constrainLabels(m.desc, labels)
- defer closer()
-
- return m.metricMap.deleteByLabels(labels, m.curry)
-}
-
-// Without explicit forwarding of Describe, Collect, Reset, those methods won't
-// show up in GoDoc.
-
-// Describe implements Collector.
-func (m *MetricVec) Describe(ch chan<- *Desc) { m.metricMap.Describe(ch) }
-
-// Collect implements Collector.
-func (m *MetricVec) Collect(ch chan<- Metric) { m.metricMap.Collect(ch) }
-
-// Reset deletes all metrics in this vector.
-func (m *MetricVec) Reset() { m.metricMap.Reset() }
-
-// CurryWith returns a vector curried with the provided labels, i.e. the
-// returned vector has those labels pre-set for all labeled operations performed
-// on it. The cardinality of the curried vector is reduced accordingly. The
-// order of the remaining labels stays the same (just with the curried labels
-// taken out of the sequence – which is relevant for the
-// (GetMetric)WithLabelValues methods). It is possible to curry a curried
-// vector, but only with labels not yet used for currying before.
-//
-// The metrics contained in the MetricVec are shared between the curried and
-// uncurried vectors. They are just accessed differently. Curried and uncurried
-// vectors behave identically in terms of collection. Only one must be
-// registered with a given registry (usually the uncurried version). The Reset
-// method deletes all metrics, even if called on a curried vector.
-//
-// Note that CurryWith is usually not called directly but through a wrapper
-// around MetricVec, implementing a vector for a specific Metric
-// implementation, for example GaugeVec.
-func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) {
- var (
- newCurry []curriedLabelValue
- oldCurry = m.curry
- iCurry int
- )
- for i, labelName := range m.desc.variableLabels.names {
- val, ok := labels[labelName]
- if iCurry < len(oldCurry) && oldCurry[iCurry].index == i {
- if ok {
- return nil, fmt.Errorf("label name %q is already curried", labelName)
- }
- newCurry = append(newCurry, oldCurry[iCurry])
- iCurry++
- } else {
- if !ok {
- continue // Label stays uncurried.
- }
- newCurry = append(newCurry, curriedLabelValue{
- i,
- m.desc.variableLabels.constrain(labelName, val),
- })
- }
- }
- if l := len(oldCurry) + len(labels) - len(newCurry); l > 0 {
- return nil, fmt.Errorf("%d unknown label(s) found during currying", l)
- }
-
- return &MetricVec{
- metricMap: m.metricMap,
- curry: newCurry,
- hashAdd: m.hashAdd,
- hashAddByte: m.hashAddByte,
- }, nil
-}
-
-// GetMetricWithLabelValues returns the Metric for the given slice of label
-// values (same order as the variable labels in Desc). If that combination of
-// label values is accessed for the first time, a new Metric is created (by
-// calling the newMetric function provided during construction of the
-// MetricVec).
-//
-// It is possible to call this method without using the returned Metric to only
-// create the new Metric but leave it in its initial state.
-//
-// Keeping the Metric for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// Delete can be used to delete the Metric from the MetricVec. In that case, the
-// Metric will still exist, but it will not be exported anymore, even if a
-// Metric with the same label values is created later.
-//
-// An error is returned if the number of label values is not the same as the
-// number of variable labels in Desc (minus any curried labels).
-//
-// Note that for more than one label value, this method is prone to mistakes
-// caused by an incorrect order of arguments. Consider GetMetricWith(Labels) as
-// an alternative to avoid that type of mistake. For higher label numbers, the
-// latter has a much more readable (albeit more verbose) syntax, but it comes
-// with a performance overhead (for creating and processing the Labels map).
-//
-// Note that GetMetricWithLabelValues is usually not called directly but through
-// a wrapper around MetricVec, implementing a vector for a specific Metric
-// implementation, for example GaugeVec.
-func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) {
- lvs = constrainLabelValues(m.desc, lvs, m.curry)
- h, err := m.hashLabelValues(lvs)
- if err != nil {
- return nil, err
- }
-
- return m.metricMap.getOrCreateMetricWithLabelValues(h, lvs, m.curry), nil
-}
-
-// GetMetricWith returns the Metric for the given Labels map (the label names
-// must match those of the variable labels in Desc). If that label map is
-// accessed for the first time, a new Metric is created. Implications of
-// creating a Metric without using it and keeping the Metric for later use
-// are the same as for GetMetricWithLabelValues.
-//
-// An error is returned if the number and names of the Labels are inconsistent
-// with those of the variable labels in Desc (minus any curried labels).
-//
-// This method is used for the same purpose as
-// GetMetricWithLabelValues(...string). See there for pros and cons of the two
-// methods.
-//
-// Note that GetMetricWith is usually not called directly but through a wrapper
-// around MetricVec, implementing a vector for a specific Metric implementation,
-// for example GaugeVec.
-func (m *MetricVec) GetMetricWith(labels Labels) (Metric, error) {
- labels, closer := constrainLabels(m.desc, labels)
- defer closer()
-
- h, err := m.hashLabels(labels)
- if err != nil {
- return nil, err
- }
-
- return m.metricMap.getOrCreateMetricWithLabels(h, labels, m.curry), nil
-}
-
-func (m *MetricVec) hashLabelValues(vals []string) (uint64, error) {
- if err := validateLabelValues(vals, len(m.desc.variableLabels.names)-len(m.curry)); err != nil {
- return 0, err
- }
-
- var (
- h = hashNew()
- curry = m.curry
- iVals, iCurry int
- )
- for i := 0; i < len(m.desc.variableLabels.names); i++ {
- if iCurry < len(curry) && curry[iCurry].index == i {
- h = m.hashAdd(h, curry[iCurry].value)
- iCurry++
- } else {
- h = m.hashAdd(h, vals[iVals])
- iVals++
- }
- h = m.hashAddByte(h, model.SeparatorByte)
- }
- return h, nil
-}
-
-func (m *MetricVec) hashLabels(labels Labels) (uint64, error) {
- if err := validateValuesInLabels(labels, len(m.desc.variableLabels.names)-len(m.curry)); err != nil {
- return 0, err
- }
-
- var (
- h = hashNew()
- curry = m.curry
- iCurry int
- )
- for i, labelName := range m.desc.variableLabels.names {
- val, ok := labels[labelName]
- if iCurry < len(curry) && curry[iCurry].index == i {
- if ok {
- return 0, fmt.Errorf("label name %q is already curried", labelName)
- }
- h = m.hashAdd(h, curry[iCurry].value)
- iCurry++
- } else {
- if !ok {
- return 0, fmt.Errorf("label name %q missing in label map", labelName)
- }
- h = m.hashAdd(h, val)
- }
- h = m.hashAddByte(h, model.SeparatorByte)
- }
- return h, nil
-}
-
-// metricWithLabelValues provides the metric and its label values for
-// disambiguation on hash collision.
-type metricWithLabelValues struct {
- values []string
- metric Metric
-}
-
-// curriedLabelValue sets the curried value for a label at the given index.
-type curriedLabelValue struct {
- index int
- value string
-}
-
-// metricMap is a helper for metricVec and shared between differently curried
-// metricVecs.
-type metricMap struct {
- mtx sync.RWMutex // Protects metrics.
- metrics map[uint64][]metricWithLabelValues
- desc *Desc
- newMetric func(labelValues ...string) Metric
-}
-
-// Describe implements Collector. It will send exactly one Desc to the provided
-// channel.
-func (m *metricMap) Describe(ch chan<- *Desc) {
- ch <- m.desc
-}
-
-// Collect implements Collector.
-func (m *metricMap) Collect(ch chan<- Metric) {
- m.mtx.RLock()
- defer m.mtx.RUnlock()
-
- for _, metrics := range m.metrics {
- for _, metric := range metrics {
- ch <- metric.metric
- }
- }
-}
-
-// Reset deletes all metrics in this vector.
-func (m *metricMap) Reset() {
- m.mtx.Lock()
- defer m.mtx.Unlock()
-
- for h := range m.metrics {
- delete(m.metrics, h)
- }
-}
-
-// deleteByHashWithLabelValues removes the metric from the hash bucket h. If
-// there are multiple matches in the bucket, use lvs to select a metric and
-// remove only that metric.
-func (m *metricMap) deleteByHashWithLabelValues(
- h uint64, lvs []string, curry []curriedLabelValue,
-) bool {
- m.mtx.Lock()
- defer m.mtx.Unlock()
-
- metrics, ok := m.metrics[h]
- if !ok {
- return false
- }
-
- i := findMetricWithLabelValues(metrics, lvs, curry)
- if i >= len(metrics) {
- return false
- }
-
- if len(metrics) > 1 {
- old := metrics
- m.metrics[h] = append(metrics[:i], metrics[i+1:]...)
- old[len(old)-1] = metricWithLabelValues{}
- } else {
- delete(m.metrics, h)
- }
- return true
-}
-
-// deleteByHashWithLabels removes the metric from the hash bucket h. If there
-// are multiple matches in the bucket, use lvs to select a metric and remove
-// only that metric.
-func (m *metricMap) deleteByHashWithLabels(
- h uint64, labels Labels, curry []curriedLabelValue,
-) bool {
- m.mtx.Lock()
- defer m.mtx.Unlock()
-
- metrics, ok := m.metrics[h]
- if !ok {
- return false
- }
- i := findMetricWithLabels(m.desc, metrics, labels, curry)
- if i >= len(metrics) {
- return false
- }
-
- if len(metrics) > 1 {
- old := metrics
- m.metrics[h] = append(metrics[:i], metrics[i+1:]...)
- old[len(old)-1] = metricWithLabelValues{}
- } else {
- delete(m.metrics, h)
- }
- return true
-}
-
-// deleteByLabels deletes a metric if the given labels are present in the metric.
-func (m *metricMap) deleteByLabels(labels Labels, curry []curriedLabelValue) int {
- m.mtx.Lock()
- defer m.mtx.Unlock()
-
- var numDeleted int
-
- for h, metrics := range m.metrics {
- i := findMetricWithPartialLabels(m.desc, metrics, labels, curry)
- if i >= len(metrics) {
- // Didn't find matching labels in this metric slice.
- continue
- }
- delete(m.metrics, h)
- numDeleted++
- }
-
- return numDeleted
-}
-
-// findMetricWithPartialLabel returns the index of the matching metric or
-// len(metrics) if not found.
-func findMetricWithPartialLabels(
- desc *Desc, metrics []metricWithLabelValues, labels Labels, curry []curriedLabelValue,
-) int {
- for i, metric := range metrics {
- if matchPartialLabels(desc, metric.values, labels, curry) {
- return i
- }
- }
- return len(metrics)
-}
-
-// indexOf searches the given slice of strings for the target string and returns
-// the index or len(items) as well as a boolean whether the search succeeded.
-func indexOf(target string, items []string) (int, bool) {
- for i, l := range items {
- if l == target {
- return i, true
- }
- }
- return len(items), false
-}
-
-// valueMatchesVariableOrCurriedValue determines if a value was previously curried,
-// and returns whether it matches either the "base" value or the curried value accordingly.
-// It also indicates whether the match is against a curried or uncurried value.
-func valueMatchesVariableOrCurriedValue(targetValue string, index int, values []string, curry []curriedLabelValue) (bool, bool) {
- for _, curriedValue := range curry {
- if curriedValue.index == index {
- // This label was curried. See if the curried value matches our target.
- return curriedValue.value == targetValue, true
- }
- }
- // This label was not curried. See if the current value matches our target label.
- return values[index] == targetValue, false
-}
-
-// matchPartialLabels searches the current metric and returns whether all of the target label:value pairs are present.
-func matchPartialLabels(desc *Desc, values []string, labels Labels, curry []curriedLabelValue) bool {
- for l, v := range labels {
- // Check if the target label exists in our metrics and get the index.
- varLabelIndex, validLabel := indexOf(l, desc.variableLabels.names)
- if validLabel {
- // Check the value of that label against the target value.
- // We don't consider curried values in partial matches.
- matches, curried := valueMatchesVariableOrCurriedValue(v, varLabelIndex, values, curry)
- if matches && !curried {
- continue
- }
- }
- return false
- }
- return true
-}
-
-// getOrCreateMetricWithLabelValues retrieves the metric by hash and label value
-// or creates it and returns the new one.
-//
-// This function holds the mutex.
-func (m *metricMap) getOrCreateMetricWithLabelValues(
- hash uint64, lvs []string, curry []curriedLabelValue,
-) Metric {
- m.mtx.RLock()
- metric, ok := m.getMetricWithHashAndLabelValues(hash, lvs, curry)
- m.mtx.RUnlock()
- if ok {
- return metric
- }
-
- m.mtx.Lock()
- defer m.mtx.Unlock()
- metric, ok = m.getMetricWithHashAndLabelValues(hash, lvs, curry)
- if !ok {
- inlinedLVs := inlineLabelValues(lvs, curry)
- metric = m.newMetric(inlinedLVs...)
- m.metrics[hash] = append(m.metrics[hash], metricWithLabelValues{values: inlinedLVs, metric: metric})
- }
- return metric
-}
-
-// getOrCreateMetricWithLabels retrieves the metric by hash and label value
-// or creates it and returns the new one.
-//
-// This function holds the mutex.
-func (m *metricMap) getOrCreateMetricWithLabels(
- hash uint64, labels Labels, curry []curriedLabelValue,
-) Metric {
- m.mtx.RLock()
- metric, ok := m.getMetricWithHashAndLabels(hash, labels, curry)
- m.mtx.RUnlock()
- if ok {
- return metric
- }
-
- m.mtx.Lock()
- defer m.mtx.Unlock()
- metric, ok = m.getMetricWithHashAndLabels(hash, labels, curry)
- if !ok {
- lvs := extractLabelValues(m.desc, labels, curry)
- metric = m.newMetric(lvs...)
- m.metrics[hash] = append(m.metrics[hash], metricWithLabelValues{values: lvs, metric: metric})
- }
- return metric
-}
-
-// getMetricWithHashAndLabelValues gets a metric while handling possible
-// collisions in the hash space. Must be called while holding the read mutex.
-func (m *metricMap) getMetricWithHashAndLabelValues(
- h uint64, lvs []string, curry []curriedLabelValue,
-) (Metric, bool) {
- metrics, ok := m.metrics[h]
- if ok {
- if i := findMetricWithLabelValues(metrics, lvs, curry); i < len(metrics) {
- return metrics[i].metric, true
- }
- }
- return nil, false
-}
-
-// getMetricWithHashAndLabels gets a metric while handling possible collisions in
-// the hash space. Must be called while holding read mutex.
-func (m *metricMap) getMetricWithHashAndLabels(
- h uint64, labels Labels, curry []curriedLabelValue,
-) (Metric, bool) {
- metrics, ok := m.metrics[h]
- if ok {
- if i := findMetricWithLabels(m.desc, metrics, labels, curry); i < len(metrics) {
- return metrics[i].metric, true
- }
- }
- return nil, false
-}
-
-// findMetricWithLabelValues returns the index of the matching metric or
-// len(metrics) if not found.
-func findMetricWithLabelValues(
- metrics []metricWithLabelValues, lvs []string, curry []curriedLabelValue,
-) int {
- for i, metric := range metrics {
- if matchLabelValues(metric.values, lvs, curry) {
- return i
- }
- }
- return len(metrics)
-}
-
-// findMetricWithLabels returns the index of the matching metric or len(metrics)
-// if not found.
-func findMetricWithLabels(
- desc *Desc, metrics []metricWithLabelValues, labels Labels, curry []curriedLabelValue,
-) int {
- for i, metric := range metrics {
- if matchLabels(desc, metric.values, labels, curry) {
- return i
- }
- }
- return len(metrics)
-}
-
-func matchLabelValues(values, lvs []string, curry []curriedLabelValue) bool {
- if len(values) != len(lvs)+len(curry) {
- return false
- }
- var iLVs, iCurry int
- for i, v := range values {
- if iCurry < len(curry) && curry[iCurry].index == i {
- if v != curry[iCurry].value {
- return false
- }
- iCurry++
- continue
- }
- if v != lvs[iLVs] {
- return false
- }
- iLVs++
- }
- return true
-}
-
-func matchLabels(desc *Desc, values []string, labels Labels, curry []curriedLabelValue) bool {
- if len(values) != len(labels)+len(curry) {
- return false
- }
- iCurry := 0
- for i, k := range desc.variableLabels.names {
- if iCurry < len(curry) && curry[iCurry].index == i {
- if values[i] != curry[iCurry].value {
- return false
- }
- iCurry++
- continue
- }
- if values[i] != labels[k] {
- return false
- }
- }
- return true
-}
-
-func extractLabelValues(desc *Desc, labels Labels, curry []curriedLabelValue) []string {
- labelValues := make([]string, len(labels)+len(curry))
- iCurry := 0
- for i, k := range desc.variableLabels.names {
- if iCurry < len(curry) && curry[iCurry].index == i {
- labelValues[i] = curry[iCurry].value
- iCurry++
- continue
- }
- labelValues[i] = labels[k]
- }
- return labelValues
-}
-
-func inlineLabelValues(lvs []string, curry []curriedLabelValue) []string {
- labelValues := make([]string, len(lvs)+len(curry))
- var iCurry, iLVs int
- for i := range labelValues {
- if iCurry < len(curry) && curry[iCurry].index == i {
- labelValues[i] = curry[iCurry].value
- iCurry++
- continue
- }
- labelValues[i] = lvs[iLVs]
- iLVs++
- }
- return labelValues
-}
-
-var labelsPool = &sync.Pool{
- New: func() interface{} {
- return make(Labels)
- },
-}
-
-func constrainLabels(desc *Desc, labels Labels) (Labels, func()) {
- if len(desc.variableLabels.labelConstraints) == 0 {
- // Fast path when there's no constraints
- return labels, func() {}
- }
-
- constrainedLabels := labelsPool.Get().(Labels)
- for l, v := range labels {
- constrainedLabels[l] = desc.variableLabels.constrain(l, v)
- }
-
- return constrainedLabels, func() {
- for k := range constrainedLabels {
- delete(constrainedLabels, k)
- }
- labelsPool.Put(constrainedLabels)
- }
-}
-
-func constrainLabelValues(desc *Desc, lvs []string, curry []curriedLabelValue) []string {
- if len(desc.variableLabels.labelConstraints) == 0 {
- // Fast path when there's no constraints
- return lvs
- }
-
- constrainedValues := make([]string, len(lvs))
- var iCurry, iLVs int
- for i := 0; i < len(lvs)+len(curry); i++ {
- if iCurry < len(curry) && curry[iCurry].index == i {
- iCurry++
- continue
- }
-
- if i < len(desc.variableLabels.names) {
- constrainedValues[iLVs] = desc.variableLabels.constrain(
- desc.variableLabels.names[i],
- lvs[iLVs],
- )
- } else {
- constrainedValues[iLVs] = lvs[iLVs]
- }
- iLVs++
- }
- return constrainedValues
-}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/vnext.go b/vendor/github.com/prometheus/client_golang/prometheus/vnext.go
deleted file mode 100644
index 42bc3a8..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/vnext.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-type v2 struct{}
-
-// V2 is a struct that can be referenced to access experimental API that might
-// be present in v2 of client golang someday. It offers extended functionality
-// of v1 with slightly changed API. It is acceptable to use some pieces from v1
-// and e.g `prometheus.NewGauge` and some from v2 e.g. `prometheus.V2.NewDesc`
-// in the same codebase.
-var V2 = v2{}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/wrap.go b/vendor/github.com/prometheus/client_golang/prometheus/wrap.go
deleted file mode 100644
index 25da157..0000000
--- a/vendor/github.com/prometheus/client_golang/prometheus/wrap.go
+++ /dev/null
@@ -1,214 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package prometheus
-
-import (
- "fmt"
- "sort"
-
- "github.com/prometheus/client_golang/prometheus/internal"
-
- dto "github.com/prometheus/client_model/go"
- "google.golang.org/protobuf/proto"
-)
-
-// WrapRegistererWith returns a Registerer wrapping the provided
-// Registerer. Collectors registered with the returned Registerer will be
-// registered with the wrapped Registerer in a modified way. The modified
-// Collector adds the provided Labels to all Metrics it collects (as
-// ConstLabels). The Metrics collected by the unmodified Collector must not
-// duplicate any of those labels. Wrapping a nil value is valid, resulting
-// in a no-op Registerer.
-//
-// WrapRegistererWith provides a way to add fixed labels to a subset of
-// Collectors. It should not be used to add fixed labels to all metrics
-// exposed. See also
-// https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels
-//
-// Conflicts between Collectors registered through the original Registerer with
-// Collectors registered through the wrapping Registerer will still be
-// detected. Any AlreadyRegisteredError returned by the Register method of
-// either Registerer will contain the ExistingCollector in the form it was
-// provided to the respective registry.
-//
-// The Collector example demonstrates a use of WrapRegistererWith.
-func WrapRegistererWith(labels Labels, reg Registerer) Registerer {
- return &wrappingRegisterer{
- wrappedRegisterer: reg,
- labels: labels,
- }
-}
-
-// WrapRegistererWithPrefix returns a Registerer wrapping the provided
-// Registerer. Collectors registered with the returned Registerer will be
-// registered with the wrapped Registerer in a modified way. The modified
-// Collector adds the provided prefix to the name of all Metrics it collects.
-// Wrapping a nil value is valid, resulting in a no-op Registerer.
-//
-// WrapRegistererWithPrefix is useful to have one place to prefix all metrics of
-// a sub-system. To make this work, register metrics of the sub-system with the
-// wrapping Registerer returned by WrapRegistererWithPrefix. It is rarely useful
-// to use the same prefix for all metrics exposed. In particular, do not prefix
-// metric names that are standardized across applications, as that would break
-// horizontal monitoring, for example the metrics provided by the Go collector
-// (see NewGoCollector) and the process collector (see NewProcessCollector). (In
-// fact, those metrics are already prefixed with “go_” or “process_”,
-// respectively.)
-//
-// Conflicts between Collectors registered through the original Registerer with
-// Collectors registered through the wrapping Registerer will still be
-// detected. Any AlreadyRegisteredError returned by the Register method of
-// either Registerer will contain the ExistingCollector in the form it was
-// provided to the respective registry.
-func WrapRegistererWithPrefix(prefix string, reg Registerer) Registerer {
- return &wrappingRegisterer{
- wrappedRegisterer: reg,
- prefix: prefix,
- }
-}
-
-type wrappingRegisterer struct {
- wrappedRegisterer Registerer
- prefix string
- labels Labels
-}
-
-func (r *wrappingRegisterer) Register(c Collector) error {
- if r.wrappedRegisterer == nil {
- return nil
- }
- return r.wrappedRegisterer.Register(&wrappingCollector{
- wrappedCollector: c,
- prefix: r.prefix,
- labels: r.labels,
- })
-}
-
-func (r *wrappingRegisterer) MustRegister(cs ...Collector) {
- if r.wrappedRegisterer == nil {
- return
- }
- for _, c := range cs {
- if err := r.Register(c); err != nil {
- panic(err)
- }
- }
-}
-
-func (r *wrappingRegisterer) Unregister(c Collector) bool {
- if r.wrappedRegisterer == nil {
- return false
- }
- return r.wrappedRegisterer.Unregister(&wrappingCollector{
- wrappedCollector: c,
- prefix: r.prefix,
- labels: r.labels,
- })
-}
-
-type wrappingCollector struct {
- wrappedCollector Collector
- prefix string
- labels Labels
-}
-
-func (c *wrappingCollector) Collect(ch chan<- Metric) {
- wrappedCh := make(chan Metric)
- go func() {
- c.wrappedCollector.Collect(wrappedCh)
- close(wrappedCh)
- }()
- for m := range wrappedCh {
- ch <- &wrappingMetric{
- wrappedMetric: m,
- prefix: c.prefix,
- labels: c.labels,
- }
- }
-}
-
-func (c *wrappingCollector) Describe(ch chan<- *Desc) {
- wrappedCh := make(chan *Desc)
- go func() {
- c.wrappedCollector.Describe(wrappedCh)
- close(wrappedCh)
- }()
- for desc := range wrappedCh {
- ch <- wrapDesc(desc, c.prefix, c.labels)
- }
-}
-
-func (c *wrappingCollector) unwrapRecursively() Collector {
- switch wc := c.wrappedCollector.(type) {
- case *wrappingCollector:
- return wc.unwrapRecursively()
- default:
- return wc
- }
-}
-
-type wrappingMetric struct {
- wrappedMetric Metric
- prefix string
- labels Labels
-}
-
-func (m *wrappingMetric) Desc() *Desc {
- return wrapDesc(m.wrappedMetric.Desc(), m.prefix, m.labels)
-}
-
-func (m *wrappingMetric) Write(out *dto.Metric) error {
- if err := m.wrappedMetric.Write(out); err != nil {
- return err
- }
- if len(m.labels) == 0 {
- // No wrapping labels.
- return nil
- }
- for ln, lv := range m.labels {
- out.Label = append(out.Label, &dto.LabelPair{
- Name: proto.String(ln),
- Value: proto.String(lv),
- })
- }
- sort.Sort(internal.LabelPairSorter(out.Label))
- return nil
-}
-
-func wrapDesc(desc *Desc, prefix string, labels Labels) *Desc {
- constLabels := Labels{}
- for _, lp := range desc.constLabelPairs {
- constLabels[*lp.Name] = *lp.Value
- }
- for ln, lv := range labels {
- if _, alreadyUsed := constLabels[ln]; alreadyUsed {
- return &Desc{
- fqName: desc.fqName,
- help: desc.help,
- variableLabels: desc.variableLabels,
- constLabelPairs: desc.constLabelPairs,
- err: fmt.Errorf("attempted wrapping with already existing label name %q", ln),
- }
- }
- constLabels[ln] = lv
- }
- // NewDesc will do remaining validations.
- newDesc := V2.NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels)
- // Propagate errors if there was any. This will override any errer
- // created by NewDesc above, i.e. earlier errors get precedence.
- if desc.err != nil {
- newDesc.err = desc.err
- }
- return newDesc
-}
diff --git a/vendor/github.com/prometheus/client_model/LICENSE b/vendor/github.com/prometheus/client_model/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/vendor/github.com/prometheus/client_model/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/prometheus/client_model/NOTICE b/vendor/github.com/prometheus/client_model/NOTICE
deleted file mode 100644
index 20110e4..0000000
--- a/vendor/github.com/prometheus/client_model/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Data model artifacts for Prometheus.
-Copyright 2012-2015 The Prometheus Authors
-
-This product includes software developed at
-SoundCloud Ltd. (http://soundcloud.com/).
diff --git a/vendor/github.com/prometheus/client_model/go/metrics.pb.go b/vendor/github.com/prometheus/client_model/go/metrics.pb.go
deleted file mode 100644
index 2f15490..0000000
--- a/vendor/github.com/prometheus/client_model/go/metrics.pb.go
+++ /dev/null
@@ -1,1399 +0,0 @@
-// Copyright 2013 Prometheus Team
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// protoc-gen-go v1.30.0
-// protoc v3.20.3
-// source: io/prometheus/client/metrics.proto
-
-package io_prometheus_client
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- timestamppb "google.golang.org/protobuf/types/known/timestamppb"
- reflect "reflect"
- sync "sync"
-)
-
-const (
- // Verify that this generated code is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
- // Verify that runtime/protoimpl is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type MetricType int32
-
-const (
- // COUNTER must use the Metric field "counter".
- MetricType_COUNTER MetricType = 0
- // GAUGE must use the Metric field "gauge".
- MetricType_GAUGE MetricType = 1
- // SUMMARY must use the Metric field "summary".
- MetricType_SUMMARY MetricType = 2
- // UNTYPED must use the Metric field "untyped".
- MetricType_UNTYPED MetricType = 3
- // HISTOGRAM must use the Metric field "histogram".
- MetricType_HISTOGRAM MetricType = 4
- // GAUGE_HISTOGRAM must use the Metric field "histogram".
- MetricType_GAUGE_HISTOGRAM MetricType = 5
-)
-
-// Enum value maps for MetricType.
-var (
- MetricType_name = map[int32]string{
- 0: "COUNTER",
- 1: "GAUGE",
- 2: "SUMMARY",
- 3: "UNTYPED",
- 4: "HISTOGRAM",
- 5: "GAUGE_HISTOGRAM",
- }
- MetricType_value = map[string]int32{
- "COUNTER": 0,
- "GAUGE": 1,
- "SUMMARY": 2,
- "UNTYPED": 3,
- "HISTOGRAM": 4,
- "GAUGE_HISTOGRAM": 5,
- }
-)
-
-func (x MetricType) Enum() *MetricType {
- p := new(MetricType)
- *p = x
- return p
-}
-
-func (x MetricType) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (MetricType) Descriptor() protoreflect.EnumDescriptor {
- return file_io_prometheus_client_metrics_proto_enumTypes[0].Descriptor()
-}
-
-func (MetricType) Type() protoreflect.EnumType {
- return &file_io_prometheus_client_metrics_proto_enumTypes[0]
-}
-
-func (x MetricType) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Do not use.
-func (x *MetricType) UnmarshalJSON(b []byte) error {
- num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)
- if err != nil {
- return err
- }
- *x = MetricType(num)
- return nil
-}
-
-// Deprecated: Use MetricType.Descriptor instead.
-func (MetricType) EnumDescriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{0}
-}
-
-type LabelPair struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
-}
-
-func (x *LabelPair) Reset() {
- *x = LabelPair{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *LabelPair) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*LabelPair) ProtoMessage() {}
-
-func (x *LabelPair) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[0]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use LabelPair.ProtoReflect.Descriptor instead.
-func (*LabelPair) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *LabelPair) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *LabelPair) GetValue() string {
- if x != nil && x.Value != nil {
- return *x.Value
- }
- return ""
-}
-
-type Gauge struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"`
-}
-
-func (x *Gauge) Reset() {
- *x = Gauge{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Gauge) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Gauge) ProtoMessage() {}
-
-func (x *Gauge) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[1]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Gauge.ProtoReflect.Descriptor instead.
-func (*Gauge) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{1}
-}
-
-func (x *Gauge) GetValue() float64 {
- if x != nil && x.Value != nil {
- return *x.Value
- }
- return 0
-}
-
-type Counter struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"`
- Exemplar *Exemplar `protobuf:"bytes,2,opt,name=exemplar" json:"exemplar,omitempty"`
- CreatedTimestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=created_timestamp,json=createdTimestamp" json:"created_timestamp,omitempty"`
-}
-
-func (x *Counter) Reset() {
- *x = Counter{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[2]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Counter) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Counter) ProtoMessage() {}
-
-func (x *Counter) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[2]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Counter.ProtoReflect.Descriptor instead.
-func (*Counter) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *Counter) GetValue() float64 {
- if x != nil && x.Value != nil {
- return *x.Value
- }
- return 0
-}
-
-func (x *Counter) GetExemplar() *Exemplar {
- if x != nil {
- return x.Exemplar
- }
- return nil
-}
-
-func (x *Counter) GetCreatedTimestamp() *timestamppb.Timestamp {
- if x != nil {
- return x.CreatedTimestamp
- }
- return nil
-}
-
-type Quantile struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Quantile *float64 `protobuf:"fixed64,1,opt,name=quantile" json:"quantile,omitempty"`
- Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"`
-}
-
-func (x *Quantile) Reset() {
- *x = Quantile{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[3]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Quantile) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Quantile) ProtoMessage() {}
-
-func (x *Quantile) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[3]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Quantile.ProtoReflect.Descriptor instead.
-func (*Quantile) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{3}
-}
-
-func (x *Quantile) GetQuantile() float64 {
- if x != nil && x.Quantile != nil {
- return *x.Quantile
- }
- return 0
-}
-
-func (x *Quantile) GetValue() float64 {
- if x != nil && x.Value != nil {
- return *x.Value
- }
- return 0
-}
-
-type Summary struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"`
- SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"`
- Quantile []*Quantile `protobuf:"bytes,3,rep,name=quantile" json:"quantile,omitempty"`
- CreatedTimestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_timestamp,json=createdTimestamp" json:"created_timestamp,omitempty"`
-}
-
-func (x *Summary) Reset() {
- *x = Summary{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[4]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Summary) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Summary) ProtoMessage() {}
-
-func (x *Summary) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[4]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Summary.ProtoReflect.Descriptor instead.
-func (*Summary) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{4}
-}
-
-func (x *Summary) GetSampleCount() uint64 {
- if x != nil && x.SampleCount != nil {
- return *x.SampleCount
- }
- return 0
-}
-
-func (x *Summary) GetSampleSum() float64 {
- if x != nil && x.SampleSum != nil {
- return *x.SampleSum
- }
- return 0
-}
-
-func (x *Summary) GetQuantile() []*Quantile {
- if x != nil {
- return x.Quantile
- }
- return nil
-}
-
-func (x *Summary) GetCreatedTimestamp() *timestamppb.Timestamp {
- if x != nil {
- return x.CreatedTimestamp
- }
- return nil
-}
-
-type Untyped struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Value *float64 `protobuf:"fixed64,1,opt,name=value" json:"value,omitempty"`
-}
-
-func (x *Untyped) Reset() {
- *x = Untyped{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[5]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Untyped) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Untyped) ProtoMessage() {}
-
-func (x *Untyped) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[5]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Untyped.ProtoReflect.Descriptor instead.
-func (*Untyped) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{5}
-}
-
-func (x *Untyped) GetValue() float64 {
- if x != nil && x.Value != nil {
- return *x.Value
- }
- return 0
-}
-
-type Histogram struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- SampleCount *uint64 `protobuf:"varint,1,opt,name=sample_count,json=sampleCount" json:"sample_count,omitempty"`
- SampleCountFloat *float64 `protobuf:"fixed64,4,opt,name=sample_count_float,json=sampleCountFloat" json:"sample_count_float,omitempty"` // Overrides sample_count if > 0.
- SampleSum *float64 `protobuf:"fixed64,2,opt,name=sample_sum,json=sampleSum" json:"sample_sum,omitempty"`
- // Buckets for the conventional histogram.
- Bucket []*Bucket `protobuf:"bytes,3,rep,name=bucket" json:"bucket,omitempty"` // Ordered in increasing order of upper_bound, +Inf bucket is optional.
- CreatedTimestamp *timestamppb.Timestamp `protobuf:"bytes,15,opt,name=created_timestamp,json=createdTimestamp" json:"created_timestamp,omitempty"`
- // schema defines the bucket schema. Currently, valid numbers are -4 <= n <= 8.
- // They are all for base-2 bucket schemas, where 1 is a bucket boundary in each case, and
- // then each power of two is divided into 2^n logarithmic buckets.
- // Or in other words, each bucket boundary is the previous boundary times 2^(2^-n).
- // In the future, more bucket schemas may be added using numbers < -4 or > 8.
- Schema *int32 `protobuf:"zigzag32,5,opt,name=schema" json:"schema,omitempty"`
- ZeroThreshold *float64 `protobuf:"fixed64,6,opt,name=zero_threshold,json=zeroThreshold" json:"zero_threshold,omitempty"` // Breadth of the zero bucket.
- ZeroCount *uint64 `protobuf:"varint,7,opt,name=zero_count,json=zeroCount" json:"zero_count,omitempty"` // Count in zero bucket.
- ZeroCountFloat *float64 `protobuf:"fixed64,8,opt,name=zero_count_float,json=zeroCountFloat" json:"zero_count_float,omitempty"` // Overrides sb_zero_count if > 0.
- // Negative buckets for the native histogram.
- NegativeSpan []*BucketSpan `protobuf:"bytes,9,rep,name=negative_span,json=negativeSpan" json:"negative_span,omitempty"`
- // Use either "negative_delta" or "negative_count", the former for
- // regular histograms with integer counts, the latter for float
- // histograms.
- NegativeDelta []int64 `protobuf:"zigzag64,10,rep,name=negative_delta,json=negativeDelta" json:"negative_delta,omitempty"` // Count delta of each bucket compared to previous one (or to zero for 1st bucket).
- NegativeCount []float64 `protobuf:"fixed64,11,rep,name=negative_count,json=negativeCount" json:"negative_count,omitempty"` // Absolute count of each bucket.
- // Positive buckets for the native histogram.
- // Use a no-op span (offset 0, length 0) for a native histogram without any
- // observations yet and with a zero_threshold of 0. Otherwise, it would be
- // indistinguishable from a classic histogram.
- PositiveSpan []*BucketSpan `protobuf:"bytes,12,rep,name=positive_span,json=positiveSpan" json:"positive_span,omitempty"`
- // Use either "positive_delta" or "positive_count", the former for
- // regular histograms with integer counts, the latter for float
- // histograms.
- PositiveDelta []int64 `protobuf:"zigzag64,13,rep,name=positive_delta,json=positiveDelta" json:"positive_delta,omitempty"` // Count delta of each bucket compared to previous one (or to zero for 1st bucket).
- PositiveCount []float64 `protobuf:"fixed64,14,rep,name=positive_count,json=positiveCount" json:"positive_count,omitempty"` // Absolute count of each bucket.
- // Only used for native histograms. These exemplars MUST have a timestamp.
- Exemplars []*Exemplar `protobuf:"bytes,16,rep,name=exemplars" json:"exemplars,omitempty"`
-}
-
-func (x *Histogram) Reset() {
- *x = Histogram{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[6]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Histogram) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Histogram) ProtoMessage() {}
-
-func (x *Histogram) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[6]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Histogram.ProtoReflect.Descriptor instead.
-func (*Histogram) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{6}
-}
-
-func (x *Histogram) GetSampleCount() uint64 {
- if x != nil && x.SampleCount != nil {
- return *x.SampleCount
- }
- return 0
-}
-
-func (x *Histogram) GetSampleCountFloat() float64 {
- if x != nil && x.SampleCountFloat != nil {
- return *x.SampleCountFloat
- }
- return 0
-}
-
-func (x *Histogram) GetSampleSum() float64 {
- if x != nil && x.SampleSum != nil {
- return *x.SampleSum
- }
- return 0
-}
-
-func (x *Histogram) GetBucket() []*Bucket {
- if x != nil {
- return x.Bucket
- }
- return nil
-}
-
-func (x *Histogram) GetCreatedTimestamp() *timestamppb.Timestamp {
- if x != nil {
- return x.CreatedTimestamp
- }
- return nil
-}
-
-func (x *Histogram) GetSchema() int32 {
- if x != nil && x.Schema != nil {
- return *x.Schema
- }
- return 0
-}
-
-func (x *Histogram) GetZeroThreshold() float64 {
- if x != nil && x.ZeroThreshold != nil {
- return *x.ZeroThreshold
- }
- return 0
-}
-
-func (x *Histogram) GetZeroCount() uint64 {
- if x != nil && x.ZeroCount != nil {
- return *x.ZeroCount
- }
- return 0
-}
-
-func (x *Histogram) GetZeroCountFloat() float64 {
- if x != nil && x.ZeroCountFloat != nil {
- return *x.ZeroCountFloat
- }
- return 0
-}
-
-func (x *Histogram) GetNegativeSpan() []*BucketSpan {
- if x != nil {
- return x.NegativeSpan
- }
- return nil
-}
-
-func (x *Histogram) GetNegativeDelta() []int64 {
- if x != nil {
- return x.NegativeDelta
- }
- return nil
-}
-
-func (x *Histogram) GetNegativeCount() []float64 {
- if x != nil {
- return x.NegativeCount
- }
- return nil
-}
-
-func (x *Histogram) GetPositiveSpan() []*BucketSpan {
- if x != nil {
- return x.PositiveSpan
- }
- return nil
-}
-
-func (x *Histogram) GetPositiveDelta() []int64 {
- if x != nil {
- return x.PositiveDelta
- }
- return nil
-}
-
-func (x *Histogram) GetPositiveCount() []float64 {
- if x != nil {
- return x.PositiveCount
- }
- return nil
-}
-
-func (x *Histogram) GetExemplars() []*Exemplar {
- if x != nil {
- return x.Exemplars
- }
- return nil
-}
-
-// A Bucket of a conventional histogram, each of which is treated as
-// an individual counter-like time series by Prometheus.
-type Bucket struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- CumulativeCount *uint64 `protobuf:"varint,1,opt,name=cumulative_count,json=cumulativeCount" json:"cumulative_count,omitempty"` // Cumulative in increasing order.
- CumulativeCountFloat *float64 `protobuf:"fixed64,4,opt,name=cumulative_count_float,json=cumulativeCountFloat" json:"cumulative_count_float,omitempty"` // Overrides cumulative_count if > 0.
- UpperBound *float64 `protobuf:"fixed64,2,opt,name=upper_bound,json=upperBound" json:"upper_bound,omitempty"` // Inclusive.
- Exemplar *Exemplar `protobuf:"bytes,3,opt,name=exemplar" json:"exemplar,omitempty"`
-}
-
-func (x *Bucket) Reset() {
- *x = Bucket{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[7]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Bucket) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Bucket) ProtoMessage() {}
-
-func (x *Bucket) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[7]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Bucket.ProtoReflect.Descriptor instead.
-func (*Bucket) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{7}
-}
-
-func (x *Bucket) GetCumulativeCount() uint64 {
- if x != nil && x.CumulativeCount != nil {
- return *x.CumulativeCount
- }
- return 0
-}
-
-func (x *Bucket) GetCumulativeCountFloat() float64 {
- if x != nil && x.CumulativeCountFloat != nil {
- return *x.CumulativeCountFloat
- }
- return 0
-}
-
-func (x *Bucket) GetUpperBound() float64 {
- if x != nil && x.UpperBound != nil {
- return *x.UpperBound
- }
- return 0
-}
-
-func (x *Bucket) GetExemplar() *Exemplar {
- if x != nil {
- return x.Exemplar
- }
- return nil
-}
-
-// A BucketSpan defines a number of consecutive buckets in a native
-// histogram with their offset. Logically, it would be more
-// straightforward to include the bucket counts in the Span. However,
-// the protobuf representation is more compact in the way the data is
-// structured here (with all the buckets in a single array separate
-// from the Spans).
-type BucketSpan struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Offset *int32 `protobuf:"zigzag32,1,opt,name=offset" json:"offset,omitempty"` // Gap to previous span, or starting point for 1st span (which can be negative).
- Length *uint32 `protobuf:"varint,2,opt,name=length" json:"length,omitempty"` // Length of consecutive buckets.
-}
-
-func (x *BucketSpan) Reset() {
- *x = BucketSpan{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[8]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *BucketSpan) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*BucketSpan) ProtoMessage() {}
-
-func (x *BucketSpan) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[8]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use BucketSpan.ProtoReflect.Descriptor instead.
-func (*BucketSpan) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{8}
-}
-
-func (x *BucketSpan) GetOffset() int32 {
- if x != nil && x.Offset != nil {
- return *x.Offset
- }
- return 0
-}
-
-func (x *BucketSpan) GetLength() uint32 {
- if x != nil && x.Length != nil {
- return *x.Length
- }
- return 0
-}
-
-type Exemplar struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"`
- Value *float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"`
- Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp" json:"timestamp,omitempty"` // OpenMetrics-style.
-}
-
-func (x *Exemplar) Reset() {
- *x = Exemplar{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[9]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Exemplar) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Exemplar) ProtoMessage() {}
-
-func (x *Exemplar) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[9]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Exemplar.ProtoReflect.Descriptor instead.
-func (*Exemplar) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{9}
-}
-
-func (x *Exemplar) GetLabel() []*LabelPair {
- if x != nil {
- return x.Label
- }
- return nil
-}
-
-func (x *Exemplar) GetValue() float64 {
- if x != nil && x.Value != nil {
- return *x.Value
- }
- return 0
-}
-
-func (x *Exemplar) GetTimestamp() *timestamppb.Timestamp {
- if x != nil {
- return x.Timestamp
- }
- return nil
-}
-
-type Metric struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Label []*LabelPair `protobuf:"bytes,1,rep,name=label" json:"label,omitempty"`
- Gauge *Gauge `protobuf:"bytes,2,opt,name=gauge" json:"gauge,omitempty"`
- Counter *Counter `protobuf:"bytes,3,opt,name=counter" json:"counter,omitempty"`
- Summary *Summary `protobuf:"bytes,4,opt,name=summary" json:"summary,omitempty"`
- Untyped *Untyped `protobuf:"bytes,5,opt,name=untyped" json:"untyped,omitempty"`
- Histogram *Histogram `protobuf:"bytes,7,opt,name=histogram" json:"histogram,omitempty"`
- TimestampMs *int64 `protobuf:"varint,6,opt,name=timestamp_ms,json=timestampMs" json:"timestamp_ms,omitempty"`
-}
-
-func (x *Metric) Reset() {
- *x = Metric{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[10]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Metric) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Metric) ProtoMessage() {}
-
-func (x *Metric) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[10]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Metric.ProtoReflect.Descriptor instead.
-func (*Metric) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{10}
-}
-
-func (x *Metric) GetLabel() []*LabelPair {
- if x != nil {
- return x.Label
- }
- return nil
-}
-
-func (x *Metric) GetGauge() *Gauge {
- if x != nil {
- return x.Gauge
- }
- return nil
-}
-
-func (x *Metric) GetCounter() *Counter {
- if x != nil {
- return x.Counter
- }
- return nil
-}
-
-func (x *Metric) GetSummary() *Summary {
- if x != nil {
- return x.Summary
- }
- return nil
-}
-
-func (x *Metric) GetUntyped() *Untyped {
- if x != nil {
- return x.Untyped
- }
- return nil
-}
-
-func (x *Metric) GetHistogram() *Histogram {
- if x != nil {
- return x.Histogram
- }
- return nil
-}
-
-func (x *Metric) GetTimestampMs() int64 {
- if x != nil && x.TimestampMs != nil {
- return *x.TimestampMs
- }
- return 0
-}
-
-type MetricFamily struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-
- Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
- Help *string `protobuf:"bytes,2,opt,name=help" json:"help,omitempty"`
- Type *MetricType `protobuf:"varint,3,opt,name=type,enum=io.prometheus.client.MetricType" json:"type,omitempty"`
- Metric []*Metric `protobuf:"bytes,4,rep,name=metric" json:"metric,omitempty"`
- Unit *string `protobuf:"bytes,5,opt,name=unit" json:"unit,omitempty"`
-}
-
-func (x *MetricFamily) Reset() {
- *x = MetricFamily{}
- if protoimpl.UnsafeEnabled {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[11]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *MetricFamily) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*MetricFamily) ProtoMessage() {}
-
-func (x *MetricFamily) ProtoReflect() protoreflect.Message {
- mi := &file_io_prometheus_client_metrics_proto_msgTypes[11]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use MetricFamily.ProtoReflect.Descriptor instead.
-func (*MetricFamily) Descriptor() ([]byte, []int) {
- return file_io_prometheus_client_metrics_proto_rawDescGZIP(), []int{11}
-}
-
-func (x *MetricFamily) GetName() string {
- if x != nil && x.Name != nil {
- return *x.Name
- }
- return ""
-}
-
-func (x *MetricFamily) GetHelp() string {
- if x != nil && x.Help != nil {
- return *x.Help
- }
- return ""
-}
-
-func (x *MetricFamily) GetType() MetricType {
- if x != nil && x.Type != nil {
- return *x.Type
- }
- return MetricType_COUNTER
-}
-
-func (x *MetricFamily) GetMetric() []*Metric {
- if x != nil {
- return x.Metric
- }
- return nil
-}
-
-func (x *MetricFamily) GetUnit() string {
- if x != nil && x.Unit != nil {
- return *x.Unit
- }
- return ""
-}
-
-var File_io_prometheus_client_metrics_proto protoreflect.FileDescriptor
-
-var file_io_prometheus_client_metrics_proto_rawDesc = []byte{
- 0x0a, 0x22, 0x69, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2f,
- 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68,
- 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67,
- 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65,
- 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x35, 0x0a, 0x09, 0x4c,
- 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
- 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05,
- 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c,
- 0x75, 0x65, 0x22, 0x1d, 0x0a, 0x05, 0x47, 0x61, 0x75, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76,
- 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
- 0x65, 0x22, 0xa4, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a,
- 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61,
- 0x6c, 0x75, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x18,
- 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65,
- 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78, 0x65,
- 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x12,
- 0x47, 0x0a, 0x11, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73,
- 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f,
- 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d,
- 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x10, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x54,
- 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x3c, 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e,
- 0x74, 0x69, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65,
- 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65,
- 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52,
- 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xd0, 0x01, 0x0a, 0x07, 0x53, 0x75, 0x6d, 0x6d, 0x61,
- 0x72, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75,
- 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65,
- 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f,
- 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x73, 0x61, 0x6d, 0x70, 0x6c,
- 0x65, 0x53, 0x75, 0x6d, 0x12, 0x3a, 0x0a, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65,
- 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d,
- 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x51, 0x75,
- 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x52, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x6c, 0x65,
- 0x12, 0x47, 0x0a, 0x11, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65,
- 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f,
- 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69,
- 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x10, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
- 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x1f, 0x0a, 0x07, 0x55, 0x6e, 0x74,
- 0x79, 0x70, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20,
- 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xea, 0x05, 0x0a, 0x09, 0x48,
- 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70,
- 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b,
- 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x73,
- 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61,
- 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x10, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x43,
- 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x61, 0x6d,
- 0x70, 0x6c, 0x65, 0x5f, 0x73, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x73,
- 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x53, 0x75, 0x6d, 0x12, 0x34, 0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b,
- 0x65, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72,
- 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e,
- 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x47,
- 0x0a, 0x11, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
- 0x61, 0x6d, 0x70, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
- 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65,
- 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x10, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69,
- 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d,
- 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12,
- 0x25, 0x0a, 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c,
- 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0d, 0x7a, 0x65, 0x72, 0x6f, 0x54, 0x68, 0x72,
- 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x63,
- 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x7a, 0x65, 0x72, 0x6f,
- 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x63, 0x6f,
- 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x01, 0x52,
- 0x0e, 0x7a, 0x65, 0x72, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12,
- 0x45, 0x0a, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x73, 0x70, 0x61, 0x6e,
- 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d,
- 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x42, 0x75,
- 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x52, 0x0c, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69,
- 0x76, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69,
- 0x76, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x12, 0x52, 0x0d,
- 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x6c, 0x74, 0x61, 0x12, 0x25, 0x0a,
- 0x0e, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18,
- 0x0b, 0x20, 0x03, 0x28, 0x01, 0x52, 0x0d, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43,
- 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x45, 0x0a, 0x0d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65,
- 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6f,
- 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65,
- 0x6e, 0x74, 0x2e, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x52, 0x0c, 0x70,
- 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x70,
- 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x64, 0x65, 0x6c, 0x74, 0x61, 0x18, 0x0d, 0x20,
- 0x03, 0x28, 0x12, 0x52, 0x0d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x44, 0x65, 0x6c,
- 0x74, 0x61, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63,
- 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x01, 0x52, 0x0d, 0x70, 0x6f, 0x73, 0x69,
- 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x09, 0x65, 0x78, 0x65,
- 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69,
- 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69,
- 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x09, 0x65, 0x78,
- 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x73, 0x22, 0xc6, 0x01, 0x0a, 0x06, 0x42, 0x75, 0x63, 0x6b,
- 0x65, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65,
- 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x63, 0x75,
- 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x34, 0x0a,
- 0x16, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e,
- 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x14, 0x63,
- 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x6c,
- 0x6f, 0x61, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x62, 0x6f, 0x75,
- 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, 0x75, 0x70, 0x70, 0x65, 0x72, 0x42,
- 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72,
- 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d,
- 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x45, 0x78,
- 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x52, 0x08, 0x65, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72,
- 0x22, 0x3c, 0x0a, 0x0a, 0x42, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x16,
- 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x11, 0x52, 0x06,
- 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68,
- 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0x91,
- 0x01, 0x0a, 0x08, 0x45, 0x78, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x72, 0x12, 0x35, 0x0a, 0x05, 0x6c,
- 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6f, 0x2e,
- 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e,
- 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x52, 0x05, 0x6c, 0x61, 0x62,
- 0x65, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
- 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65,
- 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f,
- 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69,
- 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
- 0x6d, 0x70, 0x22, 0xff, 0x02, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x35, 0x0a,
- 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69,
- 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69,
- 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x50, 0x61, 0x69, 0x72, 0x52, 0x05, 0x6c,
- 0x61, 0x62, 0x65, 0x6c, 0x12, 0x31, 0x0a, 0x05, 0x67, 0x61, 0x75, 0x67, 0x65, 0x18, 0x02, 0x20,
- 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68,
- 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x61, 0x75, 0x67, 0x65,
- 0x52, 0x05, 0x67, 0x61, 0x75, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74,
- 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72,
- 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e,
- 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72,
- 0x12, 0x37, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28,
- 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75,
- 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79,
- 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x37, 0x0a, 0x07, 0x75, 0x6e, 0x74,
- 0x79, 0x70, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6f, 0x2e,
- 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e,
- 0x74, 0x2e, 0x55, 0x6e, 0x74, 0x79, 0x70, 0x65, 0x64, 0x52, 0x07, 0x75, 0x6e, 0x74, 0x79, 0x70,
- 0x65, 0x64, 0x12, 0x3d, 0x0a, 0x09, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x18,
- 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65,
- 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x48, 0x69, 0x73,
- 0x74, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x52, 0x09, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x67, 0x72, 0x61,
- 0x6d, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x6d,
- 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
- 0x6d, 0x70, 0x4d, 0x73, 0x22, 0xb6, 0x01, 0x0a, 0x0c, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x46,
- 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x65, 0x6c,
- 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x65, 0x6c, 0x70, 0x12, 0x34, 0x0a,
- 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x69, 0x6f,
- 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65,
- 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74,
- 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x04, 0x20,
- 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68,
- 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69,
- 0x63, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x6e, 0x69,
- 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x6e, 0x69, 0x74, 0x2a, 0x62, 0x0a,
- 0x0a, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x43,
- 0x4f, 0x55, 0x4e, 0x54, 0x45, 0x52, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x47, 0x41, 0x55, 0x47,
- 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x55, 0x4d, 0x4d, 0x41, 0x52, 0x59, 0x10, 0x02,
- 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x54, 0x59, 0x50, 0x45, 0x44, 0x10, 0x03, 0x12, 0x0d, 0x0a,
- 0x09, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, 0x4d, 0x10, 0x04, 0x12, 0x13, 0x0a, 0x0f,
- 0x47, 0x41, 0x55, 0x47, 0x45, 0x5f, 0x48, 0x49, 0x53, 0x54, 0x4f, 0x47, 0x52, 0x41, 0x4d, 0x10,
- 0x05, 0x42, 0x52, 0x0a, 0x14, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65,
- 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75,
- 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73,
- 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x67, 0x6f,
- 0x3b, 0x69, 0x6f, 0x5f, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x5f, 0x63,
- 0x6c, 0x69, 0x65, 0x6e, 0x74,
-}
-
-var (
- file_io_prometheus_client_metrics_proto_rawDescOnce sync.Once
- file_io_prometheus_client_metrics_proto_rawDescData = file_io_prometheus_client_metrics_proto_rawDesc
-)
-
-func file_io_prometheus_client_metrics_proto_rawDescGZIP() []byte {
- file_io_prometheus_client_metrics_proto_rawDescOnce.Do(func() {
- file_io_prometheus_client_metrics_proto_rawDescData = protoimpl.X.CompressGZIP(file_io_prometheus_client_metrics_proto_rawDescData)
- })
- return file_io_prometheus_client_metrics_proto_rawDescData
-}
-
-var file_io_prometheus_client_metrics_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_io_prometheus_client_metrics_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
-var file_io_prometheus_client_metrics_proto_goTypes = []interface{}{
- (MetricType)(0), // 0: io.prometheus.client.MetricType
- (*LabelPair)(nil), // 1: io.prometheus.client.LabelPair
- (*Gauge)(nil), // 2: io.prometheus.client.Gauge
- (*Counter)(nil), // 3: io.prometheus.client.Counter
- (*Quantile)(nil), // 4: io.prometheus.client.Quantile
- (*Summary)(nil), // 5: io.prometheus.client.Summary
- (*Untyped)(nil), // 6: io.prometheus.client.Untyped
- (*Histogram)(nil), // 7: io.prometheus.client.Histogram
- (*Bucket)(nil), // 8: io.prometheus.client.Bucket
- (*BucketSpan)(nil), // 9: io.prometheus.client.BucketSpan
- (*Exemplar)(nil), // 10: io.prometheus.client.Exemplar
- (*Metric)(nil), // 11: io.prometheus.client.Metric
- (*MetricFamily)(nil), // 12: io.prometheus.client.MetricFamily
- (*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp
-}
-var file_io_prometheus_client_metrics_proto_depIdxs = []int32{
- 10, // 0: io.prometheus.client.Counter.exemplar:type_name -> io.prometheus.client.Exemplar
- 13, // 1: io.prometheus.client.Counter.created_timestamp:type_name -> google.protobuf.Timestamp
- 4, // 2: io.prometheus.client.Summary.quantile:type_name -> io.prometheus.client.Quantile
- 13, // 3: io.prometheus.client.Summary.created_timestamp:type_name -> google.protobuf.Timestamp
- 8, // 4: io.prometheus.client.Histogram.bucket:type_name -> io.prometheus.client.Bucket
- 13, // 5: io.prometheus.client.Histogram.created_timestamp:type_name -> google.protobuf.Timestamp
- 9, // 6: io.prometheus.client.Histogram.negative_span:type_name -> io.prometheus.client.BucketSpan
- 9, // 7: io.prometheus.client.Histogram.positive_span:type_name -> io.prometheus.client.BucketSpan
- 10, // 8: io.prometheus.client.Histogram.exemplars:type_name -> io.prometheus.client.Exemplar
- 10, // 9: io.prometheus.client.Bucket.exemplar:type_name -> io.prometheus.client.Exemplar
- 1, // 10: io.prometheus.client.Exemplar.label:type_name -> io.prometheus.client.LabelPair
- 13, // 11: io.prometheus.client.Exemplar.timestamp:type_name -> google.protobuf.Timestamp
- 1, // 12: io.prometheus.client.Metric.label:type_name -> io.prometheus.client.LabelPair
- 2, // 13: io.prometheus.client.Metric.gauge:type_name -> io.prometheus.client.Gauge
- 3, // 14: io.prometheus.client.Metric.counter:type_name -> io.prometheus.client.Counter
- 5, // 15: io.prometheus.client.Metric.summary:type_name -> io.prometheus.client.Summary
- 6, // 16: io.prometheus.client.Metric.untyped:type_name -> io.prometheus.client.Untyped
- 7, // 17: io.prometheus.client.Metric.histogram:type_name -> io.prometheus.client.Histogram
- 0, // 18: io.prometheus.client.MetricFamily.type:type_name -> io.prometheus.client.MetricType
- 11, // 19: io.prometheus.client.MetricFamily.metric:type_name -> io.prometheus.client.Metric
- 20, // [20:20] is the sub-list for method output_type
- 20, // [20:20] is the sub-list for method input_type
- 20, // [20:20] is the sub-list for extension type_name
- 20, // [20:20] is the sub-list for extension extendee
- 0, // [0:20] is the sub-list for field type_name
-}
-
-func init() { file_io_prometheus_client_metrics_proto_init() }
-func file_io_prometheus_client_metrics_proto_init() {
- if File_io_prometheus_client_metrics_proto != nil {
- return
- }
- if !protoimpl.UnsafeEnabled {
- file_io_prometheus_client_metrics_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*LabelPair); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Gauge); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Counter); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Quantile); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Summary); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Untyped); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Histogram); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Bucket); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*BucketSpan); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Exemplar); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Metric); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_io_prometheus_client_metrics_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*MetricFamily); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- }
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: file_io_prometheus_client_metrics_proto_rawDesc,
- NumEnums: 1,
- NumMessages: 12,
- NumExtensions: 0,
- NumServices: 0,
- },
- GoTypes: file_io_prometheus_client_metrics_proto_goTypes,
- DependencyIndexes: file_io_prometheus_client_metrics_proto_depIdxs,
- EnumInfos: file_io_prometheus_client_metrics_proto_enumTypes,
- MessageInfos: file_io_prometheus_client_metrics_proto_msgTypes,
- }.Build()
- File_io_prometheus_client_metrics_proto = out.File
- file_io_prometheus_client_metrics_proto_rawDesc = nil
- file_io_prometheus_client_metrics_proto_goTypes = nil
- file_io_prometheus_client_metrics_proto_depIdxs = nil
-}
diff --git a/vendor/github.com/prometheus/common/LICENSE b/vendor/github.com/prometheus/common/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/vendor/github.com/prometheus/common/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/prometheus/common/NOTICE b/vendor/github.com/prometheus/common/NOTICE
deleted file mode 100644
index 636a2c1..0000000
--- a/vendor/github.com/prometheus/common/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Common libraries shared by Prometheus Go components.
-Copyright 2015 The Prometheus Authors
-
-This product includes software developed at
-SoundCloud Ltd. (http://soundcloud.com/).
diff --git a/vendor/github.com/prometheus/common/expfmt/decode.go b/vendor/github.com/prometheus/common/expfmt/decode.go
deleted file mode 100644
index 25cfaa2..0000000
--- a/vendor/github.com/prometheus/common/expfmt/decode.go
+++ /dev/null
@@ -1,431 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package expfmt
-
-import (
- "bufio"
- "fmt"
- "io"
- "math"
- "mime"
- "net/http"
-
- dto "github.com/prometheus/client_model/go"
- "google.golang.org/protobuf/encoding/protodelim"
-
- "github.com/prometheus/common/model"
-)
-
-// Decoder types decode an input stream into metric families.
-type Decoder interface {
- Decode(*dto.MetricFamily) error
-}
-
-// DecodeOptions contains options used by the Decoder and in sample extraction.
-type DecodeOptions struct {
- // Timestamp is added to each value from the stream that has no explicit timestamp set.
- Timestamp model.Time
-}
-
-// ResponseFormat extracts the correct format from a HTTP response header.
-// If no matching format can be found FormatUnknown is returned.
-func ResponseFormat(h http.Header) Format {
- ct := h.Get(hdrContentType)
-
- mediatype, params, err := mime.ParseMediaType(ct)
- if err != nil {
- return fmtUnknown
- }
-
- const textType = "text/plain"
-
- switch mediatype {
- case ProtoType:
- if p, ok := params["proto"]; ok && p != ProtoProtocol {
- return fmtUnknown
- }
- if e, ok := params["encoding"]; ok && e != "delimited" {
- return fmtUnknown
- }
- return fmtProtoDelim
-
- case textType:
- if v, ok := params["version"]; ok && v != TextVersion {
- return fmtUnknown
- }
- return fmtText
- }
-
- return fmtUnknown
-}
-
-// NewDecoder returns a new decoder based on the given input format.
-// If the input format does not imply otherwise, a text format decoder is returned.
-func NewDecoder(r io.Reader, format Format) Decoder {
- switch format.FormatType() {
- case TypeProtoDelim:
- return &protoDecoder{r: bufio.NewReader(r)}
- }
- return &textDecoder{r: r}
-}
-
-// protoDecoder implements the Decoder interface for protocol buffers.
-type protoDecoder struct {
- r protodelim.Reader
-}
-
-// Decode implements the Decoder interface.
-func (d *protoDecoder) Decode(v *dto.MetricFamily) error {
- opts := protodelim.UnmarshalOptions{
- MaxSize: -1,
- }
- if err := opts.UnmarshalFrom(d.r, v); err != nil {
- return err
- }
- if !model.IsValidMetricName(model.LabelValue(v.GetName())) {
- return fmt.Errorf("invalid metric name %q", v.GetName())
- }
- for _, m := range v.GetMetric() {
- if m == nil {
- continue
- }
- for _, l := range m.GetLabel() {
- if l == nil {
- continue
- }
- if !model.LabelValue(l.GetValue()).IsValid() {
- return fmt.Errorf("invalid label value %q", l.GetValue())
- }
- if !model.LabelName(l.GetName()).IsValid() {
- return fmt.Errorf("invalid label name %q", l.GetName())
- }
- }
- }
- return nil
-}
-
-// textDecoder implements the Decoder interface for the text protocol.
-type textDecoder struct {
- r io.Reader
- fams map[string]*dto.MetricFamily
- err error
-}
-
-// Decode implements the Decoder interface.
-func (d *textDecoder) Decode(v *dto.MetricFamily) error {
- if d.err == nil {
- // Read all metrics in one shot.
- var p TextParser
- d.fams, d.err = p.TextToMetricFamilies(d.r)
- // If we don't get an error, store io.EOF for the end.
- if d.err == nil {
- d.err = io.EOF
- }
- }
- // Pick off one MetricFamily per Decode until there's nothing left.
- for key, fam := range d.fams {
- v.Name = fam.Name
- v.Help = fam.Help
- v.Type = fam.Type
- v.Metric = fam.Metric
- delete(d.fams, key)
- return nil
- }
- return d.err
-}
-
-// SampleDecoder wraps a Decoder to extract samples from the metric families
-// decoded by the wrapped Decoder.
-type SampleDecoder struct {
- Dec Decoder
- Opts *DecodeOptions
-
- f dto.MetricFamily
-}
-
-// Decode calls the Decode method of the wrapped Decoder and then extracts the
-// samples from the decoded MetricFamily into the provided model.Vector.
-func (sd *SampleDecoder) Decode(s *model.Vector) error {
- err := sd.Dec.Decode(&sd.f)
- if err != nil {
- return err
- }
- *s, err = extractSamples(&sd.f, sd.Opts)
- return err
-}
-
-// ExtractSamples builds a slice of samples from the provided metric
-// families. If an error occurs during sample extraction, it continues to
-// extract from the remaining metric families. The returned error is the last
-// error that has occurred.
-func ExtractSamples(o *DecodeOptions, fams ...*dto.MetricFamily) (model.Vector, error) {
- var (
- all model.Vector
- lastErr error
- )
- for _, f := range fams {
- some, err := extractSamples(f, o)
- if err != nil {
- lastErr = err
- continue
- }
- all = append(all, some...)
- }
- return all, lastErr
-}
-
-func extractSamples(f *dto.MetricFamily, o *DecodeOptions) (model.Vector, error) {
- switch f.GetType() {
- case dto.MetricType_COUNTER:
- return extractCounter(o, f), nil
- case dto.MetricType_GAUGE:
- return extractGauge(o, f), nil
- case dto.MetricType_SUMMARY:
- return extractSummary(o, f), nil
- case dto.MetricType_UNTYPED:
- return extractUntyped(o, f), nil
- case dto.MetricType_HISTOGRAM:
- return extractHistogram(o, f), nil
- }
- return nil, fmt.Errorf("expfmt.extractSamples: unknown metric family type %v", f.GetType())
-}
-
-func extractCounter(o *DecodeOptions, f *dto.MetricFamily) model.Vector {
- samples := make(model.Vector, 0, len(f.Metric))
-
- for _, m := range f.Metric {
- if m.Counter == nil {
- continue
- }
-
- lset := make(model.LabelSet, len(m.Label)+1)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName())
-
- smpl := &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(m.Counter.GetValue()),
- }
-
- if m.TimestampMs != nil {
- smpl.Timestamp = model.TimeFromUnixNano(*m.TimestampMs * 1000000)
- } else {
- smpl.Timestamp = o.Timestamp
- }
-
- samples = append(samples, smpl)
- }
-
- return samples
-}
-
-func extractGauge(o *DecodeOptions, f *dto.MetricFamily) model.Vector {
- samples := make(model.Vector, 0, len(f.Metric))
-
- for _, m := range f.Metric {
- if m.Gauge == nil {
- continue
- }
-
- lset := make(model.LabelSet, len(m.Label)+1)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName())
-
- smpl := &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(m.Gauge.GetValue()),
- }
-
- if m.TimestampMs != nil {
- smpl.Timestamp = model.TimeFromUnixNano(*m.TimestampMs * 1000000)
- } else {
- smpl.Timestamp = o.Timestamp
- }
-
- samples = append(samples, smpl)
- }
-
- return samples
-}
-
-func extractUntyped(o *DecodeOptions, f *dto.MetricFamily) model.Vector {
- samples := make(model.Vector, 0, len(f.Metric))
-
- for _, m := range f.Metric {
- if m.Untyped == nil {
- continue
- }
-
- lset := make(model.LabelSet, len(m.Label)+1)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName())
-
- smpl := &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(m.Untyped.GetValue()),
- }
-
- if m.TimestampMs != nil {
- smpl.Timestamp = model.TimeFromUnixNano(*m.TimestampMs * 1000000)
- } else {
- smpl.Timestamp = o.Timestamp
- }
-
- samples = append(samples, smpl)
- }
-
- return samples
-}
-
-func extractSummary(o *DecodeOptions, f *dto.MetricFamily) model.Vector {
- samples := make(model.Vector, 0, len(f.Metric))
-
- for _, m := range f.Metric {
- if m.Summary == nil {
- continue
- }
-
- timestamp := o.Timestamp
- if m.TimestampMs != nil {
- timestamp = model.TimeFromUnixNano(*m.TimestampMs * 1000000)
- }
-
- for _, q := range m.Summary.Quantile {
- lset := make(model.LabelSet, len(m.Label)+2)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- // BUG(matt): Update other names to "quantile".
- lset[model.LabelName(model.QuantileLabel)] = model.LabelValue(fmt.Sprint(q.GetQuantile()))
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName())
-
- samples = append(samples, &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(q.GetValue()),
- Timestamp: timestamp,
- })
- }
-
- lset := make(model.LabelSet, len(m.Label)+1)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_sum")
-
- samples = append(samples, &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(m.Summary.GetSampleSum()),
- Timestamp: timestamp,
- })
-
- lset = make(model.LabelSet, len(m.Label)+1)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_count")
-
- samples = append(samples, &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(m.Summary.GetSampleCount()),
- Timestamp: timestamp,
- })
- }
-
- return samples
-}
-
-func extractHistogram(o *DecodeOptions, f *dto.MetricFamily) model.Vector {
- samples := make(model.Vector, 0, len(f.Metric))
-
- for _, m := range f.Metric {
- if m.Histogram == nil {
- continue
- }
-
- timestamp := o.Timestamp
- if m.TimestampMs != nil {
- timestamp = model.TimeFromUnixNano(*m.TimestampMs * 1000000)
- }
-
- infSeen := false
-
- for _, q := range m.Histogram.Bucket {
- lset := make(model.LabelSet, len(m.Label)+2)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.LabelName(model.BucketLabel)] = model.LabelValue(fmt.Sprint(q.GetUpperBound()))
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_bucket")
-
- if math.IsInf(q.GetUpperBound(), +1) {
- infSeen = true
- }
-
- samples = append(samples, &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(q.GetCumulativeCount()),
- Timestamp: timestamp,
- })
- }
-
- lset := make(model.LabelSet, len(m.Label)+1)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_sum")
-
- samples = append(samples, &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(m.Histogram.GetSampleSum()),
- Timestamp: timestamp,
- })
-
- lset = make(model.LabelSet, len(m.Label)+1)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_count")
-
- count := &model.Sample{
- Metric: model.Metric(lset),
- Value: model.SampleValue(m.Histogram.GetSampleCount()),
- Timestamp: timestamp,
- }
- samples = append(samples, count)
-
- if !infSeen {
- // Append an infinity bucket sample.
- lset := make(model.LabelSet, len(m.Label)+2)
- for _, p := range m.Label {
- lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
- }
- lset[model.LabelName(model.BucketLabel)] = model.LabelValue("+Inf")
- lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_bucket")
-
- samples = append(samples, &model.Sample{
- Metric: model.Metric(lset),
- Value: count.Value,
- Timestamp: timestamp,
- })
- }
- }
-
- return samples
-}
diff --git a/vendor/github.com/prometheus/common/expfmt/encode.go b/vendor/github.com/prometheus/common/expfmt/encode.go
deleted file mode 100644
index ff5ef7a..0000000
--- a/vendor/github.com/prometheus/common/expfmt/encode.go
+++ /dev/null
@@ -1,198 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package expfmt
-
-import (
- "fmt"
- "io"
- "net/http"
-
- "google.golang.org/protobuf/encoding/protodelim"
- "google.golang.org/protobuf/encoding/prototext"
-
- "github.com/prometheus/common/model"
-
- "github.com/munnerz/goautoneg"
-
- dto "github.com/prometheus/client_model/go"
-)
-
-// Encoder types encode metric families into an underlying wire protocol.
-type Encoder interface {
- Encode(*dto.MetricFamily) error
-}
-
-// Closer is implemented by Encoders that need to be closed to finalize
-// encoding. (For example, OpenMetrics needs a final `# EOF` line.)
-//
-// Note that all Encoder implementations returned from this package implement
-// Closer, too, even if the Close call is a no-op. This happens in preparation
-// for adding a Close method to the Encoder interface directly in a (mildly
-// breaking) release in the future.
-type Closer interface {
- Close() error
-}
-
-type encoderCloser struct {
- encode func(*dto.MetricFamily) error
- close func() error
-}
-
-func (ec encoderCloser) Encode(v *dto.MetricFamily) error {
- return ec.encode(v)
-}
-
-func (ec encoderCloser) Close() error {
- return ec.close()
-}
-
-// Negotiate returns the Content-Type based on the given Accept header. If no
-// appropriate accepted type is found, FmtText is returned (which is the
-// Prometheus text format). This function will never negotiate FmtOpenMetrics,
-// as the support is still experimental. To include the option to negotiate
-// FmtOpenMetrics, use NegotiateOpenMetrics.
-func Negotiate(h http.Header) Format {
- escapingScheme := Format(fmt.Sprintf("; escaping=%s", Format(model.NameEscapingScheme.String())))
- for _, ac := range goautoneg.ParseAccept(h.Get(hdrAccept)) {
- if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" {
- switch Format(escapeParam) {
- case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
- escapingScheme = Format(fmt.Sprintf("; escaping=%s", escapeParam))
- default:
- // If the escaping parameter is unknown, ignore it.
- }
- }
- ver := ac.Params["version"]
- if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
- switch ac.Params["encoding"] {
- case "delimited":
- return fmtProtoDelim + escapingScheme
- case "text":
- return fmtProtoText + escapingScheme
- case "compact-text":
- return fmtProtoCompact + escapingScheme
- }
- }
- if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
- return fmtText + escapingScheme
- }
- }
- return fmtText + escapingScheme
-}
-
-// NegotiateIncludingOpenMetrics works like Negotiate but includes
-// FmtOpenMetrics as an option for the result. Note that this function is
-// temporary and will disappear once FmtOpenMetrics is fully supported and as
-// such may be negotiated by the normal Negotiate function.
-func NegotiateIncludingOpenMetrics(h http.Header) Format {
- escapingScheme := Format(fmt.Sprintf("; escaping=%s", Format(model.NameEscapingScheme.String())))
- for _, ac := range goautoneg.ParseAccept(h.Get(hdrAccept)) {
- if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" {
- switch Format(escapeParam) {
- case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
- escapingScheme = Format(fmt.Sprintf("; escaping=%s", escapeParam))
- default:
- // If the escaping parameter is unknown, ignore it.
- }
- }
- ver := ac.Params["version"]
- if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
- switch ac.Params["encoding"] {
- case "delimited":
- return fmtProtoDelim + escapingScheme
- case "text":
- return fmtProtoText + escapingScheme
- case "compact-text":
- return fmtProtoCompact + escapingScheme
- }
- }
- if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
- return fmtText + escapingScheme
- }
- if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") {
- switch ver {
- case OpenMetricsVersion_1_0_0:
- return fmtOpenMetrics_1_0_0 + escapingScheme
- default:
- return fmtOpenMetrics_0_0_1 + escapingScheme
- }
- }
- }
- return fmtText + escapingScheme
-}
-
-// NewEncoder returns a new encoder based on content type negotiation. All
-// Encoder implementations returned by NewEncoder also implement Closer, and
-// callers should always call the Close method. It is currently only required
-// for FmtOpenMetrics, but a future (breaking) release will add the Close method
-// to the Encoder interface directly. The current version of the Encoder
-// interface is kept for backwards compatibility.
-// In cases where the Format does not allow for UTF-8 names, the global
-// NameEscapingScheme will be applied.
-//
-// NewEncoder can be called with additional options to customize the OpenMetrics text output.
-// For example:
-// NewEncoder(w, FmtOpenMetrics_1_0_0, WithCreatedLines())
-//
-// Extra options are ignored for all other formats.
-func NewEncoder(w io.Writer, format Format, options ...EncoderOption) Encoder {
- escapingScheme := format.ToEscapingScheme()
-
- switch format.FormatType() {
- case TypeProtoDelim:
- return encoderCloser{
- encode: func(v *dto.MetricFamily) error {
- _, err := protodelim.MarshalTo(w, v)
- return err
- },
- close: func() error { return nil },
- }
- case TypeProtoCompact:
- return encoderCloser{
- encode: func(v *dto.MetricFamily) error {
- _, err := fmt.Fprintln(w, model.EscapeMetricFamily(v, escapingScheme).String())
- return err
- },
- close: func() error { return nil },
- }
- case TypeProtoText:
- return encoderCloser{
- encode: func(v *dto.MetricFamily) error {
- _, err := fmt.Fprintln(w, prototext.Format(model.EscapeMetricFamily(v, escapingScheme)))
- return err
- },
- close: func() error { return nil },
- }
- case TypeTextPlain:
- return encoderCloser{
- encode: func(v *dto.MetricFamily) error {
- _, err := MetricFamilyToText(w, model.EscapeMetricFamily(v, escapingScheme))
- return err
- },
- close: func() error { return nil },
- }
- case TypeOpenMetrics:
- return encoderCloser{
- encode: func(v *dto.MetricFamily) error {
- _, err := MetricFamilyToOpenMetrics(w, model.EscapeMetricFamily(v, escapingScheme), options...)
- return err
- },
- close: func() error {
- _, err := FinalizeOpenMetrics(w)
- return err
- },
- }
- }
- panic(fmt.Errorf("expfmt.NewEncoder: unknown format %q", format))
-}
diff --git a/vendor/github.com/prometheus/common/expfmt/expfmt.go b/vendor/github.com/prometheus/common/expfmt/expfmt.go
deleted file mode 100644
index 051b38c..0000000
--- a/vendor/github.com/prometheus/common/expfmt/expfmt.go
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package expfmt contains tools for reading and writing Prometheus metrics.
-package expfmt
-
-import (
- "fmt"
- "strings"
-
- "github.com/prometheus/common/model"
-)
-
-// Format specifies the HTTP content type of the different wire protocols.
-type Format string
-
-// Constants to assemble the Content-Type values for the different wire
-// protocols. The Content-Type strings here are all for the legacy exposition
-// formats, where valid characters for metric names and label names are limited.
-// Support for arbitrary UTF-8 characters in those names is already partially
-// implemented in this module (see model.ValidationScheme), but to actually use
-// it on the wire, new content-type strings will have to be agreed upon and
-// added here.
-const (
- TextVersion = "0.0.4"
- ProtoType = `application/vnd.google.protobuf`
- ProtoProtocol = `io.prometheus.client.MetricFamily`
- protoFmt = ProtoType + "; proto=" + ProtoProtocol + ";"
- OpenMetricsType = `application/openmetrics-text`
- OpenMetricsVersion_0_0_1 = "0.0.1"
- OpenMetricsVersion_1_0_0 = "1.0.0"
-
- // The Content-Type values for the different wire protocols. Note that these
- // values are now unexported. If code was relying on comparisons to these
- // constants, instead use FormatType().
- fmtUnknown Format = ``
- fmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8`
- fmtProtoDelim Format = protoFmt + ` encoding=delimited`
- fmtProtoText Format = protoFmt + ` encoding=text`
- fmtProtoCompact Format = protoFmt + ` encoding=compact-text`
- fmtOpenMetrics_1_0_0 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_1_0_0 + `; charset=utf-8`
- fmtOpenMetrics_0_0_1 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_0_0_1 + `; charset=utf-8`
-)
-
-const (
- hdrContentType = "Content-Type"
- hdrAccept = "Accept"
-)
-
-// FormatType is a Go enum representing the overall category for the given
-// Format. As the number of Format permutations increases, doing basic string
-// comparisons are not feasible, so this enum captures the most useful
-// high-level attribute of the Format string.
-type FormatType int
-
-const (
- TypeUnknown FormatType = iota
- TypeProtoCompact
- TypeProtoDelim
- TypeProtoText
- TypeTextPlain
- TypeOpenMetrics
-)
-
-// NewFormat generates a new Format from the type provided. Mostly used for
-// tests, most Formats should be generated as part of content negotiation in
-// encode.go. If a type has more than one version, the latest version will be
-// returned.
-func NewFormat(t FormatType) Format {
- switch t {
- case TypeProtoCompact:
- return fmtProtoCompact
- case TypeProtoDelim:
- return fmtProtoDelim
- case TypeProtoText:
- return fmtProtoText
- case TypeTextPlain:
- return fmtText
- case TypeOpenMetrics:
- return fmtOpenMetrics_1_0_0
- default:
- return fmtUnknown
- }
-}
-
-// NewOpenMetricsFormat generates a new OpenMetrics format matching the
-// specified version number.
-func NewOpenMetricsFormat(version string) (Format, error) {
- if version == OpenMetricsVersion_0_0_1 {
- return fmtOpenMetrics_0_0_1, nil
- }
- if version == OpenMetricsVersion_1_0_0 {
- return fmtOpenMetrics_1_0_0, nil
- }
- return fmtUnknown, fmt.Errorf("unknown open metrics version string")
-}
-
-// FormatType deduces an overall FormatType for the given format.
-func (f Format) FormatType() FormatType {
- toks := strings.Split(string(f), ";")
- params := make(map[string]string)
- for i, t := range toks {
- if i == 0 {
- continue
- }
- args := strings.Split(t, "=")
- if len(args) != 2 {
- continue
- }
- params[strings.TrimSpace(args[0])] = strings.TrimSpace(args[1])
- }
-
- switch strings.TrimSpace(toks[0]) {
- case ProtoType:
- if params["proto"] != ProtoProtocol {
- return TypeUnknown
- }
- switch params["encoding"] {
- case "delimited":
- return TypeProtoDelim
- case "text":
- return TypeProtoText
- case "compact-text":
- return TypeProtoCompact
- default:
- return TypeUnknown
- }
- case OpenMetricsType:
- if params["charset"] != "utf-8" {
- return TypeUnknown
- }
- return TypeOpenMetrics
- case "text/plain":
- v, ok := params["version"]
- if !ok {
- return TypeTextPlain
- }
- if v == TextVersion {
- return TypeTextPlain
- }
- return TypeUnknown
- default:
- return TypeUnknown
- }
-}
-
-// ToEscapingScheme returns an EscapingScheme depending on the Format. Iff the
-// Format contains a escaping=allow-utf-8 term, it will select NoEscaping. If a valid
-// "escaping" term exists, that will be used. Otherwise, the global default will
-// be returned.
-func (format Format) ToEscapingScheme() model.EscapingScheme {
- for _, p := range strings.Split(string(format), ";") {
- toks := strings.Split(p, "=")
- if len(toks) != 2 {
- continue
- }
- key, value := strings.TrimSpace(toks[0]), strings.TrimSpace(toks[1])
- if key == model.EscapingKey {
- scheme, err := model.ToEscapingScheme(value)
- if err != nil {
- return model.NameEscapingScheme
- }
- return scheme
- }
- }
- return model.NameEscapingScheme
-}
diff --git a/vendor/github.com/prometheus/common/expfmt/fuzz.go b/vendor/github.com/prometheus/common/expfmt/fuzz.go
deleted file mode 100644
index dfac962..0000000
--- a/vendor/github.com/prometheus/common/expfmt/fuzz.go
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Build only when actually fuzzing
-//go:build gofuzz
-// +build gofuzz
-
-package expfmt
-
-import "bytes"
-
-// Fuzz text metric parser with with github.com/dvyukov/go-fuzz:
-//
-// go-fuzz-build github.com/prometheus/common/expfmt
-// go-fuzz -bin expfmt-fuzz.zip -workdir fuzz
-//
-// Further input samples should go in the folder fuzz/corpus.
-func Fuzz(in []byte) int {
- parser := TextParser{}
- _, err := parser.TextToMetricFamilies(bytes.NewReader(in))
-
- if err != nil {
- return 0
- }
-
- return 1
-}
diff --git a/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go b/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go
deleted file mode 100644
index 353c5e9..0000000
--- a/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go
+++ /dev/null
@@ -1,696 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package expfmt
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "math"
- "strconv"
- "strings"
-
- "google.golang.org/protobuf/types/known/timestamppb"
-
- "github.com/prometheus/common/model"
-
- dto "github.com/prometheus/client_model/go"
-)
-
-type encoderOption struct {
- withCreatedLines bool
- withUnit bool
-}
-
-type EncoderOption func(*encoderOption)
-
-// WithCreatedLines is an EncoderOption that configures the OpenMetrics encoder
-// to include _created lines (See
-// https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#counter-1).
-// Created timestamps can improve the accuracy of series reset detection, but
-// come with a bandwidth cost.
-//
-// At the time of writing, created timestamp ingestion is still experimental in
-// Prometheus and need to be enabled with the feature-flag
-// `--feature-flag=created-timestamp-zero-ingestion`, and breaking changes are
-// still possible. Therefore, it is recommended to use this feature with caution.
-func WithCreatedLines() EncoderOption {
- return func(t *encoderOption) {
- t.withCreatedLines = true
- }
-}
-
-// WithUnit is an EncoderOption enabling a set unit to be written to the output
-// and to be added to the metric name, if it's not there already, as a suffix.
-// Without opting in this way, the unit will not be added to the metric name and,
-// on top of that, the unit will not be passed onto the output, even if it
-// were declared in the *dto.MetricFamily struct, i.e. even if in.Unit !=nil.
-func WithUnit() EncoderOption {
- return func(t *encoderOption) {
- t.withUnit = true
- }
-}
-
-// MetricFamilyToOpenMetrics converts a MetricFamily proto message into the
-// OpenMetrics text format and writes the resulting lines to 'out'. It returns
-// the number of bytes written and any error encountered. The output will have
-// the same order as the input, no further sorting is performed. Furthermore,
-// this function assumes the input is already sanitized and does not perform any
-// sanity checks. If the input contains duplicate metrics or invalid metric or
-// label names, the conversion will result in invalid text format output.
-//
-// If metric names conform to the legacy validation pattern, they will be placed
-// outside the brackets in the traditional way, like `foo{}`. If the metric name
-// fails the legacy validation check, it will be placed quoted inside the
-// brackets: `{"foo"}`. As stated above, the input is assumed to be santized and
-// no error will be thrown in this case.
-//
-// Similar to metric names, if label names conform to the legacy validation
-// pattern, they will be unquoted as normal, like `foo{bar="baz"}`. If the label
-// name fails the legacy validation check, it will be quoted:
-// `foo{"bar"="baz"}`. As stated above, the input is assumed to be santized and
-// no error will be thrown in this case.
-//
-// This function fulfills the type 'expfmt.encoder'.
-//
-// Note that OpenMetrics requires a final `# EOF` line. Since this function acts
-// on individual metric families, it is the responsibility of the caller to
-// append this line to 'out' once all metric families have been written.
-// Conveniently, this can be done by calling FinalizeOpenMetrics.
-//
-// The output should be fully OpenMetrics compliant. However, there are a few
-// missing features and peculiarities to avoid complications when switching from
-// Prometheus to OpenMetrics or vice versa:
-//
-// - Counters are expected to have the `_total` suffix in their metric name. In
-// the output, the suffix will be truncated from the `# TYPE`, `# HELP` and `# UNIT`
-// lines. A counter with a missing `_total` suffix is not an error. However,
-// its type will be set to `unknown` in that case to avoid invalid OpenMetrics
-// output.
-//
-// - According to the OM specs, the `# UNIT` line is optional, but if populated,
-// the unit has to be present in the metric name as its suffix:
-// (see https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#unit).
-// However, in order to accommodate any potential scenario where such a change in the
-// metric name is not desirable, the users are here given the choice of either explicitly
-// opt in, in case they wish for the unit to be included in the output AND in the metric name
-// as a suffix (see the description of the WithUnit function above),
-// or not to opt in, in case they don't want for any of that to happen.
-//
-// - No support for the following (optional) features: info type,
-// stateset type, gaugehistogram type.
-//
-// - The size of exemplar labels is not checked (i.e. it's possible to create
-// exemplars that are larger than allowed by the OpenMetrics specification).
-//
-// - The value of Counters is not checked. (OpenMetrics doesn't allow counters
-// with a `NaN` value.)
-func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily, options ...EncoderOption) (written int, err error) {
- toOM := encoderOption{}
- for _, option := range options {
- option(&toOM)
- }
-
- name := in.GetName()
- if name == "" {
- return 0, fmt.Errorf("MetricFamily has no name: %s", in)
- }
-
- // Try the interface upgrade. If it doesn't work, we'll use a
- // bufio.Writer from the sync.Pool.
- w, ok := out.(enhancedWriter)
- if !ok {
- b := bufPool.Get().(*bufio.Writer)
- b.Reset(out)
- w = b
- defer func() {
- bErr := b.Flush()
- if err == nil {
- err = bErr
- }
- bufPool.Put(b)
- }()
- }
-
- var (
- n int
- metricType = in.GetType()
- compliantName = name
- )
- if metricType == dto.MetricType_COUNTER && strings.HasSuffix(compliantName, "_total") {
- compliantName = name[:len(name)-6]
- }
- if toOM.withUnit && in.Unit != nil && !strings.HasSuffix(compliantName, fmt.Sprintf("_%s", *in.Unit)) {
- compliantName = compliantName + fmt.Sprintf("_%s", *in.Unit)
- }
-
- // Comments, first HELP, then TYPE.
- if in.Help != nil {
- n, err = w.WriteString("# HELP ")
- written += n
- if err != nil {
- return
- }
- n, err = writeName(w, compliantName)
- written += n
- if err != nil {
- return
- }
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return
- }
- n, err = writeEscapedString(w, *in.Help, true)
- written += n
- if err != nil {
- return
- }
- err = w.WriteByte('\n')
- written++
- if err != nil {
- return
- }
- }
- n, err = w.WriteString("# TYPE ")
- written += n
- if err != nil {
- return
- }
- n, err = writeName(w, compliantName)
- written += n
- if err != nil {
- return
- }
- switch metricType {
- case dto.MetricType_COUNTER:
- if strings.HasSuffix(name, "_total") {
- n, err = w.WriteString(" counter\n")
- } else {
- n, err = w.WriteString(" unknown\n")
- }
- case dto.MetricType_GAUGE:
- n, err = w.WriteString(" gauge\n")
- case dto.MetricType_SUMMARY:
- n, err = w.WriteString(" summary\n")
- case dto.MetricType_UNTYPED:
- n, err = w.WriteString(" unknown\n")
- case dto.MetricType_HISTOGRAM:
- n, err = w.WriteString(" histogram\n")
- default:
- return written, fmt.Errorf("unknown metric type %s", metricType.String())
- }
- written += n
- if err != nil {
- return
- }
- if toOM.withUnit && in.Unit != nil {
- n, err = w.WriteString("# UNIT ")
- written += n
- if err != nil {
- return
- }
- n, err = writeName(w, compliantName)
- written += n
- if err != nil {
- return
- }
-
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return
- }
- n, err = writeEscapedString(w, *in.Unit, true)
- written += n
- if err != nil {
- return
- }
- err = w.WriteByte('\n')
- written++
- if err != nil {
- return
- }
- }
-
- var createdTsBytesWritten int
-
- // Finally the samples, one line for each.
- if metricType == dto.MetricType_COUNTER && strings.HasSuffix(name, "_total") {
- compliantName = compliantName + "_total"
- }
- for _, metric := range in.Metric {
- switch metricType {
- case dto.MetricType_COUNTER:
- if metric.Counter == nil {
- return written, fmt.Errorf(
- "expected counter in metric %s %s", compliantName, metric,
- )
- }
- n, err = writeOpenMetricsSample(
- w, compliantName, "", metric, "", 0,
- metric.Counter.GetValue(), 0, false,
- metric.Counter.Exemplar,
- )
- if toOM.withCreatedLines && metric.Counter.CreatedTimestamp != nil {
- createdTsBytesWritten, err = writeOpenMetricsCreated(w, compliantName, "_total", metric, "", 0, metric.Counter.GetCreatedTimestamp())
- n += createdTsBytesWritten
- }
- case dto.MetricType_GAUGE:
- if metric.Gauge == nil {
- return written, fmt.Errorf(
- "expected gauge in metric %s %s", compliantName, metric,
- )
- }
- n, err = writeOpenMetricsSample(
- w, compliantName, "", metric, "", 0,
- metric.Gauge.GetValue(), 0, false,
- nil,
- )
- case dto.MetricType_UNTYPED:
- if metric.Untyped == nil {
- return written, fmt.Errorf(
- "expected untyped in metric %s %s", compliantName, metric,
- )
- }
- n, err = writeOpenMetricsSample(
- w, compliantName, "", metric, "", 0,
- metric.Untyped.GetValue(), 0, false,
- nil,
- )
- case dto.MetricType_SUMMARY:
- if metric.Summary == nil {
- return written, fmt.Errorf(
- "expected summary in metric %s %s", compliantName, metric,
- )
- }
- for _, q := range metric.Summary.Quantile {
- n, err = writeOpenMetricsSample(
- w, compliantName, "", metric,
- model.QuantileLabel, q.GetQuantile(),
- q.GetValue(), 0, false,
- nil,
- )
- written += n
- if err != nil {
- return
- }
- }
- n, err = writeOpenMetricsSample(
- w, compliantName, "_sum", metric, "", 0,
- metric.Summary.GetSampleSum(), 0, false,
- nil,
- )
- written += n
- if err != nil {
- return
- }
- n, err = writeOpenMetricsSample(
- w, compliantName, "_count", metric, "", 0,
- 0, metric.Summary.GetSampleCount(), true,
- nil,
- )
- if toOM.withCreatedLines && metric.Summary.CreatedTimestamp != nil {
- createdTsBytesWritten, err = writeOpenMetricsCreated(w, compliantName, "", metric, "", 0, metric.Summary.GetCreatedTimestamp())
- n += createdTsBytesWritten
- }
- case dto.MetricType_HISTOGRAM:
- if metric.Histogram == nil {
- return written, fmt.Errorf(
- "expected histogram in metric %s %s", compliantName, metric,
- )
- }
- infSeen := false
- for _, b := range metric.Histogram.Bucket {
- n, err = writeOpenMetricsSample(
- w, compliantName, "_bucket", metric,
- model.BucketLabel, b.GetUpperBound(),
- 0, b.GetCumulativeCount(), true,
- b.Exemplar,
- )
- written += n
- if err != nil {
- return
- }
- if math.IsInf(b.GetUpperBound(), +1) {
- infSeen = true
- }
- }
- if !infSeen {
- n, err = writeOpenMetricsSample(
- w, compliantName, "_bucket", metric,
- model.BucketLabel, math.Inf(+1),
- 0, metric.Histogram.GetSampleCount(), true,
- nil,
- )
- written += n
- if err != nil {
- return
- }
- }
- n, err = writeOpenMetricsSample(
- w, compliantName, "_sum", metric, "", 0,
- metric.Histogram.GetSampleSum(), 0, false,
- nil,
- )
- written += n
- if err != nil {
- return
- }
- n, err = writeOpenMetricsSample(
- w, compliantName, "_count", metric, "", 0,
- 0, metric.Histogram.GetSampleCount(), true,
- nil,
- )
- if toOM.withCreatedLines && metric.Histogram.CreatedTimestamp != nil {
- createdTsBytesWritten, err = writeOpenMetricsCreated(w, compliantName, "", metric, "", 0, metric.Histogram.GetCreatedTimestamp())
- n += createdTsBytesWritten
- }
- default:
- return written, fmt.Errorf(
- "unexpected type in metric %s %s", compliantName, metric,
- )
- }
- written += n
- if err != nil {
- return
- }
- }
- return
-}
-
-// FinalizeOpenMetrics writes the final `# EOF\n` line required by OpenMetrics.
-func FinalizeOpenMetrics(w io.Writer) (written int, err error) {
- return w.Write([]byte("# EOF\n"))
-}
-
-// writeOpenMetricsSample writes a single sample in OpenMetrics text format to
-// w, given the metric name, the metric proto message itself, optionally an
-// additional label name with a float64 value (use empty string as label name if
-// not required), the value (optionally as float64 or uint64, determined by
-// useIntValue), and optionally an exemplar (use nil if not required). The
-// function returns the number of bytes written and any error encountered.
-func writeOpenMetricsSample(
- w enhancedWriter,
- name, suffix string,
- metric *dto.Metric,
- additionalLabelName string, additionalLabelValue float64,
- floatValue float64, intValue uint64, useIntValue bool,
- exemplar *dto.Exemplar,
-) (int, error) {
- written := 0
- n, err := writeOpenMetricsNameAndLabelPairs(
- w, name+suffix, metric.Label, additionalLabelName, additionalLabelValue,
- )
- written += n
- if err != nil {
- return written, err
- }
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return written, err
- }
- if useIntValue {
- n, err = writeUint(w, intValue)
- } else {
- n, err = writeOpenMetricsFloat(w, floatValue)
- }
- written += n
- if err != nil {
- return written, err
- }
- if metric.TimestampMs != nil {
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return written, err
- }
- // TODO(beorn7): Format this directly without converting to a float first.
- n, err = writeOpenMetricsFloat(w, float64(*metric.TimestampMs)/1000)
- written += n
- if err != nil {
- return written, err
- }
- }
- if exemplar != nil && len(exemplar.Label) > 0 {
- n, err = writeExemplar(w, exemplar)
- written += n
- if err != nil {
- return written, err
- }
- }
- err = w.WriteByte('\n')
- written++
- if err != nil {
- return written, err
- }
- return written, nil
-}
-
-// writeOpenMetricsNameAndLabelPairs works like writeOpenMetricsSample but
-// formats the float in OpenMetrics style.
-func writeOpenMetricsNameAndLabelPairs(
- w enhancedWriter,
- name string,
- in []*dto.LabelPair,
- additionalLabelName string, additionalLabelValue float64,
-) (int, error) {
- var (
- written int
- separator byte = '{'
- metricInsideBraces = false
- )
-
- if name != "" {
- // If the name does not pass the legacy validity check, we must put the
- // metric name inside the braces, quoted.
- if !model.IsValidLegacyMetricName(model.LabelValue(name)) {
- metricInsideBraces = true
- err := w.WriteByte(separator)
- written++
- if err != nil {
- return written, err
- }
- separator = ','
- }
-
- n, err := writeName(w, name)
- written += n
- if err != nil {
- return written, err
- }
- }
-
- if len(in) == 0 && additionalLabelName == "" {
- if metricInsideBraces {
- err := w.WriteByte('}')
- written++
- if err != nil {
- return written, err
- }
- }
- return written, nil
- }
-
- for _, lp := range in {
- err := w.WriteByte(separator)
- written++
- if err != nil {
- return written, err
- }
- n, err := writeName(w, lp.GetName())
- written += n
- if err != nil {
- return written, err
- }
- n, err = w.WriteString(`="`)
- written += n
- if err != nil {
- return written, err
- }
- n, err = writeEscapedString(w, lp.GetValue(), true)
- written += n
- if err != nil {
- return written, err
- }
- err = w.WriteByte('"')
- written++
- if err != nil {
- return written, err
- }
- separator = ','
- }
- if additionalLabelName != "" {
- err := w.WriteByte(separator)
- written++
- if err != nil {
- return written, err
- }
- n, err := w.WriteString(additionalLabelName)
- written += n
- if err != nil {
- return written, err
- }
- n, err = w.WriteString(`="`)
- written += n
- if err != nil {
- return written, err
- }
- n, err = writeOpenMetricsFloat(w, additionalLabelValue)
- written += n
- if err != nil {
- return written, err
- }
- err = w.WriteByte('"')
- written++
- if err != nil {
- return written, err
- }
- }
- err := w.WriteByte('}')
- written++
- if err != nil {
- return written, err
- }
- return written, nil
-}
-
-// writeOpenMetricsCreated writes the created timestamp for a single time series
-// following OpenMetrics text format to w, given the metric name, the metric proto
-// message itself, optionally a suffix to be removed, e.g. '_total' for counters,
-// an additional label name with a float64 value (use empty string as label name if
-// not required) and the timestamp that represents the created timestamp.
-// The function returns the number of bytes written and any error encountered.
-func writeOpenMetricsCreated(w enhancedWriter,
- name, suffixToTrim string, metric *dto.Metric,
- additionalLabelName string, additionalLabelValue float64,
- createdTimestamp *timestamppb.Timestamp,
-) (int, error) {
- written := 0
- n, err := writeOpenMetricsNameAndLabelPairs(
- w, strings.TrimSuffix(name, suffixToTrim)+"_created", metric.Label, additionalLabelName, additionalLabelValue,
- )
- written += n
- if err != nil {
- return written, err
- }
-
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return written, err
- }
-
- // TODO(beorn7): Format this directly from components of ts to
- // avoid overflow/underflow and precision issues of the float
- // conversion.
- n, err = writeOpenMetricsFloat(w, float64(createdTimestamp.AsTime().UnixNano())/1e9)
- written += n
- if err != nil {
- return written, err
- }
-
- err = w.WriteByte('\n')
- written++
- if err != nil {
- return written, err
- }
- return written, nil
-}
-
-// writeExemplar writes the provided exemplar in OpenMetrics format to w. The
-// function returns the number of bytes written and any error encountered.
-func writeExemplar(w enhancedWriter, e *dto.Exemplar) (int, error) {
- written := 0
- n, err := w.WriteString(" # ")
- written += n
- if err != nil {
- return written, err
- }
- n, err = writeOpenMetricsNameAndLabelPairs(w, "", e.Label, "", 0)
- written += n
- if err != nil {
- return written, err
- }
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return written, err
- }
- n, err = writeOpenMetricsFloat(w, e.GetValue())
- written += n
- if err != nil {
- return written, err
- }
- if e.Timestamp != nil {
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return written, err
- }
- err = (*e).Timestamp.CheckValid()
- if err != nil {
- return written, err
- }
- ts := (*e).Timestamp.AsTime()
- // TODO(beorn7): Format this directly from components of ts to
- // avoid overflow/underflow and precision issues of the float
- // conversion.
- n, err = writeOpenMetricsFloat(w, float64(ts.UnixNano())/1e9)
- written += n
- if err != nil {
- return written, err
- }
- }
- return written, nil
-}
-
-// writeOpenMetricsFloat works like writeFloat but appends ".0" if the resulting
-// number would otherwise contain neither a "." nor an "e".
-func writeOpenMetricsFloat(w enhancedWriter, f float64) (int, error) {
- switch {
- case f == 1:
- return w.WriteString("1.0")
- case f == 0:
- return w.WriteString("0.0")
- case f == -1:
- return w.WriteString("-1.0")
- case math.IsNaN(f):
- return w.WriteString("NaN")
- case math.IsInf(f, +1):
- return w.WriteString("+Inf")
- case math.IsInf(f, -1):
- return w.WriteString("-Inf")
- default:
- bp := numBufPool.Get().(*[]byte)
- *bp = strconv.AppendFloat((*bp)[:0], f, 'g', -1, 64)
- if !bytes.ContainsAny(*bp, "e.") {
- *bp = append(*bp, '.', '0')
- }
- written, err := w.Write(*bp)
- numBufPool.Put(bp)
- return written, err
- }
-}
-
-// writeUint is like writeInt just for uint64.
-func writeUint(w enhancedWriter, u uint64) (int, error) {
- bp := numBufPool.Get().(*[]byte)
- *bp = strconv.AppendUint((*bp)[:0], u, 10)
- written, err := w.Write(*bp)
- numBufPool.Put(bp)
- return written, err
-}
diff --git a/vendor/github.com/prometheus/common/expfmt/text_create.go b/vendor/github.com/prometheus/common/expfmt/text_create.go
deleted file mode 100644
index f9b8265..0000000
--- a/vendor/github.com/prometheus/common/expfmt/text_create.go
+++ /dev/null
@@ -1,520 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package expfmt
-
-import (
- "bufio"
- "fmt"
- "io"
- "math"
- "strconv"
- "strings"
- "sync"
-
- "github.com/prometheus/common/model"
-
- dto "github.com/prometheus/client_model/go"
-)
-
-// enhancedWriter has all the enhanced write functions needed here. bufio.Writer
-// implements it.
-type enhancedWriter interface {
- io.Writer
- WriteRune(r rune) (n int, err error)
- WriteString(s string) (n int, err error)
- WriteByte(c byte) error
-}
-
-const (
- initialNumBufSize = 24
-)
-
-var (
- bufPool = sync.Pool{
- New: func() interface{} {
- return bufio.NewWriter(io.Discard)
- },
- }
- numBufPool = sync.Pool{
- New: func() interface{} {
- b := make([]byte, 0, initialNumBufSize)
- return &b
- },
- }
-)
-
-// MetricFamilyToText converts a MetricFamily proto message into text format and
-// writes the resulting lines to 'out'. It returns the number of bytes written
-// and any error encountered. The output will have the same order as the input,
-// no further sorting is performed. Furthermore, this function assumes the input
-// is already sanitized and does not perform any sanity checks. If the input
-// contains duplicate metrics or invalid metric or label names, the conversion
-// will result in invalid text format output.
-//
-// If metric names conform to the legacy validation pattern, they will be placed
-// outside the brackets in the traditional way, like `foo{}`. If the metric name
-// fails the legacy validation check, it will be placed quoted inside the
-// brackets: `{"foo"}`. As stated above, the input is assumed to be santized and
-// no error will be thrown in this case.
-//
-// Similar to metric names, if label names conform to the legacy validation
-// pattern, they will be unquoted as normal, like `foo{bar="baz"}`. If the label
-// name fails the legacy validation check, it will be quoted:
-// `foo{"bar"="baz"}`. As stated above, the input is assumed to be santized and
-// no error will be thrown in this case.
-//
-// This method fulfills the type 'prometheus.encoder'.
-func MetricFamilyToText(out io.Writer, in *dto.MetricFamily) (written int, err error) {
- // Fail-fast checks.
- if len(in.Metric) == 0 {
- return 0, fmt.Errorf("MetricFamily has no metrics: %s", in)
- }
- name := in.GetName()
- if name == "" {
- return 0, fmt.Errorf("MetricFamily has no name: %s", in)
- }
-
- // Try the interface upgrade. If it doesn't work, we'll use a
- // bufio.Writer from the sync.Pool.
- w, ok := out.(enhancedWriter)
- if !ok {
- b := bufPool.Get().(*bufio.Writer)
- b.Reset(out)
- w = b
- defer func() {
- bErr := b.Flush()
- if err == nil {
- err = bErr
- }
- bufPool.Put(b)
- }()
- }
-
- var n int
-
- // Comments, first HELP, then TYPE.
- if in.Help != nil {
- n, err = w.WriteString("# HELP ")
- written += n
- if err != nil {
- return
- }
- n, err = writeName(w, name)
- written += n
- if err != nil {
- return
- }
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return
- }
- n, err = writeEscapedString(w, *in.Help, false)
- written += n
- if err != nil {
- return
- }
- err = w.WriteByte('\n')
- written++
- if err != nil {
- return
- }
- }
- n, err = w.WriteString("# TYPE ")
- written += n
- if err != nil {
- return
- }
- n, err = writeName(w, name)
- written += n
- if err != nil {
- return
- }
- metricType := in.GetType()
- switch metricType {
- case dto.MetricType_COUNTER:
- n, err = w.WriteString(" counter\n")
- case dto.MetricType_GAUGE:
- n, err = w.WriteString(" gauge\n")
- case dto.MetricType_SUMMARY:
- n, err = w.WriteString(" summary\n")
- case dto.MetricType_UNTYPED:
- n, err = w.WriteString(" untyped\n")
- case dto.MetricType_HISTOGRAM:
- n, err = w.WriteString(" histogram\n")
- default:
- return written, fmt.Errorf("unknown metric type %s", metricType.String())
- }
- written += n
- if err != nil {
- return
- }
-
- // Finally the samples, one line for each.
- for _, metric := range in.Metric {
- switch metricType {
- case dto.MetricType_COUNTER:
- if metric.Counter == nil {
- return written, fmt.Errorf(
- "expected counter in metric %s %s", name, metric,
- )
- }
- n, err = writeSample(
- w, name, "", metric, "", 0,
- metric.Counter.GetValue(),
- )
- case dto.MetricType_GAUGE:
- if metric.Gauge == nil {
- return written, fmt.Errorf(
- "expected gauge in metric %s %s", name, metric,
- )
- }
- n, err = writeSample(
- w, name, "", metric, "", 0,
- metric.Gauge.GetValue(),
- )
- case dto.MetricType_UNTYPED:
- if metric.Untyped == nil {
- return written, fmt.Errorf(
- "expected untyped in metric %s %s", name, metric,
- )
- }
- n, err = writeSample(
- w, name, "", metric, "", 0,
- metric.Untyped.GetValue(),
- )
- case dto.MetricType_SUMMARY:
- if metric.Summary == nil {
- return written, fmt.Errorf(
- "expected summary in metric %s %s", name, metric,
- )
- }
- for _, q := range metric.Summary.Quantile {
- n, err = writeSample(
- w, name, "", metric,
- model.QuantileLabel, q.GetQuantile(),
- q.GetValue(),
- )
- written += n
- if err != nil {
- return
- }
- }
- n, err = writeSample(
- w, name, "_sum", metric, "", 0,
- metric.Summary.GetSampleSum(),
- )
- written += n
- if err != nil {
- return
- }
- n, err = writeSample(
- w, name, "_count", metric, "", 0,
- float64(metric.Summary.GetSampleCount()),
- )
- case dto.MetricType_HISTOGRAM:
- if metric.Histogram == nil {
- return written, fmt.Errorf(
- "expected histogram in metric %s %s", name, metric,
- )
- }
- infSeen := false
- for _, b := range metric.Histogram.Bucket {
- n, err = writeSample(
- w, name, "_bucket", metric,
- model.BucketLabel, b.GetUpperBound(),
- float64(b.GetCumulativeCount()),
- )
- written += n
- if err != nil {
- return
- }
- if math.IsInf(b.GetUpperBound(), +1) {
- infSeen = true
- }
- }
- if !infSeen {
- n, err = writeSample(
- w, name, "_bucket", metric,
- model.BucketLabel, math.Inf(+1),
- float64(metric.Histogram.GetSampleCount()),
- )
- written += n
- if err != nil {
- return
- }
- }
- n, err = writeSample(
- w, name, "_sum", metric, "", 0,
- metric.Histogram.GetSampleSum(),
- )
- written += n
- if err != nil {
- return
- }
- n, err = writeSample(
- w, name, "_count", metric, "", 0,
- float64(metric.Histogram.GetSampleCount()),
- )
- default:
- return written, fmt.Errorf(
- "unexpected type in metric %s %s", name, metric,
- )
- }
- written += n
- if err != nil {
- return
- }
- }
- return
-}
-
-// writeSample writes a single sample in text format to w, given the metric
-// name, the metric proto message itself, optionally an additional label name
-// with a float64 value (use empty string as label name if not required), and
-// the value. The function returns the number of bytes written and any error
-// encountered.
-func writeSample(
- w enhancedWriter,
- name, suffix string,
- metric *dto.Metric,
- additionalLabelName string, additionalLabelValue float64,
- value float64,
-) (int, error) {
- written := 0
- n, err := writeNameAndLabelPairs(
- w, name+suffix, metric.Label, additionalLabelName, additionalLabelValue,
- )
- written += n
- if err != nil {
- return written, err
- }
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return written, err
- }
- n, err = writeFloat(w, value)
- written += n
- if err != nil {
- return written, err
- }
- if metric.TimestampMs != nil {
- err = w.WriteByte(' ')
- written++
- if err != nil {
- return written, err
- }
- n, err = writeInt(w, *metric.TimestampMs)
- written += n
- if err != nil {
- return written, err
- }
- }
- err = w.WriteByte('\n')
- written++
- if err != nil {
- return written, err
- }
- return written, nil
-}
-
-// writeNameAndLabelPairs converts a slice of LabelPair proto messages plus the
-// explicitly given metric name and additional label pair into text formatted as
-// required by the text format and writes it to 'w'. An empty slice in
-// combination with an empty string 'additionalLabelName' results in nothing
-// being written. Otherwise, the label pairs are written, escaped as required by
-// the text format, and enclosed in '{...}'. The function returns the number of
-// bytes written and any error encountered. If the metric name is not
-// legacy-valid, it will be put inside the brackets as well. Legacy-invalid
-// label names will also be quoted.
-func writeNameAndLabelPairs(
- w enhancedWriter,
- name string,
- in []*dto.LabelPair,
- additionalLabelName string, additionalLabelValue float64,
-) (int, error) {
- var (
- written int
- separator byte = '{'
- metricInsideBraces = false
- )
-
- if name != "" {
- // If the name does not pass the legacy validity check, we must put the
- // metric name inside the braces.
- if !model.IsValidLegacyMetricName(model.LabelValue(name)) {
- metricInsideBraces = true
- err := w.WriteByte(separator)
- written++
- if err != nil {
- return written, err
- }
- separator = ','
- }
- n, err := writeName(w, name)
- written += n
- if err != nil {
- return written, err
- }
- }
-
- if len(in) == 0 && additionalLabelName == "" {
- if metricInsideBraces {
- err := w.WriteByte('}')
- written++
- if err != nil {
- return written, err
- }
- }
- return written, nil
- }
-
- for _, lp := range in {
- err := w.WriteByte(separator)
- written++
- if err != nil {
- return written, err
- }
- n, err := writeName(w, lp.GetName())
- written += n
- if err != nil {
- return written, err
- }
- n, err = w.WriteString(`="`)
- written += n
- if err != nil {
- return written, err
- }
- n, err = writeEscapedString(w, lp.GetValue(), true)
- written += n
- if err != nil {
- return written, err
- }
- err = w.WriteByte('"')
- written++
- if err != nil {
- return written, err
- }
- separator = ','
- }
- if additionalLabelName != "" {
- err := w.WriteByte(separator)
- written++
- if err != nil {
- return written, err
- }
- n, err := w.WriteString(additionalLabelName)
- written += n
- if err != nil {
- return written, err
- }
- n, err = w.WriteString(`="`)
- written += n
- if err != nil {
- return written, err
- }
- n, err = writeFloat(w, additionalLabelValue)
- written += n
- if err != nil {
- return written, err
- }
- err = w.WriteByte('"')
- written++
- if err != nil {
- return written, err
- }
- }
- err := w.WriteByte('}')
- written++
- if err != nil {
- return written, err
- }
- return written, nil
-}
-
-// writeEscapedString replaces '\' by '\\', new line character by '\n', and - if
-// includeDoubleQuote is true - '"' by '\"'.
-var (
- escaper = strings.NewReplacer("\\", `\\`, "\n", `\n`)
- quotedEscaper = strings.NewReplacer("\\", `\\`, "\n", `\n`, "\"", `\"`)
-)
-
-func writeEscapedString(w enhancedWriter, v string, includeDoubleQuote bool) (int, error) {
- if includeDoubleQuote {
- return quotedEscaper.WriteString(w, v)
- }
- return escaper.WriteString(w, v)
-}
-
-// writeFloat is equivalent to fmt.Fprint with a float64 argument but hardcodes
-// a few common cases for increased efficiency. For non-hardcoded cases, it uses
-// strconv.AppendFloat to avoid allocations, similar to writeInt.
-func writeFloat(w enhancedWriter, f float64) (int, error) {
- switch {
- case f == 1:
- return 1, w.WriteByte('1')
- case f == 0:
- return 1, w.WriteByte('0')
- case f == -1:
- return w.WriteString("-1")
- case math.IsNaN(f):
- return w.WriteString("NaN")
- case math.IsInf(f, +1):
- return w.WriteString("+Inf")
- case math.IsInf(f, -1):
- return w.WriteString("-Inf")
- default:
- bp := numBufPool.Get().(*[]byte)
- *bp = strconv.AppendFloat((*bp)[:0], f, 'g', -1, 64)
- written, err := w.Write(*bp)
- numBufPool.Put(bp)
- return written, err
- }
-}
-
-// writeInt is equivalent to fmt.Fprint with an int64 argument but uses
-// strconv.AppendInt with a byte slice taken from a sync.Pool to avoid
-// allocations.
-func writeInt(w enhancedWriter, i int64) (int, error) {
- bp := numBufPool.Get().(*[]byte)
- *bp = strconv.AppendInt((*bp)[:0], i, 10)
- written, err := w.Write(*bp)
- numBufPool.Put(bp)
- return written, err
-}
-
-// writeName writes a string as-is if it complies with the legacy naming
-// scheme, or escapes it in double quotes if not.
-func writeName(w enhancedWriter, name string) (int, error) {
- if model.IsValidLegacyMetricName(model.LabelValue(name)) {
- return w.WriteString(name)
- }
- var written int
- var err error
- err = w.WriteByte('"')
- written++
- if err != nil {
- return written, err
- }
- var n int
- n, err = writeEscapedString(w, name, true)
- written += n
- if err != nil {
- return written, err
- }
- err = w.WriteByte('"')
- written++
- return written, err
-}
diff --git a/vendor/github.com/prometheus/common/expfmt/text_parse.go b/vendor/github.com/prometheus/common/expfmt/text_parse.go
deleted file mode 100644
index 2649021..0000000
--- a/vendor/github.com/prometheus/common/expfmt/text_parse.go
+++ /dev/null
@@ -1,781 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package expfmt
-
-import (
- "bufio"
- "bytes"
- "errors"
- "fmt"
- "io"
- "math"
- "strconv"
- "strings"
-
- dto "github.com/prometheus/client_model/go"
-
- "google.golang.org/protobuf/proto"
-
- "github.com/prometheus/common/model"
-)
-
-// A stateFn is a function that represents a state in a state machine. By
-// executing it, the state is progressed to the next state. The stateFn returns
-// another stateFn, which represents the new state. The end state is represented
-// by nil.
-type stateFn func() stateFn
-
-// ParseError signals errors while parsing the simple and flat text-based
-// exchange format.
-type ParseError struct {
- Line int
- Msg string
-}
-
-// Error implements the error interface.
-func (e ParseError) Error() string {
- return fmt.Sprintf("text format parsing error in line %d: %s", e.Line, e.Msg)
-}
-
-// TextParser is used to parse the simple and flat text-based exchange format. Its
-// zero value is ready to use.
-type TextParser struct {
- metricFamiliesByName map[string]*dto.MetricFamily
- buf *bufio.Reader // Where the parsed input is read through.
- err error // Most recent error.
- lineCount int // Tracks the line count for error messages.
- currentByte byte // The most recent byte read.
- currentToken bytes.Buffer // Re-used each time a token has to be gathered from multiple bytes.
- currentMF *dto.MetricFamily
- currentMetric *dto.Metric
- currentLabelPair *dto.LabelPair
-
- // The remaining member variables are only used for summaries/histograms.
- currentLabels map[string]string // All labels including '__name__' but excluding 'quantile'/'le'
- // Summary specific.
- summaries map[uint64]*dto.Metric // Key is created with LabelsToSignature.
- currentQuantile float64
- // Histogram specific.
- histograms map[uint64]*dto.Metric // Key is created with LabelsToSignature.
- currentBucket float64
- // These tell us if the currently processed line ends on '_count' or
- // '_sum' respectively and belong to a summary/histogram, representing the sample
- // count and sum of that summary/histogram.
- currentIsSummaryCount, currentIsSummarySum bool
- currentIsHistogramCount, currentIsHistogramSum bool
-}
-
-// TextToMetricFamilies reads 'in' as the simple and flat text-based exchange
-// format and creates MetricFamily proto messages. It returns the MetricFamily
-// proto messages in a map where the metric names are the keys, along with any
-// error encountered.
-//
-// If the input contains duplicate metrics (i.e. lines with the same metric name
-// and exactly the same label set), the resulting MetricFamily will contain
-// duplicate Metric proto messages. Similar is true for duplicate label
-// names. Checks for duplicates have to be performed separately, if required.
-// Also note that neither the metrics within each MetricFamily are sorted nor
-// the label pairs within each Metric. Sorting is not required for the most
-// frequent use of this method, which is sample ingestion in the Prometheus
-// server. However, for presentation purposes, you might want to sort the
-// metrics, and in some cases, you must sort the labels, e.g. for consumption by
-// the metric family injection hook of the Prometheus registry.
-//
-// Summaries and histograms are rather special beasts. You would probably not
-// use them in the simple text format anyway. This method can deal with
-// summaries and histograms if they are presented in exactly the way the
-// text.Create function creates them.
-//
-// This method must not be called concurrently. If you want to parse different
-// input concurrently, instantiate a separate Parser for each goroutine.
-func (p *TextParser) TextToMetricFamilies(in io.Reader) (map[string]*dto.MetricFamily, error) {
- p.reset(in)
- for nextState := p.startOfLine; nextState != nil; nextState = nextState() {
- // Magic happens here...
- }
- // Get rid of empty metric families.
- for k, mf := range p.metricFamiliesByName {
- if len(mf.GetMetric()) == 0 {
- delete(p.metricFamiliesByName, k)
- }
- }
- // If p.err is io.EOF now, we have run into a premature end of the input
- // stream. Turn this error into something nicer and more
- // meaningful. (io.EOF is often used as a signal for the legitimate end
- // of an input stream.)
- if p.err != nil && errors.Is(p.err, io.EOF) {
- p.parseError("unexpected end of input stream")
- }
- return p.metricFamiliesByName, p.err
-}
-
-func (p *TextParser) reset(in io.Reader) {
- p.metricFamiliesByName = map[string]*dto.MetricFamily{}
- if p.buf == nil {
- p.buf = bufio.NewReader(in)
- } else {
- p.buf.Reset(in)
- }
- p.err = nil
- p.lineCount = 0
- if p.summaries == nil || len(p.summaries) > 0 {
- p.summaries = map[uint64]*dto.Metric{}
- }
- if p.histograms == nil || len(p.histograms) > 0 {
- p.histograms = map[uint64]*dto.Metric{}
- }
- p.currentQuantile = math.NaN()
- p.currentBucket = math.NaN()
-}
-
-// startOfLine represents the state where the next byte read from p.buf is the
-// start of a line (or whitespace leading up to it).
-func (p *TextParser) startOfLine() stateFn {
- p.lineCount++
- if p.skipBlankTab(); p.err != nil {
- // This is the only place that we expect to see io.EOF,
- // which is not an error but the signal that we are done.
- // Any other error that happens to align with the start of
- // a line is still an error.
- if errors.Is(p.err, io.EOF) {
- p.err = nil
- }
- return nil
- }
- switch p.currentByte {
- case '#':
- return p.startComment
- case '\n':
- return p.startOfLine // Empty line, start the next one.
- }
- return p.readingMetricName
-}
-
-// startComment represents the state where the next byte read from p.buf is the
-// start of a comment (or whitespace leading up to it).
-func (p *TextParser) startComment() stateFn {
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.currentByte == '\n' {
- return p.startOfLine
- }
- if p.readTokenUntilWhitespace(); p.err != nil {
- return nil // Unexpected end of input.
- }
- // If we have hit the end of line already, there is nothing left
- // to do. This is not considered a syntax error.
- if p.currentByte == '\n' {
- return p.startOfLine
- }
- keyword := p.currentToken.String()
- if keyword != "HELP" && keyword != "TYPE" {
- // Generic comment, ignore by fast forwarding to end of line.
- for p.currentByte != '\n' {
- if p.currentByte, p.err = p.buf.ReadByte(); p.err != nil {
- return nil // Unexpected end of input.
- }
- }
- return p.startOfLine
- }
- // There is something. Next has to be a metric name.
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.readTokenAsMetricName(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.currentByte == '\n' {
- // At the end of the line already.
- // Again, this is not considered a syntax error.
- return p.startOfLine
- }
- if !isBlankOrTab(p.currentByte) {
- p.parseError("invalid metric name in comment")
- return nil
- }
- p.setOrCreateCurrentMF()
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.currentByte == '\n' {
- // At the end of the line already.
- // Again, this is not considered a syntax error.
- return p.startOfLine
- }
- switch keyword {
- case "HELP":
- return p.readingHelp
- case "TYPE":
- return p.readingType
- }
- panic(fmt.Sprintf("code error: unexpected keyword %q", keyword))
-}
-
-// readingMetricName represents the state where the last byte read (now in
-// p.currentByte) is the first byte of a metric name.
-func (p *TextParser) readingMetricName() stateFn {
- if p.readTokenAsMetricName(); p.err != nil {
- return nil
- }
- if p.currentToken.Len() == 0 {
- p.parseError("invalid metric name")
- return nil
- }
- p.setOrCreateCurrentMF()
- // Now is the time to fix the type if it hasn't happened yet.
- if p.currentMF.Type == nil {
- p.currentMF.Type = dto.MetricType_UNTYPED.Enum()
- }
- p.currentMetric = &dto.Metric{}
- // Do not append the newly created currentMetric to
- // currentMF.Metric right now. First wait if this is a summary,
- // and the metric exists already, which we can only know after
- // having read all the labels.
- if p.skipBlankTabIfCurrentBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- return p.readingLabels
-}
-
-// readingLabels represents the state where the last byte read (now in
-// p.currentByte) is either the first byte of the label set (i.e. a '{'), or the
-// first byte of the value (otherwise).
-func (p *TextParser) readingLabels() stateFn {
- // Summaries/histograms are special. We have to reset the
- // currentLabels map, currentQuantile and currentBucket before starting to
- // read labels.
- if p.currentMF.GetType() == dto.MetricType_SUMMARY || p.currentMF.GetType() == dto.MetricType_HISTOGRAM {
- p.currentLabels = map[string]string{}
- p.currentLabels[string(model.MetricNameLabel)] = p.currentMF.GetName()
- p.currentQuantile = math.NaN()
- p.currentBucket = math.NaN()
- }
- if p.currentByte != '{' {
- return p.readingValue
- }
- return p.startLabelName
-}
-
-// startLabelName represents the state where the next byte read from p.buf is
-// the start of a label name (or whitespace leading up to it).
-func (p *TextParser) startLabelName() stateFn {
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.currentByte == '}' {
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- return p.readingValue
- }
- if p.readTokenAsLabelName(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.currentToken.Len() == 0 {
- p.parseError(fmt.Sprintf("invalid label name for metric %q", p.currentMF.GetName()))
- return nil
- }
- p.currentLabelPair = &dto.LabelPair{Name: proto.String(p.currentToken.String())}
- if p.currentLabelPair.GetName() == string(model.MetricNameLabel) {
- p.parseError(fmt.Sprintf("label name %q is reserved", model.MetricNameLabel))
- return nil
- }
- // Special summary/histogram treatment. Don't add 'quantile' and 'le'
- // labels to 'real' labels.
- if !(p.currentMF.GetType() == dto.MetricType_SUMMARY && p.currentLabelPair.GetName() == model.QuantileLabel) &&
- !(p.currentMF.GetType() == dto.MetricType_HISTOGRAM && p.currentLabelPair.GetName() == model.BucketLabel) {
- p.currentMetric.Label = append(p.currentMetric.Label, p.currentLabelPair)
- }
- if p.skipBlankTabIfCurrentBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.currentByte != '=' {
- p.parseError(fmt.Sprintf("expected '=' after label name, found %q", p.currentByte))
- return nil
- }
- // Check for duplicate label names.
- labels := make(map[string]struct{})
- for _, l := range p.currentMetric.Label {
- lName := l.GetName()
- if _, exists := labels[lName]; !exists {
- labels[lName] = struct{}{}
- } else {
- p.parseError(fmt.Sprintf("duplicate label names for metric %q", p.currentMF.GetName()))
- return nil
- }
- }
- return p.startLabelValue
-}
-
-// startLabelValue represents the state where the next byte read from p.buf is
-// the start of a (quoted) label value (or whitespace leading up to it).
-func (p *TextParser) startLabelValue() stateFn {
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.currentByte != '"' {
- p.parseError(fmt.Sprintf("expected '\"' at start of label value, found %q", p.currentByte))
- return nil
- }
- if p.readTokenAsLabelValue(); p.err != nil {
- return nil
- }
- if !model.LabelValue(p.currentToken.String()).IsValid() {
- p.parseError(fmt.Sprintf("invalid label value %q", p.currentToken.String()))
- return nil
- }
- p.currentLabelPair.Value = proto.String(p.currentToken.String())
- // Special treatment of summaries:
- // - Quantile labels are special, will result in dto.Quantile later.
- // - Other labels have to be added to currentLabels for signature calculation.
- if p.currentMF.GetType() == dto.MetricType_SUMMARY {
- if p.currentLabelPair.GetName() == model.QuantileLabel {
- if p.currentQuantile, p.err = parseFloat(p.currentLabelPair.GetValue()); p.err != nil {
- // Create a more helpful error message.
- p.parseError(fmt.Sprintf("expected float as value for 'quantile' label, got %q", p.currentLabelPair.GetValue()))
- return nil
- }
- } else {
- p.currentLabels[p.currentLabelPair.GetName()] = p.currentLabelPair.GetValue()
- }
- }
- // Similar special treatment of histograms.
- if p.currentMF.GetType() == dto.MetricType_HISTOGRAM {
- if p.currentLabelPair.GetName() == model.BucketLabel {
- if p.currentBucket, p.err = parseFloat(p.currentLabelPair.GetValue()); p.err != nil {
- // Create a more helpful error message.
- p.parseError(fmt.Sprintf("expected float as value for 'le' label, got %q", p.currentLabelPair.GetValue()))
- return nil
- }
- } else {
- p.currentLabels[p.currentLabelPair.GetName()] = p.currentLabelPair.GetValue()
- }
- }
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- switch p.currentByte {
- case ',':
- return p.startLabelName
-
- case '}':
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- return p.readingValue
- default:
- p.parseError(fmt.Sprintf("unexpected end of label value %q", p.currentLabelPair.GetValue()))
- return nil
- }
-}
-
-// readingValue represents the state where the last byte read (now in
-// p.currentByte) is the first byte of the sample value (i.e. a float).
-func (p *TextParser) readingValue() stateFn {
- // When we are here, we have read all the labels, so for the
- // special case of a summary/histogram, we can finally find out
- // if the metric already exists.
- if p.currentMF.GetType() == dto.MetricType_SUMMARY {
- signature := model.LabelsToSignature(p.currentLabels)
- if summary := p.summaries[signature]; summary != nil {
- p.currentMetric = summary
- } else {
- p.summaries[signature] = p.currentMetric
- p.currentMF.Metric = append(p.currentMF.Metric, p.currentMetric)
- }
- } else if p.currentMF.GetType() == dto.MetricType_HISTOGRAM {
- signature := model.LabelsToSignature(p.currentLabels)
- if histogram := p.histograms[signature]; histogram != nil {
- p.currentMetric = histogram
- } else {
- p.histograms[signature] = p.currentMetric
- p.currentMF.Metric = append(p.currentMF.Metric, p.currentMetric)
- }
- } else {
- p.currentMF.Metric = append(p.currentMF.Metric, p.currentMetric)
- }
- if p.readTokenUntilWhitespace(); p.err != nil {
- return nil // Unexpected end of input.
- }
- value, err := parseFloat(p.currentToken.String())
- if err != nil {
- // Create a more helpful error message.
- p.parseError(fmt.Sprintf("expected float as value, got %q", p.currentToken.String()))
- return nil
- }
- switch p.currentMF.GetType() {
- case dto.MetricType_COUNTER:
- p.currentMetric.Counter = &dto.Counter{Value: proto.Float64(value)}
- case dto.MetricType_GAUGE:
- p.currentMetric.Gauge = &dto.Gauge{Value: proto.Float64(value)}
- case dto.MetricType_UNTYPED:
- p.currentMetric.Untyped = &dto.Untyped{Value: proto.Float64(value)}
- case dto.MetricType_SUMMARY:
- // *sigh*
- if p.currentMetric.Summary == nil {
- p.currentMetric.Summary = &dto.Summary{}
- }
- switch {
- case p.currentIsSummaryCount:
- p.currentMetric.Summary.SampleCount = proto.Uint64(uint64(value))
- case p.currentIsSummarySum:
- p.currentMetric.Summary.SampleSum = proto.Float64(value)
- case !math.IsNaN(p.currentQuantile):
- p.currentMetric.Summary.Quantile = append(
- p.currentMetric.Summary.Quantile,
- &dto.Quantile{
- Quantile: proto.Float64(p.currentQuantile),
- Value: proto.Float64(value),
- },
- )
- }
- case dto.MetricType_HISTOGRAM:
- // *sigh*
- if p.currentMetric.Histogram == nil {
- p.currentMetric.Histogram = &dto.Histogram{}
- }
- switch {
- case p.currentIsHistogramCount:
- p.currentMetric.Histogram.SampleCount = proto.Uint64(uint64(value))
- case p.currentIsHistogramSum:
- p.currentMetric.Histogram.SampleSum = proto.Float64(value)
- case !math.IsNaN(p.currentBucket):
- p.currentMetric.Histogram.Bucket = append(
- p.currentMetric.Histogram.Bucket,
- &dto.Bucket{
- UpperBound: proto.Float64(p.currentBucket),
- CumulativeCount: proto.Uint64(uint64(value)),
- },
- )
- }
- default:
- p.err = fmt.Errorf("unexpected type for metric name %q", p.currentMF.GetName())
- }
- if p.currentByte == '\n' {
- return p.startOfLine
- }
- return p.startTimestamp
-}
-
-// startTimestamp represents the state where the next byte read from p.buf is
-// the start of the timestamp (or whitespace leading up to it).
-func (p *TextParser) startTimestamp() stateFn {
- if p.skipBlankTab(); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.readTokenUntilWhitespace(); p.err != nil {
- return nil // Unexpected end of input.
- }
- timestamp, err := strconv.ParseInt(p.currentToken.String(), 10, 64)
- if err != nil {
- // Create a more helpful error message.
- p.parseError(fmt.Sprintf("expected integer as timestamp, got %q", p.currentToken.String()))
- return nil
- }
- p.currentMetric.TimestampMs = proto.Int64(timestamp)
- if p.readTokenUntilNewline(false); p.err != nil {
- return nil // Unexpected end of input.
- }
- if p.currentToken.Len() > 0 {
- p.parseError(fmt.Sprintf("spurious string after timestamp: %q", p.currentToken.String()))
- return nil
- }
- return p.startOfLine
-}
-
-// readingHelp represents the state where the last byte read (now in
-// p.currentByte) is the first byte of the docstring after 'HELP'.
-func (p *TextParser) readingHelp() stateFn {
- if p.currentMF.Help != nil {
- p.parseError(fmt.Sprintf("second HELP line for metric name %q", p.currentMF.GetName()))
- return nil
- }
- // Rest of line is the docstring.
- if p.readTokenUntilNewline(true); p.err != nil {
- return nil // Unexpected end of input.
- }
- p.currentMF.Help = proto.String(p.currentToken.String())
- return p.startOfLine
-}
-
-// readingType represents the state where the last byte read (now in
-// p.currentByte) is the first byte of the type hint after 'HELP'.
-func (p *TextParser) readingType() stateFn {
- if p.currentMF.Type != nil {
- p.parseError(fmt.Sprintf("second TYPE line for metric name %q, or TYPE reported after samples", p.currentMF.GetName()))
- return nil
- }
- // Rest of line is the type.
- if p.readTokenUntilNewline(false); p.err != nil {
- return nil // Unexpected end of input.
- }
- metricType, ok := dto.MetricType_value[strings.ToUpper(p.currentToken.String())]
- if !ok {
- p.parseError(fmt.Sprintf("unknown metric type %q", p.currentToken.String()))
- return nil
- }
- p.currentMF.Type = dto.MetricType(metricType).Enum()
- return p.startOfLine
-}
-
-// parseError sets p.err to a ParseError at the current line with the given
-// message.
-func (p *TextParser) parseError(msg string) {
- p.err = ParseError{
- Line: p.lineCount,
- Msg: msg,
- }
-}
-
-// skipBlankTab reads (and discards) bytes from p.buf until it encounters a byte
-// that is neither ' ' nor '\t'. That byte is left in p.currentByte.
-func (p *TextParser) skipBlankTab() {
- for {
- if p.currentByte, p.err = p.buf.ReadByte(); p.err != nil || !isBlankOrTab(p.currentByte) {
- return
- }
- }
-}
-
-// skipBlankTabIfCurrentBlankTab works exactly as skipBlankTab but doesn't do
-// anything if p.currentByte is neither ' ' nor '\t'.
-func (p *TextParser) skipBlankTabIfCurrentBlankTab() {
- if isBlankOrTab(p.currentByte) {
- p.skipBlankTab()
- }
-}
-
-// readTokenUntilWhitespace copies bytes from p.buf into p.currentToken. The
-// first byte considered is the byte already read (now in p.currentByte). The
-// first whitespace byte encountered is still copied into p.currentByte, but not
-// into p.currentToken.
-func (p *TextParser) readTokenUntilWhitespace() {
- p.currentToken.Reset()
- for p.err == nil && !isBlankOrTab(p.currentByte) && p.currentByte != '\n' {
- p.currentToken.WriteByte(p.currentByte)
- p.currentByte, p.err = p.buf.ReadByte()
- }
-}
-
-// readTokenUntilNewline copies bytes from p.buf into p.currentToken. The first
-// byte considered is the byte already read (now in p.currentByte). The first
-// newline byte encountered is still copied into p.currentByte, but not into
-// p.currentToken. If recognizeEscapeSequence is true, two escape sequences are
-// recognized: '\\' translates into '\', and '\n' into a line-feed character.
-// All other escape sequences are invalid and cause an error.
-func (p *TextParser) readTokenUntilNewline(recognizeEscapeSequence bool) {
- p.currentToken.Reset()
- escaped := false
- for p.err == nil {
- if recognizeEscapeSequence && escaped {
- switch p.currentByte {
- case '\\':
- p.currentToken.WriteByte(p.currentByte)
- case 'n':
- p.currentToken.WriteByte('\n')
- default:
- p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte))
- return
- }
- escaped = false
- } else {
- switch p.currentByte {
- case '\n':
- return
- case '\\':
- escaped = true
- default:
- p.currentToken.WriteByte(p.currentByte)
- }
- }
- p.currentByte, p.err = p.buf.ReadByte()
- }
-}
-
-// readTokenAsMetricName copies a metric name from p.buf into p.currentToken.
-// The first byte considered is the byte already read (now in p.currentByte).
-// The first byte not part of a metric name is still copied into p.currentByte,
-// but not into p.currentToken.
-func (p *TextParser) readTokenAsMetricName() {
- p.currentToken.Reset()
- if !isValidMetricNameStart(p.currentByte) {
- return
- }
- for {
- p.currentToken.WriteByte(p.currentByte)
- p.currentByte, p.err = p.buf.ReadByte()
- if p.err != nil || !isValidMetricNameContinuation(p.currentByte) {
- return
- }
- }
-}
-
-// readTokenAsLabelName copies a label name from p.buf into p.currentToken.
-// The first byte considered is the byte already read (now in p.currentByte).
-// The first byte not part of a label name is still copied into p.currentByte,
-// but not into p.currentToken.
-func (p *TextParser) readTokenAsLabelName() {
- p.currentToken.Reset()
- if !isValidLabelNameStart(p.currentByte) {
- return
- }
- for {
- p.currentToken.WriteByte(p.currentByte)
- p.currentByte, p.err = p.buf.ReadByte()
- if p.err != nil || !isValidLabelNameContinuation(p.currentByte) {
- return
- }
- }
-}
-
-// readTokenAsLabelValue copies a label value from p.buf into p.currentToken.
-// In contrast to the other 'readTokenAs...' functions, which start with the
-// last read byte in p.currentByte, this method ignores p.currentByte and starts
-// with reading a new byte from p.buf. The first byte not part of a label value
-// is still copied into p.currentByte, but not into p.currentToken.
-func (p *TextParser) readTokenAsLabelValue() {
- p.currentToken.Reset()
- escaped := false
- for {
- if p.currentByte, p.err = p.buf.ReadByte(); p.err != nil {
- return
- }
- if escaped {
- switch p.currentByte {
- case '"', '\\':
- p.currentToken.WriteByte(p.currentByte)
- case 'n':
- p.currentToken.WriteByte('\n')
- default:
- p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte))
- return
- }
- escaped = false
- continue
- }
- switch p.currentByte {
- case '"':
- return
- case '\n':
- p.parseError(fmt.Sprintf("label value %q contains unescaped new-line", p.currentToken.String()))
- return
- case '\\':
- escaped = true
- default:
- p.currentToken.WriteByte(p.currentByte)
- }
- }
-}
-
-func (p *TextParser) setOrCreateCurrentMF() {
- p.currentIsSummaryCount = false
- p.currentIsSummarySum = false
- p.currentIsHistogramCount = false
- p.currentIsHistogramSum = false
- name := p.currentToken.String()
- if p.currentMF = p.metricFamiliesByName[name]; p.currentMF != nil {
- return
- }
- // Try out if this is a _sum or _count for a summary/histogram.
- summaryName := summaryMetricName(name)
- if p.currentMF = p.metricFamiliesByName[summaryName]; p.currentMF != nil {
- if p.currentMF.GetType() == dto.MetricType_SUMMARY {
- if isCount(name) {
- p.currentIsSummaryCount = true
- }
- if isSum(name) {
- p.currentIsSummarySum = true
- }
- return
- }
- }
- histogramName := histogramMetricName(name)
- if p.currentMF = p.metricFamiliesByName[histogramName]; p.currentMF != nil {
- if p.currentMF.GetType() == dto.MetricType_HISTOGRAM {
- if isCount(name) {
- p.currentIsHistogramCount = true
- }
- if isSum(name) {
- p.currentIsHistogramSum = true
- }
- return
- }
- }
- p.currentMF = &dto.MetricFamily{Name: proto.String(name)}
- p.metricFamiliesByName[name] = p.currentMF
-}
-
-func isValidLabelNameStart(b byte) bool {
- return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_'
-}
-
-func isValidLabelNameContinuation(b byte) bool {
- return isValidLabelNameStart(b) || (b >= '0' && b <= '9')
-}
-
-func isValidMetricNameStart(b byte) bool {
- return isValidLabelNameStart(b) || b == ':'
-}
-
-func isValidMetricNameContinuation(b byte) bool {
- return isValidLabelNameContinuation(b) || b == ':'
-}
-
-func isBlankOrTab(b byte) bool {
- return b == ' ' || b == '\t'
-}
-
-func isCount(name string) bool {
- return len(name) > 6 && name[len(name)-6:] == "_count"
-}
-
-func isSum(name string) bool {
- return len(name) > 4 && name[len(name)-4:] == "_sum"
-}
-
-func isBucket(name string) bool {
- return len(name) > 7 && name[len(name)-7:] == "_bucket"
-}
-
-func summaryMetricName(name string) string {
- switch {
- case isCount(name):
- return name[:len(name)-6]
- case isSum(name):
- return name[:len(name)-4]
- default:
- return name
- }
-}
-
-func histogramMetricName(name string) string {
- switch {
- case isCount(name):
- return name[:len(name)-6]
- case isSum(name):
- return name[:len(name)-4]
- case isBucket(name):
- return name[:len(name)-7]
- default:
- return name
- }
-}
-
-func parseFloat(s string) (float64, error) {
- if strings.ContainsAny(s, "pP_") {
- return 0, fmt.Errorf("unsupported character in float")
- }
- return strconv.ParseFloat(s, 64)
-}
diff --git a/vendor/github.com/prometheus/common/model/alert.go b/vendor/github.com/prometheus/common/model/alert.go
deleted file mode 100644
index 80d1fe9..0000000
--- a/vendor/github.com/prometheus/common/model/alert.go
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "fmt"
- "time"
-)
-
-type AlertStatus string
-
-const (
- AlertFiring AlertStatus = "firing"
- AlertResolved AlertStatus = "resolved"
-)
-
-// Alert is a generic representation of an alert in the Prometheus eco-system.
-type Alert struct {
- // Label value pairs for purpose of aggregation, matching, and disposition
- // dispatching. This must minimally include an "alertname" label.
- Labels LabelSet `json:"labels"`
-
- // Extra key/value information which does not define alert identity.
- Annotations LabelSet `json:"annotations"`
-
- // The known time range for this alert. Both ends are optional.
- StartsAt time.Time `json:"startsAt,omitempty"`
- EndsAt time.Time `json:"endsAt,omitempty"`
- GeneratorURL string `json:"generatorURL"`
-}
-
-// Name returns the name of the alert. It is equivalent to the "alertname" label.
-func (a *Alert) Name() string {
- return string(a.Labels[AlertNameLabel])
-}
-
-// Fingerprint returns a unique hash for the alert. It is equivalent to
-// the fingerprint of the alert's label set.
-func (a *Alert) Fingerprint() Fingerprint {
- return a.Labels.Fingerprint()
-}
-
-func (a *Alert) String() string {
- s := fmt.Sprintf("%s[%s]", a.Name(), a.Fingerprint().String()[:7])
- if a.Resolved() {
- return s + "[resolved]"
- }
- return s + "[active]"
-}
-
-// Resolved returns true iff the activity interval ended in the past.
-func (a *Alert) Resolved() bool {
- return a.ResolvedAt(time.Now())
-}
-
-// ResolvedAt returns true off the activity interval ended before
-// the given timestamp.
-func (a *Alert) ResolvedAt(ts time.Time) bool {
- if a.EndsAt.IsZero() {
- return false
- }
- return !a.EndsAt.After(ts)
-}
-
-// Status returns the status of the alert.
-func (a *Alert) Status() AlertStatus {
- return a.StatusAt(time.Now())
-}
-
-// StatusAt returns the status of the alert at the given timestamp.
-func (a *Alert) StatusAt(ts time.Time) AlertStatus {
- if a.ResolvedAt(ts) {
- return AlertResolved
- }
- return AlertFiring
-}
-
-// Validate checks whether the alert data is inconsistent.
-func (a *Alert) Validate() error {
- if a.StartsAt.IsZero() {
- return fmt.Errorf("start time missing")
- }
- if !a.EndsAt.IsZero() && a.EndsAt.Before(a.StartsAt) {
- return fmt.Errorf("start time must be before end time")
- }
- if err := a.Labels.Validate(); err != nil {
- return fmt.Errorf("invalid label set: %w", err)
- }
- if len(a.Labels) == 0 {
- return fmt.Errorf("at least one label pair required")
- }
- if err := a.Annotations.Validate(); err != nil {
- return fmt.Errorf("invalid annotations: %w", err)
- }
- return nil
-}
-
-// Alert is a list of alerts that can be sorted in chronological order.
-type Alerts []*Alert
-
-func (as Alerts) Len() int { return len(as) }
-func (as Alerts) Swap(i, j int) { as[i], as[j] = as[j], as[i] }
-
-func (as Alerts) Less(i, j int) bool {
- if as[i].StartsAt.Before(as[j].StartsAt) {
- return true
- }
- if as[i].EndsAt.Before(as[j].EndsAt) {
- return true
- }
- return as[i].Fingerprint() < as[j].Fingerprint()
-}
-
-// HasFiring returns true iff one of the alerts is not resolved.
-func (as Alerts) HasFiring() bool {
- for _, a := range as {
- if !a.Resolved() {
- return true
- }
- }
- return false
-}
-
-// HasFiringAt returns true iff one of the alerts is not resolved
-// at the time ts.
-func (as Alerts) HasFiringAt(ts time.Time) bool {
- for _, a := range as {
- if !a.ResolvedAt(ts) {
- return true
- }
- }
- return false
-}
-
-// Status returns StatusFiring iff at least one of the alerts is firing.
-func (as Alerts) Status() AlertStatus {
- if as.HasFiring() {
- return AlertFiring
- }
- return AlertResolved
-}
-
-// StatusAt returns StatusFiring iff at least one of the alerts is firing
-// at the time ts.
-func (as Alerts) StatusAt(ts time.Time) AlertStatus {
- if as.HasFiringAt(ts) {
- return AlertFiring
- }
- return AlertResolved
-}
diff --git a/vendor/github.com/prometheus/common/model/fingerprinting.go b/vendor/github.com/prometheus/common/model/fingerprinting.go
deleted file mode 100644
index fc4de41..0000000
--- a/vendor/github.com/prometheus/common/model/fingerprinting.go
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "fmt"
- "strconv"
-)
-
-// Fingerprint provides a hash-capable representation of a Metric.
-// For our purposes, FNV-1A 64-bit is used.
-type Fingerprint uint64
-
-// FingerprintFromString transforms a string representation into a Fingerprint.
-func FingerprintFromString(s string) (Fingerprint, error) {
- num, err := strconv.ParseUint(s, 16, 64)
- return Fingerprint(num), err
-}
-
-// ParseFingerprint parses the input string into a fingerprint.
-func ParseFingerprint(s string) (Fingerprint, error) {
- num, err := strconv.ParseUint(s, 16, 64)
- if err != nil {
- return 0, err
- }
- return Fingerprint(num), nil
-}
-
-func (f Fingerprint) String() string {
- return fmt.Sprintf("%016x", uint64(f))
-}
-
-// Fingerprints represents a collection of Fingerprint subject to a given
-// natural sorting scheme. It implements sort.Interface.
-type Fingerprints []Fingerprint
-
-// Len implements sort.Interface.
-func (f Fingerprints) Len() int {
- return len(f)
-}
-
-// Less implements sort.Interface.
-func (f Fingerprints) Less(i, j int) bool {
- return f[i] < f[j]
-}
-
-// Swap implements sort.Interface.
-func (f Fingerprints) Swap(i, j int) {
- f[i], f[j] = f[j], f[i]
-}
-
-// FingerprintSet is a set of Fingerprints.
-type FingerprintSet map[Fingerprint]struct{}
-
-// Equal returns true if both sets contain the same elements (and not more).
-func (s FingerprintSet) Equal(o FingerprintSet) bool {
- if len(s) != len(o) {
- return false
- }
-
- for k := range s {
- if _, ok := o[k]; !ok {
- return false
- }
- }
-
- return true
-}
-
-// Intersection returns the elements contained in both sets.
-func (s FingerprintSet) Intersection(o FingerprintSet) FingerprintSet {
- myLength, otherLength := len(s), len(o)
- if myLength == 0 || otherLength == 0 {
- return FingerprintSet{}
- }
-
- subSet := s
- superSet := o
-
- if otherLength < myLength {
- subSet = o
- superSet = s
- }
-
- out := FingerprintSet{}
-
- for k := range subSet {
- if _, ok := superSet[k]; ok {
- out[k] = struct{}{}
- }
- }
-
- return out
-}
diff --git a/vendor/github.com/prometheus/common/model/fnv.go b/vendor/github.com/prometheus/common/model/fnv.go
deleted file mode 100644
index 367afec..0000000
--- a/vendor/github.com/prometheus/common/model/fnv.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-// Inline and byte-free variant of hash/fnv's fnv64a.
-
-const (
- offset64 = 14695981039346656037
- prime64 = 1099511628211
-)
-
-// hashNew initializes a new fnv64a hash value.
-func hashNew() uint64 {
- return offset64
-}
-
-// hashAdd adds a string to a fnv64a hash value, returning the updated hash.
-func hashAdd(h uint64, s string) uint64 {
- for i := 0; i < len(s); i++ {
- h ^= uint64(s[i])
- h *= prime64
- }
- return h
-}
-
-// hashAddByte adds a byte to a fnv64a hash value, returning the updated hash.
-func hashAddByte(h uint64, b byte) uint64 {
- h ^= uint64(b)
- h *= prime64
- return h
-}
diff --git a/vendor/github.com/prometheus/common/model/labels.go b/vendor/github.com/prometheus/common/model/labels.go
deleted file mode 100644
index 3317ce2..0000000
--- a/vendor/github.com/prometheus/common/model/labels.go
+++ /dev/null
@@ -1,226 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "regexp"
- "strings"
- "unicode/utf8"
-)
-
-const (
- // AlertNameLabel is the name of the label containing the an alert's name.
- AlertNameLabel = "alertname"
-
- // ExportedLabelPrefix is the prefix to prepend to the label names present in
- // exported metrics if a label of the same name is added by the server.
- ExportedLabelPrefix = "exported_"
-
- // MetricNameLabel is the label name indicating the metric name of a
- // timeseries.
- MetricNameLabel = "__name__"
-
- // SchemeLabel is the name of the label that holds the scheme on which to
- // scrape a target.
- SchemeLabel = "__scheme__"
-
- // AddressLabel is the name of the label that holds the address of
- // a scrape target.
- AddressLabel = "__address__"
-
- // MetricsPathLabel is the name of the label that holds the path on which to
- // scrape a target.
- MetricsPathLabel = "__metrics_path__"
-
- // ScrapeIntervalLabel is the name of the label that holds the scrape interval
- // used to scrape a target.
- ScrapeIntervalLabel = "__scrape_interval__"
-
- // ScrapeTimeoutLabel is the name of the label that holds the scrape
- // timeout used to scrape a target.
- ScrapeTimeoutLabel = "__scrape_timeout__"
-
- // ReservedLabelPrefix is a prefix which is not legal in user-supplied
- // label names.
- ReservedLabelPrefix = "__"
-
- // MetaLabelPrefix is a prefix for labels that provide meta information.
- // Labels with this prefix are used for intermediate label processing and
- // will not be attached to time series.
- MetaLabelPrefix = "__meta_"
-
- // TmpLabelPrefix is a prefix for temporary labels as part of relabelling.
- // Labels with this prefix are used for intermediate label processing and
- // will not be attached to time series. This is reserved for use in
- // Prometheus configuration files by users.
- TmpLabelPrefix = "__tmp_"
-
- // ParamLabelPrefix is a prefix for labels that provide URL parameters
- // used to scrape a target.
- ParamLabelPrefix = "__param_"
-
- // JobLabel is the label name indicating the job from which a timeseries
- // was scraped.
- JobLabel = "job"
-
- // InstanceLabel is the label name used for the instance label.
- InstanceLabel = "instance"
-
- // BucketLabel is used for the label that defines the upper bound of a
- // bucket of a histogram ("le" -> "less or equal").
- BucketLabel = "le"
-
- // QuantileLabel is used for the label that defines the quantile in a
- // summary.
- QuantileLabel = "quantile"
-)
-
-// LabelNameRE is a regular expression matching valid label names. Note that the
-// IsValid method of LabelName performs the same check but faster than a match
-// with this regular expression.
-var LabelNameRE = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$")
-
-// A LabelName is a key for a LabelSet or Metric. It has a value associated
-// therewith.
-type LabelName string
-
-// IsValid returns true iff name matches the pattern of LabelNameRE for legacy
-// names, and iff it's valid UTF-8 if NameValidationScheme is set to
-// UTF8Validation. For the legacy matching, it does not use LabelNameRE for the
-// check but a much faster hardcoded implementation.
-func (ln LabelName) IsValid() bool {
- if len(ln) == 0 {
- return false
- }
- switch NameValidationScheme {
- case LegacyValidation:
- for i, b := range ln {
- if !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || (b >= '0' && b <= '9' && i > 0)) {
- return false
- }
- }
- case UTF8Validation:
- return utf8.ValidString(string(ln))
- default:
- panic(fmt.Sprintf("Invalid name validation scheme requested: %d", NameValidationScheme))
- }
- return true
-}
-
-// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (ln *LabelName) UnmarshalYAML(unmarshal func(interface{}) error) error {
- var s string
- if err := unmarshal(&s); err != nil {
- return err
- }
- if !LabelName(s).IsValid() {
- return fmt.Errorf("%q is not a valid label name", s)
- }
- *ln = LabelName(s)
- return nil
-}
-
-// UnmarshalJSON implements the json.Unmarshaler interface.
-func (ln *LabelName) UnmarshalJSON(b []byte) error {
- var s string
- if err := json.Unmarshal(b, &s); err != nil {
- return err
- }
- if !LabelName(s).IsValid() {
- return fmt.Errorf("%q is not a valid label name", s)
- }
- *ln = LabelName(s)
- return nil
-}
-
-// LabelNames is a sortable LabelName slice. In implements sort.Interface.
-type LabelNames []LabelName
-
-func (l LabelNames) Len() int {
- return len(l)
-}
-
-func (l LabelNames) Less(i, j int) bool {
- return l[i] < l[j]
-}
-
-func (l LabelNames) Swap(i, j int) {
- l[i], l[j] = l[j], l[i]
-}
-
-func (l LabelNames) String() string {
- labelStrings := make([]string, 0, len(l))
- for _, label := range l {
- labelStrings = append(labelStrings, string(label))
- }
- return strings.Join(labelStrings, ", ")
-}
-
-// A LabelValue is an associated value for a LabelName.
-type LabelValue string
-
-// IsValid returns true iff the string is a valid UTF-8.
-func (lv LabelValue) IsValid() bool {
- return utf8.ValidString(string(lv))
-}
-
-// LabelValues is a sortable LabelValue slice. It implements sort.Interface.
-type LabelValues []LabelValue
-
-func (l LabelValues) Len() int {
- return len(l)
-}
-
-func (l LabelValues) Less(i, j int) bool {
- return string(l[i]) < string(l[j])
-}
-
-func (l LabelValues) Swap(i, j int) {
- l[i], l[j] = l[j], l[i]
-}
-
-// LabelPair pairs a name with a value.
-type LabelPair struct {
- Name LabelName
- Value LabelValue
-}
-
-// LabelPairs is a sortable slice of LabelPair pointers. It implements
-// sort.Interface.
-type LabelPairs []*LabelPair
-
-func (l LabelPairs) Len() int {
- return len(l)
-}
-
-func (l LabelPairs) Less(i, j int) bool {
- switch {
- case l[i].Name > l[j].Name:
- return false
- case l[i].Name < l[j].Name:
- return true
- case l[i].Value > l[j].Value:
- return false
- case l[i].Value < l[j].Value:
- return true
- default:
- return false
- }
-}
-
-func (l LabelPairs) Swap(i, j int) {
- l[i], l[j] = l[j], l[i]
-}
diff --git a/vendor/github.com/prometheus/common/model/labelset.go b/vendor/github.com/prometheus/common/model/labelset.go
deleted file mode 100644
index d0ad88d..0000000
--- a/vendor/github.com/prometheus/common/model/labelset.go
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "sort"
-)
-
-// A LabelSet is a collection of LabelName and LabelValue pairs. The LabelSet
-// may be fully-qualified down to the point where it may resolve to a single
-// Metric in the data store or not. All operations that occur within the realm
-// of a LabelSet can emit a vector of Metric entities to which the LabelSet may
-// match.
-type LabelSet map[LabelName]LabelValue
-
-// Validate checks whether all names and values in the label set
-// are valid.
-func (ls LabelSet) Validate() error {
- for ln, lv := range ls {
- if !ln.IsValid() {
- return fmt.Errorf("invalid name %q", ln)
- }
- if !lv.IsValid() {
- return fmt.Errorf("invalid value %q", lv)
- }
- }
- return nil
-}
-
-// Equal returns true iff both label sets have exactly the same key/value pairs.
-func (ls LabelSet) Equal(o LabelSet) bool {
- if len(ls) != len(o) {
- return false
- }
- for ln, lv := range ls {
- olv, ok := o[ln]
- if !ok {
- return false
- }
- if olv != lv {
- return false
- }
- }
- return true
-}
-
-// Before compares the metrics, using the following criteria:
-//
-// If m has fewer labels than o, it is before o. If it has more, it is not.
-//
-// If the number of labels is the same, the superset of all label names is
-// sorted alphanumerically. The first differing label pair found in that order
-// determines the outcome: If the label does not exist at all in m, then m is
-// before o, and vice versa. Otherwise the label value is compared
-// alphanumerically.
-//
-// If m and o are equal, the method returns false.
-func (ls LabelSet) Before(o LabelSet) bool {
- if len(ls) < len(o) {
- return true
- }
- if len(ls) > len(o) {
- return false
- }
-
- lns := make(LabelNames, 0, len(ls)+len(o))
- for ln := range ls {
- lns = append(lns, ln)
- }
- for ln := range o {
- lns = append(lns, ln)
- }
- // It's probably not worth it to de-dup lns.
- sort.Sort(lns)
- for _, ln := range lns {
- mlv, ok := ls[ln]
- if !ok {
- return true
- }
- olv, ok := o[ln]
- if !ok {
- return false
- }
- if mlv < olv {
- return true
- }
- if mlv > olv {
- return false
- }
- }
- return false
-}
-
-// Clone returns a copy of the label set.
-func (ls LabelSet) Clone() LabelSet {
- lsn := make(LabelSet, len(ls))
- for ln, lv := range ls {
- lsn[ln] = lv
- }
- return lsn
-}
-
-// Merge is a helper function to non-destructively merge two label sets.
-func (l LabelSet) Merge(other LabelSet) LabelSet {
- result := make(LabelSet, len(l))
-
- for k, v := range l {
- result[k] = v
- }
-
- for k, v := range other {
- result[k] = v
- }
-
- return result
-}
-
-// Fingerprint returns the LabelSet's fingerprint.
-func (ls LabelSet) Fingerprint() Fingerprint {
- return labelSetToFingerprint(ls)
-}
-
-// FastFingerprint returns the LabelSet's Fingerprint calculated by a faster hashing
-// algorithm, which is, however, more susceptible to hash collisions.
-func (ls LabelSet) FastFingerprint() Fingerprint {
- return labelSetToFastFingerprint(ls)
-}
-
-// UnmarshalJSON implements the json.Unmarshaler interface.
-func (l *LabelSet) UnmarshalJSON(b []byte) error {
- var m map[LabelName]LabelValue
- if err := json.Unmarshal(b, &m); err != nil {
- return err
- }
- // encoding/json only unmarshals maps of the form map[string]T. It treats
- // LabelName as a string and does not call its UnmarshalJSON method.
- // Thus, we have to replicate the behavior here.
- for ln := range m {
- if !ln.IsValid() {
- return fmt.Errorf("%q is not a valid label name", ln)
- }
- }
- *l = LabelSet(m)
- return nil
-}
diff --git a/vendor/github.com/prometheus/common/model/labelset_string.go b/vendor/github.com/prometheus/common/model/labelset_string.go
deleted file mode 100644
index 481c47b..0000000
--- a/vendor/github.com/prometheus/common/model/labelset_string.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2024 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build go1.21
-
-package model
-
-import (
- "bytes"
- "slices"
- "strconv"
-)
-
-// String will look like `{foo="bar", more="less"}`. Names are sorted alphabetically.
-func (l LabelSet) String() string {
- var lna [32]string // On stack to avoid memory allocation for sorting names.
- labelNames := lna[:0]
- for name := range l {
- labelNames = append(labelNames, string(name))
- }
- slices.Sort(labelNames)
- var bytea [1024]byte // On stack to avoid memory allocation while building the output.
- b := bytes.NewBuffer(bytea[:0])
- b.WriteByte('{')
- for i, name := range labelNames {
- if i > 0 {
- b.WriteString(", ")
- }
- b.WriteString(name)
- b.WriteByte('=')
- b.Write(strconv.AppendQuote(b.AvailableBuffer(), string(l[LabelName(name)])))
- }
- b.WriteByte('}')
- return b.String()
-}
diff --git a/vendor/github.com/prometheus/common/model/labelset_string_go120.go b/vendor/github.com/prometheus/common/model/labelset_string_go120.go
deleted file mode 100644
index c421268..0000000
--- a/vendor/github.com/prometheus/common/model/labelset_string_go120.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2024 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !go1.21
-
-package model
-
-import (
- "fmt"
- "sort"
- "strings"
-)
-
-// String was optimized using functions not available for go 1.20
-// or lower. We keep the old implementation for compatibility with client_golang.
-// Once client golang drops support for go 1.20 (scheduled for August 2024), this
-// file can be removed.
-func (l LabelSet) String() string {
- labelNames := make([]string, 0, len(l))
- for name := range l {
- labelNames = append(labelNames, string(name))
- }
- sort.Strings(labelNames)
- lstrs := make([]string, 0, len(l))
- for _, name := range labelNames {
- lstrs = append(lstrs, fmt.Sprintf("%s=%q", name, l[LabelName(name)]))
- }
- return fmt.Sprintf("{%s}", strings.Join(lstrs, ", "))
-}
diff --git a/vendor/github.com/prometheus/common/model/metadata.go b/vendor/github.com/prometheus/common/model/metadata.go
deleted file mode 100644
index 447ab8a..0000000
--- a/vendor/github.com/prometheus/common/model/metadata.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2023 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-// MetricType represents metric type values.
-type MetricType string
-
-const (
- MetricTypeCounter = MetricType("counter")
- MetricTypeGauge = MetricType("gauge")
- MetricTypeHistogram = MetricType("histogram")
- MetricTypeGaugeHistogram = MetricType("gaugehistogram")
- MetricTypeSummary = MetricType("summary")
- MetricTypeInfo = MetricType("info")
- MetricTypeStateset = MetricType("stateset")
- MetricTypeUnknown = MetricType("unknown")
-)
diff --git a/vendor/github.com/prometheus/common/model/metric.go b/vendor/github.com/prometheus/common/model/metric.go
deleted file mode 100644
index eb865e5..0000000
--- a/vendor/github.com/prometheus/common/model/metric.go
+++ /dev/null
@@ -1,457 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "fmt"
- "regexp"
- "sort"
- "strings"
- "unicode/utf8"
-
- dto "github.com/prometheus/client_model/go"
- "google.golang.org/protobuf/proto"
-)
-
-var (
- // NameValidationScheme determines the method of name validation to be used by
- // all calls to IsValidMetricName() and LabelName IsValid(). Setting UTF-8 mode
- // in isolation from other components that don't support UTF-8 may result in
- // bugs or other undefined behavior. This value is intended to be set by
- // UTF-8-aware binaries as part of their startup. To avoid need for locking,
- // this value should be set once, ideally in an init(), before multiple
- // goroutines are started.
- NameValidationScheme = LegacyValidation
-
- // NameEscapingScheme defines the default way that names will be
- // escaped when presented to systems that do not support UTF-8 names. If the
- // Content-Type "escaping" term is specified, that will override this value.
- NameEscapingScheme = ValueEncodingEscaping
-)
-
-// ValidationScheme is a Go enum for determining how metric and label names will
-// be validated by this library.
-type ValidationScheme int
-
-const (
- // LegacyValidation is a setting that requirets that metric and label names
- // conform to the original Prometheus character requirements described by
- // MetricNameRE and LabelNameRE.
- LegacyValidation ValidationScheme = iota
-
- // UTF8Validation only requires that metric and label names be valid UTF-8
- // strings.
- UTF8Validation
-)
-
-type EscapingScheme int
-
-const (
- // NoEscaping indicates that a name will not be escaped. Unescaped names that
- // do not conform to the legacy validity check will use a new exposition
- // format syntax that will be officially standardized in future versions.
- NoEscaping EscapingScheme = iota
-
- // UnderscoreEscaping replaces all legacy-invalid characters with underscores.
- UnderscoreEscaping
-
- // DotsEscaping is similar to UnderscoreEscaping, except that dots are
- // converted to `_dot_` and pre-existing underscores are converted to `__`.
- DotsEscaping
-
- // ValueEncodingEscaping prepends the name with `U__` and replaces all invalid
- // characters with the unicode value, surrounded by underscores. Single
- // underscores are replaced with double underscores.
- ValueEncodingEscaping
-)
-
-const (
- // EscapingKey is the key in an Accept or Content-Type header that defines how
- // metric and label names that do not conform to the legacy character
- // requirements should be escaped when being scraped by a legacy prometheus
- // system. If a system does not explicitly pass an escaping parameter in the
- // Accept header, the default NameEscapingScheme will be used.
- EscapingKey = "escaping"
-
- // Possible values for Escaping Key:
- AllowUTF8 = "allow-utf-8" // No escaping required.
- EscapeUnderscores = "underscores"
- EscapeDots = "dots"
- EscapeValues = "values"
-)
-
-// MetricNameRE is a regular expression matching valid metric
-// names. Note that the IsValidMetricName function performs the same
-// check but faster than a match with this regular expression.
-var MetricNameRE = regexp.MustCompile(`^[a-zA-Z_:][a-zA-Z0-9_:]*$`)
-
-// A Metric is similar to a LabelSet, but the key difference is that a Metric is
-// a singleton and refers to one and only one stream of samples.
-type Metric LabelSet
-
-// Equal compares the metrics.
-func (m Metric) Equal(o Metric) bool {
- return LabelSet(m).Equal(LabelSet(o))
-}
-
-// Before compares the metrics' underlying label sets.
-func (m Metric) Before(o Metric) bool {
- return LabelSet(m).Before(LabelSet(o))
-}
-
-// Clone returns a copy of the Metric.
-func (m Metric) Clone() Metric {
- clone := make(Metric, len(m))
- for k, v := range m {
- clone[k] = v
- }
- return clone
-}
-
-func (m Metric) String() string {
- metricName, hasName := m[MetricNameLabel]
- numLabels := len(m) - 1
- if !hasName {
- numLabels = len(m)
- }
- labelStrings := make([]string, 0, numLabels)
- for label, value := range m {
- if label != MetricNameLabel {
- labelStrings = append(labelStrings, fmt.Sprintf("%s=%q", label, value))
- }
- }
-
- switch numLabels {
- case 0:
- if hasName {
- return string(metricName)
- }
- return "{}"
- default:
- sort.Strings(labelStrings)
- return fmt.Sprintf("%s{%s}", metricName, strings.Join(labelStrings, ", "))
- }
-}
-
-// Fingerprint returns a Metric's Fingerprint.
-func (m Metric) Fingerprint() Fingerprint {
- return LabelSet(m).Fingerprint()
-}
-
-// FastFingerprint returns a Metric's Fingerprint calculated by a faster hashing
-// algorithm, which is, however, more susceptible to hash collisions.
-func (m Metric) FastFingerprint() Fingerprint {
- return LabelSet(m).FastFingerprint()
-}
-
-// IsValidMetricName returns true iff name matches the pattern of MetricNameRE
-// for legacy names, and iff it's valid UTF-8 if the UTF8Validation scheme is
-// selected.
-func IsValidMetricName(n LabelValue) bool {
- switch NameValidationScheme {
- case LegacyValidation:
- return IsValidLegacyMetricName(n)
- case UTF8Validation:
- if len(n) == 0 {
- return false
- }
- return utf8.ValidString(string(n))
- default:
- panic(fmt.Sprintf("Invalid name validation scheme requested: %d", NameValidationScheme))
- }
-}
-
-// IsValidLegacyMetricName is similar to IsValidMetricName but always uses the
-// legacy validation scheme regardless of the value of NameValidationScheme.
-// This function, however, does not use MetricNameRE for the check but a much
-// faster hardcoded implementation.
-func IsValidLegacyMetricName(n LabelValue) bool {
- if len(n) == 0 {
- return false
- }
- for i, b := range n {
- if !isValidLegacyRune(b, i) {
- return false
- }
- }
- return true
-}
-
-// EscapeMetricFamily escapes the given metric names and labels with the given
-// escaping scheme. Returns a new object that uses the same pointers to fields
-// when possible and creates new escaped versions so as not to mutate the
-// input.
-func EscapeMetricFamily(v *dto.MetricFamily, scheme EscapingScheme) *dto.MetricFamily {
- if v == nil {
- return nil
- }
-
- if scheme == NoEscaping {
- return v
- }
-
- out := &dto.MetricFamily{
- Help: v.Help,
- Type: v.Type,
- Unit: v.Unit,
- }
-
- // If the name is nil, copy as-is, don't try to escape.
- if v.Name == nil || IsValidLegacyMetricName(LabelValue(v.GetName())) {
- out.Name = v.Name
- } else {
- out.Name = proto.String(EscapeName(v.GetName(), scheme))
- }
- for _, m := range v.Metric {
- if !metricNeedsEscaping(m) {
- out.Metric = append(out.Metric, m)
- continue
- }
-
- escaped := &dto.Metric{
- Gauge: m.Gauge,
- Counter: m.Counter,
- Summary: m.Summary,
- Untyped: m.Untyped,
- Histogram: m.Histogram,
- TimestampMs: m.TimestampMs,
- }
-
- for _, l := range m.Label {
- if l.GetName() == MetricNameLabel {
- if l.Value == nil || IsValidLegacyMetricName(LabelValue(l.GetValue())) {
- escaped.Label = append(escaped.Label, l)
- continue
- }
- escaped.Label = append(escaped.Label, &dto.LabelPair{
- Name: proto.String(MetricNameLabel),
- Value: proto.String(EscapeName(l.GetValue(), scheme)),
- })
- continue
- }
- if l.Name == nil || IsValidLegacyMetricName(LabelValue(l.GetName())) {
- escaped.Label = append(escaped.Label, l)
- continue
- }
- escaped.Label = append(escaped.Label, &dto.LabelPair{
- Name: proto.String(EscapeName(l.GetName(), scheme)),
- Value: l.Value,
- })
- }
- out.Metric = append(out.Metric, escaped)
- }
- return out
-}
-
-func metricNeedsEscaping(m *dto.Metric) bool {
- for _, l := range m.Label {
- if l.GetName() == MetricNameLabel && !IsValidLegacyMetricName(LabelValue(l.GetValue())) {
- return true
- }
- if !IsValidLegacyMetricName(LabelValue(l.GetName())) {
- return true
- }
- }
- return false
-}
-
-const (
- lowerhex = "0123456789abcdef"
-)
-
-// EscapeName escapes the incoming name according to the provided escaping
-// scheme. Depending on the rules of escaping, this may cause no change in the
-// string that is returned. (Especially NoEscaping, which by definition is a
-// noop). This function does not do any validation of the name.
-func EscapeName(name string, scheme EscapingScheme) string {
- if len(name) == 0 {
- return name
- }
- var escaped strings.Builder
- switch scheme {
- case NoEscaping:
- return name
- case UnderscoreEscaping:
- if IsValidLegacyMetricName(LabelValue(name)) {
- return name
- }
- for i, b := range name {
- if isValidLegacyRune(b, i) {
- escaped.WriteRune(b)
- } else {
- escaped.WriteRune('_')
- }
- }
- return escaped.String()
- case DotsEscaping:
- // Do not early return for legacy valid names, we still escape underscores.
- for i, b := range name {
- if b == '_' {
- escaped.WriteString("__")
- } else if b == '.' {
- escaped.WriteString("_dot_")
- } else if isValidLegacyRune(b, i) {
- escaped.WriteRune(b)
- } else {
- escaped.WriteRune('_')
- }
- }
- return escaped.String()
- case ValueEncodingEscaping:
- if IsValidLegacyMetricName(LabelValue(name)) {
- return name
- }
- escaped.WriteString("U__")
- for i, b := range name {
- if isValidLegacyRune(b, i) {
- escaped.WriteRune(b)
- } else if !utf8.ValidRune(b) {
- escaped.WriteString("_FFFD_")
- } else if b < 0x100 {
- escaped.WriteRune('_')
- for s := 4; s >= 0; s -= 4 {
- escaped.WriteByte(lowerhex[b>>uint(s)&0xF])
- }
- escaped.WriteRune('_')
- } else if b < 0x10000 {
- escaped.WriteRune('_')
- for s := 12; s >= 0; s -= 4 {
- escaped.WriteByte(lowerhex[b>>uint(s)&0xF])
- }
- escaped.WriteRune('_')
- }
- }
- return escaped.String()
- default:
- panic(fmt.Sprintf("invalid escaping scheme %d", scheme))
- }
-}
-
-// lower function taken from strconv.atoi
-func lower(c byte) byte {
- return c | ('x' - 'X')
-}
-
-// UnescapeName unescapes the incoming name according to the provided escaping
-// scheme if possible. Some schemes are partially or totally non-roundtripable.
-// If any error is enountered, returns the original input.
-func UnescapeName(name string, scheme EscapingScheme) string {
- if len(name) == 0 {
- return name
- }
- switch scheme {
- case NoEscaping:
- return name
- case UnderscoreEscaping:
- // It is not possible to unescape from underscore replacement.
- return name
- case DotsEscaping:
- name = strings.ReplaceAll(name, "_dot_", ".")
- name = strings.ReplaceAll(name, "__", "_")
- return name
- case ValueEncodingEscaping:
- escapedName, found := strings.CutPrefix(name, "U__")
- if !found {
- return name
- }
-
- var unescaped strings.Builder
- TOP:
- for i := 0; i < len(escapedName); i++ {
- // All non-underscores are treated normally.
- if escapedName[i] != '_' {
- unescaped.WriteByte(escapedName[i])
- continue
- }
- i++
- if i >= len(escapedName) {
- return name
- }
- // A double underscore is a single underscore.
- if escapedName[i] == '_' {
- unescaped.WriteByte('_')
- continue
- }
- // We think we are in a UTF-8 code, process it.
- var utf8Val uint
- for j := 0; i < len(escapedName); j++ {
- // This is too many characters for a utf8 value.
- if j > 4 {
- return name
- }
- // Found a closing underscore, convert to a rune, check validity, and append.
- if escapedName[i] == '_' {
- utf8Rune := rune(utf8Val)
- if !utf8.ValidRune(utf8Rune) {
- return name
- }
- unescaped.WriteRune(utf8Rune)
- continue TOP
- }
- r := lower(escapedName[i])
- utf8Val *= 16
- if r >= '0' && r <= '9' {
- utf8Val += uint(r) - '0'
- } else if r >= 'a' && r <= 'f' {
- utf8Val += uint(r) - 'a' + 10
- } else {
- return name
- }
- i++
- }
- // Didn't find closing underscore, invalid.
- return name
- }
- return unescaped.String()
- default:
- panic(fmt.Sprintf("invalid escaping scheme %d", scheme))
- }
-}
-
-func isValidLegacyRune(b rune, i int) bool {
- return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || b == ':' || (b >= '0' && b <= '9' && i > 0)
-}
-
-func (e EscapingScheme) String() string {
- switch e {
- case NoEscaping:
- return AllowUTF8
- case UnderscoreEscaping:
- return EscapeUnderscores
- case DotsEscaping:
- return EscapeDots
- case ValueEncodingEscaping:
- return EscapeValues
- default:
- panic(fmt.Sprintf("unknown format scheme %d", e))
- }
-}
-
-func ToEscapingScheme(s string) (EscapingScheme, error) {
- if s == "" {
- return NoEscaping, fmt.Errorf("got empty string instead of escaping scheme")
- }
- switch s {
- case AllowUTF8:
- return NoEscaping, nil
- case EscapeUnderscores:
- return UnderscoreEscaping, nil
- case EscapeDots:
- return DotsEscaping, nil
- case EscapeValues:
- return ValueEncodingEscaping, nil
- default:
- return NoEscaping, fmt.Errorf("unknown format scheme " + s)
- }
-}
diff --git a/vendor/github.com/prometheus/common/model/model.go b/vendor/github.com/prometheus/common/model/model.go
deleted file mode 100644
index a7b9691..0000000
--- a/vendor/github.com/prometheus/common/model/model.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package model contains common data structures that are shared across
-// Prometheus components and libraries.
-package model
diff --git a/vendor/github.com/prometheus/common/model/signature.go b/vendor/github.com/prometheus/common/model/signature.go
deleted file mode 100644
index dc8a002..0000000
--- a/vendor/github.com/prometheus/common/model/signature.go
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2014 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "sort"
-)
-
-// SeparatorByte is a byte that cannot occur in valid UTF-8 sequences and is
-// used to separate label names, label values, and other strings from each other
-// when calculating their combined hash value (aka signature aka fingerprint).
-const SeparatorByte byte = 255
-
-// cache the signature of an empty label set.
-var emptyLabelSignature = hashNew()
-
-// LabelsToSignature returns a quasi-unique signature (i.e., fingerprint) for a
-// given label set. (Collisions are possible but unlikely if the number of label
-// sets the function is applied to is small.)
-func LabelsToSignature(labels map[string]string) uint64 {
- if len(labels) == 0 {
- return emptyLabelSignature
- }
-
- labelNames := make([]string, 0, len(labels))
- for labelName := range labels {
- labelNames = append(labelNames, labelName)
- }
- sort.Strings(labelNames)
-
- sum := hashNew()
- for _, labelName := range labelNames {
- sum = hashAdd(sum, labelName)
- sum = hashAddByte(sum, SeparatorByte)
- sum = hashAdd(sum, labels[labelName])
- sum = hashAddByte(sum, SeparatorByte)
- }
- return sum
-}
-
-// labelSetToFingerprint works exactly as LabelsToSignature but takes a LabelSet as
-// parameter (rather than a label map) and returns a Fingerprint.
-func labelSetToFingerprint(ls LabelSet) Fingerprint {
- if len(ls) == 0 {
- return Fingerprint(emptyLabelSignature)
- }
-
- labelNames := make(LabelNames, 0, len(ls))
- for labelName := range ls {
- labelNames = append(labelNames, labelName)
- }
- sort.Sort(labelNames)
-
- sum := hashNew()
- for _, labelName := range labelNames {
- sum = hashAdd(sum, string(labelName))
- sum = hashAddByte(sum, SeparatorByte)
- sum = hashAdd(sum, string(ls[labelName]))
- sum = hashAddByte(sum, SeparatorByte)
- }
- return Fingerprint(sum)
-}
-
-// labelSetToFastFingerprint works similar to labelSetToFingerprint but uses a
-// faster and less allocation-heavy hash function, which is more susceptible to
-// create hash collisions. Therefore, collision detection should be applied.
-func labelSetToFastFingerprint(ls LabelSet) Fingerprint {
- if len(ls) == 0 {
- return Fingerprint(emptyLabelSignature)
- }
-
- var result uint64
- for labelName, labelValue := range ls {
- sum := hashNew()
- sum = hashAdd(sum, string(labelName))
- sum = hashAddByte(sum, SeparatorByte)
- sum = hashAdd(sum, string(labelValue))
- result ^= sum
- }
- return Fingerprint(result)
-}
-
-// SignatureForLabels works like LabelsToSignature but takes a Metric as
-// parameter (rather than a label map) and only includes the labels with the
-// specified LabelNames into the signature calculation. The labels passed in
-// will be sorted by this function.
-func SignatureForLabels(m Metric, labels ...LabelName) uint64 {
- if len(labels) == 0 {
- return emptyLabelSignature
- }
-
- sort.Sort(LabelNames(labels))
-
- sum := hashNew()
- for _, label := range labels {
- sum = hashAdd(sum, string(label))
- sum = hashAddByte(sum, SeparatorByte)
- sum = hashAdd(sum, string(m[label]))
- sum = hashAddByte(sum, SeparatorByte)
- }
- return sum
-}
-
-// SignatureWithoutLabels works like LabelsToSignature but takes a Metric as
-// parameter (rather than a label map) and excludes the labels with any of the
-// specified LabelNames from the signature calculation.
-func SignatureWithoutLabels(m Metric, labels map[LabelName]struct{}) uint64 {
- if len(m) == 0 {
- return emptyLabelSignature
- }
-
- labelNames := make(LabelNames, 0, len(m))
- for labelName := range m {
- if _, exclude := labels[labelName]; !exclude {
- labelNames = append(labelNames, labelName)
- }
- }
- if len(labelNames) == 0 {
- return emptyLabelSignature
- }
- sort.Sort(labelNames)
-
- sum := hashNew()
- for _, labelName := range labelNames {
- sum = hashAdd(sum, string(labelName))
- sum = hashAddByte(sum, SeparatorByte)
- sum = hashAdd(sum, string(m[labelName]))
- sum = hashAddByte(sum, SeparatorByte)
- }
- return sum
-}
diff --git a/vendor/github.com/prometheus/common/model/silence.go b/vendor/github.com/prometheus/common/model/silence.go
deleted file mode 100644
index 910b0b7..0000000
--- a/vendor/github.com/prometheus/common/model/silence.go
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2015 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "regexp"
- "time"
-)
-
-// Matcher describes a matches the value of a given label.
-type Matcher struct {
- Name LabelName `json:"name"`
- Value string `json:"value"`
- IsRegex bool `json:"isRegex"`
-}
-
-func (m *Matcher) UnmarshalJSON(b []byte) error {
- type plain Matcher
- if err := json.Unmarshal(b, (*plain)(m)); err != nil {
- return err
- }
-
- if len(m.Name) == 0 {
- return fmt.Errorf("label name in matcher must not be empty")
- }
- if m.IsRegex {
- if _, err := regexp.Compile(m.Value); err != nil {
- return err
- }
- }
- return nil
-}
-
-// Validate returns true iff all fields of the matcher have valid values.
-func (m *Matcher) Validate() error {
- if !m.Name.IsValid() {
- return fmt.Errorf("invalid name %q", m.Name)
- }
- if m.IsRegex {
- if _, err := regexp.Compile(m.Value); err != nil {
- return fmt.Errorf("invalid regular expression %q", m.Value)
- }
- } else if !LabelValue(m.Value).IsValid() || len(m.Value) == 0 {
- return fmt.Errorf("invalid value %q", m.Value)
- }
- return nil
-}
-
-// Silence defines the representation of a silence definition in the Prometheus
-// eco-system.
-type Silence struct {
- ID uint64 `json:"id,omitempty"`
-
- Matchers []*Matcher `json:"matchers"`
-
- StartsAt time.Time `json:"startsAt"`
- EndsAt time.Time `json:"endsAt"`
-
- CreatedAt time.Time `json:"createdAt,omitempty"`
- CreatedBy string `json:"createdBy"`
- Comment string `json:"comment,omitempty"`
-}
-
-// Validate returns true iff all fields of the silence have valid values.
-func (s *Silence) Validate() error {
- if len(s.Matchers) == 0 {
- return fmt.Errorf("at least one matcher required")
- }
- for _, m := range s.Matchers {
- if err := m.Validate(); err != nil {
- return fmt.Errorf("invalid matcher: %w", err)
- }
- }
- if s.StartsAt.IsZero() {
- return fmt.Errorf("start time missing")
- }
- if s.EndsAt.IsZero() {
- return fmt.Errorf("end time missing")
- }
- if s.EndsAt.Before(s.StartsAt) {
- return fmt.Errorf("start time must be before end time")
- }
- if s.CreatedBy == "" {
- return fmt.Errorf("creator information missing")
- }
- if s.Comment == "" {
- return fmt.Errorf("comment missing")
- }
- if s.CreatedAt.IsZero() {
- return fmt.Errorf("creation timestamp missing")
- }
- return nil
-}
diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go
deleted file mode 100644
index 5727452..0000000
--- a/vendor/github.com/prometheus/common/model/time.go
+++ /dev/null
@@ -1,340 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "encoding/json"
- "errors"
- "fmt"
- "math"
- "strconv"
- "strings"
- "time"
-)
-
-const (
- // MinimumTick is the minimum supported time resolution. This has to be
- // at least time.Second in order for the code below to work.
- minimumTick = time.Millisecond
- // second is the Time duration equivalent to one second.
- second = int64(time.Second / minimumTick)
- // The number of nanoseconds per minimum tick.
- nanosPerTick = int64(minimumTick / time.Nanosecond)
-
- // Earliest is the earliest Time representable. Handy for
- // initializing a high watermark.
- Earliest = Time(math.MinInt64)
- // Latest is the latest Time representable. Handy for initializing
- // a low watermark.
- Latest = Time(math.MaxInt64)
-)
-
-// Time is the number of milliseconds since the epoch
-// (1970-01-01 00:00 UTC) excluding leap seconds.
-type Time int64
-
-// Interval describes an interval between two timestamps.
-type Interval struct {
- Start, End Time
-}
-
-// Now returns the current time as a Time.
-func Now() Time {
- return TimeFromUnixNano(time.Now().UnixNano())
-}
-
-// TimeFromUnix returns the Time equivalent to the Unix Time t
-// provided in seconds.
-func TimeFromUnix(t int64) Time {
- return Time(t * second)
-}
-
-// TimeFromUnixNano returns the Time equivalent to the Unix Time
-// t provided in nanoseconds.
-func TimeFromUnixNano(t int64) Time {
- return Time(t / nanosPerTick)
-}
-
-// Equal reports whether two Times represent the same instant.
-func (t Time) Equal(o Time) bool {
- return t == o
-}
-
-// Before reports whether the Time t is before o.
-func (t Time) Before(o Time) bool {
- return t < o
-}
-
-// After reports whether the Time t is after o.
-func (t Time) After(o Time) bool {
- return t > o
-}
-
-// Add returns the Time t + d.
-func (t Time) Add(d time.Duration) Time {
- return t + Time(d/minimumTick)
-}
-
-// Sub returns the Duration t - o.
-func (t Time) Sub(o Time) time.Duration {
- return time.Duration(t-o) * minimumTick
-}
-
-// Time returns the time.Time representation of t.
-func (t Time) Time() time.Time {
- return time.Unix(int64(t)/second, (int64(t)%second)*nanosPerTick)
-}
-
-// Unix returns t as a Unix time, the number of seconds elapsed
-// since January 1, 1970 UTC.
-func (t Time) Unix() int64 {
- return int64(t) / second
-}
-
-// UnixNano returns t as a Unix time, the number of nanoseconds elapsed
-// since January 1, 1970 UTC.
-func (t Time) UnixNano() int64 {
- return int64(t) * nanosPerTick
-}
-
-// The number of digits after the dot.
-var dotPrecision = int(math.Log10(float64(second)))
-
-// String returns a string representation of the Time.
-func (t Time) String() string {
- return strconv.FormatFloat(float64(t)/float64(second), 'f', -1, 64)
-}
-
-// MarshalJSON implements the json.Marshaler interface.
-func (t Time) MarshalJSON() ([]byte, error) {
- return []byte(t.String()), nil
-}
-
-// UnmarshalJSON implements the json.Unmarshaler interface.
-func (t *Time) UnmarshalJSON(b []byte) error {
- p := strings.Split(string(b), ".")
- switch len(p) {
- case 1:
- v, err := strconv.ParseInt(string(p[0]), 10, 64)
- if err != nil {
- return err
- }
- *t = Time(v * second)
-
- case 2:
- v, err := strconv.ParseInt(string(p[0]), 10, 64)
- if err != nil {
- return err
- }
- v *= second
-
- prec := dotPrecision - len(p[1])
- if prec < 0 {
- p[1] = p[1][:dotPrecision]
- } else if prec > 0 {
- p[1] = p[1] + strings.Repeat("0", prec)
- }
-
- va, err := strconv.ParseInt(p[1], 10, 32)
- if err != nil {
- return err
- }
-
- // If the value was something like -0.1 the negative is lost in the
- // parsing because of the leading zero, this ensures that we capture it.
- if len(p[0]) > 0 && p[0][0] == '-' && v+va > 0 {
- *t = Time(v+va) * -1
- } else {
- *t = Time(v + va)
- }
-
- default:
- return fmt.Errorf("invalid time %q", string(b))
- }
- return nil
-}
-
-// Duration wraps time.Duration. It is used to parse the custom duration format
-// from YAML.
-// This type should not propagate beyond the scope of input/output processing.
-type Duration time.Duration
-
-// Set implements pflag/flag.Value
-func (d *Duration) Set(s string) error {
- var err error
- *d, err = ParseDuration(s)
- return err
-}
-
-// Type implements pflag.Value
-func (d *Duration) Type() string {
- return "duration"
-}
-
-func isdigit(c byte) bool { return c >= '0' && c <= '9' }
-
-// Units are required to go in order from biggest to smallest.
-// This guards against confusion from "1m1d" being 1 minute + 1 day, not 1 month + 1 day.
-var unitMap = map[string]struct {
- pos int
- mult uint64
-}{
- "ms": {7, uint64(time.Millisecond)},
- "s": {6, uint64(time.Second)},
- "m": {5, uint64(time.Minute)},
- "h": {4, uint64(time.Hour)},
- "d": {3, uint64(24 * time.Hour)},
- "w": {2, uint64(7 * 24 * time.Hour)},
- "y": {1, uint64(365 * 24 * time.Hour)},
-}
-
-// ParseDuration parses a string into a time.Duration, assuming that a year
-// always has 365d, a week always has 7d, and a day always has 24h.
-func ParseDuration(s string) (Duration, error) {
- switch s {
- case "0":
- // Allow 0 without a unit.
- return 0, nil
- case "":
- return 0, errors.New("empty duration string")
- }
-
- orig := s
- var dur uint64
- lastUnitPos := 0
-
- for s != "" {
- if !isdigit(s[0]) {
- return 0, fmt.Errorf("not a valid duration string: %q", orig)
- }
- // Consume [0-9]*
- i := 0
- for ; i < len(s) && isdigit(s[i]); i++ {
- }
- v, err := strconv.ParseUint(s[:i], 10, 0)
- if err != nil {
- return 0, fmt.Errorf("not a valid duration string: %q", orig)
- }
- s = s[i:]
-
- // Consume unit.
- for i = 0; i < len(s) && !isdigit(s[i]); i++ {
- }
- if i == 0 {
- return 0, fmt.Errorf("not a valid duration string: %q", orig)
- }
- u := s[:i]
- s = s[i:]
- unit, ok := unitMap[u]
- if !ok {
- return 0, fmt.Errorf("unknown unit %q in duration %q", u, orig)
- }
- if unit.pos <= lastUnitPos { // Units must go in order from biggest to smallest.
- return 0, fmt.Errorf("not a valid duration string: %q", orig)
- }
- lastUnitPos = unit.pos
- // Check if the provided duration overflows time.Duration (> ~ 290years).
- if v > 1<<63/unit.mult {
- return 0, errors.New("duration out of range")
- }
- dur += v * unit.mult
- if dur > 1<<63-1 {
- return 0, errors.New("duration out of range")
- }
- }
- return Duration(dur), nil
-}
-
-func (d Duration) String() string {
- var (
- ms = int64(time.Duration(d) / time.Millisecond)
- r = ""
- )
- if ms == 0 {
- return "0s"
- }
-
- f := func(unit string, mult int64, exact bool) {
- if exact && ms%mult != 0 {
- return
- }
- if v := ms / mult; v > 0 {
- r += fmt.Sprintf("%d%s", v, unit)
- ms -= v * mult
- }
- }
-
- // Only format years and weeks if the remainder is zero, as it is often
- // easier to read 90d than 12w6d.
- f("y", 1000*60*60*24*365, true)
- f("w", 1000*60*60*24*7, true)
-
- f("d", 1000*60*60*24, false)
- f("h", 1000*60*60, false)
- f("m", 1000*60, false)
- f("s", 1000, false)
- f("ms", 1, false)
-
- return r
-}
-
-// MarshalJSON implements the json.Marshaler interface.
-func (d Duration) MarshalJSON() ([]byte, error) {
- return json.Marshal(d.String())
-}
-
-// UnmarshalJSON implements the json.Unmarshaler interface.
-func (d *Duration) UnmarshalJSON(bytes []byte) error {
- var s string
- if err := json.Unmarshal(bytes, &s); err != nil {
- return err
- }
- dur, err := ParseDuration(s)
- if err != nil {
- return err
- }
- *d = dur
- return nil
-}
-
-// MarshalText implements the encoding.TextMarshaler interface.
-func (d *Duration) MarshalText() ([]byte, error) {
- return []byte(d.String()), nil
-}
-
-// UnmarshalText implements the encoding.TextUnmarshaler interface.
-func (d *Duration) UnmarshalText(text []byte) error {
- var err error
- *d, err = ParseDuration(string(text))
- return err
-}
-
-// MarshalYAML implements the yaml.Marshaler interface.
-func (d Duration) MarshalYAML() (interface{}, error) {
- return d.String(), nil
-}
-
-// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
- var s string
- if err := unmarshal(&s); err != nil {
- return err
- }
- dur, err := ParseDuration(s)
- if err != nil {
- return err
- }
- *d = dur
- return nil
-}
diff --git a/vendor/github.com/prometheus/common/model/value.go b/vendor/github.com/prometheus/common/model/value.go
deleted file mode 100644
index 8050637..0000000
--- a/vendor/github.com/prometheus/common/model/value.go
+++ /dev/null
@@ -1,364 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "sort"
- "strconv"
- "strings"
-)
-
-// ZeroSample is the pseudo zero-value of Sample used to signal a
-// non-existing sample. It is a Sample with timestamp Earliest, value 0.0,
-// and metric nil. Note that the natural zero value of Sample has a timestamp
-// of 0, which is possible to appear in a real Sample and thus not suitable
-// to signal a non-existing Sample.
-var ZeroSample = Sample{Timestamp: Earliest}
-
-// Sample is a sample pair associated with a metric. A single sample must either
-// define Value or Histogram but not both. Histogram == nil implies the Value
-// field is used, otherwise it should be ignored.
-type Sample struct {
- Metric Metric `json:"metric"`
- Value SampleValue `json:"value"`
- Timestamp Time `json:"timestamp"`
- Histogram *SampleHistogram `json:"histogram"`
-}
-
-// Equal compares first the metrics, then the timestamp, then the value. The
-// semantics of value equality is defined by SampleValue.Equal.
-func (s *Sample) Equal(o *Sample) bool {
- if s == o {
- return true
- }
-
- if !s.Metric.Equal(o.Metric) {
- return false
- }
- if !s.Timestamp.Equal(o.Timestamp) {
- return false
- }
- if s.Histogram != nil {
- return s.Histogram.Equal(o.Histogram)
- }
- return s.Value.Equal(o.Value)
-}
-
-func (s Sample) String() string {
- if s.Histogram != nil {
- return fmt.Sprintf("%s => %s", s.Metric, SampleHistogramPair{
- Timestamp: s.Timestamp,
- Histogram: s.Histogram,
- })
- }
- return fmt.Sprintf("%s => %s", s.Metric, SamplePair{
- Timestamp: s.Timestamp,
- Value: s.Value,
- })
-}
-
-// MarshalJSON implements json.Marshaler.
-func (s Sample) MarshalJSON() ([]byte, error) {
- if s.Histogram != nil {
- v := struct {
- Metric Metric `json:"metric"`
- Histogram SampleHistogramPair `json:"histogram"`
- }{
- Metric: s.Metric,
- Histogram: SampleHistogramPair{
- Timestamp: s.Timestamp,
- Histogram: s.Histogram,
- },
- }
- return json.Marshal(&v)
- }
- v := struct {
- Metric Metric `json:"metric"`
- Value SamplePair `json:"value"`
- }{
- Metric: s.Metric,
- Value: SamplePair{
- Timestamp: s.Timestamp,
- Value: s.Value,
- },
- }
- return json.Marshal(&v)
-}
-
-// UnmarshalJSON implements json.Unmarshaler.
-func (s *Sample) UnmarshalJSON(b []byte) error {
- v := struct {
- Metric Metric `json:"metric"`
- Value SamplePair `json:"value"`
- Histogram SampleHistogramPair `json:"histogram"`
- }{
- Metric: s.Metric,
- Value: SamplePair{
- Timestamp: s.Timestamp,
- Value: s.Value,
- },
- Histogram: SampleHistogramPair{
- Timestamp: s.Timestamp,
- Histogram: s.Histogram,
- },
- }
-
- if err := json.Unmarshal(b, &v); err != nil {
- return err
- }
-
- s.Metric = v.Metric
- if v.Histogram.Histogram != nil {
- s.Timestamp = v.Histogram.Timestamp
- s.Histogram = v.Histogram.Histogram
- } else {
- s.Timestamp = v.Value.Timestamp
- s.Value = v.Value.Value
- }
-
- return nil
-}
-
-// Samples is a sortable Sample slice. It implements sort.Interface.
-type Samples []*Sample
-
-func (s Samples) Len() int {
- return len(s)
-}
-
-// Less compares first the metrics, then the timestamp.
-func (s Samples) Less(i, j int) bool {
- switch {
- case s[i].Metric.Before(s[j].Metric):
- return true
- case s[j].Metric.Before(s[i].Metric):
- return false
- case s[i].Timestamp.Before(s[j].Timestamp):
- return true
- default:
- return false
- }
-}
-
-func (s Samples) Swap(i, j int) {
- s[i], s[j] = s[j], s[i]
-}
-
-// Equal compares two sets of samples and returns true if they are equal.
-func (s Samples) Equal(o Samples) bool {
- if len(s) != len(o) {
- return false
- }
-
- for i, sample := range s {
- if !sample.Equal(o[i]) {
- return false
- }
- }
- return true
-}
-
-// SampleStream is a stream of Values belonging to an attached COWMetric.
-type SampleStream struct {
- Metric Metric `json:"metric"`
- Values []SamplePair `json:"values"`
- Histograms []SampleHistogramPair `json:"histograms"`
-}
-
-func (ss SampleStream) String() string {
- valuesLength := len(ss.Values)
- vals := make([]string, valuesLength+len(ss.Histograms))
- for i, v := range ss.Values {
- vals[i] = v.String()
- }
- for i, v := range ss.Histograms {
- vals[i+valuesLength] = v.String()
- }
- return fmt.Sprintf("%s =>\n%s", ss.Metric, strings.Join(vals, "\n"))
-}
-
-func (ss SampleStream) MarshalJSON() ([]byte, error) {
- if len(ss.Histograms) > 0 && len(ss.Values) > 0 {
- v := struct {
- Metric Metric `json:"metric"`
- Values []SamplePair `json:"values"`
- Histograms []SampleHistogramPair `json:"histograms"`
- }{
- Metric: ss.Metric,
- Values: ss.Values,
- Histograms: ss.Histograms,
- }
- return json.Marshal(&v)
- } else if len(ss.Histograms) > 0 {
- v := struct {
- Metric Metric `json:"metric"`
- Histograms []SampleHistogramPair `json:"histograms"`
- }{
- Metric: ss.Metric,
- Histograms: ss.Histograms,
- }
- return json.Marshal(&v)
- } else {
- v := struct {
- Metric Metric `json:"metric"`
- Values []SamplePair `json:"values"`
- }{
- Metric: ss.Metric,
- Values: ss.Values,
- }
- return json.Marshal(&v)
- }
-}
-
-func (ss *SampleStream) UnmarshalJSON(b []byte) error {
- v := struct {
- Metric Metric `json:"metric"`
- Values []SamplePair `json:"values"`
- Histograms []SampleHistogramPair `json:"histograms"`
- }{
- Metric: ss.Metric,
- Values: ss.Values,
- Histograms: ss.Histograms,
- }
-
- if err := json.Unmarshal(b, &v); err != nil {
- return err
- }
-
- ss.Metric = v.Metric
- ss.Values = v.Values
- ss.Histograms = v.Histograms
-
- return nil
-}
-
-// Scalar is a scalar value evaluated at the set timestamp.
-type Scalar struct {
- Value SampleValue `json:"value"`
- Timestamp Time `json:"timestamp"`
-}
-
-func (s Scalar) String() string {
- return fmt.Sprintf("scalar: %v @[%v]", s.Value, s.Timestamp)
-}
-
-// MarshalJSON implements json.Marshaler.
-func (s Scalar) MarshalJSON() ([]byte, error) {
- v := strconv.FormatFloat(float64(s.Value), 'f', -1, 64)
- return json.Marshal([...]interface{}{s.Timestamp, string(v)})
-}
-
-// UnmarshalJSON implements json.Unmarshaler.
-func (s *Scalar) UnmarshalJSON(b []byte) error {
- var f string
- v := [...]interface{}{&s.Timestamp, &f}
-
- if err := json.Unmarshal(b, &v); err != nil {
- return err
- }
-
- value, err := strconv.ParseFloat(f, 64)
- if err != nil {
- return fmt.Errorf("error parsing sample value: %w", err)
- }
- s.Value = SampleValue(value)
- return nil
-}
-
-// String is a string value evaluated at the set timestamp.
-type String struct {
- Value string `json:"value"`
- Timestamp Time `json:"timestamp"`
-}
-
-func (s *String) String() string {
- return s.Value
-}
-
-// MarshalJSON implements json.Marshaler.
-func (s String) MarshalJSON() ([]byte, error) {
- return json.Marshal([]interface{}{s.Timestamp, s.Value})
-}
-
-// UnmarshalJSON implements json.Unmarshaler.
-func (s *String) UnmarshalJSON(b []byte) error {
- v := [...]interface{}{&s.Timestamp, &s.Value}
- return json.Unmarshal(b, &v)
-}
-
-// Vector is basically only an alias for Samples, but the
-// contract is that in a Vector, all Samples have the same timestamp.
-type Vector []*Sample
-
-func (vec Vector) String() string {
- entries := make([]string, len(vec))
- for i, s := range vec {
- entries[i] = s.String()
- }
- return strings.Join(entries, "\n")
-}
-
-func (vec Vector) Len() int { return len(vec) }
-func (vec Vector) Swap(i, j int) { vec[i], vec[j] = vec[j], vec[i] }
-
-// Less compares first the metrics, then the timestamp.
-func (vec Vector) Less(i, j int) bool {
- switch {
- case vec[i].Metric.Before(vec[j].Metric):
- return true
- case vec[j].Metric.Before(vec[i].Metric):
- return false
- case vec[i].Timestamp.Before(vec[j].Timestamp):
- return true
- default:
- return false
- }
-}
-
-// Equal compares two sets of samples and returns true if they are equal.
-func (vec Vector) Equal(o Vector) bool {
- if len(vec) != len(o) {
- return false
- }
-
- for i, sample := range vec {
- if !sample.Equal(o[i]) {
- return false
- }
- }
- return true
-}
-
-// Matrix is a list of time series.
-type Matrix []*SampleStream
-
-func (m Matrix) Len() int { return len(m) }
-func (m Matrix) Less(i, j int) bool { return m[i].Metric.Before(m[j].Metric) }
-func (m Matrix) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
-
-func (mat Matrix) String() string {
- matCp := make(Matrix, len(mat))
- copy(matCp, mat)
- sort.Sort(matCp)
-
- strs := make([]string, len(matCp))
-
- for i, ss := range matCp {
- strs[i] = ss.String()
- }
-
- return strings.Join(strs, "\n")
-}
diff --git a/vendor/github.com/prometheus/common/model/value_float.go b/vendor/github.com/prometheus/common/model/value_float.go
deleted file mode 100644
index ae35cc2..0000000
--- a/vendor/github.com/prometheus/common/model/value_float.go
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "math"
- "strconv"
-)
-
-// ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a
-// non-existing sample pair. It is a SamplePair with timestamp Earliest and
-// value 0.0. Note that the natural zero value of SamplePair has a timestamp
-// of 0, which is possible to appear in a real SamplePair and thus not
-// suitable to signal a non-existing SamplePair.
-var ZeroSamplePair = SamplePair{Timestamp: Earliest}
-
-// A SampleValue is a representation of a value for a given sample at a given
-// time.
-type SampleValue float64
-
-// MarshalJSON implements json.Marshaler.
-func (v SampleValue) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.String())
-}
-
-// UnmarshalJSON implements json.Unmarshaler.
-func (v *SampleValue) UnmarshalJSON(b []byte) error {
- if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' {
- return fmt.Errorf("sample value must be a quoted string")
- }
- f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64)
- if err != nil {
- return err
- }
- *v = SampleValue(f)
- return nil
-}
-
-// Equal returns true if the value of v and o is equal or if both are NaN. Note
-// that v==o is false if both are NaN. If you want the conventional float
-// behavior, use == to compare two SampleValues.
-func (v SampleValue) Equal(o SampleValue) bool {
- if v == o {
- return true
- }
- return math.IsNaN(float64(v)) && math.IsNaN(float64(o))
-}
-
-func (v SampleValue) String() string {
- return strconv.FormatFloat(float64(v), 'f', -1, 64)
-}
-
-// SamplePair pairs a SampleValue with a Timestamp.
-type SamplePair struct {
- Timestamp Time
- Value SampleValue
-}
-
-func (s SamplePair) MarshalJSON() ([]byte, error) {
- t, err := json.Marshal(s.Timestamp)
- if err != nil {
- return nil, err
- }
- v, err := json.Marshal(s.Value)
- if err != nil {
- return nil, err
- }
- return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil
-}
-
-// UnmarshalJSON implements json.Unmarshaler.
-func (s *SamplePair) UnmarshalJSON(b []byte) error {
- v := [...]json.Unmarshaler{&s.Timestamp, &s.Value}
- return json.Unmarshal(b, &v)
-}
-
-// Equal returns true if this SamplePair and o have equal Values and equal
-// Timestamps. The semantics of Value equality is defined by SampleValue.Equal.
-func (s *SamplePair) Equal(o *SamplePair) bool {
- return s == o || (s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp))
-}
-
-func (s SamplePair) String() string {
- return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp)
-}
diff --git a/vendor/github.com/prometheus/common/model/value_histogram.go b/vendor/github.com/prometheus/common/model/value_histogram.go
deleted file mode 100644
index 54bb038..0000000
--- a/vendor/github.com/prometheus/common/model/value_histogram.go
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "strconv"
- "strings"
-)
-
-type FloatString float64
-
-func (v FloatString) String() string {
- return strconv.FormatFloat(float64(v), 'f', -1, 64)
-}
-
-func (v FloatString) MarshalJSON() ([]byte, error) {
- return json.Marshal(v.String())
-}
-
-func (v *FloatString) UnmarshalJSON(b []byte) error {
- if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' {
- return fmt.Errorf("float value must be a quoted string")
- }
- f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64)
- if err != nil {
- return err
- }
- *v = FloatString(f)
- return nil
-}
-
-type HistogramBucket struct {
- Boundaries int32
- Lower FloatString
- Upper FloatString
- Count FloatString
-}
-
-func (s HistogramBucket) MarshalJSON() ([]byte, error) {
- b, err := json.Marshal(s.Boundaries)
- if err != nil {
- return nil, err
- }
- l, err := json.Marshal(s.Lower)
- if err != nil {
- return nil, err
- }
- u, err := json.Marshal(s.Upper)
- if err != nil {
- return nil, err
- }
- c, err := json.Marshal(s.Count)
- if err != nil {
- return nil, err
- }
- return []byte(fmt.Sprintf("[%s,%s,%s,%s]", b, l, u, c)), nil
-}
-
-func (s *HistogramBucket) UnmarshalJSON(buf []byte) error {
- tmp := []interface{}{&s.Boundaries, &s.Lower, &s.Upper, &s.Count}
- wantLen := len(tmp)
- if err := json.Unmarshal(buf, &tmp); err != nil {
- return err
- }
- if gotLen := len(tmp); gotLen != wantLen {
- return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen)
- }
- return nil
-}
-
-func (s *HistogramBucket) Equal(o *HistogramBucket) bool {
- return s == o || (s.Boundaries == o.Boundaries && s.Lower == o.Lower && s.Upper == o.Upper && s.Count == o.Count)
-}
-
-func (b HistogramBucket) String() string {
- var sb strings.Builder
- lowerInclusive := b.Boundaries == 1 || b.Boundaries == 3
- upperInclusive := b.Boundaries == 0 || b.Boundaries == 3
- if lowerInclusive {
- sb.WriteRune('[')
- } else {
- sb.WriteRune('(')
- }
- fmt.Fprintf(&sb, "%g,%g", b.Lower, b.Upper)
- if upperInclusive {
- sb.WriteRune(']')
- } else {
- sb.WriteRune(')')
- }
- fmt.Fprintf(&sb, ":%v", b.Count)
- return sb.String()
-}
-
-type HistogramBuckets []*HistogramBucket
-
-func (s HistogramBuckets) Equal(o HistogramBuckets) bool {
- if len(s) != len(o) {
- return false
- }
-
- for i, bucket := range s {
- if !bucket.Equal(o[i]) {
- return false
- }
- }
- return true
-}
-
-type SampleHistogram struct {
- Count FloatString `json:"count"`
- Sum FloatString `json:"sum"`
- Buckets HistogramBuckets `json:"buckets"`
-}
-
-func (s SampleHistogram) String() string {
- return fmt.Sprintf("Count: %f, Sum: %f, Buckets: %v", s.Count, s.Sum, s.Buckets)
-}
-
-func (s *SampleHistogram) Equal(o *SampleHistogram) bool {
- return s == o || (s.Count == o.Count && s.Sum == o.Sum && s.Buckets.Equal(o.Buckets))
-}
-
-type SampleHistogramPair struct {
- Timestamp Time
- // Histogram should never be nil, it's only stored as pointer for efficiency.
- Histogram *SampleHistogram
-}
-
-func (s SampleHistogramPair) MarshalJSON() ([]byte, error) {
- if s.Histogram == nil {
- return nil, fmt.Errorf("histogram is nil")
- }
- t, err := json.Marshal(s.Timestamp)
- if err != nil {
- return nil, err
- }
- v, err := json.Marshal(s.Histogram)
- if err != nil {
- return nil, err
- }
- return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil
-}
-
-func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error {
- tmp := []interface{}{&s.Timestamp, &s.Histogram}
- wantLen := len(tmp)
- if err := json.Unmarshal(buf, &tmp); err != nil {
- return err
- }
- if gotLen := len(tmp); gotLen != wantLen {
- return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen)
- }
- if s.Histogram == nil {
- return fmt.Errorf("histogram is null")
- }
- return nil
-}
-
-func (s SampleHistogramPair) String() string {
- return fmt.Sprintf("%s @[%s]", s.Histogram, s.Timestamp)
-}
-
-func (s *SampleHistogramPair) Equal(o *SampleHistogramPair) bool {
- return s == o || (s.Histogram.Equal(o.Histogram) && s.Timestamp.Equal(o.Timestamp))
-}
diff --git a/vendor/github.com/prometheus/common/model/value_type.go b/vendor/github.com/prometheus/common/model/value_type.go
deleted file mode 100644
index 726c50e..0000000
--- a/vendor/github.com/prometheus/common/model/value_type.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2013 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
-)
-
-// Value is a generic interface for values resulting from a query evaluation.
-type Value interface {
- Type() ValueType
- String() string
-}
-
-func (Matrix) Type() ValueType { return ValMatrix }
-func (Vector) Type() ValueType { return ValVector }
-func (*Scalar) Type() ValueType { return ValScalar }
-func (*String) Type() ValueType { return ValString }
-
-type ValueType int
-
-const (
- ValNone ValueType = iota
- ValScalar
- ValVector
- ValMatrix
- ValString
-)
-
-// MarshalJSON implements json.Marshaler.
-func (et ValueType) MarshalJSON() ([]byte, error) {
- return json.Marshal(et.String())
-}
-
-func (et *ValueType) UnmarshalJSON(b []byte) error {
- var s string
- if err := json.Unmarshal(b, &s); err != nil {
- return err
- }
- switch s {
- case "":
- *et = ValNone
- case "scalar":
- *et = ValScalar
- case "vector":
- *et = ValVector
- case "matrix":
- *et = ValMatrix
- case "string":
- *et = ValString
- default:
- return fmt.Errorf("unknown value type %q", s)
- }
- return nil
-}
-
-func (e ValueType) String() string {
- switch e {
- case ValNone:
- return ""
- case ValScalar:
- return "scalar"
- case ValVector:
- return "vector"
- case ValMatrix:
- return "matrix"
- case ValString:
- return "string"
- }
- panic("ValueType.String: unhandled value type")
-}
diff --git a/vendor/github.com/prometheus/procfs/.gitignore b/vendor/github.com/prometheus/procfs/.gitignore
deleted file mode 100644
index 7cc33ae..0000000
--- a/vendor/github.com/prometheus/procfs/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/testdata/fixtures/
-/fixtures
diff --git a/vendor/github.com/prometheus/procfs/.golangci.yml b/vendor/github.com/prometheus/procfs/.golangci.yml
deleted file mode 100644
index 126df9e..0000000
--- a/vendor/github.com/prometheus/procfs/.golangci.yml
+++ /dev/null
@@ -1,22 +0,0 @@
----
-linters:
- enable:
- - errcheck
- - godot
- - gosimple
- - govet
- - ineffassign
- - misspell
- - revive
- - staticcheck
- - testifylint
- - unused
-
-linter-settings:
- godot:
- capital: true
- exclude:
- # Ignore "See: URL"
- - 'See:'
- misspell:
- locale: US
diff --git a/vendor/github.com/prometheus/procfs/CODE_OF_CONDUCT.md b/vendor/github.com/prometheus/procfs/CODE_OF_CONDUCT.md
deleted file mode 100644
index d325872..0000000
--- a/vendor/github.com/prometheus/procfs/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Prometheus Community Code of Conduct
-
-Prometheus follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/main/code-of-conduct.md).
diff --git a/vendor/github.com/prometheus/procfs/CONTRIBUTING.md b/vendor/github.com/prometheus/procfs/CONTRIBUTING.md
deleted file mode 100644
index 853eb9d..0000000
--- a/vendor/github.com/prometheus/procfs/CONTRIBUTING.md
+++ /dev/null
@@ -1,121 +0,0 @@
-# Contributing
-
-Prometheus uses GitHub to manage reviews of pull requests.
-
-* If you are a new contributor see: [Steps to Contribute](#steps-to-contribute)
-
-* If you have a trivial fix or improvement, go ahead and create a pull request,
- addressing (with `@...`) a suitable maintainer of this repository (see
- [MAINTAINERS.md](MAINTAINERS.md)) in the description of the pull request.
-
-* If you plan to do something more involved, first discuss your ideas
- on our [mailing list](https://groups.google.com/forum/?fromgroups#!forum/prometheus-developers).
- This will avoid unnecessary work and surely give you and us a good deal
- of inspiration. Also please see our [non-goals issue](https://github.com/prometheus/docs/issues/149) on areas that the Prometheus community doesn't plan to work on.
-
-* Relevant coding style guidelines are the [Go Code Review
- Comments](https://code.google.com/p/go-wiki/wiki/CodeReviewComments)
- and the _Formatting and style_ section of Peter Bourgon's [Go: Best
- Practices for Production
- Environments](https://peter.bourgon.org/go-in-production/#formatting-and-style).
-
-* Be sure to sign off on the [DCO](https://github.com/probot/dco#how-it-works)
-
-## Steps to Contribute
-
-Should you wish to work on an issue, please claim it first by commenting on the GitHub issue that you want to work on it. This is to prevent duplicated efforts from contributors on the same issue.
-
-Please check the [`help-wanted`](https://github.com/prometheus/procfs/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) label to find issues that are good for getting started. If you have questions about one of the issues, with or without the tag, please comment on them and one of the maintainers will clarify it. For a quicker response, contact us over [IRC](https://prometheus.io/community).
-
-For quickly compiling and testing your changes do:
-```
-make test # Make sure all the tests pass before you commit and push :)
-```
-
-We use [`golangci-lint`](https://github.com/golangci/golangci-lint) for linting the code. If it reports an issue and you think that the warning needs to be disregarded or is a false-positive, you can add a special comment `//nolint:linter1[,linter2,...]` before the offending line. Use this sparingly though, fixing the code to comply with the linter's recommendation is in general the preferred course of action.
-
-## Pull Request Checklist
-
-* Branch from the master branch and, if needed, rebase to the current master branch before submitting your pull request. If it doesn't merge cleanly with master you may be asked to rebase your changes.
-
-* Commits should be as small as possible, while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests).
-
-* If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment, or you can ask for a review on IRC channel [#prometheus](https://webchat.freenode.net/?channels=#prometheus) on irc.freenode.net (for the easiest start, [join via Riot](https://riot.im/app/#/room/#prometheus:matrix.org)).
-
-* Add tests relevant to the fixed bug or new feature.
-
-## Dependency management
-
-The Prometheus project uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages. This requires a working Go environment with version 1.12 or greater installed.
-
-All dependencies are vendored in the `vendor/` directory.
-
-To add or update a new dependency, use the `go get` command:
-
-```bash
-# Pick the latest tagged release.
-go get example.com/some/module/pkg
-
-# Pick a specific version.
-go get example.com/some/module/pkg@vX.Y.Z
-```
-
-Tidy up the `go.mod` and `go.sum` files and copy the new/updated dependency to the `vendor/` directory:
-
-
-```bash
-# The GO111MODULE variable can be omitted when the code isn't located in GOPATH.
-GO111MODULE=on go mod tidy
-
-GO111MODULE=on go mod vendor
-```
-
-You have to commit the changes to `go.mod`, `go.sum` and the `vendor/` directory before submitting the pull request.
-
-
-## API Implementation Guidelines
-
-### Naming and Documentation
-
-Public functions and structs should normally be named according to the file(s) being read and parsed. For example,
-the `fs.BuddyInfo()` function reads the file `/proc/buddyinfo`. In addition, the godoc for each public function
-should contain the path to the file(s) being read and a URL of the linux kernel documentation describing the file(s).
-
-### Reading vs. Parsing
-
-Most functionality in this library consists of reading files and then parsing the text into structured data. In most
-cases reading and parsing should be separated into different functions/methods with a public `fs.Thing()` method and
-a private `parseThing(r Reader)` function. This provides a logical separation and allows parsing to be tested
-directly without the need to read from the filesystem. Using a `Reader` argument is preferred over other data types
-such as `string` or `*File` because it provides the most flexibility regarding the data source. When a set of files
-in a directory needs to be parsed, then a `path` string parameter to the parse function can be used instead.
-
-### /proc and /sys filesystem I/O
-
-The `proc` and `sys` filesystems are pseudo file systems and work a bit differently from standard disk I/O.
-Many of the files are changing continuously and the data being read can in some cases change between subsequent
-reads in the same file. Also, most of the files are relatively small (less than a few KBs), and system calls
-to the `stat` function will often return the wrong size. Therefore, for most files it's recommended to read the
-full file in a single operation using an internal utility function called `util.ReadFileNoStat`.
-This function is similar to `os.ReadFile`, but it avoids the system call to `stat` to get the current size of
-the file.
-
-Note that parsing the file's contents can still be performed one line at a time. This is done by first reading
-the full file, and then using a scanner on the `[]byte` or `string` containing the data.
-
-```
- data, err := util.ReadFileNoStat("/proc/cpuinfo")
- if err != nil {
- return err
- }
- reader := bytes.NewReader(data)
- scanner := bufio.NewScanner(reader)
-```
-
-The `/sys` filesystem contains many very small files which contain only a single numeric or text value. These files
-can be read using an internal function called `util.SysReadFile` which is similar to `os.ReadFile` but does
-not bother to check the size of the file before reading.
-```
- data, err := util.SysReadFile("/sys/class/power_supply/BAT0/capacity")
-```
-
diff --git a/vendor/github.com/prometheus/procfs/LICENSE b/vendor/github.com/prometheus/procfs/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/vendor/github.com/prometheus/procfs/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/prometheus/procfs/MAINTAINERS.md b/vendor/github.com/prometheus/procfs/MAINTAINERS.md
deleted file mode 100644
index e00f3b3..0000000
--- a/vendor/github.com/prometheus/procfs/MAINTAINERS.md
+++ /dev/null
@@ -1,3 +0,0 @@
-* Johannes 'fish' Ziemke @discordianfish
-* Paul Gier @pgier
-* Ben Kochie @SuperQ
diff --git a/vendor/github.com/prometheus/procfs/Makefile b/vendor/github.com/prometheus/procfs/Makefile
deleted file mode 100644
index 7edfe4d..0000000
--- a/vendor/github.com/prometheus/procfs/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2018 The Prometheus Authors
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-include Makefile.common
-
-%/.unpacked: %.ttar
- @echo ">> extracting fixtures $*"
- ./ttar -C $(dir $*) -x -f $*.ttar
- touch $@
-
-fixtures: testdata/fixtures/.unpacked
-
-update_fixtures:
- rm -vf testdata/fixtures/.unpacked
- ./ttar -c -f testdata/fixtures.ttar -C testdata/ fixtures/
-
-.PHONY: build
-build:
-
-.PHONY: test
-test: testdata/fixtures/.unpacked common-test
diff --git a/vendor/github.com/prometheus/procfs/Makefile.common b/vendor/github.com/prometheus/procfs/Makefile.common
deleted file mode 100644
index 1617292..0000000
--- a/vendor/github.com/prometheus/procfs/Makefile.common
+++ /dev/null
@@ -1,277 +0,0 @@
-# Copyright 2018 The Prometheus Authors
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-# A common Makefile that includes rules to be reused in different prometheus projects.
-# !!! Open PRs only against the prometheus/prometheus/Makefile.common repository!
-
-# Example usage :
-# Create the main Makefile in the root project directory.
-# include Makefile.common
-# customTarget:
-# @echo ">> Running customTarget"
-#
-
-# Ensure GOBIN is not set during build so that promu is installed to the correct path
-unexport GOBIN
-
-GO ?= go
-GOFMT ?= $(GO)fmt
-FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
-GOOPTS ?=
-GOHOSTOS ?= $(shell $(GO) env GOHOSTOS)
-GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH)
-
-GO_VERSION ?= $(shell $(GO) version)
-GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
-PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')
-
-PROMU := $(FIRST_GOPATH)/bin/promu
-pkgs = ./...
-
-ifeq (arm, $(GOHOSTARCH))
- GOHOSTARM ?= $(shell GOARM= $(GO) env GOARM)
- GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)v$(GOHOSTARM)
-else
- GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)
-endif
-
-GOTEST := $(GO) test
-GOTEST_DIR :=
-ifneq ($(CIRCLE_JOB),)
-ifneq ($(shell command -v gotestsum 2> /dev/null),)
- GOTEST_DIR := test-results
- GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml --
-endif
-endif
-
-PROMU_VERSION ?= 0.17.0
-PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
-
-SKIP_GOLANGCI_LINT :=
-GOLANGCI_LINT :=
-GOLANGCI_LINT_OPTS ?=
-GOLANGCI_LINT_VERSION ?= v1.59.0
-# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
-# windows isn't included here because of the path separator being different.
-ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
- ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386 arm64))
- # If we're in CI and there is an Actions file, that means the linter
- # is being run in Actions, so we don't need to run it here.
- ifneq (,$(SKIP_GOLANGCI_LINT))
- GOLANGCI_LINT :=
- else ifeq (,$(CIRCLE_JOB))
- GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
- else ifeq (,$(wildcard .github/workflows/golangci-lint.yml))
- GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
- endif
- endif
-endif
-
-PREFIX ?= $(shell pwd)
-BIN_DIR ?= $(shell pwd)
-DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
-DOCKERFILE_PATH ?= ./Dockerfile
-DOCKERBUILD_CONTEXT ?= ./
-DOCKER_REPO ?= prom
-
-DOCKER_ARCHS ?= amd64
-
-BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS))
-PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS))
-TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS))
-
-SANITIZED_DOCKER_IMAGE_TAG := $(subst +,-,$(DOCKER_IMAGE_TAG))
-
-ifeq ($(GOHOSTARCH),amd64)
- ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows))
- # Only supported on amd64
- test-flags := -race
- endif
-endif
-
-# This rule is used to forward a target like "build" to "common-build". This
-# allows a new "build" target to be defined in a Makefile which includes this
-# one and override "common-build" without override warnings.
-%: common-% ;
-
-.PHONY: common-all
-common-all: precheck style check_license lint yamllint unused build test
-
-.PHONY: common-style
-common-style:
- @echo ">> checking code style"
- @fmtRes=$$($(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \
- if [ -n "$${fmtRes}" ]; then \
- echo "gofmt checking failed!"; echo "$${fmtRes}"; echo; \
- echo "Please ensure you are using $$($(GO) version) for formatting code."; \
- exit 1; \
- fi
-
-.PHONY: common-check_license
-common-check_license:
- @echo ">> checking license header"
- @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
- awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
- done); \
- if [ -n "$${licRes}" ]; then \
- echo "license header checking failed:"; echo "$${licRes}"; \
- exit 1; \
- fi
-
-.PHONY: common-deps
-common-deps:
- @echo ">> getting dependencies"
- $(GO) mod download
-
-.PHONY: update-go-deps
-update-go-deps:
- @echo ">> updating Go dependencies"
- @for m in $$($(GO) list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
- $(GO) get -d $$m; \
- done
- $(GO) mod tidy
-
-.PHONY: common-test-short
-common-test-short: $(GOTEST_DIR)
- @echo ">> running short tests"
- $(GOTEST) -short $(GOOPTS) $(pkgs)
-
-.PHONY: common-test
-common-test: $(GOTEST_DIR)
- @echo ">> running all tests"
- $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)
-
-$(GOTEST_DIR):
- @mkdir -p $@
-
-.PHONY: common-format
-common-format:
- @echo ">> formatting code"
- $(GO) fmt $(pkgs)
-
-.PHONY: common-vet
-common-vet:
- @echo ">> vetting code"
- $(GO) vet $(GOOPTS) $(pkgs)
-
-.PHONY: common-lint
-common-lint: $(GOLANGCI_LINT)
-ifdef GOLANGCI_LINT
- @echo ">> running golangci-lint"
- $(GOLANGCI_LINT) run $(GOLANGCI_LINT_OPTS) $(pkgs)
-endif
-
-.PHONY: common-lint-fix
-common-lint-fix: $(GOLANGCI_LINT)
-ifdef GOLANGCI_LINT
- @echo ">> running golangci-lint fix"
- $(GOLANGCI_LINT) run --fix $(GOLANGCI_LINT_OPTS) $(pkgs)
-endif
-
-.PHONY: common-yamllint
-common-yamllint:
- @echo ">> running yamllint on all YAML files in the repository"
-ifeq (, $(shell command -v yamllint 2> /dev/null))
- @echo "yamllint not installed so skipping"
-else
- yamllint .
-endif
-
-# For backward-compatibility.
-.PHONY: common-staticcheck
-common-staticcheck: lint
-
-.PHONY: common-unused
-common-unused:
- @echo ">> running check for unused/missing packages in go.mod"
- $(GO) mod tidy
- @git diff --exit-code -- go.sum go.mod
-
-.PHONY: common-build
-common-build: promu
- @echo ">> building binaries"
- $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)
-
-.PHONY: common-tarball
-common-tarball: promu
- @echo ">> building release tarball"
- $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
-
-.PHONY: common-docker-repo-name
-common-docker-repo-name:
- @echo "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)"
-
-.PHONY: common-docker $(BUILD_DOCKER_ARCHS)
-common-docker: $(BUILD_DOCKER_ARCHS)
-$(BUILD_DOCKER_ARCHS): common-docker-%:
- docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" \
- -f $(DOCKERFILE_PATH) \
- --build-arg ARCH="$*" \
- --build-arg OS="linux" \
- $(DOCKERBUILD_CONTEXT)
-
-.PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS)
-common-docker-publish: $(PUBLISH_DOCKER_ARCHS)
-$(PUBLISH_DOCKER_ARCHS): common-docker-publish-%:
- docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)"
-
-DOCKER_MAJOR_VERSION_TAG = $(firstword $(subst ., ,$(shell cat VERSION)))
-.PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS)
-common-docker-tag-latest: $(TAG_DOCKER_ARCHS)
-$(TAG_DOCKER_ARCHS): common-docker-tag-latest-%:
- docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:latest"
- docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)"
-
-.PHONY: common-docker-manifest
-common-docker-manifest:
- DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(SANITIZED_DOCKER_IMAGE_TAG))
- DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)"
-
-.PHONY: promu
-promu: $(PROMU)
-
-$(PROMU):
- $(eval PROMU_TMP := $(shell mktemp -d))
- curl -s -L $(PROMU_URL) | tar -xvzf - -C $(PROMU_TMP)
- mkdir -p $(FIRST_GOPATH)/bin
- cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
- rm -r $(PROMU_TMP)
-
-.PHONY: proto
-proto:
- @echo ">> generating code from proto files"
- @./scripts/genproto.sh
-
-ifdef GOLANGCI_LINT
-$(GOLANGCI_LINT):
- mkdir -p $(FIRST_GOPATH)/bin
- curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_LINT_VERSION)/install.sh \
- | sed -e '/install -d/d' \
- | sh -s -- -b $(FIRST_GOPATH)/bin $(GOLANGCI_LINT_VERSION)
-endif
-
-.PHONY: precheck
-precheck::
-
-define PRECHECK_COMMAND_template =
-precheck:: $(1)_precheck
-
-PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1)))
-.PHONY: $(1)_precheck
-$(1)_precheck:
- @if ! $$(PRECHECK_COMMAND_$(1)) 1>/dev/null 2>&1; then \
- echo "Execution of '$$(PRECHECK_COMMAND_$(1))' command failed. Is $(1) installed?"; \
- exit 1; \
- fi
-endef
diff --git a/vendor/github.com/prometheus/procfs/NOTICE b/vendor/github.com/prometheus/procfs/NOTICE
deleted file mode 100644
index 53c5e9a..0000000
--- a/vendor/github.com/prometheus/procfs/NOTICE
+++ /dev/null
@@ -1,7 +0,0 @@
-procfs provides functions to retrieve system, kernel and process
-metrics from the pseudo-filesystem proc.
-
-Copyright 2014-2015 The Prometheus Authors
-
-This product includes software developed at
-SoundCloud Ltd. (http://soundcloud.com/).
diff --git a/vendor/github.com/prometheus/procfs/README.md b/vendor/github.com/prometheus/procfs/README.md
deleted file mode 100644
index 1224816..0000000
--- a/vendor/github.com/prometheus/procfs/README.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# procfs
-
-This package provides functions to retrieve system, kernel, and process
-metrics from the pseudo-filesystems /proc and /sys.
-
-*WARNING*: This package is a work in progress. Its API may still break in
-backwards-incompatible ways without warnings. Use it at your own risk.
-
-[![Go Reference](https://pkg.go.dev/badge/github.com/prometheus/procfs.svg)](https://pkg.go.dev/github.com/prometheus/procfs)
-[![CircleCI](https://circleci.com/gh/prometheus/procfs/tree/master.svg?style=svg)](https://circleci.com/gh/prometheus/procfs/tree/master)
-[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/procfs)](https://goreportcard.com/report/github.com/prometheus/procfs)
-
-## Usage
-
-The procfs library is organized by packages based on whether the gathered data is coming from
-/proc, /sys, or both. Each package contains an `FS` type which represents the path to either /proc,
-/sys, or both. For example, cpu statistics are gathered from
-`/proc/stat` and are available via the root procfs package. First, the proc filesystem mount
-point is initialized, and then the stat information is read.
-
-```go
-fs, err := procfs.NewFS("/proc")
-stats, err := fs.Stat()
-```
-
-Some sub-packages such as `blockdevice`, require access to both the proc and sys filesystems.
-
-```go
- fs, err := blockdevice.NewFS("/proc", "/sys")
- stats, err := fs.ProcDiskstats()
-```
-
-## Package Organization
-
-The packages in this project are organized according to (1) whether the data comes from the `/proc` or
-`/sys` filesystem and (2) the type of information being retrieved. For example, most process information
-can be gathered from the functions in the root `procfs` package. Information about block devices such as disk drives
-is available in the `blockdevices` sub-package.
-
-## Building and Testing
-
-The procfs library is intended to be built as part of another application, so there are no distributable binaries.
-However, most of the API includes unit tests which can be run with `make test`.
-
-### Updating Test Fixtures
-
-The procfs library includes a set of test fixtures which include many example files from
-the `/proc` and `/sys` filesystems. These fixtures are included as a [ttar](https://github.com/ideaship/ttar) file
-which is extracted automatically during testing. To add/update the test fixtures, first
-ensure the `fixtures` directory is up to date by removing the existing directory and then
-extracting the ttar file using `make fixtures/.unpacked` or just `make test`.
-
-```bash
-rm -rf testdata/fixtures
-make test
-```
-
-Next, make the required changes to the extracted files in the `fixtures` directory. When
-the changes are complete, run `make update_fixtures` to create a new `fixtures.ttar` file
-based on the updated `fixtures` directory. And finally, verify the changes using
-`git diff testdata/fixtures.ttar`.
diff --git a/vendor/github.com/prometheus/procfs/SECURITY.md b/vendor/github.com/prometheus/procfs/SECURITY.md
deleted file mode 100644
index fed02d8..0000000
--- a/vendor/github.com/prometheus/procfs/SECURITY.md
+++ /dev/null
@@ -1,6 +0,0 @@
-# Reporting a security issue
-
-The Prometheus security policy, including how to report vulnerabilities, can be
-found here:
-
-
diff --git a/vendor/github.com/prometheus/procfs/arp.go b/vendor/github.com/prometheus/procfs/arp.go
deleted file mode 100644
index cdcc8a7..0000000
--- a/vendor/github.com/prometheus/procfs/arp.go
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "fmt"
- "net"
- "os"
- "strconv"
- "strings"
-)
-
-// Learned from include/uapi/linux/if_arp.h.
-const (
- // completed entry (ha valid).
- ATFComplete = 0x02
- // permanent entry.
- ATFPermanent = 0x04
- // Publish entry.
- ATFPublish = 0x08
- // Has requested trailers.
- ATFUseTrailers = 0x10
- // Obsoleted: Want to use a netmask (only for proxy entries).
- ATFNetmask = 0x20
- // Don't answer this addresses.
- ATFDontPublish = 0x40
-)
-
-// ARPEntry contains a single row of the columnar data represented in
-// /proc/net/arp.
-type ARPEntry struct {
- // IP address
- IPAddr net.IP
- // MAC address
- HWAddr net.HardwareAddr
- // Name of the device
- Device string
- // Flags
- Flags byte
-}
-
-// GatherARPEntries retrieves all the ARP entries, parse the relevant columns,
-// and then return a slice of ARPEntry's.
-func (fs FS) GatherARPEntries() ([]ARPEntry, error) {
- data, err := os.ReadFile(fs.proc.Path("net/arp"))
- if err != nil {
- return nil, fmt.Errorf("%w: error reading arp %s: %w", ErrFileRead, fs.proc.Path("net/arp"), err)
- }
-
- return parseARPEntries(data)
-}
-
-func parseARPEntries(data []byte) ([]ARPEntry, error) {
- lines := strings.Split(string(data), "\n")
- entries := make([]ARPEntry, 0)
- var err error
- const (
- expectedDataWidth = 6
- expectedHeaderWidth = 9
- )
- for _, line := range lines {
- columns := strings.Fields(line)
- width := len(columns)
-
- if width == expectedHeaderWidth || width == 0 {
- continue
- } else if width == expectedDataWidth {
- entry, err := parseARPEntry(columns)
- if err != nil {
- return []ARPEntry{}, fmt.Errorf("%w: Failed to parse ARP entry: %v: %w", ErrFileParse, entry, err)
- }
- entries = append(entries, entry)
- } else {
- return []ARPEntry{}, fmt.Errorf("%w: %d columns found, but expected %d: %w", ErrFileParse, width, expectedDataWidth, err)
- }
-
- }
-
- return entries, err
-}
-
-func parseARPEntry(columns []string) (ARPEntry, error) {
- entry := ARPEntry{Device: columns[5]}
- ip := net.ParseIP(columns[0])
- entry.IPAddr = ip
-
- if mac, err := net.ParseMAC(columns[3]); err == nil {
- entry.HWAddr = mac
- } else {
- return ARPEntry{}, err
- }
-
- if flags, err := strconv.ParseUint(columns[2], 0, 8); err == nil {
- entry.Flags = byte(flags)
- } else {
- return ARPEntry{}, err
- }
-
- return entry, nil
-}
-
-// IsComplete returns true if ARP entry is marked with complete flag.
-func (entry *ARPEntry) IsComplete() bool {
- return entry.Flags&ATFComplete != 0
-}
diff --git a/vendor/github.com/prometheus/procfs/buddyinfo.go b/vendor/github.com/prometheus/procfs/buddyinfo.go
deleted file mode 100644
index 8380750..0000000
--- a/vendor/github.com/prometheus/procfs/buddyinfo.go
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2017 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "fmt"
- "io"
- "os"
- "strconv"
- "strings"
-)
-
-// A BuddyInfo is the details parsed from /proc/buddyinfo.
-// The data is comprised of an array of free fragments of each size.
-// The sizes are 2^n*PAGE_SIZE, where n is the array index.
-type BuddyInfo struct {
- Node string
- Zone string
- Sizes []float64
-}
-
-// BuddyInfo reads the buddyinfo statistics from the specified `proc` filesystem.
-func (fs FS) BuddyInfo() ([]BuddyInfo, error) {
- file, err := os.Open(fs.proc.Path("buddyinfo"))
- if err != nil {
- return nil, err
- }
- defer file.Close()
-
- return parseBuddyInfo(file)
-}
-
-func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
- var (
- buddyInfo = []BuddyInfo{}
- scanner = bufio.NewScanner(r)
- bucketCount = -1
- )
-
- for scanner.Scan() {
- var err error
- line := scanner.Text()
- parts := strings.Fields(line)
-
- if len(parts) < 4 {
- return nil, fmt.Errorf("%w: Invalid number of fields, found: %v", ErrFileParse, parts)
- }
-
- node := strings.TrimSuffix(parts[1], ",")
- zone := strings.TrimSuffix(parts[3], ",")
- arraySize := len(parts[4:])
-
- if bucketCount == -1 {
- bucketCount = arraySize
- } else {
- if bucketCount != arraySize {
- return nil, fmt.Errorf("%w: mismatch in number of buddyinfo buckets, previous count %d, new count %d", ErrFileParse, bucketCount, arraySize)
- }
- }
-
- sizes := make([]float64, arraySize)
- for i := 0; i < arraySize; i++ {
- sizes[i], err = strconv.ParseFloat(parts[i+4], 64)
- if err != nil {
- return nil, fmt.Errorf("%w: Invalid valid in buddyinfo: %f: %w", ErrFileParse, sizes[i], err)
- }
- }
-
- buddyInfo = append(buddyInfo, BuddyInfo{node, zone, sizes})
- }
-
- return buddyInfo, scanner.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/cmdline.go b/vendor/github.com/prometheus/procfs/cmdline.go
deleted file mode 100644
index bf4f3b4..0000000
--- a/vendor/github.com/prometheus/procfs/cmdline.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2021 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// CmdLine returns the command line of the kernel.
-func (fs FS) CmdLine() ([]string, error) {
- data, err := util.ReadFileNoStat(fs.proc.Path("cmdline"))
- if err != nil {
- return nil, err
- }
-
- return strings.Fields(string(data)), nil
-}
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo.go b/vendor/github.com/prometheus/procfs/cpuinfo.go
deleted file mode 100644
index f0950bb..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo.go
+++ /dev/null
@@ -1,519 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux
-// +build linux
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "errors"
- "fmt"
- "regexp"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// CPUInfo contains general information about a system CPU found in /proc/cpuinfo.
-type CPUInfo struct {
- Processor uint
- VendorID string
- CPUFamily string
- Model string
- ModelName string
- Stepping string
- Microcode string
- CPUMHz float64
- CacheSize string
- PhysicalID string
- Siblings uint
- CoreID string
- CPUCores uint
- APICID string
- InitialAPICID string
- FPU string
- FPUException string
- CPUIDLevel uint
- WP string
- Flags []string
- Bugs []string
- BogoMips float64
- CLFlushSize uint
- CacheAlignment uint
- AddressSizes string
- PowerManagement string
-}
-
-var (
- cpuinfoClockRegexp = regexp.MustCompile(`([\d.]+)`)
- cpuinfoS390XProcessorRegexp = regexp.MustCompile(`^processor\s+(\d+):.*`)
-)
-
-// CPUInfo returns information about current system CPUs.
-// See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
-func (fs FS) CPUInfo() ([]CPUInfo, error) {
- data, err := util.ReadFileNoStat(fs.proc.Path("cpuinfo"))
- if err != nil {
- return nil, err
- }
- return parseCPUInfo(data)
-}
-
-func parseCPUInfoX86(info []byte) ([]CPUInfo, error) {
- scanner := bufio.NewScanner(bytes.NewReader(info))
-
- // find the first "processor" line
- firstLine := firstNonEmptyLine(scanner)
- if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
- return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine)
- }
- field := strings.SplitN(firstLine, ": ", 2)
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- firstcpu := CPUInfo{Processor: uint(v)}
- cpuinfo := []CPUInfo{firstcpu}
- i := 0
-
- for scanner.Scan() {
- line := scanner.Text()
- if !strings.Contains(line, ":") {
- continue
- }
- field := strings.SplitN(line, ": ", 2)
- switch strings.TrimSpace(field[0]) {
- case "processor":
- cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
- i++
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].Processor = uint(v)
- case "vendor", "vendor_id":
- cpuinfo[i].VendorID = field[1]
- case "cpu family":
- cpuinfo[i].CPUFamily = field[1]
- case "model":
- cpuinfo[i].Model = field[1]
- case "model name":
- cpuinfo[i].ModelName = field[1]
- case "stepping":
- cpuinfo[i].Stepping = field[1]
- case "microcode":
- cpuinfo[i].Microcode = field[1]
- case "cpu MHz":
- v, err := strconv.ParseFloat(field[1], 64)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].CPUMHz = v
- case "cache size":
- cpuinfo[i].CacheSize = field[1]
- case "physical id":
- cpuinfo[i].PhysicalID = field[1]
- case "siblings":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].Siblings = uint(v)
- case "core id":
- cpuinfo[i].CoreID = field[1]
- case "cpu cores":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].CPUCores = uint(v)
- case "apicid":
- cpuinfo[i].APICID = field[1]
- case "initial apicid":
- cpuinfo[i].InitialAPICID = field[1]
- case "fpu":
- cpuinfo[i].FPU = field[1]
- case "fpu_exception":
- cpuinfo[i].FPUException = field[1]
- case "cpuid level":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].CPUIDLevel = uint(v)
- case "wp":
- cpuinfo[i].WP = field[1]
- case "flags":
- cpuinfo[i].Flags = strings.Fields(field[1])
- case "bugs":
- cpuinfo[i].Bugs = strings.Fields(field[1])
- case "bogomips":
- v, err := strconv.ParseFloat(field[1], 64)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].BogoMips = v
- case "clflush size":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].CLFlushSize = uint(v)
- case "cache_alignment":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].CacheAlignment = uint(v)
- case "address sizes":
- cpuinfo[i].AddressSizes = field[1]
- case "power management":
- cpuinfo[i].PowerManagement = field[1]
- }
- }
- return cpuinfo, nil
-}
-
-func parseCPUInfoARM(info []byte) ([]CPUInfo, error) {
- scanner := bufio.NewScanner(bytes.NewReader(info))
-
- firstLine := firstNonEmptyLine(scanner)
- match, err := regexp.MatchString("^[Pp]rocessor", firstLine)
- if !match || !strings.Contains(firstLine, ":") {
- return nil, fmt.Errorf("%w: Cannot parse line: %q: %w", ErrFileParse, firstLine, err)
-
- }
- field := strings.SplitN(firstLine, ": ", 2)
- cpuinfo := []CPUInfo{}
- featuresLine := ""
- commonCPUInfo := CPUInfo{}
- i := 0
- if strings.TrimSpace(field[0]) == "Processor" {
- commonCPUInfo = CPUInfo{ModelName: field[1]}
- i = -1
- } else {
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- firstcpu := CPUInfo{Processor: uint(v)}
- cpuinfo = []CPUInfo{firstcpu}
- }
-
- for scanner.Scan() {
- line := scanner.Text()
- if !strings.Contains(line, ":") {
- continue
- }
- field := strings.SplitN(line, ": ", 2)
- switch strings.TrimSpace(field[0]) {
- case "processor":
- cpuinfo = append(cpuinfo, commonCPUInfo) // start of the next processor
- i++
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].Processor = uint(v)
- case "BogoMIPS":
- if i == -1 {
- cpuinfo = append(cpuinfo, commonCPUInfo) // There is only one processor
- i++
- cpuinfo[i].Processor = 0
- }
- v, err := strconv.ParseFloat(field[1], 64)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].BogoMips = v
- case "Features":
- featuresLine = line
- case "model name":
- cpuinfo[i].ModelName = field[1]
- }
- }
- fields := strings.SplitN(featuresLine, ": ", 2)
- for i := range cpuinfo {
- cpuinfo[i].Flags = strings.Fields(fields[1])
- }
- return cpuinfo, nil
-
-}
-
-func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) {
- scanner := bufio.NewScanner(bytes.NewReader(info))
-
- firstLine := firstNonEmptyLine(scanner)
- if !strings.HasPrefix(firstLine, "vendor_id") || !strings.Contains(firstLine, ":") {
- return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine)
- }
- field := strings.SplitN(firstLine, ": ", 2)
- cpuinfo := []CPUInfo{}
- commonCPUInfo := CPUInfo{VendorID: field[1]}
-
- for scanner.Scan() {
- line := scanner.Text()
- if !strings.Contains(line, ":") {
- continue
- }
- field := strings.SplitN(line, ": ", 2)
- switch strings.TrimSpace(field[0]) {
- case "bogomips per cpu":
- v, err := strconv.ParseFloat(field[1], 64)
- if err != nil {
- return nil, err
- }
- commonCPUInfo.BogoMips = v
- case "features":
- commonCPUInfo.Flags = strings.Fields(field[1])
- }
- if strings.HasPrefix(line, "processor") {
- match := cpuinfoS390XProcessorRegexp.FindStringSubmatch(line)
- if len(match) < 2 {
- return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
- }
- cpu := commonCPUInfo
- v, err := strconv.ParseUint(match[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpu.Processor = uint(v)
- cpuinfo = append(cpuinfo, cpu)
- }
- if strings.HasPrefix(line, "cpu number") {
- break
- }
- }
-
- i := 0
- for scanner.Scan() {
- line := scanner.Text()
- if !strings.Contains(line, ":") {
- continue
- }
- field := strings.SplitN(line, ": ", 2)
- switch strings.TrimSpace(field[0]) {
- case "cpu number":
- i++
- case "cpu MHz dynamic":
- clock := cpuinfoClockRegexp.FindString(strings.TrimSpace(field[1]))
- v, err := strconv.ParseFloat(clock, 64)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].CPUMHz = v
- case "physical id":
- cpuinfo[i].PhysicalID = field[1]
- case "core id":
- cpuinfo[i].CoreID = field[1]
- case "cpu cores":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].CPUCores = uint(v)
- case "siblings":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].Siblings = uint(v)
- }
- }
-
- return cpuinfo, nil
-}
-
-func parseCPUInfoMips(info []byte) ([]CPUInfo, error) {
- scanner := bufio.NewScanner(bytes.NewReader(info))
-
- // find the first "processor" line
- firstLine := firstNonEmptyLine(scanner)
- if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") {
- return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
- }
- field := strings.SplitN(firstLine, ": ", 2)
- cpuinfo := []CPUInfo{}
- systemType := field[1]
-
- i := 0
-
- for scanner.Scan() {
- line := scanner.Text()
- if !strings.Contains(line, ":") {
- continue
- }
- field := strings.SplitN(line, ": ", 2)
- switch strings.TrimSpace(field[0]) {
- case "processor":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- i = int(v)
- cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
- cpuinfo[i].Processor = uint(v)
- cpuinfo[i].VendorID = systemType
- case "cpu model":
- cpuinfo[i].ModelName = field[1]
- case "BogoMIPS":
- v, err := strconv.ParseFloat(field[1], 64)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].BogoMips = v
- }
- }
- return cpuinfo, nil
-}
-
-func parseCPUInfoLoong(info []byte) ([]CPUInfo, error) {
- scanner := bufio.NewScanner(bytes.NewReader(info))
- // find the first "processor" line
- firstLine := firstNonEmptyLine(scanner)
- if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") {
- return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
- }
- field := strings.SplitN(firstLine, ": ", 2)
- cpuinfo := []CPUInfo{}
- systemType := field[1]
- i := 0
- for scanner.Scan() {
- line := scanner.Text()
- if !strings.Contains(line, ":") {
- continue
- }
- field := strings.SplitN(line, ": ", 2)
- switch strings.TrimSpace(field[0]) {
- case "processor":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- i = int(v)
- cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
- cpuinfo[i].Processor = uint(v)
- cpuinfo[i].VendorID = systemType
- case "CPU Family":
- cpuinfo[i].CPUFamily = field[1]
- case "Model Name":
- cpuinfo[i].ModelName = field[1]
- }
- }
- return cpuinfo, nil
-}
-
-func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
- scanner := bufio.NewScanner(bytes.NewReader(info))
-
- firstLine := firstNonEmptyLine(scanner)
- if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
- return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
- }
- field := strings.SplitN(firstLine, ": ", 2)
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- firstcpu := CPUInfo{Processor: uint(v)}
- cpuinfo := []CPUInfo{firstcpu}
- i := 0
-
- for scanner.Scan() {
- line := scanner.Text()
- if !strings.Contains(line, ":") {
- continue
- }
- field := strings.SplitN(line, ": ", 2)
- switch strings.TrimSpace(field[0]) {
- case "processor":
- cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
- i++
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].Processor = uint(v)
- case "cpu":
- cpuinfo[i].VendorID = field[1]
- case "clock":
- clock := cpuinfoClockRegexp.FindString(strings.TrimSpace(field[1]))
- v, err := strconv.ParseFloat(clock, 64)
- if err != nil {
- return nil, err
- }
- cpuinfo[i].CPUMHz = v
- }
- }
- return cpuinfo, nil
-}
-
-func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) {
- scanner := bufio.NewScanner(bytes.NewReader(info))
-
- firstLine := firstNonEmptyLine(scanner)
- if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
- return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
- }
- field := strings.SplitN(firstLine, ": ", 2)
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- firstcpu := CPUInfo{Processor: uint(v)}
- cpuinfo := []CPUInfo{firstcpu}
- i := 0
-
- for scanner.Scan() {
- line := scanner.Text()
- if !strings.Contains(line, ":") {
- continue
- }
- field := strings.SplitN(line, ": ", 2)
- switch strings.TrimSpace(field[0]) {
- case "processor":
- v, err := strconv.ParseUint(field[1], 0, 32)
- if err != nil {
- return nil, err
- }
- i = int(v)
- cpuinfo = append(cpuinfo, CPUInfo{}) // start of the next processor
- cpuinfo[i].Processor = uint(v)
- case "hart":
- cpuinfo[i].CoreID = field[1]
- case "isa":
- cpuinfo[i].ModelName = field[1]
- }
- }
- return cpuinfo, nil
-}
-
-func parseCPUInfoDummy(_ []byte) ([]CPUInfo, error) { // nolint:unused,deadcode
- return nil, errors.New("not implemented")
-}
-
-// firstNonEmptyLine advances the scanner to the first non-empty line
-// and returns the contents of that line.
-func firstNonEmptyLine(scanner *bufio.Scanner) string {
- for scanner.Scan() {
- line := scanner.Text()
- if strings.TrimSpace(line) != "" {
- return line
- }
- }
- return ""
-}
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_armx.go b/vendor/github.com/prometheus/procfs/cpuinfo_armx.go
deleted file mode 100644
index 64cfd53..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo_armx.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux && (arm || arm64)
-// +build linux
-// +build arm arm64
-
-package procfs
-
-var parseCPUInfo = parseCPUInfoARM
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go b/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go
deleted file mode 100644
index d88442f..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo_loong64.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux
-// +build linux
-
-package procfs
-
-var parseCPUInfo = parseCPUInfoLoong
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_mipsx.go b/vendor/github.com/prometheus/procfs/cpuinfo_mipsx.go
deleted file mode 100644
index c11207f..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo_mipsx.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux && (mips || mipsle || mips64 || mips64le)
-// +build linux
-// +build mips mipsle mips64 mips64le
-
-package procfs
-
-var parseCPUInfo = parseCPUInfoMips
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_others.go b/vendor/github.com/prometheus/procfs/cpuinfo_others.go
deleted file mode 100644
index a6b2b31..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo_others.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux && !386 && !amd64 && !arm && !arm64 && !loong64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x
-// +build linux,!386,!amd64,!arm,!arm64,!loong64,!mips,!mips64,!mips64le,!mipsle,!ppc64,!ppc64le,!riscv64,!s390x
-
-package procfs
-
-var parseCPUInfo = parseCPUInfoDummy
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_ppcx.go b/vendor/github.com/prometheus/procfs/cpuinfo_ppcx.go
deleted file mode 100644
index 003bc2a..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo_ppcx.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux && (ppc64 || ppc64le)
-// +build linux
-// +build ppc64 ppc64le
-
-package procfs
-
-var parseCPUInfo = parseCPUInfoPPC
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go b/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
deleted file mode 100644
index 1c9b731..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo_riscvx.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux && (riscv || riscv64)
-// +build linux
-// +build riscv riscv64
-
-package procfs
-
-var parseCPUInfo = parseCPUInfoRISCV
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_s390x.go b/vendor/github.com/prometheus/procfs/cpuinfo_s390x.go
deleted file mode 100644
index fa3686b..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo_s390x.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux
-// +build linux
-
-package procfs
-
-var parseCPUInfo = parseCPUInfoS390X
diff --git a/vendor/github.com/prometheus/procfs/cpuinfo_x86.go b/vendor/github.com/prometheus/procfs/cpuinfo_x86.go
deleted file mode 100644
index a0ef555..0000000
--- a/vendor/github.com/prometheus/procfs/cpuinfo_x86.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build linux && (386 || amd64)
-// +build linux
-// +build 386 amd64
-
-package procfs
-
-var parseCPUInfo = parseCPUInfoX86
diff --git a/vendor/github.com/prometheus/procfs/crypto.go b/vendor/github.com/prometheus/procfs/crypto.go
deleted file mode 100644
index 5f2a37a..0000000
--- a/vendor/github.com/prometheus/procfs/crypto.go
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Crypto holds info parsed from /proc/crypto.
-type Crypto struct {
- Alignmask *uint64
- Async bool
- Blocksize *uint64
- Chunksize *uint64
- Ctxsize *uint64
- Digestsize *uint64
- Driver string
- Geniv string
- Internal string
- Ivsize *uint64
- Maxauthsize *uint64
- MaxKeysize *uint64
- MinKeysize *uint64
- Module string
- Name string
- Priority *int64
- Refcnt *int64
- Seedsize *uint64
- Selftest string
- Type string
- Walksize *uint64
-}
-
-// Crypto parses an crypto-file (/proc/crypto) and returns a slice of
-// structs containing the relevant info. More information available here:
-// https://kernel.readthedocs.io/en/sphinx-samples/crypto-API.html
-func (fs FS) Crypto() ([]Crypto, error) {
- path := fs.proc.Path("crypto")
- b, err := util.ReadFileNoStat(path)
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot read file %v: %w", ErrFileRead, b, err)
-
- }
-
- crypto, err := parseCrypto(bytes.NewReader(b))
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse %v: %w", ErrFileParse, crypto, err)
- }
-
- return crypto, nil
-}
-
-// parseCrypto parses a /proc/crypto stream into Crypto elements.
-func parseCrypto(r io.Reader) ([]Crypto, error) {
- var out []Crypto
-
- s := bufio.NewScanner(r)
- for s.Scan() {
- text := s.Text()
- switch {
- case strings.HasPrefix(text, "name"):
- // Each crypto element begins with its name.
- out = append(out, Crypto{})
- case text == "":
- continue
- }
-
- kv := strings.Split(text, ":")
- if len(kv) != 2 {
- return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, text)
- }
-
- k := strings.TrimSpace(kv[0])
- v := strings.TrimSpace(kv[1])
-
- // Parse the key/value pair into the currently focused element.
- c := &out[len(out)-1]
- if err := c.parseKV(k, v); err != nil {
- return nil, err
- }
- }
-
- if err := s.Err(); err != nil {
- return nil, err
- }
-
- return out, nil
-}
-
-// parseKV parses a key/value pair into the appropriate field of c.
-func (c *Crypto) parseKV(k, v string) error {
- vp := util.NewValueParser(v)
-
- switch k {
- case "async":
- // Interpret literal yes as true.
- c.Async = v == "yes"
- case "blocksize":
- c.Blocksize = vp.PUInt64()
- case "chunksize":
- c.Chunksize = vp.PUInt64()
- case "digestsize":
- c.Digestsize = vp.PUInt64()
- case "driver":
- c.Driver = v
- case "geniv":
- c.Geniv = v
- case "internal":
- c.Internal = v
- case "ivsize":
- c.Ivsize = vp.PUInt64()
- case "maxauthsize":
- c.Maxauthsize = vp.PUInt64()
- case "max keysize":
- c.MaxKeysize = vp.PUInt64()
- case "min keysize":
- c.MinKeysize = vp.PUInt64()
- case "module":
- c.Module = v
- case "name":
- c.Name = v
- case "priority":
- c.Priority = vp.PInt64()
- case "refcnt":
- c.Refcnt = vp.PInt64()
- case "seedsize":
- c.Seedsize = vp.PUInt64()
- case "selftest":
- c.Selftest = v
- case "type":
- c.Type = v
- case "walksize":
- c.Walksize = vp.PUInt64()
- }
-
- return vp.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/doc.go b/vendor/github.com/prometheus/procfs/doc.go
deleted file mode 100644
index f9d961e..0000000
--- a/vendor/github.com/prometheus/procfs/doc.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2014 Prometheus Team
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package procfs provides functions to retrieve system, kernel and process
-// metrics from the pseudo-filesystem proc.
-//
-// Example:
-//
-// package main
-//
-// import (
-// "fmt"
-// "log"
-//
-// "github.com/prometheus/procfs"
-// )
-//
-// func main() {
-// p, err := procfs.Self()
-// if err != nil {
-// log.Fatalf("could not get process: %s", err)
-// }
-//
-// stat, err := p.Stat()
-// if err != nil {
-// log.Fatalf("could not get process stat: %s", err)
-// }
-//
-// fmt.Printf("command: %s\n", stat.Comm)
-// fmt.Printf("cpu time: %fs\n", stat.CPUTime())
-// fmt.Printf("vsize: %dB\n", stat.VirtualMemory())
-// fmt.Printf("rss: %dB\n", stat.ResidentMemory())
-// }
-package procfs
diff --git a/vendor/github.com/prometheus/procfs/fs.go b/vendor/github.com/prometheus/procfs/fs.go
deleted file mode 100644
index 4980c87..0000000
--- a/vendor/github.com/prometheus/procfs/fs.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "github.com/prometheus/procfs/internal/fs"
-)
-
-// FS represents the pseudo-filesystem sys, which provides an interface to
-// kernel data structures.
-type FS struct {
- proc fs.FS
- isReal bool
-}
-
-// DefaultMountPoint is the common mount point of the proc filesystem.
-const DefaultMountPoint = fs.DefaultProcMountPoint
-
-// NewDefaultFS returns a new proc FS mounted under the default proc mountPoint.
-// It will error if the mount point directory can't be read or is a file.
-func NewDefaultFS() (FS, error) {
- return NewFS(DefaultMountPoint)
-}
-
-// NewFS returns a new proc FS mounted under the given proc mountPoint. It will error
-// if the mount point directory can't be read or is a file.
-func NewFS(mountPoint string) (FS, error) {
- fs, err := fs.NewFS(mountPoint)
- if err != nil {
- return FS{}, err
- }
-
- isReal, err := isRealProc(mountPoint)
- if err != nil {
- return FS{}, err
- }
-
- return FS{fs, isReal}, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/fs_statfs_notype.go b/vendor/github.com/prometheus/procfs/fs_statfs_notype.go
deleted file mode 100644
index 134767d..0000000
--- a/vendor/github.com/prometheus/procfs/fs_statfs_notype.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !freebsd && !linux
-// +build !freebsd,!linux
-
-package procfs
-
-// isRealProc returns true on architectures that don't have a Type argument
-// in their Statfs_t struct
-func isRealProc(mountPoint string) (bool, error) {
- return true, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/fs_statfs_type.go b/vendor/github.com/prometheus/procfs/fs_statfs_type.go
deleted file mode 100644
index 80df79c..0000000
--- a/vendor/github.com/prometheus/procfs/fs_statfs_type.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build freebsd || linux
-// +build freebsd linux
-
-package procfs
-
-import (
- "syscall"
-)
-
-// isRealProc determines whether supplied mountpoint is really a proc filesystem.
-func isRealProc(mountPoint string) (bool, error) {
- stat := syscall.Statfs_t{}
- err := syscall.Statfs(mountPoint, &stat)
- if err != nil {
- return false, err
- }
-
- // 0x9fa0 is PROC_SUPER_MAGIC: https://elixir.bootlin.com/linux/v6.1/source/include/uapi/linux/magic.h#L87
- return stat.Type == 0x9fa0, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/fscache.go b/vendor/github.com/prometheus/procfs/fscache.go
deleted file mode 100644
index cf2e3ea..0000000
--- a/vendor/github.com/prometheus/procfs/fscache.go
+++ /dev/null
@@ -1,422 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Fscacheinfo represents fscache statistics.
-type Fscacheinfo struct {
- // Number of index cookies allocated
- IndexCookiesAllocated uint64
- // data storage cookies allocated
- DataStorageCookiesAllocated uint64
- // Number of special cookies allocated
- SpecialCookiesAllocated uint64
- // Number of objects allocated
- ObjectsAllocated uint64
- // Number of object allocation failures
- ObjectAllocationsFailure uint64
- // Number of objects that reached the available state
- ObjectsAvailable uint64
- // Number of objects that reached the dead state
- ObjectsDead uint64
- // Number of objects that didn't have a coherency check
- ObjectsWithoutCoherencyCheck uint64
- // Number of objects that passed a coherency check
- ObjectsWithCoherencyCheck uint64
- // Number of objects that needed a coherency data update
- ObjectsNeedCoherencyCheckUpdate uint64
- // Number of objects that were declared obsolete
- ObjectsDeclaredObsolete uint64
- // Number of pages marked as being cached
- PagesMarkedAsBeingCached uint64
- // Number of uncache page requests seen
- UncachePagesRequestSeen uint64
- // Number of acquire cookie requests seen
- AcquireCookiesRequestSeen uint64
- // Number of acq reqs given a NULL parent
- AcquireRequestsWithNullParent uint64
- // Number of acq reqs rejected due to no cache available
- AcquireRequestsRejectedNoCacheAvailable uint64
- // Number of acq reqs succeeded
- AcquireRequestsSucceeded uint64
- // Number of acq reqs rejected due to error
- AcquireRequestsRejectedDueToError uint64
- // Number of acq reqs failed on ENOMEM
- AcquireRequestsFailedDueToEnomem uint64
- // Number of lookup calls made on cache backends
- LookupsNumber uint64
- // Number of negative lookups made
- LookupsNegative uint64
- // Number of positive lookups made
- LookupsPositive uint64
- // Number of objects created by lookup
- ObjectsCreatedByLookup uint64
- // Number of lookups timed out and requeued
- LookupsTimedOutAndRequed uint64
- InvalidationsNumber uint64
- InvalidationsRunning uint64
- // Number of update cookie requests seen
- UpdateCookieRequestSeen uint64
- // Number of upd reqs given a NULL parent
- UpdateRequestsWithNullParent uint64
- // Number of upd reqs granted CPU time
- UpdateRequestsRunning uint64
- // Number of relinquish cookie requests seen
- RelinquishCookiesRequestSeen uint64
- // Number of rlq reqs given a NULL parent
- RelinquishCookiesWithNullParent uint64
- // Number of rlq reqs waited on completion of creation
- RelinquishRequestsWaitingCompleteCreation uint64
- // Relinqs rtr
- RelinquishRetries uint64
- // Number of attribute changed requests seen
- AttributeChangedRequestsSeen uint64
- // Number of attr changed requests queued
- AttributeChangedRequestsQueued uint64
- // Number of attr changed rejected -ENOBUFS
- AttributeChangedRejectDueToEnobufs uint64
- // Number of attr changed failed -ENOMEM
- AttributeChangedFailedDueToEnomem uint64
- // Number of attr changed ops given CPU time
- AttributeChangedOps uint64
- // Number of allocation requests seen
- AllocationRequestsSeen uint64
- // Number of successful alloc reqs
- AllocationOkRequests uint64
- // Number of alloc reqs that waited on lookup completion
- AllocationWaitingOnLookup uint64
- // Number of alloc reqs rejected -ENOBUFS
- AllocationsRejectedDueToEnobufs uint64
- // Number of alloc reqs aborted -ERESTARTSYS
- AllocationsAbortedDueToErestartsys uint64
- // Number of alloc reqs submitted
- AllocationOperationsSubmitted uint64
- // Number of alloc reqs waited for CPU time
- AllocationsWaitedForCPU uint64
- // Number of alloc reqs aborted due to object death
- AllocationsAbortedDueToObjectDeath uint64
- // Number of retrieval (read) requests seen
- RetrievalsReadRequests uint64
- // Number of successful retr reqs
- RetrievalsOk uint64
- // Number of retr reqs that waited on lookup completion
- RetrievalsWaitingLookupCompletion uint64
- // Number of retr reqs returned -ENODATA
- RetrievalsReturnedEnodata uint64
- // Number of retr reqs rejected -ENOBUFS
- RetrievalsRejectedDueToEnobufs uint64
- // Number of retr reqs aborted -ERESTARTSYS
- RetrievalsAbortedDueToErestartsys uint64
- // Number of retr reqs failed -ENOMEM
- RetrievalsFailedDueToEnomem uint64
- // Number of retr reqs submitted
- RetrievalsRequests uint64
- // Number of retr reqs waited for CPU time
- RetrievalsWaitingCPU uint64
- // Number of retr reqs aborted due to object death
- RetrievalsAbortedDueToObjectDeath uint64
- // Number of storage (write) requests seen
- StoreWriteRequests uint64
- // Number of successful store reqs
- StoreSuccessfulRequests uint64
- // Number of store reqs on a page already pending storage
- StoreRequestsOnPendingStorage uint64
- // Number of store reqs rejected -ENOBUFS
- StoreRequestsRejectedDueToEnobufs uint64
- // Number of store reqs failed -ENOMEM
- StoreRequestsFailedDueToEnomem uint64
- // Number of store reqs submitted
- StoreRequestsSubmitted uint64
- // Number of store reqs granted CPU time
- StoreRequestsRunning uint64
- // Number of pages given store req processing time
- StorePagesWithRequestsProcessing uint64
- // Number of store reqs deleted from tracking tree
- StoreRequestsDeleted uint64
- // Number of store reqs over store limit
- StoreRequestsOverStoreLimit uint64
- // Number of release reqs against pages with no pending store
- ReleaseRequestsAgainstPagesWithNoPendingStorage uint64
- // Number of release reqs against pages stored by time lock granted
- ReleaseRequestsAgainstPagesStoredByTimeLockGranted uint64
- // Number of release reqs ignored due to in-progress store
- ReleaseRequestsIgnoredDueToInProgressStore uint64
- // Number of page stores cancelled due to release req
- PageStoresCancelledByReleaseRequests uint64
- VmscanWaiting uint64
- // Number of times async ops added to pending queues
- OpsPending uint64
- // Number of times async ops given CPU time
- OpsRunning uint64
- // Number of times async ops queued for processing
- OpsEnqueued uint64
- // Number of async ops cancelled
- OpsCancelled uint64
- // Number of async ops rejected due to object lookup/create failure
- OpsRejected uint64
- // Number of async ops initialised
- OpsInitialised uint64
- // Number of async ops queued for deferred release
- OpsDeferred uint64
- // Number of async ops released (should equal ini=N when idle)
- OpsReleased uint64
- // Number of deferred-release async ops garbage collected
- OpsGarbageCollected uint64
- // Number of in-progress alloc_object() cache ops
- CacheopAllocationsinProgress uint64
- // Number of in-progress lookup_object() cache ops
- CacheopLookupObjectInProgress uint64
- // Number of in-progress lookup_complete() cache ops
- CacheopLookupCompleteInPorgress uint64
- // Number of in-progress grab_object() cache ops
- CacheopGrabObjectInProgress uint64
- CacheopInvalidations uint64
- // Number of in-progress update_object() cache ops
- CacheopUpdateObjectInProgress uint64
- // Number of in-progress drop_object() cache ops
- CacheopDropObjectInProgress uint64
- // Number of in-progress put_object() cache ops
- CacheopPutObjectInProgress uint64
- // Number of in-progress attr_changed() cache ops
- CacheopAttributeChangeInProgress uint64
- // Number of in-progress sync_cache() cache ops
- CacheopSyncCacheInProgress uint64
- // Number of in-progress read_or_alloc_page() cache ops
- CacheopReadOrAllocPageInProgress uint64
- // Number of in-progress read_or_alloc_pages() cache ops
- CacheopReadOrAllocPagesInProgress uint64
- // Number of in-progress allocate_page() cache ops
- CacheopAllocatePageInProgress uint64
- // Number of in-progress allocate_pages() cache ops
- CacheopAllocatePagesInProgress uint64
- // Number of in-progress write_page() cache ops
- CacheopWritePagesInProgress uint64
- // Number of in-progress uncache_page() cache ops
- CacheopUncachePagesInProgress uint64
- // Number of in-progress dissociate_pages() cache ops
- CacheopDissociatePagesInProgress uint64
- // Number of object lookups/creations rejected due to lack of space
- CacheevLookupsAndCreationsRejectedLackSpace uint64
- // Number of stale objects deleted
- CacheevStaleObjectsDeleted uint64
- // Number of objects retired when relinquished
- CacheevRetiredWhenReliquished uint64
- // Number of objects culled
- CacheevObjectsCulled uint64
-}
-
-// Fscacheinfo returns information about current fscache statistics.
-// See https://www.kernel.org/doc/Documentation/filesystems/caching/fscache.txt
-func (fs FS) Fscacheinfo() (Fscacheinfo, error) {
- b, err := util.ReadFileNoStat(fs.proc.Path("fs/fscache/stats"))
- if err != nil {
- return Fscacheinfo{}, err
- }
-
- m, err := parseFscacheinfo(bytes.NewReader(b))
- if err != nil {
- return Fscacheinfo{}, fmt.Errorf("%w: Cannot parse %v: %w", ErrFileParse, m, err)
- }
-
- return *m, nil
-}
-
-func setFSCacheFields(fields []string, setFields ...*uint64) error {
- var err error
- if len(fields) < len(setFields) {
- return fmt.Errorf("%w: Expected %d, but got %d: %w", ErrFileParse, len(setFields), len(fields), err)
- }
-
- for i := range setFields {
- *setFields[i], err = strconv.ParseUint(strings.Split(fields[i], "=")[1], 0, 64)
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-func parseFscacheinfo(r io.Reader) (*Fscacheinfo, error) {
- var m Fscacheinfo
- s := bufio.NewScanner(r)
- for s.Scan() {
- fields := strings.Fields(s.Text())
- if len(fields) < 2 {
- return nil, fmt.Errorf("%w: malformed Fscacheinfo line: %q", ErrFileParse, s.Text())
- }
-
- switch fields[0] {
- case "Cookies:":
- err := setFSCacheFields(fields[1:], &m.IndexCookiesAllocated, &m.DataStorageCookiesAllocated,
- &m.SpecialCookiesAllocated)
- if err != nil {
- return &m, err
- }
- case "Objects:":
- err := setFSCacheFields(fields[1:], &m.ObjectsAllocated, &m.ObjectAllocationsFailure,
- &m.ObjectsAvailable, &m.ObjectsDead)
- if err != nil {
- return &m, err
- }
- case "ChkAux":
- err := setFSCacheFields(fields[2:], &m.ObjectsWithoutCoherencyCheck, &m.ObjectsWithCoherencyCheck,
- &m.ObjectsNeedCoherencyCheckUpdate, &m.ObjectsDeclaredObsolete)
- if err != nil {
- return &m, err
- }
- case "Pages":
- err := setFSCacheFields(fields[2:], &m.PagesMarkedAsBeingCached, &m.UncachePagesRequestSeen)
- if err != nil {
- return &m, err
- }
- case "Acquire:":
- err := setFSCacheFields(fields[1:], &m.AcquireCookiesRequestSeen, &m.AcquireRequestsWithNullParent,
- &m.AcquireRequestsRejectedNoCacheAvailable, &m.AcquireRequestsSucceeded, &m.AcquireRequestsRejectedDueToError,
- &m.AcquireRequestsFailedDueToEnomem)
- if err != nil {
- return &m, err
- }
- case "Lookups:":
- err := setFSCacheFields(fields[1:], &m.LookupsNumber, &m.LookupsNegative, &m.LookupsPositive,
- &m.ObjectsCreatedByLookup, &m.LookupsTimedOutAndRequed)
- if err != nil {
- return &m, err
- }
- case "Invals":
- err := setFSCacheFields(fields[2:], &m.InvalidationsNumber, &m.InvalidationsRunning)
- if err != nil {
- return &m, err
- }
- case "Updates:":
- err := setFSCacheFields(fields[1:], &m.UpdateCookieRequestSeen, &m.UpdateRequestsWithNullParent,
- &m.UpdateRequestsRunning)
- if err != nil {
- return &m, err
- }
- case "Relinqs:":
- err := setFSCacheFields(fields[1:], &m.RelinquishCookiesRequestSeen, &m.RelinquishCookiesWithNullParent,
- &m.RelinquishRequestsWaitingCompleteCreation, &m.RelinquishRetries)
- if err != nil {
- return &m, err
- }
- case "AttrChg:":
- err := setFSCacheFields(fields[1:], &m.AttributeChangedRequestsSeen, &m.AttributeChangedRequestsQueued,
- &m.AttributeChangedRejectDueToEnobufs, &m.AttributeChangedFailedDueToEnomem, &m.AttributeChangedOps)
- if err != nil {
- return &m, err
- }
- case "Allocs":
- if strings.Split(fields[2], "=")[0] == "n" {
- err := setFSCacheFields(fields[2:], &m.AllocationRequestsSeen, &m.AllocationOkRequests,
- &m.AllocationWaitingOnLookup, &m.AllocationsRejectedDueToEnobufs, &m.AllocationsAbortedDueToErestartsys)
- if err != nil {
- return &m, err
- }
- } else {
- err := setFSCacheFields(fields[2:], &m.AllocationOperationsSubmitted, &m.AllocationsWaitedForCPU,
- &m.AllocationsAbortedDueToObjectDeath)
- if err != nil {
- return &m, err
- }
- }
- case "Retrvls:":
- if strings.Split(fields[1], "=")[0] == "n" {
- err := setFSCacheFields(fields[1:], &m.RetrievalsReadRequests, &m.RetrievalsOk, &m.RetrievalsWaitingLookupCompletion,
- &m.RetrievalsReturnedEnodata, &m.RetrievalsRejectedDueToEnobufs, &m.RetrievalsAbortedDueToErestartsys,
- &m.RetrievalsFailedDueToEnomem)
- if err != nil {
- return &m, err
- }
- } else {
- err := setFSCacheFields(fields[1:], &m.RetrievalsRequests, &m.RetrievalsWaitingCPU, &m.RetrievalsAbortedDueToObjectDeath)
- if err != nil {
- return &m, err
- }
- }
- case "Stores":
- if strings.Split(fields[2], "=")[0] == "n" {
- err := setFSCacheFields(fields[2:], &m.StoreWriteRequests, &m.StoreSuccessfulRequests,
- &m.StoreRequestsOnPendingStorage, &m.StoreRequestsRejectedDueToEnobufs, &m.StoreRequestsFailedDueToEnomem)
- if err != nil {
- return &m, err
- }
- } else {
- err := setFSCacheFields(fields[2:], &m.StoreRequestsSubmitted, &m.StoreRequestsRunning,
- &m.StorePagesWithRequestsProcessing, &m.StoreRequestsDeleted, &m.StoreRequestsOverStoreLimit)
- if err != nil {
- return &m, err
- }
- }
- case "VmScan":
- err := setFSCacheFields(fields[2:], &m.ReleaseRequestsAgainstPagesWithNoPendingStorage,
- &m.ReleaseRequestsAgainstPagesStoredByTimeLockGranted, &m.ReleaseRequestsIgnoredDueToInProgressStore,
- &m.PageStoresCancelledByReleaseRequests, &m.VmscanWaiting)
- if err != nil {
- return &m, err
- }
- case "Ops":
- if strings.Split(fields[2], "=")[0] == "pend" {
- err := setFSCacheFields(fields[2:], &m.OpsPending, &m.OpsRunning, &m.OpsEnqueued, &m.OpsCancelled, &m.OpsRejected)
- if err != nil {
- return &m, err
- }
- } else {
- err := setFSCacheFields(fields[2:], &m.OpsInitialised, &m.OpsDeferred, &m.OpsReleased, &m.OpsGarbageCollected)
- if err != nil {
- return &m, err
- }
- }
- case "CacheOp:":
- if strings.Split(fields[1], "=")[0] == "alo" {
- err := setFSCacheFields(fields[1:], &m.CacheopAllocationsinProgress, &m.CacheopLookupObjectInProgress,
- &m.CacheopLookupCompleteInPorgress, &m.CacheopGrabObjectInProgress)
- if err != nil {
- return &m, err
- }
- } else if strings.Split(fields[1], "=")[0] == "inv" {
- err := setFSCacheFields(fields[1:], &m.CacheopInvalidations, &m.CacheopUpdateObjectInProgress,
- &m.CacheopDropObjectInProgress, &m.CacheopPutObjectInProgress, &m.CacheopAttributeChangeInProgress,
- &m.CacheopSyncCacheInProgress)
- if err != nil {
- return &m, err
- }
- } else {
- err := setFSCacheFields(fields[1:], &m.CacheopReadOrAllocPageInProgress, &m.CacheopReadOrAllocPagesInProgress,
- &m.CacheopAllocatePageInProgress, &m.CacheopAllocatePagesInProgress, &m.CacheopWritePagesInProgress,
- &m.CacheopUncachePagesInProgress, &m.CacheopDissociatePagesInProgress)
- if err != nil {
- return &m, err
- }
- }
- case "CacheEv:":
- err := setFSCacheFields(fields[1:], &m.CacheevLookupsAndCreationsRejectedLackSpace, &m.CacheevStaleObjectsDeleted,
- &m.CacheevRetiredWhenReliquished, &m.CacheevObjectsCulled)
- if err != nil {
- return &m, err
- }
- }
- }
-
- return &m, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/internal/fs/fs.go b/vendor/github.com/prometheus/procfs/internal/fs/fs.go
deleted file mode 100644
index 3c18c76..0000000
--- a/vendor/github.com/prometheus/procfs/internal/fs/fs.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package fs
-
-import (
- "fmt"
- "os"
- "path/filepath"
-)
-
-const (
- // DefaultProcMountPoint is the common mount point of the proc filesystem.
- DefaultProcMountPoint = "/proc"
-
- // DefaultSysMountPoint is the common mount point of the sys filesystem.
- DefaultSysMountPoint = "/sys"
-
- // DefaultConfigfsMountPoint is the common mount point of the configfs.
- DefaultConfigfsMountPoint = "/sys/kernel/config"
-)
-
-// FS represents a pseudo-filesystem, normally /proc or /sys, which provides an
-// interface to kernel data structures.
-type FS string
-
-// NewFS returns a new FS mounted under the given mountPoint. It will error
-// if the mount point can't be read.
-func NewFS(mountPoint string) (FS, error) {
- info, err := os.Stat(mountPoint)
- if err != nil {
- return "", fmt.Errorf("could not read %q: %w", mountPoint, err)
- }
- if !info.IsDir() {
- return "", fmt.Errorf("mount point %q is not a directory", mountPoint)
- }
-
- return FS(mountPoint), nil
-}
-
-// Path appends the given path elements to the filesystem path, adding separators
-// as necessary.
-func (fs FS) Path(p ...string) string {
- return filepath.Join(append([]string{string(fs)}, p...)...)
-}
diff --git a/vendor/github.com/prometheus/procfs/internal/util/parse.go b/vendor/github.com/prometheus/procfs/internal/util/parse.go
deleted file mode 100644
index 14272dc..0000000
--- a/vendor/github.com/prometheus/procfs/internal/util/parse.go
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package util
-
-import (
- "os"
- "strconv"
- "strings"
-)
-
-// ParseUint32s parses a slice of strings into a slice of uint32s.
-func ParseUint32s(ss []string) ([]uint32, error) {
- us := make([]uint32, 0, len(ss))
- for _, s := range ss {
- u, err := strconv.ParseUint(s, 10, 32)
- if err != nil {
- return nil, err
- }
-
- us = append(us, uint32(u))
- }
-
- return us, nil
-}
-
-// ParseUint64s parses a slice of strings into a slice of uint64s.
-func ParseUint64s(ss []string) ([]uint64, error) {
- us := make([]uint64, 0, len(ss))
- for _, s := range ss {
- u, err := strconv.ParseUint(s, 10, 64)
- if err != nil {
- return nil, err
- }
-
- us = append(us, u)
- }
-
- return us, nil
-}
-
-// ParsePInt64s parses a slice of strings into a slice of int64 pointers.
-func ParsePInt64s(ss []string) ([]*int64, error) {
- us := make([]*int64, 0, len(ss))
- for _, s := range ss {
- u, err := strconv.ParseInt(s, 10, 64)
- if err != nil {
- return nil, err
- }
-
- us = append(us, &u)
- }
-
- return us, nil
-}
-
-// Parses a uint64 from given hex in string.
-func ParseHexUint64s(ss []string) ([]*uint64, error) {
- us := make([]*uint64, 0, len(ss))
- for _, s := range ss {
- u, err := strconv.ParseUint(s, 16, 64)
- if err != nil {
- return nil, err
- }
-
- us = append(us, &u)
- }
-
- return us, nil
-}
-
-// ReadUintFromFile reads a file and attempts to parse a uint64 from it.
-func ReadUintFromFile(path string) (uint64, error) {
- data, err := os.ReadFile(path)
- if err != nil {
- return 0, err
- }
- return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64)
-}
-
-// ReadIntFromFile reads a file and attempts to parse a int64 from it.
-func ReadIntFromFile(path string) (int64, error) {
- data, err := os.ReadFile(path)
- if err != nil {
- return 0, err
- }
- return strconv.ParseInt(strings.TrimSpace(string(data)), 10, 64)
-}
-
-// ParseBool parses a string into a boolean pointer.
-func ParseBool(b string) *bool {
- var truth bool
- switch b {
- case "enabled":
- truth = true
- case "disabled":
- truth = false
- default:
- return nil
- }
- return &truth
-}
diff --git a/vendor/github.com/prometheus/procfs/internal/util/readfile.go b/vendor/github.com/prometheus/procfs/internal/util/readfile.go
deleted file mode 100644
index 71b7a70..0000000
--- a/vendor/github.com/prometheus/procfs/internal/util/readfile.go
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package util
-
-import (
- "io"
- "os"
-)
-
-// ReadFileNoStat uses io.ReadAll to read contents of entire file.
-// This is similar to os.ReadFile but without the call to os.Stat, because
-// many files in /proc and /sys report incorrect file sizes (either 0 or 4096).
-// Reads a max file size of 1024kB. For files larger than this, a scanner
-// should be used.
-func ReadFileNoStat(filename string) ([]byte, error) {
- const maxBufferSize = 1024 * 1024
-
- f, err := os.Open(filename)
- if err != nil {
- return nil, err
- }
- defer f.Close()
-
- reader := io.LimitReader(f, maxBufferSize)
- return io.ReadAll(reader)
-}
diff --git a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile.go b/vendor/github.com/prometheus/procfs/internal/util/sysreadfile.go
deleted file mode 100644
index 1ab875c..0000000
--- a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build (linux || darwin) && !appengine
-// +build linux darwin
-// +build !appengine
-
-package util
-
-import (
- "bytes"
- "os"
- "syscall"
-)
-
-// SysReadFile is a simplified os.ReadFile that invokes syscall.Read directly.
-// https://github.com/prometheus/node_exporter/pull/728/files
-//
-// Note that this function will not read files larger than 128 bytes.
-func SysReadFile(file string) (string, error) {
- f, err := os.Open(file)
- if err != nil {
- return "", err
- }
- defer f.Close()
-
- // On some machines, hwmon drivers are broken and return EAGAIN. This causes
- // Go's os.ReadFile implementation to poll forever.
- //
- // Since we either want to read data or bail immediately, do the simplest
- // possible read using syscall directly.
- const sysFileBufferSize = 128
- b := make([]byte, sysFileBufferSize)
- n, err := syscall.Read(int(f.Fd()), b)
- if err != nil {
- return "", err
- }
-
- return string(bytes.TrimSpace(b[:n])), nil
-}
diff --git a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile_compat.go b/vendor/github.com/prometheus/procfs/internal/util/sysreadfile_compat.go
deleted file mode 100644
index 1d86f5e..0000000
--- a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile_compat.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build (linux && appengine) || (!linux && !darwin)
-// +build linux,appengine !linux,!darwin
-
-package util
-
-import (
- "fmt"
-)
-
-// SysReadFile is here implemented as a noop for builds that do not support
-// the read syscall. For example Windows, or Linux on Google App Engine.
-func SysReadFile(file string) (string, error) {
- return "", fmt.Errorf("not supported on this platform")
-}
diff --git a/vendor/github.com/prometheus/procfs/internal/util/valueparser.go b/vendor/github.com/prometheus/procfs/internal/util/valueparser.go
deleted file mode 100644
index fe2355d..0000000
--- a/vendor/github.com/prometheus/procfs/internal/util/valueparser.go
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package util
-
-import (
- "strconv"
-)
-
-// TODO(mdlayher): util packages are an anti-pattern and this should be moved
-// somewhere else that is more focused in the future.
-
-// A ValueParser enables parsing a single string into a variety of data types
-// in a concise and safe way. The Err method must be invoked after invoking
-// any other methods to ensure a value was successfully parsed.
-type ValueParser struct {
- v string
- err error
-}
-
-// NewValueParser creates a ValueParser using the input string.
-func NewValueParser(v string) *ValueParser {
- return &ValueParser{v: v}
-}
-
-// Int interprets the underlying value as an int and returns that value.
-func (vp *ValueParser) Int() int { return int(vp.int64()) }
-
-// PInt64 interprets the underlying value as an int64 and returns a pointer to
-// that value.
-func (vp *ValueParser) PInt64() *int64 {
- if vp.err != nil {
- return nil
- }
-
- v := vp.int64()
- return &v
-}
-
-// int64 interprets the underlying value as an int64 and returns that value.
-// TODO: export if/when necessary.
-func (vp *ValueParser) int64() int64 {
- if vp.err != nil {
- return 0
- }
-
- // A base value of zero makes ParseInt infer the correct base using the
- // string's prefix, if any.
- const base = 0
- v, err := strconv.ParseInt(vp.v, base, 64)
- if err != nil {
- vp.err = err
- return 0
- }
-
- return v
-}
-
-// PUInt64 interprets the underlying value as an uint64 and returns a pointer to
-// that value.
-func (vp *ValueParser) PUInt64() *uint64 {
- if vp.err != nil {
- return nil
- }
-
- // A base value of zero makes ParseInt infer the correct base using the
- // string's prefix, if any.
- const base = 0
- v, err := strconv.ParseUint(vp.v, base, 64)
- if err != nil {
- vp.err = err
- return nil
- }
-
- return &v
-}
-
-// Err returns the last error, if any, encountered by the ValueParser.
-func (vp *ValueParser) Err() error {
- return vp.err
-}
diff --git a/vendor/github.com/prometheus/procfs/ipvs.go b/vendor/github.com/prometheus/procfs/ipvs.go
deleted file mode 100644
index bc3a20c..0000000
--- a/vendor/github.com/prometheus/procfs/ipvs.go
+++ /dev/null
@@ -1,241 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "encoding/hex"
- "errors"
- "fmt"
- "io"
- "net"
- "os"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// IPVSStats holds IPVS statistics, as exposed by the kernel in `/proc/net/ip_vs_stats`.
-type IPVSStats struct {
- // Total count of connections.
- Connections uint64
- // Total incoming packages processed.
- IncomingPackets uint64
- // Total outgoing packages processed.
- OutgoingPackets uint64
- // Total incoming traffic.
- IncomingBytes uint64
- // Total outgoing traffic.
- OutgoingBytes uint64
-}
-
-// IPVSBackendStatus holds current metrics of one virtual / real address pair.
-type IPVSBackendStatus struct {
- // The local (virtual) IP address.
- LocalAddress net.IP
- // The remote (real) IP address.
- RemoteAddress net.IP
- // The local (virtual) port.
- LocalPort uint16
- // The remote (real) port.
- RemotePort uint16
- // The local firewall mark
- LocalMark string
- // The transport protocol (TCP, UDP).
- Proto string
- // The current number of active connections for this virtual/real address pair.
- ActiveConn uint64
- // The current number of inactive connections for this virtual/real address pair.
- InactConn uint64
- // The current weight of this virtual/real address pair.
- Weight uint64
-}
-
-// IPVSStats reads the IPVS statistics from the specified `proc` filesystem.
-func (fs FS) IPVSStats() (IPVSStats, error) {
- data, err := util.ReadFileNoStat(fs.proc.Path("net/ip_vs_stats"))
- if err != nil {
- return IPVSStats{}, err
- }
-
- return parseIPVSStats(bytes.NewReader(data))
-}
-
-// parseIPVSStats performs the actual parsing of `ip_vs_stats`.
-func parseIPVSStats(r io.Reader) (IPVSStats, error) {
- var (
- statContent []byte
- statLines []string
- statFields []string
- stats IPVSStats
- )
-
- statContent, err := io.ReadAll(r)
- if err != nil {
- return IPVSStats{}, err
- }
-
- statLines = strings.SplitN(string(statContent), "\n", 4)
- if len(statLines) != 4 {
- return IPVSStats{}, errors.New("ip_vs_stats corrupt: too short")
- }
-
- statFields = strings.Fields(statLines[2])
- if len(statFields) != 5 {
- return IPVSStats{}, errors.New("ip_vs_stats corrupt: unexpected number of fields")
- }
-
- stats.Connections, err = strconv.ParseUint(statFields[0], 16, 64)
- if err != nil {
- return IPVSStats{}, err
- }
- stats.IncomingPackets, err = strconv.ParseUint(statFields[1], 16, 64)
- if err != nil {
- return IPVSStats{}, err
- }
- stats.OutgoingPackets, err = strconv.ParseUint(statFields[2], 16, 64)
- if err != nil {
- return IPVSStats{}, err
- }
- stats.IncomingBytes, err = strconv.ParseUint(statFields[3], 16, 64)
- if err != nil {
- return IPVSStats{}, err
- }
- stats.OutgoingBytes, err = strconv.ParseUint(statFields[4], 16, 64)
- if err != nil {
- return IPVSStats{}, err
- }
-
- return stats, nil
-}
-
-// IPVSBackendStatus reads and returns the status of all (virtual,real) server pairs from the specified `proc` filesystem.
-func (fs FS) IPVSBackendStatus() ([]IPVSBackendStatus, error) {
- file, err := os.Open(fs.proc.Path("net/ip_vs"))
- if err != nil {
- return nil, err
- }
- defer file.Close()
-
- return parseIPVSBackendStatus(file)
-}
-
-func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
- var (
- status []IPVSBackendStatus
- scanner = bufio.NewScanner(file)
- proto string
- localMark string
- localAddress net.IP
- localPort uint16
- err error
- )
-
- for scanner.Scan() {
- fields := strings.Fields(scanner.Text())
- if len(fields) == 0 {
- continue
- }
- switch {
- case fields[0] == "IP" || fields[0] == "Prot" || fields[1] == "RemoteAddress:Port":
- continue
- case fields[0] == "TCP" || fields[0] == "UDP":
- if len(fields) < 2 {
- continue
- }
- proto = fields[0]
- localMark = ""
- localAddress, localPort, err = parseIPPort(fields[1])
- if err != nil {
- return nil, err
- }
- case fields[0] == "FWM":
- if len(fields) < 2 {
- continue
- }
- proto = fields[0]
- localMark = fields[1]
- localAddress = nil
- localPort = 0
- case fields[0] == "->":
- if len(fields) < 6 {
- continue
- }
- remoteAddress, remotePort, err := parseIPPort(fields[1])
- if err != nil {
- return nil, err
- }
- weight, err := strconv.ParseUint(fields[3], 10, 64)
- if err != nil {
- return nil, err
- }
- activeConn, err := strconv.ParseUint(fields[4], 10, 64)
- if err != nil {
- return nil, err
- }
- inactConn, err := strconv.ParseUint(fields[5], 10, 64)
- if err != nil {
- return nil, err
- }
- status = append(status, IPVSBackendStatus{
- LocalAddress: localAddress,
- LocalPort: localPort,
- LocalMark: localMark,
- RemoteAddress: remoteAddress,
- RemotePort: remotePort,
- Proto: proto,
- Weight: weight,
- ActiveConn: activeConn,
- InactConn: inactConn,
- })
- }
- }
- return status, nil
-}
-
-func parseIPPort(s string) (net.IP, uint16, error) {
- var (
- ip net.IP
- err error
- )
-
- switch len(s) {
- case 13:
- ip, err = hex.DecodeString(s[0:8])
- if err != nil {
- return nil, 0, err
- }
- case 46:
- ip = net.ParseIP(s[1:40])
- if ip == nil {
- return nil, 0, fmt.Errorf("%w: Invalid IPv6 addr %s: %w", ErrFileParse, s[1:40], err)
- }
- default:
- return nil, 0, fmt.Errorf("%w: Unexpected IP:Port %s: %w", ErrFileParse, s, err)
- }
-
- portString := s[len(s)-4:]
- if len(portString) != 4 {
- return nil, 0,
- fmt.Errorf("%w: Unexpected port string format %s: %w", ErrFileParse, portString, err)
- }
- port, err := strconv.ParseUint(portString, 16, 16)
- if err != nil {
- return nil, 0, err
- }
-
- return ip, uint16(port), nil
-}
diff --git a/vendor/github.com/prometheus/procfs/kernel_random.go b/vendor/github.com/prometheus/procfs/kernel_random.go
deleted file mode 100644
index db88566..0000000
--- a/vendor/github.com/prometheus/procfs/kernel_random.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !windows
-// +build !windows
-
-package procfs
-
-import (
- "os"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// KernelRandom contains information about to the kernel's random number generator.
-type KernelRandom struct {
- // EntropyAvaliable gives the available entropy, in bits.
- EntropyAvaliable *uint64
- // PoolSize gives the size of the entropy pool, in bits.
- PoolSize *uint64
- // URandomMinReseedSeconds is the number of seconds after which the DRNG will be reseeded.
- URandomMinReseedSeconds *uint64
- // WriteWakeupThreshold the number of bits of entropy below which we wake up processes
- // that do a select(2) or poll(2) for write access to /dev/random.
- WriteWakeupThreshold *uint64
- // ReadWakeupThreshold is the number of bits of entropy required for waking up processes that sleep
- // waiting for entropy from /dev/random.
- ReadWakeupThreshold *uint64
-}
-
-// KernelRandom returns values from /proc/sys/kernel/random.
-func (fs FS) KernelRandom() (KernelRandom, error) {
- random := KernelRandom{}
-
- for file, p := range map[string]**uint64{
- "entropy_avail": &random.EntropyAvaliable,
- "poolsize": &random.PoolSize,
- "urandom_min_reseed_secs": &random.URandomMinReseedSeconds,
- "write_wakeup_threshold": &random.WriteWakeupThreshold,
- "read_wakeup_threshold": &random.ReadWakeupThreshold,
- } {
- val, err := util.ReadUintFromFile(fs.proc.Path("sys", "kernel", "random", file))
- if os.IsNotExist(err) {
- continue
- }
- if err != nil {
- return random, err
- }
- *p = &val
- }
-
- return random, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/loadavg.go b/vendor/github.com/prometheus/procfs/loadavg.go
deleted file mode 100644
index 332e76c..0000000
--- a/vendor/github.com/prometheus/procfs/loadavg.go
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "fmt"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// LoadAvg represents an entry in /proc/loadavg.
-type LoadAvg struct {
- Load1 float64
- Load5 float64
- Load15 float64
-}
-
-// LoadAvg returns loadavg from /proc.
-func (fs FS) LoadAvg() (*LoadAvg, error) {
- path := fs.proc.Path("loadavg")
-
- data, err := util.ReadFileNoStat(path)
- if err != nil {
- return nil, err
- }
- return parseLoad(data)
-}
-
-// Parse /proc loadavg and return 1m, 5m and 15m.
-func parseLoad(loadavgBytes []byte) (*LoadAvg, error) {
- loads := make([]float64, 3)
- parts := strings.Fields(string(loadavgBytes))
- if len(parts) < 3 {
- return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, string(loadavgBytes))
- }
-
- var err error
- for i, load := range parts[0:3] {
- loads[i], err = strconv.ParseFloat(load, 64)
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse load: %f: %w", ErrFileParse, loads[i], err)
- }
- }
- return &LoadAvg{
- Load1: loads[0],
- Load5: loads[1],
- Load15: loads[2],
- }, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/mdstat.go b/vendor/github.com/prometheus/procfs/mdstat.go
deleted file mode 100644
index 67a9d2b..0000000
--- a/vendor/github.com/prometheus/procfs/mdstat.go
+++ /dev/null
@@ -1,276 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "fmt"
- "os"
- "regexp"
- "strconv"
- "strings"
-)
-
-var (
- statusLineRE = regexp.MustCompile(`(\d+) blocks .*\[(\d+)/(\d+)\] \[([U_]+)\]`)
- recoveryLineBlocksRE = regexp.MustCompile(`\((\d+/\d+)\)`)
- recoveryLinePctRE = regexp.MustCompile(`= (.+)%`)
- recoveryLineFinishRE = regexp.MustCompile(`finish=(.+)min`)
- recoveryLineSpeedRE = regexp.MustCompile(`speed=(.+)[A-Z]`)
- componentDeviceRE = regexp.MustCompile(`(.*)\[\d+\]`)
-)
-
-// MDStat holds info parsed from /proc/mdstat.
-type MDStat struct {
- // Name of the device.
- Name string
- // activity-state of the device.
- ActivityState string
- // Number of active disks.
- DisksActive int64
- // Total number of disks the device requires.
- DisksTotal int64
- // Number of failed disks.
- DisksFailed int64
- // Number of "down" disks. (the _ indicator in the status line)
- DisksDown int64
- // Spare disks in the device.
- DisksSpare int64
- // Number of blocks the device holds.
- BlocksTotal int64
- // Number of blocks on the device that are in sync.
- BlocksSynced int64
- // Number of blocks on the device that need to be synced.
- BlocksToBeSynced int64
- // progress percentage of current sync
- BlocksSyncedPct float64
- // estimated finishing time for current sync (in minutes)
- BlocksSyncedFinishTime float64
- // current sync speed (in Kilobytes/sec)
- BlocksSyncedSpeed float64
- // Name of md component devices
- Devices []string
-}
-
-// MDStat parses an mdstat-file (/proc/mdstat) and returns a slice of
-// structs containing the relevant info. More information available here:
-// https://raid.wiki.kernel.org/index.php/Mdstat
-func (fs FS) MDStat() ([]MDStat, error) {
- data, err := os.ReadFile(fs.proc.Path("mdstat"))
- if err != nil {
- return nil, err
- }
- mdstat, err := parseMDStat(data)
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse %v: %w", ErrFileParse, fs.proc.Path("mdstat"), err)
- }
- return mdstat, nil
-}
-
-// parseMDStat parses data from mdstat file (/proc/mdstat) and returns a slice of
-// structs containing the relevant info.
-func parseMDStat(mdStatData []byte) ([]MDStat, error) {
- mdStats := []MDStat{}
- lines := strings.Split(string(mdStatData), "\n")
-
- for i, line := range lines {
- if strings.TrimSpace(line) == "" || line[0] == ' ' ||
- strings.HasPrefix(line, "Personalities") ||
- strings.HasPrefix(line, "unused") {
- continue
- }
-
- deviceFields := strings.Fields(line)
- if len(deviceFields) < 3 {
- return nil, fmt.Errorf("%w: Expected 3+ lines, got %q", ErrFileParse, line)
- }
- mdName := deviceFields[0] // mdx
- state := deviceFields[2] // active or inactive
-
- if len(lines) <= i+3 {
- return nil, fmt.Errorf("%w: Too few lines for md device: %q", ErrFileParse, mdName)
- }
-
- // Failed disks have the suffix (F) & Spare disks have the suffix (S).
- fail := int64(strings.Count(line, "(F)"))
- spare := int64(strings.Count(line, "(S)"))
- active, total, down, size, err := evalStatusLine(lines[i], lines[i+1])
-
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse md device lines: %v: %w", ErrFileParse, active, err)
- }
-
- syncLineIdx := i + 2
- if strings.Contains(lines[i+2], "bitmap") { // skip bitmap line
- syncLineIdx++
- }
-
- // If device is syncing at the moment, get the number of currently
- // synced bytes, otherwise that number equals the size of the device.
- blocksSynced := size
- blocksToBeSynced := size
- speed := float64(0)
- finish := float64(0)
- pct := float64(0)
- recovering := strings.Contains(lines[syncLineIdx], "recovery")
- resyncing := strings.Contains(lines[syncLineIdx], "resync")
- checking := strings.Contains(lines[syncLineIdx], "check")
-
- // Append recovery and resyncing state info.
- if recovering || resyncing || checking {
- if recovering {
- state = "recovering"
- } else if checking {
- state = "checking"
- } else {
- state = "resyncing"
- }
-
- // Handle case when resync=PENDING or resync=DELAYED.
- if strings.Contains(lines[syncLineIdx], "PENDING") ||
- strings.Contains(lines[syncLineIdx], "DELAYED") {
- blocksSynced = 0
- } else {
- blocksSynced, blocksToBeSynced, pct, finish, speed, err = evalRecoveryLine(lines[syncLineIdx])
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse sync line in md device: %q: %w", ErrFileParse, mdName, err)
- }
- }
- }
-
- mdStats = append(mdStats, MDStat{
- Name: mdName,
- ActivityState: state,
- DisksActive: active,
- DisksFailed: fail,
- DisksDown: down,
- DisksSpare: spare,
- DisksTotal: total,
- BlocksTotal: size,
- BlocksSynced: blocksSynced,
- BlocksToBeSynced: blocksToBeSynced,
- BlocksSyncedPct: pct,
- BlocksSyncedFinishTime: finish,
- BlocksSyncedSpeed: speed,
- Devices: evalComponentDevices(deviceFields),
- })
- }
-
- return mdStats, nil
-}
-
-func evalStatusLine(deviceLine, statusLine string) (active, total, down, size int64, err error) {
- statusFields := strings.Fields(statusLine)
- if len(statusFields) < 1 {
- return 0, 0, 0, 0, fmt.Errorf("%w: Unexpected statusline %q: %w", ErrFileParse, statusLine, err)
- }
-
- sizeStr := statusFields[0]
- size, err = strconv.ParseInt(sizeStr, 10, 64)
- if err != nil {
- return 0, 0, 0, 0, fmt.Errorf("%w: Unexpected statusline %q: %w", ErrFileParse, statusLine, err)
- }
-
- if strings.Contains(deviceLine, "raid0") || strings.Contains(deviceLine, "linear") {
- // In the device deviceLine, only disks have a number associated with them in [].
- total = int64(strings.Count(deviceLine, "["))
- return total, total, 0, size, nil
- }
-
- if strings.Contains(deviceLine, "inactive") {
- return 0, 0, 0, size, nil
- }
-
- matches := statusLineRE.FindStringSubmatch(statusLine)
- if len(matches) != 5 {
- return 0, 0, 0, 0, fmt.Errorf("%w: Could not fild all substring matches %s: %w", ErrFileParse, statusLine, err)
- }
-
- total, err = strconv.ParseInt(matches[2], 10, 64)
- if err != nil {
- return 0, 0, 0, 0, fmt.Errorf("%w: Unexpected statusline %q: %w", ErrFileParse, statusLine, err)
- }
-
- active, err = strconv.ParseInt(matches[3], 10, 64)
- if err != nil {
- return 0, 0, 0, 0, fmt.Errorf("%w: Unexpected active %d: %w", ErrFileParse, active, err)
- }
- down = int64(strings.Count(matches[4], "_"))
-
- return active, total, down, size, nil
-}
-
-func evalRecoveryLine(recoveryLine string) (blocksSynced int64, blocksToBeSynced int64, pct float64, finish float64, speed float64, err error) {
- matches := recoveryLineBlocksRE.FindStringSubmatch(recoveryLine)
- if len(matches) != 2 {
- return 0, 0, 0, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine blocks %s: %w", ErrFileParse, recoveryLine, err)
- }
-
- blocks := strings.Split(matches[1], "/")
- blocksSynced, err = strconv.ParseInt(blocks[0], 10, 64)
- if err != nil {
- return 0, 0, 0, 0, 0, fmt.Errorf("%w: Unable to parse recovery blocks synced %q: %w", ErrFileParse, matches[1], err)
- }
-
- blocksToBeSynced, err = strconv.ParseInt(blocks[1], 10, 64)
- if err != nil {
- return blocksSynced, 0, 0, 0, 0, fmt.Errorf("%w: Unable to parse recovery to be synced blocks %q: %w", ErrFileParse, matches[2], err)
- }
-
- // Get percentage complete
- matches = recoveryLinePctRE.FindStringSubmatch(recoveryLine)
- if len(matches) != 2 {
- return blocksSynced, blocksToBeSynced, 0, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching percentage %s", ErrFileParse, recoveryLine)
- }
- pct, err = strconv.ParseFloat(strings.TrimSpace(matches[1]), 64)
- if err != nil {
- return blocksSynced, blocksToBeSynced, 0, 0, 0, fmt.Errorf("%w: Error parsing float from recoveryLine %q", ErrFileParse, recoveryLine)
- }
-
- // Get time expected left to complete
- matches = recoveryLineFinishRE.FindStringSubmatch(recoveryLine)
- if len(matches) != 2 {
- return blocksSynced, blocksToBeSynced, pct, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching est. finish time: %s", ErrFileParse, recoveryLine)
- }
- finish, err = strconv.ParseFloat(matches[1], 64)
- if err != nil {
- return blocksSynced, blocksToBeSynced, pct, 0, 0, fmt.Errorf("%w: Unable to parse float from recoveryLine: %q", ErrFileParse, recoveryLine)
- }
-
- // Get recovery speed
- matches = recoveryLineSpeedRE.FindStringSubmatch(recoveryLine)
- if len(matches) != 2 {
- return blocksSynced, blocksToBeSynced, pct, finish, 0, fmt.Errorf("%w: Unexpected recoveryLine value: %s", ErrFileParse, recoveryLine)
- }
- speed, err = strconv.ParseFloat(matches[1], 64)
- if err != nil {
- return blocksSynced, blocksToBeSynced, pct, finish, 0, fmt.Errorf("%w: Error parsing float from recoveryLine: %q: %w", ErrFileParse, recoveryLine, err)
- }
-
- return blocksSynced, blocksToBeSynced, pct, finish, speed, nil
-}
-
-func evalComponentDevices(deviceFields []string) []string {
- mdComponentDevices := make([]string, 0)
- if len(deviceFields) > 3 {
- for _, field := range deviceFields[4:] {
- match := componentDeviceRE.FindStringSubmatch(field)
- if match == nil {
- continue
- }
- mdComponentDevices = append(mdComponentDevices, match[1])
- }
- }
-
- return mdComponentDevices
-}
diff --git a/vendor/github.com/prometheus/procfs/meminfo.go b/vendor/github.com/prometheus/procfs/meminfo.go
deleted file mode 100644
index 4b2c405..0000000
--- a/vendor/github.com/prometheus/procfs/meminfo.go
+++ /dev/null
@@ -1,389 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Meminfo represents memory statistics.
-type Meminfo struct {
- // Total usable ram (i.e. physical ram minus a few reserved
- // bits and the kernel binary code)
- MemTotal *uint64
- // The sum of LowFree+HighFree
- MemFree *uint64
- // An estimate of how much memory is available for starting
- // new applications, without swapping. Calculated from
- // MemFree, SReclaimable, the size of the file LRU lists, and
- // the low watermarks in each zone. The estimate takes into
- // account that the system needs some page cache to function
- // well, and that not all reclaimable slab will be
- // reclaimable, due to items being in use. The impact of those
- // factors will vary from system to system.
- MemAvailable *uint64
- // Relatively temporary storage for raw disk blocks shouldn't
- // get tremendously large (20MB or so)
- Buffers *uint64
- Cached *uint64
- // Memory that once was swapped out, is swapped back in but
- // still also is in the swapfile (if memory is needed it
- // doesn't need to be swapped out AGAIN because it is already
- // in the swapfile. This saves I/O)
- SwapCached *uint64
- // Memory that has been used more recently and usually not
- // reclaimed unless absolutely necessary.
- Active *uint64
- // Memory which has been less recently used. It is more
- // eligible to be reclaimed for other purposes
- Inactive *uint64
- ActiveAnon *uint64
- InactiveAnon *uint64
- ActiveFile *uint64
- InactiveFile *uint64
- Unevictable *uint64
- Mlocked *uint64
- // total amount of swap space available
- SwapTotal *uint64
- // Memory which has been evicted from RAM, and is temporarily
- // on the disk
- SwapFree *uint64
- // Memory which is waiting to get written back to the disk
- Dirty *uint64
- // Memory which is actively being written back to the disk
- Writeback *uint64
- // Non-file backed pages mapped into userspace page tables
- AnonPages *uint64
- // files which have been mapped, such as libraries
- Mapped *uint64
- Shmem *uint64
- // in-kernel data structures cache
- Slab *uint64
- // Part of Slab, that might be reclaimed, such as caches
- SReclaimable *uint64
- // Part of Slab, that cannot be reclaimed on memory pressure
- SUnreclaim *uint64
- KernelStack *uint64
- // amount of memory dedicated to the lowest level of page
- // tables.
- PageTables *uint64
- // NFS pages sent to the server, but not yet committed to
- // stable storage
- NFSUnstable *uint64
- // Memory used for block device "bounce buffers"
- Bounce *uint64
- // Memory used by FUSE for temporary writeback buffers
- WritebackTmp *uint64
- // Based on the overcommit ratio ('vm.overcommit_ratio'),
- // this is the total amount of memory currently available to
- // be allocated on the system. This limit is only adhered to
- // if strict overcommit accounting is enabled (mode 2 in
- // 'vm.overcommit_memory').
- // The CommitLimit is calculated with the following formula:
- // CommitLimit = ([total RAM pages] - [total huge TLB pages]) *
- // overcommit_ratio / 100 + [total swap pages]
- // For example, on a system with 1G of physical RAM and 7G
- // of swap with a `vm.overcommit_ratio` of 30 it would
- // yield a CommitLimit of 7.3G.
- // For more details, see the memory overcommit documentation
- // in vm/overcommit-accounting.
- CommitLimit *uint64
- // The amount of memory presently allocated on the system.
- // The committed memory is a sum of all of the memory which
- // has been allocated by processes, even if it has not been
- // "used" by them as of yet. A process which malloc()'s 1G
- // of memory, but only touches 300M of it will show up as
- // using 1G. This 1G is memory which has been "committed" to
- // by the VM and can be used at any time by the allocating
- // application. With strict overcommit enabled on the system
- // (mode 2 in 'vm.overcommit_memory'),allocations which would
- // exceed the CommitLimit (detailed above) will not be permitted.
- // This is useful if one needs to guarantee that processes will
- // not fail due to lack of memory once that memory has been
- // successfully allocated.
- CommittedAS *uint64
- // total size of vmalloc memory area
- VmallocTotal *uint64
- // amount of vmalloc area which is used
- VmallocUsed *uint64
- // largest contiguous block of vmalloc area which is free
- VmallocChunk *uint64
- Percpu *uint64
- HardwareCorrupted *uint64
- AnonHugePages *uint64
- ShmemHugePages *uint64
- ShmemPmdMapped *uint64
- CmaTotal *uint64
- CmaFree *uint64
- HugePagesTotal *uint64
- HugePagesFree *uint64
- HugePagesRsvd *uint64
- HugePagesSurp *uint64
- Hugepagesize *uint64
- DirectMap4k *uint64
- DirectMap2M *uint64
- DirectMap1G *uint64
-
- // The struct fields below are the byte-normalized counterparts to the
- // existing struct fields. Values are normalized using the optional
- // unit field in the meminfo line.
- MemTotalBytes *uint64
- MemFreeBytes *uint64
- MemAvailableBytes *uint64
- BuffersBytes *uint64
- CachedBytes *uint64
- SwapCachedBytes *uint64
- ActiveBytes *uint64
- InactiveBytes *uint64
- ActiveAnonBytes *uint64
- InactiveAnonBytes *uint64
- ActiveFileBytes *uint64
- InactiveFileBytes *uint64
- UnevictableBytes *uint64
- MlockedBytes *uint64
- SwapTotalBytes *uint64
- SwapFreeBytes *uint64
- DirtyBytes *uint64
- WritebackBytes *uint64
- AnonPagesBytes *uint64
- MappedBytes *uint64
- ShmemBytes *uint64
- SlabBytes *uint64
- SReclaimableBytes *uint64
- SUnreclaimBytes *uint64
- KernelStackBytes *uint64
- PageTablesBytes *uint64
- NFSUnstableBytes *uint64
- BounceBytes *uint64
- WritebackTmpBytes *uint64
- CommitLimitBytes *uint64
- CommittedASBytes *uint64
- VmallocTotalBytes *uint64
- VmallocUsedBytes *uint64
- VmallocChunkBytes *uint64
- PercpuBytes *uint64
- HardwareCorruptedBytes *uint64
- AnonHugePagesBytes *uint64
- ShmemHugePagesBytes *uint64
- ShmemPmdMappedBytes *uint64
- CmaTotalBytes *uint64
- CmaFreeBytes *uint64
- HugepagesizeBytes *uint64
- DirectMap4kBytes *uint64
- DirectMap2MBytes *uint64
- DirectMap1GBytes *uint64
-}
-
-// Meminfo returns an information about current kernel/system memory statistics.
-// See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
-func (fs FS) Meminfo() (Meminfo, error) {
- b, err := util.ReadFileNoStat(fs.proc.Path("meminfo"))
- if err != nil {
- return Meminfo{}, err
- }
-
- m, err := parseMemInfo(bytes.NewReader(b))
- if err != nil {
- return Meminfo{}, fmt.Errorf("%w: %w", ErrFileParse, err)
- }
-
- return *m, nil
-}
-
-func parseMemInfo(r io.Reader) (*Meminfo, error) {
- var m Meminfo
- s := bufio.NewScanner(r)
- for s.Scan() {
- fields := strings.Fields(s.Text())
- var val, valBytes uint64
-
- val, err := strconv.ParseUint(fields[1], 0, 64)
- if err != nil {
- return nil, err
- }
-
- switch len(fields) {
- case 2:
- // No unit present, use the parsed the value as bytes directly.
- valBytes = val
- case 3:
- // Unit present in optional 3rd field, convert it to
- // bytes. The only unit supported within the Linux
- // kernel is `kB`.
- if fields[2] != "kB" {
- return nil, fmt.Errorf("%w: Unsupported unit in optional 3rd field %q", ErrFileParse, fields[2])
- }
-
- valBytes = 1024 * val
-
- default:
- return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, s.Text())
- }
-
- switch fields[0] {
- case "MemTotal:":
- m.MemTotal = &val
- m.MemTotalBytes = &valBytes
- case "MemFree:":
- m.MemFree = &val
- m.MemFreeBytes = &valBytes
- case "MemAvailable:":
- m.MemAvailable = &val
- m.MemAvailableBytes = &valBytes
- case "Buffers:":
- m.Buffers = &val
- m.BuffersBytes = &valBytes
- case "Cached:":
- m.Cached = &val
- m.CachedBytes = &valBytes
- case "SwapCached:":
- m.SwapCached = &val
- m.SwapCachedBytes = &valBytes
- case "Active:":
- m.Active = &val
- m.ActiveBytes = &valBytes
- case "Inactive:":
- m.Inactive = &val
- m.InactiveBytes = &valBytes
- case "Active(anon):":
- m.ActiveAnon = &val
- m.ActiveAnonBytes = &valBytes
- case "Inactive(anon):":
- m.InactiveAnon = &val
- m.InactiveAnonBytes = &valBytes
- case "Active(file):":
- m.ActiveFile = &val
- m.ActiveFileBytes = &valBytes
- case "Inactive(file):":
- m.InactiveFile = &val
- m.InactiveFileBytes = &valBytes
- case "Unevictable:":
- m.Unevictable = &val
- m.UnevictableBytes = &valBytes
- case "Mlocked:":
- m.Mlocked = &val
- m.MlockedBytes = &valBytes
- case "SwapTotal:":
- m.SwapTotal = &val
- m.SwapTotalBytes = &valBytes
- case "SwapFree:":
- m.SwapFree = &val
- m.SwapFreeBytes = &valBytes
- case "Dirty:":
- m.Dirty = &val
- m.DirtyBytes = &valBytes
- case "Writeback:":
- m.Writeback = &val
- m.WritebackBytes = &valBytes
- case "AnonPages:":
- m.AnonPages = &val
- m.AnonPagesBytes = &valBytes
- case "Mapped:":
- m.Mapped = &val
- m.MappedBytes = &valBytes
- case "Shmem:":
- m.Shmem = &val
- m.ShmemBytes = &valBytes
- case "Slab:":
- m.Slab = &val
- m.SlabBytes = &valBytes
- case "SReclaimable:":
- m.SReclaimable = &val
- m.SReclaimableBytes = &valBytes
- case "SUnreclaim:":
- m.SUnreclaim = &val
- m.SUnreclaimBytes = &valBytes
- case "KernelStack:":
- m.KernelStack = &val
- m.KernelStackBytes = &valBytes
- case "PageTables:":
- m.PageTables = &val
- m.PageTablesBytes = &valBytes
- case "NFS_Unstable:":
- m.NFSUnstable = &val
- m.NFSUnstableBytes = &valBytes
- case "Bounce:":
- m.Bounce = &val
- m.BounceBytes = &valBytes
- case "WritebackTmp:":
- m.WritebackTmp = &val
- m.WritebackTmpBytes = &valBytes
- case "CommitLimit:":
- m.CommitLimit = &val
- m.CommitLimitBytes = &valBytes
- case "Committed_AS:":
- m.CommittedAS = &val
- m.CommittedASBytes = &valBytes
- case "VmallocTotal:":
- m.VmallocTotal = &val
- m.VmallocTotalBytes = &valBytes
- case "VmallocUsed:":
- m.VmallocUsed = &val
- m.VmallocUsedBytes = &valBytes
- case "VmallocChunk:":
- m.VmallocChunk = &val
- m.VmallocChunkBytes = &valBytes
- case "Percpu:":
- m.Percpu = &val
- m.PercpuBytes = &valBytes
- case "HardwareCorrupted:":
- m.HardwareCorrupted = &val
- m.HardwareCorruptedBytes = &valBytes
- case "AnonHugePages:":
- m.AnonHugePages = &val
- m.AnonHugePagesBytes = &valBytes
- case "ShmemHugePages:":
- m.ShmemHugePages = &val
- m.ShmemHugePagesBytes = &valBytes
- case "ShmemPmdMapped:":
- m.ShmemPmdMapped = &val
- m.ShmemPmdMappedBytes = &valBytes
- case "CmaTotal:":
- m.CmaTotal = &val
- m.CmaTotalBytes = &valBytes
- case "CmaFree:":
- m.CmaFree = &val
- m.CmaFreeBytes = &valBytes
- case "HugePages_Total:":
- m.HugePagesTotal = &val
- case "HugePages_Free:":
- m.HugePagesFree = &val
- case "HugePages_Rsvd:":
- m.HugePagesRsvd = &val
- case "HugePages_Surp:":
- m.HugePagesSurp = &val
- case "Hugepagesize:":
- m.Hugepagesize = &val
- m.HugepagesizeBytes = &valBytes
- case "DirectMap4k:":
- m.DirectMap4k = &val
- m.DirectMap4kBytes = &valBytes
- case "DirectMap2M:":
- m.DirectMap2M = &val
- m.DirectMap2MBytes = &valBytes
- case "DirectMap1G:":
- m.DirectMap1G = &val
- m.DirectMap1GBytes = &valBytes
- }
- }
-
- return &m, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/mountinfo.go b/vendor/github.com/prometheus/procfs/mountinfo.go
deleted file mode 100644
index a704c5e..0000000
--- a/vendor/github.com/prometheus/procfs/mountinfo.go
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// A MountInfo is a type that describes the details, options
-// for each mount, parsed from /proc/self/mountinfo.
-// The fields described in each entry of /proc/self/mountinfo
-// is described in the following man page.
-// http://man7.org/linux/man-pages/man5/proc.5.html
-type MountInfo struct {
- // Unique ID for the mount
- MountID int
- // The ID of the parent mount
- ParentID int
- // The value of `st_dev` for the files on this FS
- MajorMinorVer string
- // The pathname of the directory in the FS that forms
- // the root for this mount
- Root string
- // The pathname of the mount point relative to the root
- MountPoint string
- // Mount options
- Options map[string]string
- // Zero or more optional fields
- OptionalFields map[string]string
- // The Filesystem type
- FSType string
- // FS specific information or "none"
- Source string
- // Superblock options
- SuperOptions map[string]string
-}
-
-// Reads each line of the mountinfo file, and returns a list of formatted MountInfo structs.
-func parseMountInfo(info []byte) ([]*MountInfo, error) {
- mounts := []*MountInfo{}
- scanner := bufio.NewScanner(bytes.NewReader(info))
- for scanner.Scan() {
- mountString := scanner.Text()
- parsedMounts, err := parseMountInfoString(mountString)
- if err != nil {
- return nil, err
- }
- mounts = append(mounts, parsedMounts)
- }
-
- err := scanner.Err()
- return mounts, err
-}
-
-// Parses a mountinfo file line, and converts it to a MountInfo struct.
-// An important check here is to see if the hyphen separator, as if it does not exist,
-// it means that the line is malformed.
-func parseMountInfoString(mountString string) (*MountInfo, error) {
- var err error
-
- mountInfo := strings.Split(mountString, " ")
- mountInfoLength := len(mountInfo)
- if mountInfoLength < 10 {
- return nil, fmt.Errorf("%w: Too few fields in mount string: %s", ErrFileParse, mountString)
- }
-
- if mountInfo[mountInfoLength-4] != "-" {
- return nil, fmt.Errorf("%w: couldn't find separator in expected field: %s", ErrFileParse, mountInfo[mountInfoLength-4])
- }
-
- mount := &MountInfo{
- MajorMinorVer: mountInfo[2],
- Root: mountInfo[3],
- MountPoint: mountInfo[4],
- Options: mountOptionsParser(mountInfo[5]),
- OptionalFields: nil,
- FSType: mountInfo[mountInfoLength-3],
- Source: mountInfo[mountInfoLength-2],
- SuperOptions: mountOptionsParser(mountInfo[mountInfoLength-1]),
- }
-
- mount.MountID, err = strconv.Atoi(mountInfo[0])
- if err != nil {
- return nil, fmt.Errorf("%w: mount ID: %q", ErrFileParse, mount.MountID)
- }
- mount.ParentID, err = strconv.Atoi(mountInfo[1])
- if err != nil {
- return nil, fmt.Errorf("%w: parent ID: %q", ErrFileParse, mount.ParentID)
- }
- // Has optional fields, which is a space separated list of values.
- // Example: shared:2 master:7
- if mountInfo[6] != "" {
- mount.OptionalFields, err = mountOptionsParseOptionalFields(mountInfo[6 : mountInfoLength-4])
- if err != nil {
- return nil, fmt.Errorf("%w: %w", ErrFileParse, err)
- }
- }
- return mount, nil
-}
-
-// mountOptionsIsValidField checks a string against a valid list of optional fields keys.
-func mountOptionsIsValidField(s string) bool {
- switch s {
- case
- "shared",
- "master",
- "propagate_from",
- "unbindable":
- return true
- }
- return false
-}
-
-// mountOptionsParseOptionalFields parses a list of optional fields strings into a double map of strings.
-func mountOptionsParseOptionalFields(o []string) (map[string]string, error) {
- optionalFields := make(map[string]string)
- for _, field := range o {
- optionSplit := strings.SplitN(field, ":", 2)
- value := ""
- if len(optionSplit) == 2 {
- value = optionSplit[1]
- }
- if mountOptionsIsValidField(optionSplit[0]) {
- optionalFields[optionSplit[0]] = value
- }
- }
- return optionalFields, nil
-}
-
-// mountOptionsParser parses the mount options, superblock options.
-func mountOptionsParser(mountOptions string) map[string]string {
- opts := make(map[string]string)
- options := strings.Split(mountOptions, ",")
- for _, opt := range options {
- splitOption := strings.Split(opt, "=")
- if len(splitOption) < 2 {
- key := splitOption[0]
- opts[key] = ""
- } else {
- key, value := splitOption[0], splitOption[1]
- opts[key] = value
- }
- }
- return opts
-}
-
-// GetMounts retrieves mountinfo information from `/proc/self/mountinfo`.
-func GetMounts() ([]*MountInfo, error) {
- data, err := util.ReadFileNoStat("/proc/self/mountinfo")
- if err != nil {
- return nil, err
- }
- return parseMountInfo(data)
-}
-
-// GetProcMounts retrieves mountinfo information from a processes' `/proc//mountinfo`.
-func GetProcMounts(pid int) ([]*MountInfo, error) {
- data, err := util.ReadFileNoStat(fmt.Sprintf("/proc/%d/mountinfo", pid))
- if err != nil {
- return nil, err
- }
- return parseMountInfo(data)
-}
diff --git a/vendor/github.com/prometheus/procfs/mountstats.go b/vendor/github.com/prometheus/procfs/mountstats.go
deleted file mode 100644
index 75a3b6c..0000000
--- a/vendor/github.com/prometheus/procfs/mountstats.go
+++ /dev/null
@@ -1,707 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-// While implementing parsing of /proc/[pid]/mountstats, this blog was used
-// heavily as a reference:
-// https://utcc.utoronto.ca/~cks/space/blog/linux/NFSMountstatsIndex
-//
-// Special thanks to Chris Siebenmann for all of his posts explaining the
-// various statistics available for NFS.
-
-import (
- "bufio"
- "fmt"
- "io"
- "strconv"
- "strings"
- "time"
-)
-
-// Constants shared between multiple functions.
-const (
- deviceEntryLen = 8
-
- fieldBytesLen = 8
- fieldEventsLen = 27
-
- statVersion10 = "1.0"
- statVersion11 = "1.1"
-
- fieldTransport10TCPLen = 10
- fieldTransport10UDPLen = 7
-
- fieldTransport11TCPLen = 13
- fieldTransport11UDPLen = 10
-
- // kernel version >= 4.14 MaxLen
- // See: https://elixir.bootlin.com/linux/v6.4.8/source/net/sunrpc/xprtrdma/xprt_rdma.h#L393
- fieldTransport11RDMAMaxLen = 28
-
- // kernel version <= 4.2 MinLen
- // See: https://elixir.bootlin.com/linux/v4.2.8/source/net/sunrpc/xprtrdma/xprt_rdma.h#L331
- fieldTransport11RDMAMinLen = 20
-)
-
-// A Mount is a device mount parsed from /proc/[pid]/mountstats.
-type Mount struct {
- // Name of the device.
- Device string
- // The mount point of the device.
- Mount string
- // The filesystem type used by the device.
- Type string
- // If available additional statistics related to this Mount.
- // Use a type assertion to determine if additional statistics are available.
- Stats MountStats
-}
-
-// A MountStats is a type which contains detailed statistics for a specific
-// type of Mount.
-type MountStats interface {
- mountStats()
-}
-
-// A MountStatsNFS is a MountStats implementation for NFSv3 and v4 mounts.
-type MountStatsNFS struct {
- // The version of statistics provided.
- StatVersion string
- // The mount options of the NFS mount.
- Opts map[string]string
- // The age of the NFS mount.
- Age time.Duration
- // Statistics related to byte counters for various operations.
- Bytes NFSBytesStats
- // Statistics related to various NFS event occurrences.
- Events NFSEventsStats
- // Statistics broken down by filesystem operation.
- Operations []NFSOperationStats
- // Statistics about the NFS RPC transport.
- Transport []NFSTransportStats
-}
-
-// mountStats implements MountStats.
-func (m MountStatsNFS) mountStats() {}
-
-// A NFSBytesStats contains statistics about the number of bytes read and written
-// by an NFS client to and from an NFS server.
-type NFSBytesStats struct {
- // Number of bytes read using the read() syscall.
- Read uint64
- // Number of bytes written using the write() syscall.
- Write uint64
- // Number of bytes read using the read() syscall in O_DIRECT mode.
- DirectRead uint64
- // Number of bytes written using the write() syscall in O_DIRECT mode.
- DirectWrite uint64
- // Number of bytes read from the NFS server, in total.
- ReadTotal uint64
- // Number of bytes written to the NFS server, in total.
- WriteTotal uint64
- // Number of pages read directly via mmap()'d files.
- ReadPages uint64
- // Number of pages written directly via mmap()'d files.
- WritePages uint64
-}
-
-// A NFSEventsStats contains statistics about NFS event occurrences.
-type NFSEventsStats struct {
- // Number of times cached inode attributes are re-validated from the server.
- InodeRevalidate uint64
- // Number of times cached dentry nodes are re-validated from the server.
- DnodeRevalidate uint64
- // Number of times an inode cache is cleared.
- DataInvalidate uint64
- // Number of times cached inode attributes are invalidated.
- AttributeInvalidate uint64
- // Number of times files or directories have been open()'d.
- VFSOpen uint64
- // Number of times a directory lookup has occurred.
- VFSLookup uint64
- // Number of times permissions have been checked.
- VFSAccess uint64
- // Number of updates (and potential writes) to pages.
- VFSUpdatePage uint64
- // Number of pages read directly via mmap()'d files.
- VFSReadPage uint64
- // Number of times a group of pages have been read.
- VFSReadPages uint64
- // Number of pages written directly via mmap()'d files.
- VFSWritePage uint64
- // Number of times a group of pages have been written.
- VFSWritePages uint64
- // Number of times directory entries have been read with getdents().
- VFSGetdents uint64
- // Number of times attributes have been set on inodes.
- VFSSetattr uint64
- // Number of pending writes that have been forcefully flushed to the server.
- VFSFlush uint64
- // Number of times fsync() has been called on directories and files.
- VFSFsync uint64
- // Number of times locking has been attempted on a file.
- VFSLock uint64
- // Number of times files have been closed and released.
- VFSFileRelease uint64
- // Unknown. Possibly unused.
- CongestionWait uint64
- // Number of times files have been truncated.
- Truncation uint64
- // Number of times a file has been grown due to writes beyond its existing end.
- WriteExtension uint64
- // Number of times a file was removed while still open by another process.
- SillyRename uint64
- // Number of times the NFS server gave less data than expected while reading.
- ShortRead uint64
- // Number of times the NFS server wrote less data than expected while writing.
- ShortWrite uint64
- // Number of times the NFS server indicated EJUKEBOX; retrieving data from
- // offline storage.
- JukeboxDelay uint64
- // Number of NFS v4.1+ pNFS reads.
- PNFSRead uint64
- // Number of NFS v4.1+ pNFS writes.
- PNFSWrite uint64
-}
-
-// A NFSOperationStats contains statistics for a single operation.
-type NFSOperationStats struct {
- // The name of the operation.
- Operation string
- // Number of requests performed for this operation.
- Requests uint64
- // Number of times an actual RPC request has been transmitted for this operation.
- Transmissions uint64
- // Number of times a request has had a major timeout.
- MajorTimeouts uint64
- // Number of bytes sent for this operation, including RPC headers and payload.
- BytesSent uint64
- // Number of bytes received for this operation, including RPC headers and payload.
- BytesReceived uint64
- // Duration all requests spent queued for transmission before they were sent.
- CumulativeQueueMilliseconds uint64
- // Duration it took to get a reply back after the request was transmitted.
- CumulativeTotalResponseMilliseconds uint64
- // Duration from when a request was enqueued to when it was completely handled.
- CumulativeTotalRequestMilliseconds uint64
- // The count of operations that complete with tk_status < 0. These statuses usually indicate error conditions.
- Errors uint64
-}
-
-// A NFSTransportStats contains statistics for the NFS mount RPC requests and
-// responses.
-type NFSTransportStats struct {
- // The transport protocol used for the NFS mount.
- Protocol string
- // The local port used for the NFS mount.
- Port uint64
- // Number of times the client has had to establish a connection from scratch
- // to the NFS server.
- Bind uint64
- // Number of times the client has made a TCP connection to the NFS server.
- Connect uint64
- // Duration (in jiffies, a kernel internal unit of time) the NFS mount has
- // spent waiting for connections to the server to be established.
- ConnectIdleTime uint64
- // Duration since the NFS mount last saw any RPC traffic.
- IdleTimeSeconds uint64
- // Number of RPC requests for this mount sent to the NFS server.
- Sends uint64
- // Number of RPC responses for this mount received from the NFS server.
- Receives uint64
- // Number of times the NFS server sent a response with a transaction ID
- // unknown to this client.
- BadTransactionIDs uint64
- // A running counter, incremented on each request as the current difference
- // ebetween sends and receives.
- CumulativeActiveRequests uint64
- // A running counter, incremented on each request by the current backlog
- // queue size.
- CumulativeBacklog uint64
-
- // Stats below only available with stat version 1.1.
-
- // Maximum number of simultaneously active RPC requests ever used.
- MaximumRPCSlotsUsed uint64
- // A running counter, incremented on each request as the current size of the
- // sending queue.
- CumulativeSendingQueue uint64
- // A running counter, incremented on each request as the current size of the
- // pending queue.
- CumulativePendingQueue uint64
-
- // Stats below only available with stat version 1.1.
- // Transport over RDMA
-
- // accessed when sending a call
- ReadChunkCount uint64
- WriteChunkCount uint64
- ReplyChunkCount uint64
- TotalRdmaRequest uint64
-
- // rarely accessed error counters
- PullupCopyCount uint64
- HardwayRegisterCount uint64
- FailedMarshalCount uint64
- BadReplyCount uint64
- MrsRecovered uint64
- MrsOrphaned uint64
- MrsAllocated uint64
- EmptySendctxQ uint64
-
- // accessed when receiving a reply
- TotalRdmaReply uint64
- FixupCopyCount uint64
- ReplyWaitsForSend uint64
- LocalInvNeeded uint64
- NomsgCallCount uint64
- BcallCount uint64
-}
-
-// parseMountStats parses a /proc/[pid]/mountstats file and returns a slice
-// of Mount structures containing detailed information about each mount.
-// If available, statistics for each mount are parsed as well.
-func parseMountStats(r io.Reader) ([]*Mount, error) {
- const (
- device = "device"
- statVersionPrefix = "statvers="
-
- nfs3Type = "nfs"
- nfs4Type = "nfs4"
- )
-
- var mounts []*Mount
-
- s := bufio.NewScanner(r)
- for s.Scan() {
- // Only look for device entries in this function
- ss := strings.Fields(string(s.Bytes()))
- if len(ss) == 0 || ss[0] != device {
- continue
- }
-
- m, err := parseMount(ss)
- if err != nil {
- return nil, err
- }
-
- // Does this mount also possess statistics information?
- if len(ss) > deviceEntryLen {
- // Only NFSv3 and v4 are supported for parsing statistics
- if m.Type != nfs3Type && m.Type != nfs4Type {
- return nil, fmt.Errorf("%w: Cannot parse MountStats for %q", ErrFileParse, m.Type)
- }
-
- statVersion := strings.TrimPrefix(ss[8], statVersionPrefix)
-
- stats, err := parseMountStatsNFS(s, statVersion)
- if err != nil {
- return nil, err
- }
-
- m.Stats = stats
- }
-
- mounts = append(mounts, m)
- }
-
- return mounts, s.Err()
-}
-
-// parseMount parses an entry in /proc/[pid]/mountstats in the format:
-//
-// device [device] mounted on [mount] with fstype [type]
-func parseMount(ss []string) (*Mount, error) {
- if len(ss) < deviceEntryLen {
- return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss)
- }
-
- // Check for specific words appearing at specific indices to ensure
- // the format is consistent with what we expect
- format := []struct {
- i int
- s string
- }{
- {i: 0, s: "device"},
- {i: 2, s: "mounted"},
- {i: 3, s: "on"},
- {i: 5, s: "with"},
- {i: 6, s: "fstype"},
- }
-
- for _, f := range format {
- if ss[f.i] != f.s {
- return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss)
- }
- }
-
- return &Mount{
- Device: ss[1],
- Mount: ss[4],
- Type: ss[7],
- }, nil
-}
-
-// parseMountStatsNFS parses a MountStatsNFS by scanning additional information
-// related to NFS statistics.
-func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, error) {
- // Field indicators for parsing specific types of data
- const (
- fieldOpts = "opts:"
- fieldAge = "age:"
- fieldBytes = "bytes:"
- fieldEvents = "events:"
- fieldPerOpStats = "per-op"
- fieldTransport = "xprt:"
- )
-
- stats := &MountStatsNFS{
- StatVersion: statVersion,
- }
-
- for s.Scan() {
- ss := strings.Fields(string(s.Bytes()))
- if len(ss) == 0 {
- break
- }
-
- switch ss[0] {
- case fieldOpts:
- if len(ss) < 2 {
- return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss)
- }
- if stats.Opts == nil {
- stats.Opts = map[string]string{}
- }
- for _, opt := range strings.Split(ss[1], ",") {
- split := strings.Split(opt, "=")
- if len(split) == 2 {
- stats.Opts[split[0]] = split[1]
- } else {
- stats.Opts[opt] = ""
- }
- }
- case fieldAge:
- if len(ss) < 2 {
- return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss)
- }
- // Age integer is in seconds
- d, err := time.ParseDuration(ss[1] + "s")
- if err != nil {
- return nil, err
- }
-
- stats.Age = d
- case fieldBytes:
- if len(ss) < 2 {
- return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss)
- }
- bstats, err := parseNFSBytesStats(ss[1:])
- if err != nil {
- return nil, err
- }
-
- stats.Bytes = *bstats
- case fieldEvents:
- if len(ss) < 2 {
- return nil, fmt.Errorf("%w: Incomplete information for NFS events: %v", ErrFileParse, ss)
- }
- estats, err := parseNFSEventsStats(ss[1:])
- if err != nil {
- return nil, err
- }
-
- stats.Events = *estats
- case fieldTransport:
- if len(ss) < 3 {
- return nil, fmt.Errorf("%w: Incomplete information for NFS transport stats: %v", ErrFileParse, ss)
- }
-
- tstats, err := parseNFSTransportStats(ss[1:], statVersion)
- if err != nil {
- return nil, err
- }
-
- stats.Transport = append(stats.Transport, *tstats)
- }
-
- // When encountering "per-operation statistics", we must break this
- // loop and parse them separately to ensure we can terminate parsing
- // before reaching another device entry; hence why this 'if' statement
- // is not just another switch case
- if ss[0] == fieldPerOpStats {
- break
- }
- }
-
- if err := s.Err(); err != nil {
- return nil, err
- }
-
- // NFS per-operation stats appear last before the next device entry
- perOpStats, err := parseNFSOperationStats(s)
- if err != nil {
- return nil, err
- }
-
- stats.Operations = perOpStats
-
- return stats, nil
-}
-
-// parseNFSBytesStats parses a NFSBytesStats line using an input set of
-// integer fields.
-func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) {
- if len(ss) != fieldBytesLen {
- return nil, fmt.Errorf("%w: Invalid NFS bytes stats: %v", ErrFileParse, ss)
- }
-
- ns := make([]uint64, 0, fieldBytesLen)
- for _, s := range ss {
- n, err := strconv.ParseUint(s, 10, 64)
- if err != nil {
- return nil, err
- }
-
- ns = append(ns, n)
- }
-
- return &NFSBytesStats{
- Read: ns[0],
- Write: ns[1],
- DirectRead: ns[2],
- DirectWrite: ns[3],
- ReadTotal: ns[4],
- WriteTotal: ns[5],
- ReadPages: ns[6],
- WritePages: ns[7],
- }, nil
-}
-
-// parseNFSEventsStats parses a NFSEventsStats line using an input set of
-// integer fields.
-func parseNFSEventsStats(ss []string) (*NFSEventsStats, error) {
- if len(ss) != fieldEventsLen {
- return nil, fmt.Errorf("%w: invalid NFS events stats: %v", ErrFileParse, ss)
- }
-
- ns := make([]uint64, 0, fieldEventsLen)
- for _, s := range ss {
- n, err := strconv.ParseUint(s, 10, 64)
- if err != nil {
- return nil, err
- }
-
- ns = append(ns, n)
- }
-
- return &NFSEventsStats{
- InodeRevalidate: ns[0],
- DnodeRevalidate: ns[1],
- DataInvalidate: ns[2],
- AttributeInvalidate: ns[3],
- VFSOpen: ns[4],
- VFSLookup: ns[5],
- VFSAccess: ns[6],
- VFSUpdatePage: ns[7],
- VFSReadPage: ns[8],
- VFSReadPages: ns[9],
- VFSWritePage: ns[10],
- VFSWritePages: ns[11],
- VFSGetdents: ns[12],
- VFSSetattr: ns[13],
- VFSFlush: ns[14],
- VFSFsync: ns[15],
- VFSLock: ns[16],
- VFSFileRelease: ns[17],
- CongestionWait: ns[18],
- Truncation: ns[19],
- WriteExtension: ns[20],
- SillyRename: ns[21],
- ShortRead: ns[22],
- ShortWrite: ns[23],
- JukeboxDelay: ns[24],
- PNFSRead: ns[25],
- PNFSWrite: ns[26],
- }, nil
-}
-
-// parseNFSOperationStats parses a slice of NFSOperationStats by scanning
-// additional information about per-operation statistics until an empty
-// line is reached.
-func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) {
- const (
- // Minimum number of expected fields in each per-operation statistics set
- minFields = 9
- )
-
- var ops []NFSOperationStats
-
- for s.Scan() {
- ss := strings.Fields(string(s.Bytes()))
- if len(ss) == 0 {
- // Must break when reading a blank line after per-operation stats to
- // enable top-level function to parse the next device entry
- break
- }
-
- if len(ss) < minFields {
- return nil, fmt.Errorf("%w: invalid NFS per-operations stats: %v", ErrFileParse, ss)
- }
-
- // Skip string operation name for integers
- ns := make([]uint64, 0, minFields-1)
- for _, st := range ss[1:] {
- n, err := strconv.ParseUint(st, 10, 64)
- if err != nil {
- return nil, err
- }
-
- ns = append(ns, n)
- }
- opStats := NFSOperationStats{
- Operation: strings.TrimSuffix(ss[0], ":"),
- Requests: ns[0],
- Transmissions: ns[1],
- MajorTimeouts: ns[2],
- BytesSent: ns[3],
- BytesReceived: ns[4],
- CumulativeQueueMilliseconds: ns[5],
- CumulativeTotalResponseMilliseconds: ns[6],
- CumulativeTotalRequestMilliseconds: ns[7],
- }
-
- if len(ns) > 8 {
- opStats.Errors = ns[8]
- }
-
- ops = append(ops, opStats)
- }
-
- return ops, s.Err()
-}
-
-// parseNFSTransportStats parses a NFSTransportStats line using an input set of
-// integer fields matched to a specific stats version.
-func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats, error) {
- // Extract the protocol field. It is the only string value in the line
- protocol := ss[0]
- ss = ss[1:]
-
- switch statVersion {
- case statVersion10:
- var expectedLength int
- if protocol == "tcp" {
- expectedLength = fieldTransport10TCPLen
- } else if protocol == "udp" {
- expectedLength = fieldTransport10UDPLen
- } else {
- return nil, fmt.Errorf("%w: Invalid NFS protocol \"%s\" in stats 1.0 statement: %v", ErrFileParse, protocol, ss)
- }
- if len(ss) != expectedLength {
- return nil, fmt.Errorf("%w: Invalid NFS transport stats 1.0 statement: %v", ErrFileParse, ss)
- }
- case statVersion11:
- var expectedLength int
- if protocol == "tcp" {
- expectedLength = fieldTransport11TCPLen
- } else if protocol == "udp" {
- expectedLength = fieldTransport11UDPLen
- } else if protocol == "rdma" {
- expectedLength = fieldTransport11RDMAMinLen
- } else {
- return nil, fmt.Errorf("%w: invalid NFS protocol \"%s\" in stats 1.1 statement: %v", ErrFileParse, protocol, ss)
- }
- if (len(ss) != expectedLength && (protocol == "tcp" || protocol == "udp")) ||
- (protocol == "rdma" && len(ss) < expectedLength) {
- return nil, fmt.Errorf("%w: invalid NFS transport stats 1.1 statement: %v, protocol: %v", ErrFileParse, ss, protocol)
- }
- default:
- return nil, fmt.Errorf("%w: Unrecognized NFS transport stats version: %q, protocol: %v", ErrFileParse, statVersion, protocol)
- }
-
- // Allocate enough for v1.1 stats since zero value for v1.1 stats will be okay
- // in a v1.0 response. Since the stat length is bigger for TCP stats, we use
- // the TCP length here.
- //
- // Note: slice length must be set to length of v1.1 stats to avoid a panic when
- // only v1.0 stats are present.
- // See: https://github.com/prometheus/node_exporter/issues/571.
- //
- // Note: NFS Over RDMA slice length is fieldTransport11RDMAMaxLen
- ns := make([]uint64, fieldTransport11RDMAMaxLen+3)
- for i, s := range ss {
- n, err := strconv.ParseUint(s, 10, 64)
- if err != nil {
- return nil, err
- }
-
- ns[i] = n
- }
-
- // The fields differ depending on the transport protocol (TCP or UDP)
- // From https://utcc.utoronto.ca/%7Ecks/space/blog/linux/NFSMountstatsXprt
- //
- // For the udp RPC transport there is no connection count, connect idle time,
- // or idle time (fields #3, #4, and #5); all other fields are the same. So
- // we set them to 0 here.
- if protocol == "udp" {
- ns = append(ns[:2], append(make([]uint64, 3), ns[2:]...)...)
- } else if protocol == "tcp" {
- ns = append(ns[:fieldTransport11TCPLen], make([]uint64, fieldTransport11RDMAMaxLen-fieldTransport11TCPLen+3)...)
- } else if protocol == "rdma" {
- ns = append(ns[:fieldTransport10TCPLen], append(make([]uint64, 3), ns[fieldTransport10TCPLen:]...)...)
- }
-
- return &NFSTransportStats{
- // NFS xprt over tcp or udp
- Protocol: protocol,
- Port: ns[0],
- Bind: ns[1],
- Connect: ns[2],
- ConnectIdleTime: ns[3],
- IdleTimeSeconds: ns[4],
- Sends: ns[5],
- Receives: ns[6],
- BadTransactionIDs: ns[7],
- CumulativeActiveRequests: ns[8],
- CumulativeBacklog: ns[9],
-
- // NFS xprt over tcp or udp
- // And statVersion 1.1
- MaximumRPCSlotsUsed: ns[10],
- CumulativeSendingQueue: ns[11],
- CumulativePendingQueue: ns[12],
-
- // NFS xprt over rdma
- // And stat Version 1.1
- ReadChunkCount: ns[13],
- WriteChunkCount: ns[14],
- ReplyChunkCount: ns[15],
- TotalRdmaRequest: ns[16],
- PullupCopyCount: ns[17],
- HardwayRegisterCount: ns[18],
- FailedMarshalCount: ns[19],
- BadReplyCount: ns[20],
- MrsRecovered: ns[21],
- MrsOrphaned: ns[22],
- MrsAllocated: ns[23],
- EmptySendctxQ: ns[24],
- TotalRdmaReply: ns[25],
- FixupCopyCount: ns[26],
- ReplyWaitsForSend: ns[27],
- LocalInvNeeded: ns[28],
- NomsgCallCount: ns[29],
- BcallCount: ns[30],
- }, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/net_conntrackstat.go b/vendor/github.com/prometheus/procfs/net_conntrackstat.go
deleted file mode 100644
index 316df5f..0000000
--- a/vendor/github.com/prometheus/procfs/net_conntrackstat.go
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// A ConntrackStatEntry represents one line from net/stat/nf_conntrack
-// and contains netfilter conntrack statistics at one CPU core.
-type ConntrackStatEntry struct {
- Entries uint64
- Searched uint64
- Found uint64
- New uint64
- Invalid uint64
- Ignore uint64
- Delete uint64
- DeleteList uint64
- Insert uint64
- InsertFailed uint64
- Drop uint64
- EarlyDrop uint64
- SearchRestart uint64
-}
-
-// ConntrackStat retrieves netfilter's conntrack statistics, split by CPU cores.
-func (fs FS) ConntrackStat() ([]ConntrackStatEntry, error) {
- return readConntrackStat(fs.proc.Path("net", "stat", "nf_conntrack"))
-}
-
-// Parses a slice of ConntrackStatEntries from the given filepath.
-func readConntrackStat(path string) ([]ConntrackStatEntry, error) {
- // This file is small and can be read with one syscall.
- b, err := util.ReadFileNoStat(path)
- if err != nil {
- // Do not wrap this error so the caller can detect os.IsNotExist and
- // similar conditions.
- return nil, err
- }
-
- stat, err := parseConntrackStat(bytes.NewReader(b))
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot read file: %v: %w", ErrFileRead, path, err)
- }
-
- return stat, nil
-}
-
-// Reads the contents of a conntrack statistics file and parses a slice of ConntrackStatEntries.
-func parseConntrackStat(r io.Reader) ([]ConntrackStatEntry, error) {
- var entries []ConntrackStatEntry
-
- scanner := bufio.NewScanner(r)
- scanner.Scan()
- for scanner.Scan() {
- fields := strings.Fields(scanner.Text())
- conntrackEntry, err := parseConntrackStatEntry(fields)
- if err != nil {
- return nil, err
- }
- entries = append(entries, *conntrackEntry)
- }
-
- return entries, nil
-}
-
-// Parses a ConntrackStatEntry from given array of fields.
-func parseConntrackStatEntry(fields []string) (*ConntrackStatEntry, error) {
- entries, err := util.ParseHexUint64s(fields)
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse entry: %d: %w", ErrFileParse, entries, err)
- }
- numEntries := len(entries)
- if numEntries < 16 || numEntries > 17 {
- return nil,
- fmt.Errorf("%w: invalid conntrackstat entry, invalid number of fields: %d", ErrFileParse, numEntries)
- }
-
- stats := &ConntrackStatEntry{
- Entries: *entries[0],
- Searched: *entries[1],
- Found: *entries[2],
- New: *entries[3],
- Invalid: *entries[4],
- Ignore: *entries[5],
- Delete: *entries[6],
- DeleteList: *entries[7],
- Insert: *entries[8],
- InsertFailed: *entries[9],
- Drop: *entries[10],
- EarlyDrop: *entries[11],
- }
-
- // Ignore missing search_restart on Linux < 2.6.35.
- if numEntries == 17 {
- stats.SearchRestart = *entries[16]
- }
-
- return stats, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/net_dev.go b/vendor/github.com/prometheus/procfs/net_dev.go
deleted file mode 100644
index e66208a..0000000
--- a/vendor/github.com/prometheus/procfs/net_dev.go
+++ /dev/null
@@ -1,205 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "errors"
- "os"
- "sort"
- "strconv"
- "strings"
-)
-
-// NetDevLine is single line parsed from /proc/net/dev or /proc/[pid]/net/dev.
-type NetDevLine struct {
- Name string `json:"name"` // The name of the interface.
- RxBytes uint64 `json:"rx_bytes"` // Cumulative count of bytes received.
- RxPackets uint64 `json:"rx_packets"` // Cumulative count of packets received.
- RxErrors uint64 `json:"rx_errors"` // Cumulative count of receive errors encountered.
- RxDropped uint64 `json:"rx_dropped"` // Cumulative count of packets dropped while receiving.
- RxFIFO uint64 `json:"rx_fifo"` // Cumulative count of FIFO buffer errors.
- RxFrame uint64 `json:"rx_frame"` // Cumulative count of packet framing errors.
- RxCompressed uint64 `json:"rx_compressed"` // Cumulative count of compressed packets received by the device driver.
- RxMulticast uint64 `json:"rx_multicast"` // Cumulative count of multicast frames received by the device driver.
- TxBytes uint64 `json:"tx_bytes"` // Cumulative count of bytes transmitted.
- TxPackets uint64 `json:"tx_packets"` // Cumulative count of packets transmitted.
- TxErrors uint64 `json:"tx_errors"` // Cumulative count of transmit errors encountered.
- TxDropped uint64 `json:"tx_dropped"` // Cumulative count of packets dropped while transmitting.
- TxFIFO uint64 `json:"tx_fifo"` // Cumulative count of FIFO buffer errors.
- TxCollisions uint64 `json:"tx_collisions"` // Cumulative count of collisions detected on the interface.
- TxCarrier uint64 `json:"tx_carrier"` // Cumulative count of carrier losses detected by the device driver.
- TxCompressed uint64 `json:"tx_compressed"` // Cumulative count of compressed packets transmitted by the device driver.
-}
-
-// NetDev is parsed from /proc/net/dev or /proc/[pid]/net/dev. The map keys
-// are interface names.
-type NetDev map[string]NetDevLine
-
-// NetDev returns kernel/system statistics read from /proc/net/dev.
-func (fs FS) NetDev() (NetDev, error) {
- return newNetDev(fs.proc.Path("net/dev"))
-}
-
-// NetDev returns kernel/system statistics read from /proc/[pid]/net/dev.
-func (p Proc) NetDev() (NetDev, error) {
- return newNetDev(p.path("net/dev"))
-}
-
-// newNetDev creates a new NetDev from the contents of the given file.
-func newNetDev(file string) (NetDev, error) {
- f, err := os.Open(file)
- if err != nil {
- return NetDev{}, err
- }
- defer f.Close()
-
- netDev := NetDev{}
- s := bufio.NewScanner(f)
- for n := 0; s.Scan(); n++ {
- // Skip the 2 header lines.
- if n < 2 {
- continue
- }
-
- line, err := netDev.parseLine(s.Text())
- if err != nil {
- return netDev, err
- }
-
- netDev[line.Name] = *line
- }
-
- return netDev, s.Err()
-}
-
-// parseLine parses a single line from the /proc/net/dev file. Header lines
-// must be filtered prior to calling this method.
-func (netDev NetDev) parseLine(rawLine string) (*NetDevLine, error) {
- idx := strings.LastIndex(rawLine, ":")
- if idx == -1 {
- return nil, errors.New("invalid net/dev line, missing colon")
- }
- fields := strings.Fields(strings.TrimSpace(rawLine[idx+1:]))
-
- var err error
- line := &NetDevLine{}
-
- // Interface Name
- line.Name = strings.TrimSpace(rawLine[:idx])
- if line.Name == "" {
- return nil, errors.New("invalid net/dev line, empty interface name")
- }
-
- // RX
- line.RxBytes, err = strconv.ParseUint(fields[0], 10, 64)
- if err != nil {
- return nil, err
- }
- line.RxPackets, err = strconv.ParseUint(fields[1], 10, 64)
- if err != nil {
- return nil, err
- }
- line.RxErrors, err = strconv.ParseUint(fields[2], 10, 64)
- if err != nil {
- return nil, err
- }
- line.RxDropped, err = strconv.ParseUint(fields[3], 10, 64)
- if err != nil {
- return nil, err
- }
- line.RxFIFO, err = strconv.ParseUint(fields[4], 10, 64)
- if err != nil {
- return nil, err
- }
- line.RxFrame, err = strconv.ParseUint(fields[5], 10, 64)
- if err != nil {
- return nil, err
- }
- line.RxCompressed, err = strconv.ParseUint(fields[6], 10, 64)
- if err != nil {
- return nil, err
- }
- line.RxMulticast, err = strconv.ParseUint(fields[7], 10, 64)
- if err != nil {
- return nil, err
- }
-
- // TX
- line.TxBytes, err = strconv.ParseUint(fields[8], 10, 64)
- if err != nil {
- return nil, err
- }
- line.TxPackets, err = strconv.ParseUint(fields[9], 10, 64)
- if err != nil {
- return nil, err
- }
- line.TxErrors, err = strconv.ParseUint(fields[10], 10, 64)
- if err != nil {
- return nil, err
- }
- line.TxDropped, err = strconv.ParseUint(fields[11], 10, 64)
- if err != nil {
- return nil, err
- }
- line.TxFIFO, err = strconv.ParseUint(fields[12], 10, 64)
- if err != nil {
- return nil, err
- }
- line.TxCollisions, err = strconv.ParseUint(fields[13], 10, 64)
- if err != nil {
- return nil, err
- }
- line.TxCarrier, err = strconv.ParseUint(fields[14], 10, 64)
- if err != nil {
- return nil, err
- }
- line.TxCompressed, err = strconv.ParseUint(fields[15], 10, 64)
- if err != nil {
- return nil, err
- }
-
- return line, nil
-}
-
-// Total aggregates the values across interfaces and returns a new NetDevLine.
-// The Name field will be a sorted comma separated list of interface names.
-func (netDev NetDev) Total() NetDevLine {
- total := NetDevLine{}
-
- names := make([]string, 0, len(netDev))
- for _, ifc := range netDev {
- names = append(names, ifc.Name)
- total.RxBytes += ifc.RxBytes
- total.RxPackets += ifc.RxPackets
- total.RxErrors += ifc.RxErrors
- total.RxDropped += ifc.RxDropped
- total.RxFIFO += ifc.RxFIFO
- total.RxFrame += ifc.RxFrame
- total.RxCompressed += ifc.RxCompressed
- total.RxMulticast += ifc.RxMulticast
- total.TxBytes += ifc.TxBytes
- total.TxPackets += ifc.TxPackets
- total.TxErrors += ifc.TxErrors
- total.TxDropped += ifc.TxDropped
- total.TxFIFO += ifc.TxFIFO
- total.TxCollisions += ifc.TxCollisions
- total.TxCarrier += ifc.TxCarrier
- total.TxCompressed += ifc.TxCompressed
- }
- sort.Strings(names)
- total.Name = strings.Join(names, ", ")
-
- return total
-}
diff --git a/vendor/github.com/prometheus/procfs/net_ip_socket.go b/vendor/github.com/prometheus/procfs/net_ip_socket.go
deleted file mode 100644
index b70f1fc..0000000
--- a/vendor/github.com/prometheus/procfs/net_ip_socket.go
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "encoding/hex"
- "fmt"
- "io"
- "net"
- "os"
- "strconv"
- "strings"
-)
-
-const (
- // readLimit is used by io.LimitReader while reading the content of the
- // /proc/net/udp{,6} files. The number of lines inside such a file is dynamic
- // as each line represents a single used socket.
- // In theory, the number of available sockets is 65535 (2^16 - 1) per IP.
- // With e.g. 150 Byte per line and the maximum number of 65535,
- // the reader needs to handle 150 Byte * 65535 =~ 10 MB for a single IP.
- readLimit = 4294967296 // Byte -> 4 GiB
-)
-
-// This contains generic data structures for both udp and tcp sockets.
-type (
- // NetIPSocket represents the contents of /proc/net/{t,u}dp{,6} file without the header.
- NetIPSocket []*netIPSocketLine
-
- // NetIPSocketSummary provides already computed values like the total queue lengths or
- // the total number of used sockets. In contrast to NetIPSocket it does not collect
- // the parsed lines into a slice.
- NetIPSocketSummary struct {
- // TxQueueLength shows the total queue length of all parsed tx_queue lengths.
- TxQueueLength uint64
- // RxQueueLength shows the total queue length of all parsed rx_queue lengths.
- RxQueueLength uint64
- // UsedSockets shows the total number of parsed lines representing the
- // number of used sockets.
- UsedSockets uint64
- // Drops shows the total number of dropped packets of all UPD sockets.
- Drops *uint64
- }
-
- // netIPSocketLine represents the fields parsed from a single line
- // in /proc/net/{t,u}dp{,6}. Fields which are not used by IPSocket are skipped.
- // Drops is non-nil for udp{,6}, but nil for tcp{,6}.
- // For the proc file format details, see https://linux.die.net/man/5/proc.
- netIPSocketLine struct {
- Sl uint64
- LocalAddr net.IP
- LocalPort uint64
- RemAddr net.IP
- RemPort uint64
- St uint64
- TxQueue uint64
- RxQueue uint64
- UID uint64
- Inode uint64
- Drops *uint64
- }
-)
-
-func newNetIPSocket(file string) (NetIPSocket, error) {
- f, err := os.Open(file)
- if err != nil {
- return nil, err
- }
- defer f.Close()
-
- var netIPSocket NetIPSocket
- isUDP := strings.Contains(file, "udp")
-
- lr := io.LimitReader(f, readLimit)
- s := bufio.NewScanner(lr)
- s.Scan() // skip first line with headers
- for s.Scan() {
- fields := strings.Fields(s.Text())
- line, err := parseNetIPSocketLine(fields, isUDP)
- if err != nil {
- return nil, err
- }
- netIPSocket = append(netIPSocket, line)
- }
- if err := s.Err(); err != nil {
- return nil, err
- }
- return netIPSocket, nil
-}
-
-// newNetIPSocketSummary creates a new NetIPSocket{,6} from the contents of the given file.
-func newNetIPSocketSummary(file string) (*NetIPSocketSummary, error) {
- f, err := os.Open(file)
- if err != nil {
- return nil, err
- }
- defer f.Close()
-
- var netIPSocketSummary NetIPSocketSummary
- var udpPacketDrops uint64
- isUDP := strings.Contains(file, "udp")
-
- lr := io.LimitReader(f, readLimit)
- s := bufio.NewScanner(lr)
- s.Scan() // skip first line with headers
- for s.Scan() {
- fields := strings.Fields(s.Text())
- line, err := parseNetIPSocketLine(fields, isUDP)
- if err != nil {
- return nil, err
- }
- netIPSocketSummary.TxQueueLength += line.TxQueue
- netIPSocketSummary.RxQueueLength += line.RxQueue
- netIPSocketSummary.UsedSockets++
- if isUDP {
- udpPacketDrops += *line.Drops
- netIPSocketSummary.Drops = &udpPacketDrops
- }
- }
- if err := s.Err(); err != nil {
- return nil, err
- }
- return &netIPSocketSummary, nil
-}
-
-// the /proc/net/{t,u}dp{,6} files are network byte order for ipv4 and for ipv6 the address is four words consisting of four bytes each. In each of those four words the four bytes are written in reverse order.
-
-func parseIP(hexIP string) (net.IP, error) {
- var byteIP []byte
- byteIP, err := hex.DecodeString(hexIP)
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse socket field in %q: %w", ErrFileParse, hexIP, err)
- }
- switch len(byteIP) {
- case 4:
- return net.IP{byteIP[3], byteIP[2], byteIP[1], byteIP[0]}, nil
- case 16:
- i := net.IP{
- byteIP[3], byteIP[2], byteIP[1], byteIP[0],
- byteIP[7], byteIP[6], byteIP[5], byteIP[4],
- byteIP[11], byteIP[10], byteIP[9], byteIP[8],
- byteIP[15], byteIP[14], byteIP[13], byteIP[12],
- }
- return i, nil
- default:
- return nil, fmt.Errorf("%w: Unable to parse IP %s: %v", ErrFileParse, hexIP, nil)
- }
-}
-
-// parseNetIPSocketLine parses a single line, represented by a list of fields.
-func parseNetIPSocketLine(fields []string, isUDP bool) (*netIPSocketLine, error) {
- line := &netIPSocketLine{}
- if len(fields) < 10 {
- return nil, fmt.Errorf(
- "%w: Less than 10 columns found %q",
- ErrFileParse,
- strings.Join(fields, " "),
- )
- }
- var err error // parse error
-
- // sl
- s := strings.Split(fields[0], ":")
- if len(s) != 2 {
- return nil, fmt.Errorf("%w: Unable to parse sl field in line %q", ErrFileParse, fields[0])
- }
-
- if line.Sl, err = strconv.ParseUint(s[0], 0, 64); err != nil {
- return nil, fmt.Errorf("%w: Unable to parse sl field in %q: %w", ErrFileParse, line.Sl, err)
- }
- // local_address
- l := strings.Split(fields[1], ":")
- if len(l) != 2 {
- return nil, fmt.Errorf("%w: Unable to parse local_address field in %q", ErrFileParse, fields[1])
- }
- if line.LocalAddr, err = parseIP(l[0]); err != nil {
- return nil, err
- }
- if line.LocalPort, err = strconv.ParseUint(l[1], 16, 64); err != nil {
- return nil, fmt.Errorf("%w: Unable to parse local_address port value line %q: %w", ErrFileParse, line.LocalPort, err)
- }
-
- // remote_address
- r := strings.Split(fields[2], ":")
- if len(r) != 2 {
- return nil, fmt.Errorf("%w: Unable to parse rem_address field in %q", ErrFileParse, fields[1])
- }
- if line.RemAddr, err = parseIP(r[0]); err != nil {
- return nil, err
- }
- if line.RemPort, err = strconv.ParseUint(r[1], 16, 64); err != nil {
- return nil, fmt.Errorf("%w: Cannot parse rem_address port value in %q: %w", ErrFileParse, line.RemPort, err)
- }
-
- // st
- if line.St, err = strconv.ParseUint(fields[3], 16, 64); err != nil {
- return nil, fmt.Errorf("%w: Cannot parse st value in %q: %w", ErrFileParse, line.St, err)
- }
-
- // tx_queue and rx_queue
- q := strings.Split(fields[4], ":")
- if len(q) != 2 {
- return nil, fmt.Errorf(
- "%w: Missing colon for tx/rx queues in socket line %q",
- ErrFileParse,
- fields[4],
- )
- }
- if line.TxQueue, err = strconv.ParseUint(q[0], 16, 64); err != nil {
- return nil, fmt.Errorf("%w: Cannot parse tx_queue value in %q: %w", ErrFileParse, line.TxQueue, err)
- }
- if line.RxQueue, err = strconv.ParseUint(q[1], 16, 64); err != nil {
- return nil, fmt.Errorf("%w: Cannot parse trx_queue value in %q: %w", ErrFileParse, line.RxQueue, err)
- }
-
- // uid
- if line.UID, err = strconv.ParseUint(fields[7], 0, 64); err != nil {
- return nil, fmt.Errorf("%w: Cannot parse UID value in %q: %w", ErrFileParse, line.UID, err)
- }
-
- // inode
- if line.Inode, err = strconv.ParseUint(fields[9], 0, 64); err != nil {
- return nil, fmt.Errorf("%w: Cannot parse inode value in %q: %w", ErrFileParse, line.Inode, err)
- }
-
- // drops
- if isUDP {
- drops, err := strconv.ParseUint(fields[12], 0, 64)
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse drops value in %q: %w", ErrFileParse, drops, err)
- }
- line.Drops = &drops
- }
-
- return line, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/net_protocols.go b/vendor/github.com/prometheus/procfs/net_protocols.go
deleted file mode 100644
index b6c77b7..0000000
--- a/vendor/github.com/prometheus/procfs/net_protocols.go
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// NetProtocolStats stores the contents from /proc/net/protocols.
-type NetProtocolStats map[string]NetProtocolStatLine
-
-// NetProtocolStatLine contains a single line parsed from /proc/net/protocols. We
-// only care about the first six columns as the rest are not likely to change
-// and only serve to provide a set of capabilities for each protocol.
-type NetProtocolStatLine struct {
- Name string // 0 The name of the protocol
- Size uint64 // 1 The size, in bytes, of a given protocol structure. e.g. sizeof(struct tcp_sock) or sizeof(struct unix_sock)
- Sockets int64 // 2 Number of sockets in use by this protocol
- Memory int64 // 3 Number of 4KB pages allocated by all sockets of this protocol
- Pressure int // 4 This is either yes, no, or NI (not implemented). For the sake of simplicity we treat NI as not experiencing memory pressure.
- MaxHeader uint64 // 5 Protocol specific max header size
- Slab bool // 6 Indicates whether or not memory is allocated from the SLAB
- ModuleName string // 7 The name of the module that implemented this protocol or "kernel" if not from a module
- Capabilities NetProtocolCapabilities
-}
-
-// NetProtocolCapabilities contains a list of capabilities for each protocol.
-type NetProtocolCapabilities struct {
- Close bool // 8
- Connect bool // 9
- Disconnect bool // 10
- Accept bool // 11
- IoCtl bool // 12
- Init bool // 13
- Destroy bool // 14
- Shutdown bool // 15
- SetSockOpt bool // 16
- GetSockOpt bool // 17
- SendMsg bool // 18
- RecvMsg bool // 19
- SendPage bool // 20
- Bind bool // 21
- BacklogRcv bool // 22
- Hash bool // 23
- UnHash bool // 24
- GetPort bool // 25
- EnterMemoryPressure bool // 26
-}
-
-// NetProtocols reads stats from /proc/net/protocols and returns a map of
-// PortocolStatLine entries. As of this writing no official Linux Documentation
-// exists, however the source is fairly self-explanatory and the format seems
-// stable since its introduction in 2.6.12-rc2
-// Linux 2.6.12-rc2 - https://elixir.bootlin.com/linux/v2.6.12-rc2/source/net/core/sock.c#L1452
-// Linux 5.10 - https://elixir.bootlin.com/linux/v5.10.4/source/net/core/sock.c#L3586
-func (fs FS) NetProtocols() (NetProtocolStats, error) {
- data, err := util.ReadFileNoStat(fs.proc.Path("net/protocols"))
- if err != nil {
- return NetProtocolStats{}, err
- }
- return parseNetProtocols(bufio.NewScanner(bytes.NewReader(data)))
-}
-
-func parseNetProtocols(s *bufio.Scanner) (NetProtocolStats, error) {
- nps := NetProtocolStats{}
-
- // Skip the header line
- s.Scan()
-
- for s.Scan() {
- line, err := nps.parseLine(s.Text())
- if err != nil {
- return NetProtocolStats{}, err
- }
-
- nps[line.Name] = *line
- }
- return nps, nil
-}
-
-func (ps NetProtocolStats) parseLine(rawLine string) (*NetProtocolStatLine, error) {
- line := &NetProtocolStatLine{Capabilities: NetProtocolCapabilities{}}
- var err error
- const enabled = "yes"
- const disabled = "no"
-
- fields := strings.Fields(rawLine)
- line.Name = fields[0]
- line.Size, err = strconv.ParseUint(fields[1], 10, 64)
- if err != nil {
- return nil, err
- }
- line.Sockets, err = strconv.ParseInt(fields[2], 10, 64)
- if err != nil {
- return nil, err
- }
- line.Memory, err = strconv.ParseInt(fields[3], 10, 64)
- if err != nil {
- return nil, err
- }
- if fields[4] == enabled {
- line.Pressure = 1
- } else if fields[4] == disabled {
- line.Pressure = 0
- } else {
- line.Pressure = -1
- }
- line.MaxHeader, err = strconv.ParseUint(fields[5], 10, 64)
- if err != nil {
- return nil, err
- }
- if fields[6] == enabled {
- line.Slab = true
- } else if fields[6] == disabled {
- line.Slab = false
- } else {
- return nil, fmt.Errorf("%w: capability for protocol: %s", ErrFileParse, line.Name)
- }
- line.ModuleName = fields[7]
-
- err = line.Capabilities.parseCapabilities(fields[8:])
- if err != nil {
- return nil, err
- }
-
- return line, nil
-}
-
-func (pc *NetProtocolCapabilities) parseCapabilities(capabilities []string) error {
- // The capabilities are all bools so we can loop over to map them
- capabilityFields := [...]*bool{
- &pc.Close,
- &pc.Connect,
- &pc.Disconnect,
- &pc.Accept,
- &pc.IoCtl,
- &pc.Init,
- &pc.Destroy,
- &pc.Shutdown,
- &pc.SetSockOpt,
- &pc.GetSockOpt,
- &pc.SendMsg,
- &pc.RecvMsg,
- &pc.SendPage,
- &pc.Bind,
- &pc.BacklogRcv,
- &pc.Hash,
- &pc.UnHash,
- &pc.GetPort,
- &pc.EnterMemoryPressure,
- }
-
- for i := 0; i < len(capabilities); i++ {
- if capabilities[i] == "y" {
- *capabilityFields[i] = true
- } else if capabilities[i] == "n" {
- *capabilityFields[i] = false
- } else {
- return fmt.Errorf("%w: capability block for protocol: position %d", ErrFileParse, i)
- }
- }
- return nil
-}
diff --git a/vendor/github.com/prometheus/procfs/net_route.go b/vendor/github.com/prometheus/procfs/net_route.go
deleted file mode 100644
index deb7029..0000000
--- a/vendor/github.com/prometheus/procfs/net_route.go
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright 2023 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-const (
- blackholeRepresentation string = "*"
- blackholeIfaceName string = "blackhole"
- routeLineColumns int = 11
-)
-
-// A NetRouteLine represents one line from net/route.
-type NetRouteLine struct {
- Iface string
- Destination uint32
- Gateway uint32
- Flags uint32
- RefCnt uint32
- Use uint32
- Metric uint32
- Mask uint32
- MTU uint32
- Window uint32
- IRTT uint32
-}
-
-func (fs FS) NetRoute() ([]NetRouteLine, error) {
- return readNetRoute(fs.proc.Path("net", "route"))
-}
-
-func readNetRoute(path string) ([]NetRouteLine, error) {
- b, err := util.ReadFileNoStat(path)
- if err != nil {
- return nil, err
- }
-
- routelines, err := parseNetRoute(bytes.NewReader(b))
- if err != nil {
- return nil, fmt.Errorf("failed to read net route from %s: %w", path, err)
- }
- return routelines, nil
-}
-
-func parseNetRoute(r io.Reader) ([]NetRouteLine, error) {
- var routelines []NetRouteLine
-
- scanner := bufio.NewScanner(r)
- scanner.Scan()
- for scanner.Scan() {
- fields := strings.Fields(scanner.Text())
- routeline, err := parseNetRouteLine(fields)
- if err != nil {
- return nil, err
- }
- routelines = append(routelines, *routeline)
- }
- return routelines, nil
-}
-
-func parseNetRouteLine(fields []string) (*NetRouteLine, error) {
- if len(fields) != routeLineColumns {
- return nil, fmt.Errorf("invalid routeline, num of digits: %d", len(fields))
- }
- iface := fields[0]
- if iface == blackholeRepresentation {
- iface = blackholeIfaceName
- }
- destination, err := strconv.ParseUint(fields[1], 16, 32)
- if err != nil {
- return nil, err
- }
- gateway, err := strconv.ParseUint(fields[2], 16, 32)
- if err != nil {
- return nil, err
- }
- flags, err := strconv.ParseUint(fields[3], 10, 32)
- if err != nil {
- return nil, err
- }
- refcnt, err := strconv.ParseUint(fields[4], 10, 32)
- if err != nil {
- return nil, err
- }
- use, err := strconv.ParseUint(fields[5], 10, 32)
- if err != nil {
- return nil, err
- }
- metric, err := strconv.ParseUint(fields[6], 10, 32)
- if err != nil {
- return nil, err
- }
- mask, err := strconv.ParseUint(fields[7], 16, 32)
- if err != nil {
- return nil, err
- }
- mtu, err := strconv.ParseUint(fields[8], 10, 32)
- if err != nil {
- return nil, err
- }
- window, err := strconv.ParseUint(fields[9], 10, 32)
- if err != nil {
- return nil, err
- }
- irtt, err := strconv.ParseUint(fields[10], 10, 32)
- if err != nil {
- return nil, err
- }
- routeline := &NetRouteLine{
- Iface: iface,
- Destination: uint32(destination),
- Gateway: uint32(gateway),
- Flags: uint32(flags),
- RefCnt: uint32(refcnt),
- Use: uint32(use),
- Metric: uint32(metric),
- Mask: uint32(mask),
- MTU: uint32(mtu),
- Window: uint32(window),
- IRTT: uint32(irtt),
- }
- return routeline, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/net_sockstat.go b/vendor/github.com/prometheus/procfs/net_sockstat.go
deleted file mode 100644
index fae62b1..0000000
--- a/vendor/github.com/prometheus/procfs/net_sockstat.go
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// A NetSockstat contains the output of /proc/net/sockstat{,6} for IPv4 or IPv6,
-// respectively.
-type NetSockstat struct {
- // Used is non-nil for IPv4 sockstat results, but nil for IPv6.
- Used *int
- Protocols []NetSockstatProtocol
-}
-
-// A NetSockstatProtocol contains statistics about a given socket protocol.
-// Pointer fields indicate that the value may or may not be present on any
-// given protocol.
-type NetSockstatProtocol struct {
- Protocol string
- InUse int
- Orphan *int
- TW *int
- Alloc *int
- Mem *int
- Memory *int
-}
-
-// NetSockstat retrieves IPv4 socket statistics.
-func (fs FS) NetSockstat() (*NetSockstat, error) {
- return readSockstat(fs.proc.Path("net", "sockstat"))
-}
-
-// NetSockstat6 retrieves IPv6 socket statistics.
-//
-// If IPv6 is disabled on this kernel, the returned error can be checked with
-// os.IsNotExist.
-func (fs FS) NetSockstat6() (*NetSockstat, error) {
- return readSockstat(fs.proc.Path("net", "sockstat6"))
-}
-
-// readSockstat opens and parses a NetSockstat from the input file.
-func readSockstat(name string) (*NetSockstat, error) {
- // This file is small and can be read with one syscall.
- b, err := util.ReadFileNoStat(name)
- if err != nil {
- // Do not wrap this error so the caller can detect os.IsNotExist and
- // similar conditions.
- return nil, err
- }
-
- stat, err := parseSockstat(bytes.NewReader(b))
- if err != nil {
- return nil, fmt.Errorf("%w: sockstats from %q: %w", ErrFileRead, name, err)
- }
-
- return stat, nil
-}
-
-// parseSockstat reads the contents of a sockstat file and parses a NetSockstat.
-func parseSockstat(r io.Reader) (*NetSockstat, error) {
- var stat NetSockstat
- s := bufio.NewScanner(r)
- for s.Scan() {
- // Expect a minimum of a protocol and one key/value pair.
- fields := strings.Split(s.Text(), " ")
- if len(fields) < 3 {
- return nil, fmt.Errorf("%w: Malformed sockstat line: %q", ErrFileParse, s.Text())
- }
-
- // The remaining fields are key/value pairs.
- kvs, err := parseSockstatKVs(fields[1:])
- if err != nil {
- return nil, fmt.Errorf("%w: sockstat key/value pairs from %q: %w", ErrFileParse, s.Text(), err)
- }
-
- // The first field is the protocol. We must trim its colon suffix.
- proto := strings.TrimSuffix(fields[0], ":")
- switch proto {
- case "sockets":
- // Special case: IPv4 has a sockets "used" key/value pair that we
- // embed at the top level of the structure.
- used := kvs["used"]
- stat.Used = &used
- default:
- // Parse all other lines as individual protocols.
- nsp := parseSockstatProtocol(kvs)
- nsp.Protocol = proto
- stat.Protocols = append(stat.Protocols, nsp)
- }
- }
-
- if err := s.Err(); err != nil {
- return nil, err
- }
-
- return &stat, nil
-}
-
-// parseSockstatKVs parses a string slice into a map of key/value pairs.
-func parseSockstatKVs(kvs []string) (map[string]int, error) {
- if len(kvs)%2 != 0 {
- return nil, fmt.Errorf("%w:: Odd number of fields in key/value pairs %q", ErrFileParse, kvs)
- }
-
- // Iterate two values at a time to gather key/value pairs.
- out := make(map[string]int, len(kvs)/2)
- for i := 0; i < len(kvs); i += 2 {
- vp := util.NewValueParser(kvs[i+1])
- out[kvs[i]] = vp.Int()
-
- if err := vp.Err(); err != nil {
- return nil, err
- }
- }
-
- return out, nil
-}
-
-// parseSockstatProtocol parses a NetSockstatProtocol from the input kvs map.
-func parseSockstatProtocol(kvs map[string]int) NetSockstatProtocol {
- var nsp NetSockstatProtocol
- for k, v := range kvs {
- // Capture the range variable to ensure we get unique pointers for
- // each of the optional fields.
- v := v
- switch k {
- case "inuse":
- nsp.InUse = v
- case "orphan":
- nsp.Orphan = &v
- case "tw":
- nsp.TW = &v
- case "alloc":
- nsp.Alloc = &v
- case "mem":
- nsp.Mem = &v
- case "memory":
- nsp.Memory = &v
- }
- }
-
- return nsp
-}
diff --git a/vendor/github.com/prometheus/procfs/net_softnet.go b/vendor/github.com/prometheus/procfs/net_softnet.go
deleted file mode 100644
index 71c8059..0000000
--- a/vendor/github.com/prometheus/procfs/net_softnet.go
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// For the proc file format details,
-// See:
-// * Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2343
-// * Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086
-// * Linux 4.18 https://elixir.bootlin.com/linux/v4.18/source/net/core/net-procfs.c#L162
-// * Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169
-
-// SoftnetStat contains a single row of data from /proc/net/softnet_stat.
-type SoftnetStat struct {
- // Number of processed packets.
- Processed uint32
- // Number of dropped packets.
- Dropped uint32
- // Number of times processing packets ran out of quota.
- TimeSqueezed uint32
- // Number of collision occur while obtaining device lock while transmitting.
- CPUCollision uint32
- // Number of times cpu woken up received_rps.
- ReceivedRps uint32
- // number of times flow limit has been reached.
- FlowLimitCount uint32
- // Softnet backlog status.
- SoftnetBacklogLen uint32
- // CPU id owning this softnet_data.
- Index uint32
- // softnet_data's Width.
- Width int
-}
-
-var softNetProcFile = "net/softnet_stat"
-
-// NetSoftnetStat reads data from /proc/net/softnet_stat.
-func (fs FS) NetSoftnetStat() ([]SoftnetStat, error) {
- b, err := util.ReadFileNoStat(fs.proc.Path(softNetProcFile))
- if err != nil {
- return nil, err
- }
-
- entries, err := parseSoftnet(bytes.NewReader(b))
- if err != nil {
- return nil, fmt.Errorf("%w: /proc/net/softnet_stat: %w", ErrFileParse, err)
- }
-
- return entries, nil
-}
-
-func parseSoftnet(r io.Reader) ([]SoftnetStat, error) {
- const minColumns = 9
-
- s := bufio.NewScanner(r)
-
- var stats []SoftnetStat
- cpuIndex := 0
- for s.Scan() {
- columns := strings.Fields(s.Text())
- width := len(columns)
- softnetStat := SoftnetStat{}
-
- if width < minColumns {
- return nil, fmt.Errorf("%w: detected %d columns, but expected at least %d", ErrFileParse, width, minColumns)
- }
-
- // Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2347
- if width >= minColumns {
- us, err := parseHexUint32s(columns[0:9])
- if err != nil {
- return nil, err
- }
-
- softnetStat.Processed = us[0]
- softnetStat.Dropped = us[1]
- softnetStat.TimeSqueezed = us[2]
- softnetStat.CPUCollision = us[8]
- }
-
- // Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086
- if width >= 10 {
- us, err := parseHexUint32s(columns[9:10])
- if err != nil {
- return nil, err
- }
-
- softnetStat.ReceivedRps = us[0]
- }
-
- // Linux 4.18 https://elixir.bootlin.com/linux/v4.18/source/net/core/net-procfs.c#L162
- if width >= 11 {
- us, err := parseHexUint32s(columns[10:11])
- if err != nil {
- return nil, err
- }
-
- softnetStat.FlowLimitCount = us[0]
- }
-
- // Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169
- if width >= 13 {
- us, err := parseHexUint32s(columns[11:13])
- if err != nil {
- return nil, err
- }
-
- softnetStat.SoftnetBacklogLen = us[0]
- softnetStat.Index = us[1]
- } else {
- // For older kernels, create the Index based on the scan line number.
- softnetStat.Index = uint32(cpuIndex)
- }
- softnetStat.Width = width
- stats = append(stats, softnetStat)
- cpuIndex++
- }
-
- return stats, nil
-}
-
-func parseHexUint32s(ss []string) ([]uint32, error) {
- us := make([]uint32, 0, len(ss))
- for _, s := range ss {
- u, err := strconv.ParseUint(s, 16, 32)
- if err != nil {
- return nil, err
- }
-
- us = append(us, uint32(u))
- }
-
- return us, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/net_tcp.go b/vendor/github.com/prometheus/procfs/net_tcp.go
deleted file mode 100644
index 5277629..0000000
--- a/vendor/github.com/prometheus/procfs/net_tcp.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-type (
- // NetTCP represents the contents of /proc/net/tcp{,6} file without the header.
- NetTCP []*netIPSocketLine
-
- // NetTCPSummary provides already computed values like the total queue lengths or
- // the total number of used sockets. In contrast to NetTCP it does not collect
- // the parsed lines into a slice.
- NetTCPSummary NetIPSocketSummary
-)
-
-// NetTCP returns the IPv4 kernel/networking statistics for TCP datagrams
-// read from /proc/net/tcp.
-func (fs FS) NetTCP() (NetTCP, error) {
- return newNetTCP(fs.proc.Path("net/tcp"))
-}
-
-// NetTCP6 returns the IPv6 kernel/networking statistics for TCP datagrams
-// read from /proc/net/tcp6.
-func (fs FS) NetTCP6() (NetTCP, error) {
- return newNetTCP(fs.proc.Path("net/tcp6"))
-}
-
-// NetTCPSummary returns already computed statistics like the total queue lengths
-// for TCP datagrams read from /proc/net/tcp.
-func (fs FS) NetTCPSummary() (*NetTCPSummary, error) {
- return newNetTCPSummary(fs.proc.Path("net/tcp"))
-}
-
-// NetTCP6Summary returns already computed statistics like the total queue lengths
-// for TCP datagrams read from /proc/net/tcp6.
-func (fs FS) NetTCP6Summary() (*NetTCPSummary, error) {
- return newNetTCPSummary(fs.proc.Path("net/tcp6"))
-}
-
-// newNetTCP creates a new NetTCP{,6} from the contents of the given file.
-func newNetTCP(file string) (NetTCP, error) {
- n, err := newNetIPSocket(file)
- n1 := NetTCP(n)
- return n1, err
-}
-
-func newNetTCPSummary(file string) (*NetTCPSummary, error) {
- n, err := newNetIPSocketSummary(file)
- if n == nil {
- return nil, err
- }
- n1 := NetTCPSummary(*n)
- return &n1, err
-}
diff --git a/vendor/github.com/prometheus/procfs/net_tls_stat.go b/vendor/github.com/prometheus/procfs/net_tls_stat.go
deleted file mode 100644
index 13994c1..0000000
--- a/vendor/github.com/prometheus/procfs/net_tls_stat.go
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2023 Prometheus Team
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "fmt"
- "os"
- "strconv"
- "strings"
-)
-
-// TLSStat struct represents data in /proc/net/tls_stat.
-// See https://docs.kernel.org/networking/tls.html#statistics
-type TLSStat struct {
- // number of TX sessions currently installed where host handles cryptography
- TLSCurrTxSw int
- // number of RX sessions currently installed where host handles cryptography
- TLSCurrRxSw int
- // number of TX sessions currently installed where NIC handles cryptography
- TLSCurrTxDevice int
- // number of RX sessions currently installed where NIC handles cryptography
- TLSCurrRxDevice int
- //number of TX sessions opened with host cryptography
- TLSTxSw int
- //number of RX sessions opened with host cryptography
- TLSRxSw int
- // number of TX sessions opened with NIC cryptography
- TLSTxDevice int
- // number of RX sessions opened with NIC cryptography
- TLSRxDevice int
- // record decryption failed (e.g. due to incorrect authentication tag)
- TLSDecryptError int
- // number of RX resyncs sent to NICs handling cryptography
- TLSRxDeviceResync int
- // number of RX records which had to be re-decrypted due to TLS_RX_EXPECT_NO_PAD mis-prediction. Note that this counter will also increment for non-data records.
- TLSDecryptRetry int
- // number of data RX records which had to be re-decrypted due to TLS_RX_EXPECT_NO_PAD mis-prediction.
- TLSRxNoPadViolation int
-}
-
-// NewTLSStat reads the tls_stat statistics.
-func NewTLSStat() (TLSStat, error) {
- fs, err := NewFS(DefaultMountPoint)
- if err != nil {
- return TLSStat{}, err
- }
-
- return fs.NewTLSStat()
-}
-
-// NewTLSStat reads the tls_stat statistics.
-func (fs FS) NewTLSStat() (TLSStat, error) {
- file, err := os.Open(fs.proc.Path("net/tls_stat"))
- if err != nil {
- return TLSStat{}, err
- }
- defer file.Close()
-
- var (
- tlsstat = TLSStat{}
- s = bufio.NewScanner(file)
- )
-
- for s.Scan() {
- fields := strings.Fields(s.Text())
-
- if len(fields) != 2 {
- return TLSStat{}, fmt.Errorf("%w: %q line %q", ErrFileParse, file.Name(), s.Text())
- }
-
- name := fields[0]
- value, err := strconv.Atoi(fields[1])
- if err != nil {
- return TLSStat{}, err
- }
-
- switch name {
- case "TlsCurrTxSw":
- tlsstat.TLSCurrTxSw = value
- case "TlsCurrRxSw":
- tlsstat.TLSCurrRxSw = value
- case "TlsCurrTxDevice":
- tlsstat.TLSCurrTxDevice = value
- case "TlsCurrRxDevice":
- tlsstat.TLSCurrRxDevice = value
- case "TlsTxSw":
- tlsstat.TLSTxSw = value
- case "TlsRxSw":
- tlsstat.TLSRxSw = value
- case "TlsTxDevice":
- tlsstat.TLSTxDevice = value
- case "TlsRxDevice":
- tlsstat.TLSRxDevice = value
- case "TlsDecryptError":
- tlsstat.TLSDecryptError = value
- case "TlsRxDeviceResync":
- tlsstat.TLSRxDeviceResync = value
- case "TlsDecryptRetry":
- tlsstat.TLSDecryptRetry = value
- case "TlsRxNoPadViolation":
- tlsstat.TLSRxNoPadViolation = value
- }
-
- }
-
- return tlsstat, s.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/net_udp.go b/vendor/github.com/prometheus/procfs/net_udp.go
deleted file mode 100644
index 9ac3daf..0000000
--- a/vendor/github.com/prometheus/procfs/net_udp.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-type (
- // NetUDP represents the contents of /proc/net/udp{,6} file without the header.
- NetUDP []*netIPSocketLine
-
- // NetUDPSummary provides already computed values like the total queue lengths or
- // the total number of used sockets. In contrast to NetUDP it does not collect
- // the parsed lines into a slice.
- NetUDPSummary NetIPSocketSummary
-)
-
-// NetUDP returns the IPv4 kernel/networking statistics for UDP datagrams
-// read from /proc/net/udp.
-func (fs FS) NetUDP() (NetUDP, error) {
- return newNetUDP(fs.proc.Path("net/udp"))
-}
-
-// NetUDP6 returns the IPv6 kernel/networking statistics for UDP datagrams
-// read from /proc/net/udp6.
-func (fs FS) NetUDP6() (NetUDP, error) {
- return newNetUDP(fs.proc.Path("net/udp6"))
-}
-
-// NetUDPSummary returns already computed statistics like the total queue lengths
-// for UDP datagrams read from /proc/net/udp.
-func (fs FS) NetUDPSummary() (*NetUDPSummary, error) {
- return newNetUDPSummary(fs.proc.Path("net/udp"))
-}
-
-// NetUDP6Summary returns already computed statistics like the total queue lengths
-// for UDP datagrams read from /proc/net/udp6.
-func (fs FS) NetUDP6Summary() (*NetUDPSummary, error) {
- return newNetUDPSummary(fs.proc.Path("net/udp6"))
-}
-
-// newNetUDP creates a new NetUDP{,6} from the contents of the given file.
-func newNetUDP(file string) (NetUDP, error) {
- n, err := newNetIPSocket(file)
- n1 := NetUDP(n)
- return n1, err
-}
-
-func newNetUDPSummary(file string) (*NetUDPSummary, error) {
- n, err := newNetIPSocketSummary(file)
- if n == nil {
- return nil, err
- }
- n1 := NetUDPSummary(*n)
- return &n1, err
-}
diff --git a/vendor/github.com/prometheus/procfs/net_unix.go b/vendor/github.com/prometheus/procfs/net_unix.go
deleted file mode 100644
index d868ceb..0000000
--- a/vendor/github.com/prometheus/procfs/net_unix.go
+++ /dev/null
@@ -1,257 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "fmt"
- "io"
- "os"
- "strconv"
- "strings"
-)
-
-// For the proc file format details,
-// see https://elixir.bootlin.com/linux/v4.17/source/net/unix/af_unix.c#L2815
-// and https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/net.h#L48.
-
-// Constants for the various /proc/net/unix enumerations.
-// TODO: match against x/sys/unix or similar?
-const (
- netUnixTypeStream = 1
- netUnixTypeDgram = 2
- netUnixTypeSeqpacket = 5
-
- netUnixFlagDefault = 0
- netUnixFlagListen = 1 << 16
-
- netUnixStateUnconnected = 1
- netUnixStateConnecting = 2
- netUnixStateConnected = 3
- netUnixStateDisconnected = 4
-)
-
-// NetUNIXType is the type of the type field.
-type NetUNIXType uint64
-
-// NetUNIXFlags is the type of the flags field.
-type NetUNIXFlags uint64
-
-// NetUNIXState is the type of the state field.
-type NetUNIXState uint64
-
-// NetUNIXLine represents a line of /proc/net/unix.
-type NetUNIXLine struct {
- KernelPtr string
- RefCount uint64
- Protocol uint64
- Flags NetUNIXFlags
- Type NetUNIXType
- State NetUNIXState
- Inode uint64
- Path string
-}
-
-// NetUNIX holds the data read from /proc/net/unix.
-type NetUNIX struct {
- Rows []*NetUNIXLine
-}
-
-// NetUNIX returns data read from /proc/net/unix.
-func (fs FS) NetUNIX() (*NetUNIX, error) {
- return readNetUNIX(fs.proc.Path("net/unix"))
-}
-
-// readNetUNIX reads data in /proc/net/unix format from the specified file.
-func readNetUNIX(file string) (*NetUNIX, error) {
- // This file could be quite large and a streaming read is desirable versus
- // reading the entire contents at once.
- f, err := os.Open(file)
- if err != nil {
- return nil, err
- }
- defer f.Close()
-
- return parseNetUNIX(f)
-}
-
-// parseNetUNIX creates a NetUnix structure from the incoming stream.
-func parseNetUNIX(r io.Reader) (*NetUNIX, error) {
- // Begin scanning by checking for the existence of Inode.
- s := bufio.NewScanner(r)
- s.Scan()
-
- // From the man page of proc(5), it does not contain an Inode field,
- // but in actually it exists. This code works for both cases.
- hasInode := strings.Contains(s.Text(), "Inode")
-
- // Expect a minimum number of fields, but Inode and Path are optional:
- // Num RefCount Protocol Flags Type St Inode Path
- minFields := 6
- if hasInode {
- minFields++
- }
-
- var nu NetUNIX
- for s.Scan() {
- line := s.Text()
- item, err := nu.parseLine(line, hasInode, minFields)
- if err != nil {
- return nil, fmt.Errorf("%w: /proc/net/unix encountered data %q: %w", ErrFileParse, line, err)
- }
-
- nu.Rows = append(nu.Rows, item)
- }
-
- if err := s.Err(); err != nil {
- return nil, fmt.Errorf("%w: /proc/net/unix encountered data: %w", ErrFileParse, err)
- }
-
- return &nu, nil
-}
-
-func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine, error) {
- fields := strings.Fields(line)
-
- l := len(fields)
- if l < min {
- return nil, fmt.Errorf("%w: expected at least %d fields but got %d", ErrFileParse, min, l)
- }
-
- // Field offsets are as follows:
- // Num RefCount Protocol Flags Type St Inode Path
-
- kernelPtr := strings.TrimSuffix(fields[0], ":")
-
- users, err := u.parseUsers(fields[1])
- if err != nil {
- return nil, fmt.Errorf("%w: ref count %q: %w", ErrFileParse, fields[1], err)
- }
-
- flags, err := u.parseFlags(fields[3])
- if err != nil {
- return nil, fmt.Errorf("%w: Unable to parse flags %q: %w", ErrFileParse, fields[3], err)
- }
-
- typ, err := u.parseType(fields[4])
- if err != nil {
- return nil, fmt.Errorf("%w: Failed to parse type %q: %w", ErrFileParse, fields[4], err)
- }
-
- state, err := u.parseState(fields[5])
- if err != nil {
- return nil, fmt.Errorf("%w: Failed to parse state %q: %w", ErrFileParse, fields[5], err)
- }
-
- var inode uint64
- if hasInode {
- inode, err = u.parseInode(fields[6])
- if err != nil {
- return nil, fmt.Errorf("%w failed to parse inode %q: %w", ErrFileParse, fields[6], err)
- }
- }
-
- n := &NetUNIXLine{
- KernelPtr: kernelPtr,
- RefCount: users,
- Type: typ,
- Flags: flags,
- State: state,
- Inode: inode,
- }
-
- // Path field is optional.
- if l > min {
- // Path occurs at either index 6 or 7 depending on whether inode is
- // already present.
- pathIdx := 7
- if !hasInode {
- pathIdx--
- }
-
- n.Path = fields[pathIdx]
- }
-
- return n, nil
-}
-
-func (u NetUNIX) parseUsers(s string) (uint64, error) {
- return strconv.ParseUint(s, 16, 32)
-}
-
-func (u NetUNIX) parseType(s string) (NetUNIXType, error) {
- typ, err := strconv.ParseUint(s, 16, 16)
- if err != nil {
- return 0, err
- }
-
- return NetUNIXType(typ), nil
-}
-
-func (u NetUNIX) parseFlags(s string) (NetUNIXFlags, error) {
- flags, err := strconv.ParseUint(s, 16, 32)
- if err != nil {
- return 0, err
- }
-
- return NetUNIXFlags(flags), nil
-}
-
-func (u NetUNIX) parseState(s string) (NetUNIXState, error) {
- st, err := strconv.ParseInt(s, 16, 8)
- if err != nil {
- return 0, err
- }
-
- return NetUNIXState(st), nil
-}
-
-func (u NetUNIX) parseInode(s string) (uint64, error) {
- return strconv.ParseUint(s, 10, 64)
-}
-
-func (t NetUNIXType) String() string {
- switch t {
- case netUnixTypeStream:
- return "stream"
- case netUnixTypeDgram:
- return "dgram"
- case netUnixTypeSeqpacket:
- return "seqpacket"
- }
- return "unknown"
-}
-
-func (f NetUNIXFlags) String() string {
- switch f {
- case netUnixFlagListen:
- return "listen"
- default:
- return "default"
- }
-}
-
-func (s NetUNIXState) String() string {
- switch s {
- case netUnixStateUnconnected:
- return "unconnected"
- case netUnixStateConnecting:
- return "connecting"
- case netUnixStateConnected:
- return "connected"
- case netUnixStateDisconnected:
- return "disconnected"
- }
- return "unknown"
-}
diff --git a/vendor/github.com/prometheus/procfs/net_wireless.go b/vendor/github.com/prometheus/procfs/net_wireless.go
deleted file mode 100644
index 7c597bc..0000000
--- a/vendor/github.com/prometheus/procfs/net_wireless.go
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright 2023 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Wireless models the content of /proc/net/wireless.
-type Wireless struct {
- Name string
-
- // Status is the current 4-digit hex value status of the interface.
- Status uint64
-
- // QualityLink is the link quality.
- QualityLink int
-
- // QualityLevel is the signal gain (dBm).
- QualityLevel int
-
- // QualityNoise is the signal noise baseline (dBm).
- QualityNoise int
-
- // DiscardedNwid is the number of discarded packets with wrong nwid/essid.
- DiscardedNwid int
-
- // DiscardedCrypt is the number of discarded packets with wrong code/decode (WEP).
- DiscardedCrypt int
-
- // DiscardedFrag is the number of discarded packets that can't perform MAC reassembly.
- DiscardedFrag int
-
- // DiscardedRetry is the number of discarded packets that reached max MAC retries.
- DiscardedRetry int
-
- // DiscardedMisc is the number of discarded packets for other reasons.
- DiscardedMisc int
-
- // MissedBeacon is the number of missed beacons/superframe.
- MissedBeacon int
-}
-
-// Wireless returns kernel wireless statistics.
-func (fs FS) Wireless() ([]*Wireless, error) {
- b, err := util.ReadFileNoStat(fs.proc.Path("net/wireless"))
- if err != nil {
- return nil, err
- }
-
- m, err := parseWireless(bytes.NewReader(b))
- if err != nil {
- return nil, fmt.Errorf("%w: wireless: %w", ErrFileParse, err)
- }
-
- return m, nil
-}
-
-// parseWireless parses the contents of /proc/net/wireless.
-/*
-Inter-| sta-| Quality | Discarded packets | Missed | WE
-face | tus | link level noise | nwid crypt frag retry misc | beacon | 22
- eth1: 0000 5. -256. -10. 0 1 0 3 0 0
- eth2: 0000 5. -256. -20. 0 2 0 4 0 0
-*/
-func parseWireless(r io.Reader) ([]*Wireless, error) {
- var (
- interfaces []*Wireless
- scanner = bufio.NewScanner(r)
- )
-
- for n := 0; scanner.Scan(); n++ {
- // Skip the 2 header lines.
- if n < 2 {
- continue
- }
-
- line := scanner.Text()
-
- parts := strings.Split(line, ":")
- if len(parts) != 2 {
- return nil, fmt.Errorf("%w: expected 2 parts after splitting line by ':', got %d for line %q", ErrFileParse, len(parts), line)
- }
-
- name := strings.TrimSpace(parts[0])
- stats := strings.Fields(parts[1])
-
- if len(stats) < 10 {
- return nil, fmt.Errorf("%w: invalid number of fields in line %d, expected 10+, got %d: %q", ErrFileParse, n, len(stats), line)
- }
-
- status, err := strconv.ParseUint(stats[0], 16, 16)
- if err != nil {
- return nil, fmt.Errorf("%w: invalid status in line %d: %q", ErrFileParse, n, line)
- }
-
- qlink, err := strconv.Atoi(strings.TrimSuffix(stats[1], "."))
- if err != nil {
- return nil, fmt.Errorf("%w: parse Quality:link as integer %q: %w", ErrFileParse, qlink, err)
- }
-
- qlevel, err := strconv.Atoi(strings.TrimSuffix(stats[2], "."))
- if err != nil {
- return nil, fmt.Errorf("%w: Quality:level as integer %q: %w", ErrFileParse, qlevel, err)
- }
-
- qnoise, err := strconv.Atoi(strings.TrimSuffix(stats[3], "."))
- if err != nil {
- return nil, fmt.Errorf("%w: Quality:noise as integer %q: %w", ErrFileParse, qnoise, err)
- }
-
- dnwid, err := strconv.Atoi(stats[4])
- if err != nil {
- return nil, fmt.Errorf("%w: Discarded:nwid as integer %q: %w", ErrFileParse, dnwid, err)
- }
-
- dcrypt, err := strconv.Atoi(stats[5])
- if err != nil {
- return nil, fmt.Errorf("%w: Discarded:crypt as integer %q: %w", ErrFileParse, dcrypt, err)
- }
-
- dfrag, err := strconv.Atoi(stats[6])
- if err != nil {
- return nil, fmt.Errorf("%w: Discarded:frag as integer %q: %w", ErrFileParse, dfrag, err)
- }
-
- dretry, err := strconv.Atoi(stats[7])
- if err != nil {
- return nil, fmt.Errorf("%w: Discarded:retry as integer %q: %w", ErrFileParse, dretry, err)
- }
-
- dmisc, err := strconv.Atoi(stats[8])
- if err != nil {
- return nil, fmt.Errorf("%w: Discarded:misc as integer %q: %w", ErrFileParse, dmisc, err)
- }
-
- mbeacon, err := strconv.Atoi(stats[9])
- if err != nil {
- return nil, fmt.Errorf("%w: Missed:beacon as integer %q: %w", ErrFileParse, mbeacon, err)
- }
-
- w := &Wireless{
- Name: name,
- Status: status,
- QualityLink: qlink,
- QualityLevel: qlevel,
- QualityNoise: qnoise,
- DiscardedNwid: dnwid,
- DiscardedCrypt: dcrypt,
- DiscardedFrag: dfrag,
- DiscardedRetry: dretry,
- DiscardedMisc: dmisc,
- MissedBeacon: mbeacon,
- }
-
- interfaces = append(interfaces, w)
- }
-
- if err := scanner.Err(); err != nil {
- return nil, fmt.Errorf("%w: Failed to scan /proc/net/wireless: %w", ErrFileRead, err)
- }
-
- return interfaces, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/net_xfrm.go b/vendor/github.com/prometheus/procfs/net_xfrm.go
deleted file mode 100644
index 932ef20..0000000
--- a/vendor/github.com/prometheus/procfs/net_xfrm.go
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright 2017 Prometheus Team
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "fmt"
- "os"
- "strconv"
- "strings"
-)
-
-// XfrmStat models the contents of /proc/net/xfrm_stat.
-type XfrmStat struct {
- // All errors which are not matched by other
- XfrmInError int
- // No buffer is left
- XfrmInBufferError int
- // Header Error
- XfrmInHdrError int
- // No state found
- // i.e. either inbound SPI, address, or IPSEC protocol at SA is wrong
- XfrmInNoStates int
- // Transformation protocol specific error
- // e.g. SA Key is wrong
- XfrmInStateProtoError int
- // Transformation mode specific error
- XfrmInStateModeError int
- // Sequence error
- // e.g. sequence number is out of window
- XfrmInStateSeqError int
- // State is expired
- XfrmInStateExpired int
- // State has mismatch option
- // e.g. UDP encapsulation type is mismatched
- XfrmInStateMismatch int
- // State is invalid
- XfrmInStateInvalid int
- // No matching template for states
- // e.g. Inbound SAs are correct but SP rule is wrong
- XfrmInTmplMismatch int
- // No policy is found for states
- // e.g. Inbound SAs are correct but no SP is found
- XfrmInNoPols int
- // Policy discards
- XfrmInPolBlock int
- // Policy error
- XfrmInPolError int
- // All errors which are not matched by others
- XfrmOutError int
- // Bundle generation error
- XfrmOutBundleGenError int
- // Bundle check error
- XfrmOutBundleCheckError int
- // No state was found
- XfrmOutNoStates int
- // Transformation protocol specific error
- XfrmOutStateProtoError int
- // Transportation mode specific error
- XfrmOutStateModeError int
- // Sequence error
- // i.e sequence number overflow
- XfrmOutStateSeqError int
- // State is expired
- XfrmOutStateExpired int
- // Policy discads
- XfrmOutPolBlock int
- // Policy is dead
- XfrmOutPolDead int
- // Policy Error
- XfrmOutPolError int
- // Forward routing of a packet is not allowed
- XfrmFwdHdrError int
- // State is invalid, perhaps expired
- XfrmOutStateInvalid int
- // State hasn’t been fully acquired before use
- XfrmAcquireError int
-}
-
-// NewXfrmStat reads the xfrm_stat statistics.
-func NewXfrmStat() (XfrmStat, error) {
- fs, err := NewFS(DefaultMountPoint)
- if err != nil {
- return XfrmStat{}, err
- }
-
- return fs.NewXfrmStat()
-}
-
-// NewXfrmStat reads the xfrm_stat statistics from the 'proc' filesystem.
-func (fs FS) NewXfrmStat() (XfrmStat, error) {
- file, err := os.Open(fs.proc.Path("net/xfrm_stat"))
- if err != nil {
- return XfrmStat{}, err
- }
- defer file.Close()
-
- var (
- x = XfrmStat{}
- s = bufio.NewScanner(file)
- )
-
- for s.Scan() {
- fields := strings.Fields(s.Text())
-
- if len(fields) != 2 {
- return XfrmStat{}, fmt.Errorf("%w: %q line %q", ErrFileParse, file.Name(), s.Text())
- }
-
- name := fields[0]
- value, err := strconv.Atoi(fields[1])
- if err != nil {
- return XfrmStat{}, err
- }
-
- switch name {
- case "XfrmInError":
- x.XfrmInError = value
- case "XfrmInBufferError":
- x.XfrmInBufferError = value
- case "XfrmInHdrError":
- x.XfrmInHdrError = value
- case "XfrmInNoStates":
- x.XfrmInNoStates = value
- case "XfrmInStateProtoError":
- x.XfrmInStateProtoError = value
- case "XfrmInStateModeError":
- x.XfrmInStateModeError = value
- case "XfrmInStateSeqError":
- x.XfrmInStateSeqError = value
- case "XfrmInStateExpired":
- x.XfrmInStateExpired = value
- case "XfrmInStateInvalid":
- x.XfrmInStateInvalid = value
- case "XfrmInTmplMismatch":
- x.XfrmInTmplMismatch = value
- case "XfrmInNoPols":
- x.XfrmInNoPols = value
- case "XfrmInPolBlock":
- x.XfrmInPolBlock = value
- case "XfrmInPolError":
- x.XfrmInPolError = value
- case "XfrmOutError":
- x.XfrmOutError = value
- case "XfrmInStateMismatch":
- x.XfrmInStateMismatch = value
- case "XfrmOutBundleGenError":
- x.XfrmOutBundleGenError = value
- case "XfrmOutBundleCheckError":
- x.XfrmOutBundleCheckError = value
- case "XfrmOutNoStates":
- x.XfrmOutNoStates = value
- case "XfrmOutStateProtoError":
- x.XfrmOutStateProtoError = value
- case "XfrmOutStateModeError":
- x.XfrmOutStateModeError = value
- case "XfrmOutStateSeqError":
- x.XfrmOutStateSeqError = value
- case "XfrmOutStateExpired":
- x.XfrmOutStateExpired = value
- case "XfrmOutPolBlock":
- x.XfrmOutPolBlock = value
- case "XfrmOutPolDead":
- x.XfrmOutPolDead = value
- case "XfrmOutPolError":
- x.XfrmOutPolError = value
- case "XfrmFwdHdrError":
- x.XfrmFwdHdrError = value
- case "XfrmOutStateInvalid":
- x.XfrmOutStateInvalid = value
- case "XfrmAcquireError":
- x.XfrmAcquireError = value
- }
-
- }
-
- return x, s.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/netstat.go b/vendor/github.com/prometheus/procfs/netstat.go
deleted file mode 100644
index 742dff4..0000000
--- a/vendor/github.com/prometheus/procfs/netstat.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "os"
- "path/filepath"
- "strconv"
- "strings"
-)
-
-// NetStat contains statistics for all the counters from one file.
-type NetStat struct {
- Stats map[string][]uint64
- Filename string
-}
-
-// NetStat retrieves stats from `/proc/net/stat/`.
-func (fs FS) NetStat() ([]NetStat, error) {
- statFiles, err := filepath.Glob(fs.proc.Path("net/stat/*"))
- if err != nil {
- return nil, err
- }
-
- var netStatsTotal []NetStat
-
- for _, filePath := range statFiles {
- procNetstat, err := parseNetstat(filePath)
- if err != nil {
- return nil, err
- }
- procNetstat.Filename = filepath.Base(filePath)
-
- netStatsTotal = append(netStatsTotal, procNetstat)
- }
- return netStatsTotal, nil
-}
-
-// parseNetstat parses the metrics from `/proc/net/stat/` file
-// and returns a NetStat structure.
-func parseNetstat(filePath string) (NetStat, error) {
- netStat := NetStat{
- Stats: make(map[string][]uint64),
- }
- file, err := os.Open(filePath)
- if err != nil {
- return netStat, err
- }
- defer file.Close()
-
- scanner := bufio.NewScanner(file)
- scanner.Scan()
-
- // First string is always a header for stats
- var headers []string
- headers = append(headers, strings.Fields(scanner.Text())...)
-
- // Other strings represent per-CPU counters
- for scanner.Scan() {
- for num, counter := range strings.Fields(scanner.Text()) {
- value, err := strconv.ParseUint(counter, 16, 64)
- if err != nil {
- return NetStat{}, err
- }
- netStat.Stats[headers[num]] = append(netStat.Stats[headers[num]], value)
- }
- }
-
- return netStat, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/proc.go b/vendor/github.com/prometheus/procfs/proc.go
deleted file mode 100644
index 1427963..0000000
--- a/vendor/github.com/prometheus/procfs/proc.go
+++ /dev/null
@@ -1,338 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io"
- "os"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Proc provides information about a running process.
-type Proc struct {
- // The process ID.
- PID int
-
- fs FS
-}
-
-// Procs represents a list of Proc structs.
-type Procs []Proc
-
-var (
- ErrFileParse = errors.New("Error Parsing File")
- ErrFileRead = errors.New("Error Reading File")
- ErrMountPoint = errors.New("Error Accessing Mount point")
-)
-
-func (p Procs) Len() int { return len(p) }
-func (p Procs) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-func (p Procs) Less(i, j int) bool { return p[i].PID < p[j].PID }
-
-// Self returns a process for the current process read via /proc/self.
-func Self() (Proc, error) {
- fs, err := NewFS(DefaultMountPoint)
- if err != nil || errors.Unwrap(err) == ErrMountPoint {
- return Proc{}, err
- }
- return fs.Self()
-}
-
-// NewProc returns a process for the given pid under /proc.
-func NewProc(pid int) (Proc, error) {
- fs, err := NewFS(DefaultMountPoint)
- if err != nil {
- return Proc{}, err
- }
- return fs.Proc(pid)
-}
-
-// AllProcs returns a list of all currently available processes under /proc.
-func AllProcs() (Procs, error) {
- fs, err := NewFS(DefaultMountPoint)
- if err != nil {
- return Procs{}, err
- }
- return fs.AllProcs()
-}
-
-// Self returns a process for the current process.
-func (fs FS) Self() (Proc, error) {
- p, err := os.Readlink(fs.proc.Path("self"))
- if err != nil {
- return Proc{}, err
- }
- pid, err := strconv.Atoi(strings.Replace(p, string(fs.proc), "", -1))
- if err != nil {
- return Proc{}, err
- }
- return fs.Proc(pid)
-}
-
-// NewProc returns a process for the given pid.
-//
-// Deprecated: Use fs.Proc() instead.
-func (fs FS) NewProc(pid int) (Proc, error) {
- return fs.Proc(pid)
-}
-
-// Proc returns a process for the given pid.
-func (fs FS) Proc(pid int) (Proc, error) {
- if _, err := os.Stat(fs.proc.Path(strconv.Itoa(pid))); err != nil {
- return Proc{}, err
- }
- return Proc{PID: pid, fs: fs}, nil
-}
-
-// AllProcs returns a list of all currently available processes.
-func (fs FS) AllProcs() (Procs, error) {
- d, err := os.Open(fs.proc.Path())
- if err != nil {
- return Procs{}, err
- }
- defer d.Close()
-
- names, err := d.Readdirnames(-1)
- if err != nil {
- return Procs{}, fmt.Errorf("%w: Cannot read file: %v: %w", ErrFileRead, names, err)
- }
-
- p := Procs{}
- for _, n := range names {
- pid, err := strconv.ParseInt(n, 10, 64)
- if err != nil {
- continue
- }
- p = append(p, Proc{PID: int(pid), fs: fs})
- }
-
- return p, nil
-}
-
-// CmdLine returns the command line of a process.
-func (p Proc) CmdLine() ([]string, error) {
- data, err := util.ReadFileNoStat(p.path("cmdline"))
- if err != nil {
- return nil, err
- }
-
- if len(data) < 1 {
- return []string{}, nil
- }
-
- return strings.Split(string(bytes.TrimRight(data, "\x00")), "\x00"), nil
-}
-
-// Wchan returns the wchan (wait channel) of a process.
-func (p Proc) Wchan() (string, error) {
- f, err := os.Open(p.path("wchan"))
- if err != nil {
- return "", err
- }
- defer f.Close()
-
- data, err := io.ReadAll(f)
- if err != nil {
- return "", err
- }
-
- wchan := string(data)
- if wchan == "" || wchan == "0" {
- return "", nil
- }
-
- return wchan, nil
-}
-
-// Comm returns the command name of a process.
-func (p Proc) Comm() (string, error) {
- data, err := util.ReadFileNoStat(p.path("comm"))
- if err != nil {
- return "", err
- }
-
- return strings.TrimSpace(string(data)), nil
-}
-
-// Executable returns the absolute path of the executable command of a process.
-func (p Proc) Executable() (string, error) {
- exe, err := os.Readlink(p.path("exe"))
- if os.IsNotExist(err) {
- return "", nil
- }
-
- return exe, err
-}
-
-// Cwd returns the absolute path to the current working directory of the process.
-func (p Proc) Cwd() (string, error) {
- wd, err := os.Readlink(p.path("cwd"))
- if os.IsNotExist(err) {
- return "", nil
- }
-
- return wd, err
-}
-
-// RootDir returns the absolute path to the process's root directory (as set by chroot).
-func (p Proc) RootDir() (string, error) {
- rdir, err := os.Readlink(p.path("root"))
- if os.IsNotExist(err) {
- return "", nil
- }
-
- return rdir, err
-}
-
-// FileDescriptors returns the currently open file descriptors of a process.
-func (p Proc) FileDescriptors() ([]uintptr, error) {
- names, err := p.fileDescriptors()
- if err != nil {
- return nil, err
- }
-
- fds := make([]uintptr, len(names))
- for i, n := range names {
- fd, err := strconv.ParseInt(n, 10, 32)
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot parse line: %v: %w", ErrFileParse, i, err)
- }
- fds[i] = uintptr(fd)
- }
-
- return fds, nil
-}
-
-// FileDescriptorTargets returns the targets of all file descriptors of a process.
-// If a file descriptor is not a symlink to a file (like a socket), that value will be the empty string.
-func (p Proc) FileDescriptorTargets() ([]string, error) {
- names, err := p.fileDescriptors()
- if err != nil {
- return nil, err
- }
-
- targets := make([]string, len(names))
-
- for i, name := range names {
- target, err := os.Readlink(p.path("fd", name))
- if err == nil {
- targets[i] = target
- }
- }
-
- return targets, nil
-}
-
-// FileDescriptorsLen returns the number of currently open file descriptors of
-// a process.
-func (p Proc) FileDescriptorsLen() (int, error) {
- // Use fast path if available (Linux v6.2): https://github.com/torvalds/linux/commit/f1f1f2569901
- if p.fs.isReal {
- stat, err := os.Stat(p.path("fd"))
- if err != nil {
- return 0, err
- }
-
- size := stat.Size()
- if size > 0 {
- return int(size), nil
- }
- }
-
- fds, err := p.fileDescriptors()
- if err != nil {
- return 0, err
- }
-
- return len(fds), nil
-}
-
-// MountStats retrieves statistics and configuration for mount points in a
-// process's namespace.
-func (p Proc) MountStats() ([]*Mount, error) {
- f, err := os.Open(p.path("mountstats"))
- if err != nil {
- return nil, err
- }
- defer f.Close()
-
- return parseMountStats(f)
-}
-
-// MountInfo retrieves mount information for mount points in a
-// process's namespace.
-// It supplies information missing in `/proc/self/mounts` and
-// fixes various other problems with that file too.
-func (p Proc) MountInfo() ([]*MountInfo, error) {
- data, err := util.ReadFileNoStat(p.path("mountinfo"))
- if err != nil {
- return nil, err
- }
- return parseMountInfo(data)
-}
-
-func (p Proc) fileDescriptors() ([]string, error) {
- d, err := os.Open(p.path("fd"))
- if err != nil {
- return nil, err
- }
- defer d.Close()
-
- names, err := d.Readdirnames(-1)
- if err != nil {
- return nil, fmt.Errorf("%w: Cannot read file: %v: %w", ErrFileRead, names, err)
- }
-
- return names, nil
-}
-
-func (p Proc) path(pa ...string) string {
- return p.fs.proc.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...)
-}
-
-// FileDescriptorsInfo retrieves information about all file descriptors of
-// the process.
-func (p Proc) FileDescriptorsInfo() (ProcFDInfos, error) {
- names, err := p.fileDescriptors()
- if err != nil {
- return nil, err
- }
-
- var fdinfos ProcFDInfos
-
- for _, n := range names {
- fdinfo, err := p.FDInfo(n)
- if err != nil {
- continue
- }
- fdinfos = append(fdinfos, *fdinfo)
- }
-
- return fdinfos, nil
-}
-
-// Schedstat returns task scheduling information for the process.
-func (p Proc) Schedstat() (ProcSchedstat, error) {
- contents, err := os.ReadFile(p.path("schedstat"))
- if err != nil {
- return ProcSchedstat{}, err
- }
- return parseProcSchedstat(string(contents))
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_cgroup.go b/vendor/github.com/prometheus/procfs/proc_cgroup.go
deleted file mode 100644
index daeed7f..0000000
--- a/vendor/github.com/prometheus/procfs/proc_cgroup.go
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the placement of a PID inside a
-// specific control hierarchy. The kernel has two cgroup APIs, v1 and v2. v1 has one hierarchy per available resource
-// controller, while v2 has one unified hierarchy shared by all controllers. Regardless of v1 or v2, all hierarchies
-// contain all running processes, so the question answerable with a Cgroup struct is 'where is this process in
-// this hierarchy' (where==what path on the specific cgroupfs). By prefixing this path with the mount point of
-// *this specific* hierarchy, you can locate the relevant pseudo-files needed to read/set the data for this PID
-// in this hierarchy
-//
-// Also see http://man7.org/linux/man-pages/man7/cgroups.7.html
-type Cgroup struct {
- // HierarchyID that can be matched to a named hierarchy using /proc/cgroups. Cgroups V2 only has one
- // hierarchy, so HierarchyID is always 0. For cgroups v1 this is a unique ID number
- HierarchyID int
- // Controllers using this hierarchy of processes. Controllers are also known as subsystems. For
- // Cgroups V2 this may be empty, as all active controllers use the same hierarchy
- Controllers []string
- // Path of this control group, relative to the mount point of the cgroupfs representing this specific
- // hierarchy
- Path string
-}
-
-// parseCgroupString parses each line of the /proc/[pid]/cgroup file
-// Line format is hierarchyID:[controller1,controller2]:path.
-func parseCgroupString(cgroupStr string) (*Cgroup, error) {
- var err error
-
- fields := strings.SplitN(cgroupStr, ":", 3)
- if len(fields) < 3 {
- return nil, fmt.Errorf("%w: 3+ fields required, found %d fields in cgroup string: %s", ErrFileParse, len(fields), cgroupStr)
- }
-
- cgroup := &Cgroup{
- Path: fields[2],
- Controllers: nil,
- }
- cgroup.HierarchyID, err = strconv.Atoi(fields[0])
- if err != nil {
- return nil, fmt.Errorf("%w: hierarchy ID: %q", ErrFileParse, cgroup.HierarchyID)
- }
- if fields[1] != "" {
- ssNames := strings.Split(fields[1], ",")
- cgroup.Controllers = append(cgroup.Controllers, ssNames...)
- }
- return cgroup, nil
-}
-
-// parseCgroups reads each line of the /proc/[pid]/cgroup file.
-func parseCgroups(data []byte) ([]Cgroup, error) {
- var cgroups []Cgroup
- scanner := bufio.NewScanner(bytes.NewReader(data))
- for scanner.Scan() {
- mountString := scanner.Text()
- parsedMounts, err := parseCgroupString(mountString)
- if err != nil {
- return nil, err
- }
- cgroups = append(cgroups, *parsedMounts)
- }
-
- err := scanner.Err()
- return cgroups, err
-}
-
-// Cgroups reads from /proc//cgroups and returns a []*Cgroup struct locating this PID in each process
-// control hierarchy running on this system. On every system (v1 and v2), all hierarchies contain all processes,
-// so the len of the returned struct is equal to the number of active hierarchies on this system.
-func (p Proc) Cgroups() ([]Cgroup, error) {
- data, err := util.ReadFileNoStat(p.path("cgroup"))
- if err != nil {
- return nil, err
- }
- return parseCgroups(data)
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_cgroups.go b/vendor/github.com/prometheus/procfs/proc_cgroups.go
deleted file mode 100644
index 5dd4938..0000000
--- a/vendor/github.com/prometheus/procfs/proc_cgroups.go
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2021 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// CgroupSummary models one line from /proc/cgroups.
-// This file contains information about the controllers that are compiled into the kernel.
-//
-// Also see http://man7.org/linux/man-pages/man7/cgroups.7.html
-type CgroupSummary struct {
- // The name of the controller. controller is also known as subsystem.
- SubsysName string
- // The unique ID of the cgroup hierarchy on which this controller is mounted.
- Hierarchy int
- // The number of control groups in this hierarchy using this controller.
- Cgroups int
- // This field contains the value 1 if this controller is enabled, or 0 if it has been disabled
- Enabled int
-}
-
-// parseCgroupSummary parses each line of the /proc/cgroup file
-// Line format is `subsys_name hierarchy num_cgroups enabled`.
-func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) {
- var err error
-
- fields := strings.Fields(CgroupSummaryStr)
- // require at least 4 fields
- if len(fields) < 4 {
- return nil, fmt.Errorf("%w: 4+ fields required, found %d fields in cgroup info string: %s", ErrFileParse, len(fields), CgroupSummaryStr)
- }
-
- CgroupSummary := &CgroupSummary{
- SubsysName: fields[0],
- }
- CgroupSummary.Hierarchy, err = strconv.Atoi(fields[1])
- if err != nil {
- return nil, fmt.Errorf("%w: Unable to parse hierarchy ID from %q", ErrFileParse, fields[1])
- }
- CgroupSummary.Cgroups, err = strconv.Atoi(fields[2])
- if err != nil {
- return nil, fmt.Errorf("%w: Unable to parse Cgroup Num from %q", ErrFileParse, fields[2])
- }
- CgroupSummary.Enabled, err = strconv.Atoi(fields[3])
- if err != nil {
- return nil, fmt.Errorf("%w: Unable to parse Enabled from %q", ErrFileParse, fields[3])
- }
- return CgroupSummary, nil
-}
-
-// parseCgroupSummary reads each line of the /proc/cgroup file.
-func parseCgroupSummary(data []byte) ([]CgroupSummary, error) {
- var CgroupSummarys []CgroupSummary
- scanner := bufio.NewScanner(bytes.NewReader(data))
- for scanner.Scan() {
- CgroupSummaryString := scanner.Text()
- // ignore comment lines
- if strings.HasPrefix(CgroupSummaryString, "#") {
- continue
- }
- CgroupSummary, err := parseCgroupSummaryString(CgroupSummaryString)
- if err != nil {
- return nil, err
- }
- CgroupSummarys = append(CgroupSummarys, *CgroupSummary)
- }
-
- err := scanner.Err()
- return CgroupSummarys, err
-}
-
-// CgroupSummarys returns information about current /proc/cgroups.
-func (fs FS) CgroupSummarys() ([]CgroupSummary, error) {
- data, err := util.ReadFileNoStat(fs.proc.Path("cgroups"))
- if err != nil {
- return nil, err
- }
- return parseCgroupSummary(data)
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_environ.go b/vendor/github.com/prometheus/procfs/proc_environ.go
deleted file mode 100644
index 57a8989..0000000
--- a/vendor/github.com/prometheus/procfs/proc_environ.go
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Environ reads process environments from `/proc//environ`.
-func (p Proc) Environ() ([]string, error) {
- environments := make([]string, 0)
-
- data, err := util.ReadFileNoStat(p.path("environ"))
- if err != nil {
- return environments, err
- }
-
- environments = strings.Split(string(data), "\000")
- if len(environments) > 0 {
- environments = environments[:len(environments)-1]
- }
-
- return environments, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_fdinfo.go b/vendor/github.com/prometheus/procfs/proc_fdinfo.go
deleted file mode 100644
index fa761b3..0000000
--- a/vendor/github.com/prometheus/procfs/proc_fdinfo.go
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "regexp"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-var (
- rPos = regexp.MustCompile(`^pos:\s+(\d+)$`)
- rFlags = regexp.MustCompile(`^flags:\s+(\d+)$`)
- rMntID = regexp.MustCompile(`^mnt_id:\s+(\d+)$`)
- rIno = regexp.MustCompile(`^ino:\s+(\d+)$`)
- rInotify = regexp.MustCompile(`^inotify`)
- rInotifyParts = regexp.MustCompile(`^inotify\s+wd:([0-9a-f]+)\s+ino:([0-9a-f]+)\s+sdev:([0-9a-f]+)(?:\s+mask:([0-9a-f]+))?`)
-)
-
-// ProcFDInfo contains represents file descriptor information.
-type ProcFDInfo struct {
- // File descriptor
- FD string
- // File offset
- Pos string
- // File access mode and status flags
- Flags string
- // Mount point ID
- MntID string
- // Inode number
- Ino string
- // List of inotify lines (structured) in the fdinfo file (kernel 3.8+ only)
- InotifyInfos []InotifyInfo
-}
-
-// FDInfo constructor. On kernels older than 3.8, InotifyInfos will always be empty.
-func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) {
- data, err := util.ReadFileNoStat(p.path("fdinfo", fd))
- if err != nil {
- return nil, err
- }
-
- var text, pos, flags, mntid, ino string
- var inotify []InotifyInfo
-
- scanner := bufio.NewScanner(bytes.NewReader(data))
- for scanner.Scan() {
- text = scanner.Text()
- if rPos.MatchString(text) {
- pos = rPos.FindStringSubmatch(text)[1]
- } else if rFlags.MatchString(text) {
- flags = rFlags.FindStringSubmatch(text)[1]
- } else if rMntID.MatchString(text) {
- mntid = rMntID.FindStringSubmatch(text)[1]
- } else if rIno.MatchString(text) {
- ino = rIno.FindStringSubmatch(text)[1]
- } else if rInotify.MatchString(text) {
- newInotify, err := parseInotifyInfo(text)
- if err != nil {
- return nil, err
- }
- inotify = append(inotify, *newInotify)
- }
- }
-
- i := &ProcFDInfo{
- FD: fd,
- Pos: pos,
- Flags: flags,
- MntID: mntid,
- Ino: ino,
- InotifyInfos: inotify,
- }
-
- return i, nil
-}
-
-// InotifyInfo represents a single inotify line in the fdinfo file.
-type InotifyInfo struct {
- // Watch descriptor number
- WD string
- // Inode number
- Ino string
- // Device ID
- Sdev string
- // Mask of events being monitored
- Mask string
-}
-
-// InotifyInfo constructor. Only available on kernel 3.8+.
-func parseInotifyInfo(line string) (*InotifyInfo, error) {
- m := rInotifyParts.FindStringSubmatch(line)
- if len(m) >= 4 {
- var mask string
- if len(m) == 5 {
- mask = m[4]
- }
- i := &InotifyInfo{
- WD: m[1],
- Ino: m[2],
- Sdev: m[3],
- Mask: mask,
- }
- return i, nil
- }
- return nil, fmt.Errorf("%w: invalid inode entry: %q", ErrFileParse, line)
-}
-
-// ProcFDInfos represents a list of ProcFDInfo structs.
-type ProcFDInfos []ProcFDInfo
-
-func (p ProcFDInfos) Len() int { return len(p) }
-func (p ProcFDInfos) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-func (p ProcFDInfos) Less(i, j int) bool { return p[i].FD < p[j].FD }
-
-// InotifyWatchLen returns the total number of inotify watches.
-func (p ProcFDInfos) InotifyWatchLen() (int, error) {
- length := 0
- for _, f := range p {
- length += len(f.InotifyInfos)
- }
-
- return length, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_interrupts.go b/vendor/github.com/prometheus/procfs/proc_interrupts.go
deleted file mode 100644
index 86b4b45..0000000
--- a/vendor/github.com/prometheus/procfs/proc_interrupts.go
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "errors"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Interrupt represents a single interrupt line.
-type Interrupt struct {
- // Info is the type of interrupt.
- Info string
- // Devices is the name of the device that is located at that IRQ
- Devices string
- // Values is the number of interrupts per CPU.
- Values []string
-}
-
-// Interrupts models the content of /proc/interrupts. Key is the IRQ number.
-// - https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-proc-interrupts
-// - https://raspberrypi.stackexchange.com/questions/105802/explanation-of-proc-interrupts-output
-type Interrupts map[string]Interrupt
-
-// Interrupts creates a new instance from a given Proc instance.
-func (p Proc) Interrupts() (Interrupts, error) {
- data, err := util.ReadFileNoStat(p.path("interrupts"))
- if err != nil {
- return nil, err
- }
- return parseInterrupts(bytes.NewReader(data))
-}
-
-func parseInterrupts(r io.Reader) (Interrupts, error) {
- var (
- interrupts = Interrupts{}
- scanner = bufio.NewScanner(r)
- )
-
- if !scanner.Scan() {
- return nil, errors.New("interrupts empty")
- }
- cpuNum := len(strings.Fields(scanner.Text())) // one header per cpu
-
- for scanner.Scan() {
- parts := strings.Fields(scanner.Text())
- if len(parts) == 0 { // skip empty lines
- continue
- }
- if len(parts) < 2 {
- return nil, fmt.Errorf("%w: Not enough fields in interrupts (expected 2+ fields but got %d): %s", ErrFileParse, len(parts), parts)
- }
- intName := parts[0][:len(parts[0])-1] // remove trailing :
-
- if len(parts) == 2 {
- interrupts[intName] = Interrupt{
- Info: "",
- Devices: "",
- Values: []string{
- parts[1],
- },
- }
- continue
- }
-
- intr := Interrupt{
- Values: parts[1 : cpuNum+1],
- }
-
- if _, err := strconv.Atoi(intName); err == nil { // numeral interrupt
- intr.Info = parts[cpuNum+1]
- intr.Devices = strings.Join(parts[cpuNum+2:], " ")
- } else {
- intr.Info = strings.Join(parts[cpuNum+1:], " ")
- }
- interrupts[intName] = intr
- }
-
- return interrupts, scanner.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_io.go b/vendor/github.com/prometheus/procfs/proc_io.go
deleted file mode 100644
index 776f349..0000000
--- a/vendor/github.com/prometheus/procfs/proc_io.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "fmt"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// ProcIO models the content of /proc//io.
-type ProcIO struct {
- // Chars read.
- RChar uint64
- // Chars written.
- WChar uint64
- // Read syscalls.
- SyscR uint64
- // Write syscalls.
- SyscW uint64
- // Bytes read.
- ReadBytes uint64
- // Bytes written.
- WriteBytes uint64
- // Bytes written, but taking into account truncation. See
- // Documentation/filesystems/proc.txt in the kernel sources for
- // detailed explanation.
- CancelledWriteBytes int64
-}
-
-// IO creates a new ProcIO instance from a given Proc instance.
-func (p Proc) IO() (ProcIO, error) {
- pio := ProcIO{}
-
- data, err := util.ReadFileNoStat(p.path("io"))
- if err != nil {
- return pio, err
- }
-
- ioFormat := "rchar: %d\nwchar: %d\nsyscr: %d\nsyscw: %d\n" +
- "read_bytes: %d\nwrite_bytes: %d\n" +
- "cancelled_write_bytes: %d\n"
-
- _, err = fmt.Sscanf(string(data), ioFormat, &pio.RChar, &pio.WChar, &pio.SyscR,
- &pio.SyscW, &pio.ReadBytes, &pio.WriteBytes, &pio.CancelledWriteBytes)
-
- return pio, err
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_limits.go b/vendor/github.com/prometheus/procfs/proc_limits.go
deleted file mode 100644
index 9530b14..0000000
--- a/vendor/github.com/prometheus/procfs/proc_limits.go
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "fmt"
- "os"
- "regexp"
- "strconv"
-)
-
-// ProcLimits represents the soft limits for each of the process's resource
-// limits. For more information see getrlimit(2):
-// http://man7.org/linux/man-pages/man2/getrlimit.2.html.
-type ProcLimits struct {
- // CPU time limit in seconds.
- CPUTime uint64
- // Maximum size of files that the process may create.
- FileSize uint64
- // Maximum size of the process's data segment (initialized data,
- // uninitialized data, and heap).
- DataSize uint64
- // Maximum size of the process stack in bytes.
- StackSize uint64
- // Maximum size of a core file.
- CoreFileSize uint64
- // Limit of the process's resident set in pages.
- ResidentSet uint64
- // Maximum number of processes that can be created for the real user ID of
- // the calling process.
- Processes uint64
- // Value one greater than the maximum file descriptor number that can be
- // opened by this process.
- OpenFiles uint64
- // Maximum number of bytes of memory that may be locked into RAM.
- LockedMemory uint64
- // Maximum size of the process's virtual memory address space in bytes.
- AddressSpace uint64
- // Limit on the combined number of flock(2) locks and fcntl(2) leases that
- // this process may establish.
- FileLocks uint64
- // Limit of signals that may be queued for the real user ID of the calling
- // process.
- PendingSignals uint64
- // Limit on the number of bytes that can be allocated for POSIX message
- // queues for the real user ID of the calling process.
- MsqqueueSize uint64
- // Limit of the nice priority set using setpriority(2) or nice(2).
- NicePriority uint64
- // Limit of the real-time priority set using sched_setscheduler(2) or
- // sched_setparam(2).
- RealtimePriority uint64
- // Limit (in microseconds) on the amount of CPU time that a process
- // scheduled under a real-time scheduling policy may consume without making
- // a blocking system call.
- RealtimeTimeout uint64
-}
-
-const (
- limitsFields = 4
- limitsUnlimited = "unlimited"
-)
-
-var (
- limitsMatch = regexp.MustCompile(`(Max \w+\s{0,1}?\w*\s{0,1}\w*)\s{2,}(\w+)\s+(\w+)`)
-)
-
-// NewLimits returns the current soft limits of the process.
-//
-// Deprecated: Use p.Limits() instead.
-func (p Proc) NewLimits() (ProcLimits, error) {
- return p.Limits()
-}
-
-// Limits returns the current soft limits of the process.
-func (p Proc) Limits() (ProcLimits, error) {
- f, err := os.Open(p.path("limits"))
- if err != nil {
- return ProcLimits{}, err
- }
- defer f.Close()
-
- var (
- l = ProcLimits{}
- s = bufio.NewScanner(f)
- )
-
- s.Scan() // Skip limits header
-
- for s.Scan() {
- //fields := limitsMatch.Split(s.Text(), limitsFields)
- fields := limitsMatch.FindStringSubmatch(s.Text())
- if len(fields) != limitsFields {
- return ProcLimits{}, fmt.Errorf("%w: couldn't parse %q line %q", ErrFileParse, f.Name(), s.Text())
- }
-
- switch fields[1] {
- case "Max cpu time":
- l.CPUTime, err = parseUint(fields[2])
- case "Max file size":
- l.FileSize, err = parseUint(fields[2])
- case "Max data size":
- l.DataSize, err = parseUint(fields[2])
- case "Max stack size":
- l.StackSize, err = parseUint(fields[2])
- case "Max core file size":
- l.CoreFileSize, err = parseUint(fields[2])
- case "Max resident set":
- l.ResidentSet, err = parseUint(fields[2])
- case "Max processes":
- l.Processes, err = parseUint(fields[2])
- case "Max open files":
- l.OpenFiles, err = parseUint(fields[2])
- case "Max locked memory":
- l.LockedMemory, err = parseUint(fields[2])
- case "Max address space":
- l.AddressSpace, err = parseUint(fields[2])
- case "Max file locks":
- l.FileLocks, err = parseUint(fields[2])
- case "Max pending signals":
- l.PendingSignals, err = parseUint(fields[2])
- case "Max msgqueue size":
- l.MsqqueueSize, err = parseUint(fields[2])
- case "Max nice priority":
- l.NicePriority, err = parseUint(fields[2])
- case "Max realtime priority":
- l.RealtimePriority, err = parseUint(fields[2])
- case "Max realtime timeout":
- l.RealtimeTimeout, err = parseUint(fields[2])
- }
- if err != nil {
- return ProcLimits{}, err
- }
- }
-
- return l, s.Err()
-}
-
-func parseUint(s string) (uint64, error) {
- if s == limitsUnlimited {
- return 18446744073709551615, nil
- }
- i, err := strconv.ParseUint(s, 10, 64)
- if err != nil {
- return 0, fmt.Errorf("%w: couldn't parse value %q: %w", ErrFileParse, s, err)
- }
- return i, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_maps.go b/vendor/github.com/prometheus/procfs/proc_maps.go
deleted file mode 100644
index 7e75c28..0000000
--- a/vendor/github.com/prometheus/procfs/proc_maps.go
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) && !js
-// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
-// +build !js
-
-package procfs
-
-import (
- "bufio"
- "fmt"
- "os"
- "strconv"
- "strings"
-
- "golang.org/x/sys/unix"
-)
-
-// ProcMapPermissions contains permission settings read from `/proc/[pid]/maps`.
-type ProcMapPermissions struct {
- // mapping has the [R]ead flag set
- Read bool
- // mapping has the [W]rite flag set
- Write bool
- // mapping has the [X]ecutable flag set
- Execute bool
- // mapping has the [S]hared flag set
- Shared bool
- // mapping is marked as [P]rivate (copy on write)
- Private bool
-}
-
-// ProcMap contains the process memory-mappings of the process
-// read from `/proc/[pid]/maps`.
-type ProcMap struct {
- // The start address of current mapping.
- StartAddr uintptr
- // The end address of the current mapping
- EndAddr uintptr
- // The permissions for this mapping
- Perms *ProcMapPermissions
- // The current offset into the file/fd (e.g., shared libs)
- Offset int64
- // Device owner of this mapping (major:minor) in Mkdev format.
- Dev uint64
- // The inode of the device above
- Inode uint64
- // The file or psuedofile (or empty==anonymous)
- Pathname string
-}
-
-// parseDevice parses the device token of a line and converts it to a dev_t
-// (mkdev) like structure.
-func parseDevice(s string) (uint64, error) {
- i := strings.Index(s, ":")
- if i == -1 {
- return 0, fmt.Errorf("%w: expected separator `:` in %s", ErrFileParse, s)
- }
-
- major, err := strconv.ParseUint(s[0:i], 16, 0)
- if err != nil {
- return 0, err
- }
-
- minor, err := strconv.ParseUint(s[i+1:], 16, 0)
- if err != nil {
- return 0, err
- }
-
- return unix.Mkdev(uint32(major), uint32(minor)), nil
-}
-
-// parseAddress converts a hex-string to a uintptr.
-func parseAddress(s string) (uintptr, error) {
- a, err := strconv.ParseUint(s, 16, 0)
- if err != nil {
- return 0, err
- }
-
- return uintptr(a), nil
-}
-
-// parseAddresses parses the start-end address.
-func parseAddresses(s string) (uintptr, uintptr, error) {
- idx := strings.Index(s, "-")
- if idx == -1 {
- return 0, 0, fmt.Errorf("%w: expected separator `-` in %s", ErrFileParse, s)
- }
-
- saddr, err := parseAddress(s[0:idx])
- if err != nil {
- return 0, 0, err
- }
-
- eaddr, err := parseAddress(s[idx+1:])
- if err != nil {
- return 0, 0, err
- }
-
- return saddr, eaddr, nil
-}
-
-// parsePermissions parses a token and returns any that are set.
-func parsePermissions(s string) (*ProcMapPermissions, error) {
- if len(s) < 4 {
- return nil, fmt.Errorf("%w: invalid permissions token", ErrFileParse)
- }
-
- perms := ProcMapPermissions{}
- for _, ch := range s {
- switch ch {
- case 'r':
- perms.Read = true
- case 'w':
- perms.Write = true
- case 'x':
- perms.Execute = true
- case 'p':
- perms.Private = true
- case 's':
- perms.Shared = true
- }
- }
-
- return &perms, nil
-}
-
-// parseProcMap will attempt to parse a single line within a proc/[pid]/maps
-// buffer.
-func parseProcMap(text string) (*ProcMap, error) {
- fields := strings.Fields(text)
- if len(fields) < 5 {
- return nil, fmt.Errorf("%w: truncated procmap entry", ErrFileParse)
- }
-
- saddr, eaddr, err := parseAddresses(fields[0])
- if err != nil {
- return nil, err
- }
-
- perms, err := parsePermissions(fields[1])
- if err != nil {
- return nil, err
- }
-
- offset, err := strconv.ParseInt(fields[2], 16, 0)
- if err != nil {
- return nil, err
- }
-
- device, err := parseDevice(fields[3])
- if err != nil {
- return nil, err
- }
-
- inode, err := strconv.ParseUint(fields[4], 10, 0)
- if err != nil {
- return nil, err
- }
-
- pathname := ""
-
- if len(fields) >= 5 {
- pathname = strings.Join(fields[5:], " ")
- }
-
- return &ProcMap{
- StartAddr: saddr,
- EndAddr: eaddr,
- Perms: perms,
- Offset: offset,
- Dev: device,
- Inode: inode,
- Pathname: pathname,
- }, nil
-}
-
-// ProcMaps reads from /proc/[pid]/maps to get the memory-mappings of the
-// process.
-func (p Proc) ProcMaps() ([]*ProcMap, error) {
- file, err := os.Open(p.path("maps"))
- if err != nil {
- return nil, err
- }
- defer file.Close()
-
- maps := []*ProcMap{}
- scan := bufio.NewScanner(file)
-
- for scan.Scan() {
- m, err := parseProcMap(scan.Text())
- if err != nil {
- return nil, err
- }
-
- maps = append(maps, m)
- }
-
- return maps, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_netstat.go b/vendor/github.com/prometheus/procfs/proc_netstat.go
deleted file mode 100644
index 8e3ff4d..0000000
--- a/vendor/github.com/prometheus/procfs/proc_netstat.go
+++ /dev/null
@@ -1,443 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// ProcNetstat models the content of /proc//net/netstat.
-type ProcNetstat struct {
- // The process ID.
- PID int
- TcpExt
- IpExt
-}
-
-type TcpExt struct { // nolint:revive
- SyncookiesSent *float64
- SyncookiesRecv *float64
- SyncookiesFailed *float64
- EmbryonicRsts *float64
- PruneCalled *float64
- RcvPruned *float64
- OfoPruned *float64
- OutOfWindowIcmps *float64
- LockDroppedIcmps *float64
- ArpFilter *float64
- TW *float64
- TWRecycled *float64
- TWKilled *float64
- PAWSActive *float64
- PAWSEstab *float64
- DelayedACKs *float64
- DelayedACKLocked *float64
- DelayedACKLost *float64
- ListenOverflows *float64
- ListenDrops *float64
- TCPHPHits *float64
- TCPPureAcks *float64
- TCPHPAcks *float64
- TCPRenoRecovery *float64
- TCPSackRecovery *float64
- TCPSACKReneging *float64
- TCPSACKReorder *float64
- TCPRenoReorder *float64
- TCPTSReorder *float64
- TCPFullUndo *float64
- TCPPartialUndo *float64
- TCPDSACKUndo *float64
- TCPLossUndo *float64
- TCPLostRetransmit *float64
- TCPRenoFailures *float64
- TCPSackFailures *float64
- TCPLossFailures *float64
- TCPFastRetrans *float64
- TCPSlowStartRetrans *float64
- TCPTimeouts *float64
- TCPLossProbes *float64
- TCPLossProbeRecovery *float64
- TCPRenoRecoveryFail *float64
- TCPSackRecoveryFail *float64
- TCPRcvCollapsed *float64
- TCPDSACKOldSent *float64
- TCPDSACKOfoSent *float64
- TCPDSACKRecv *float64
- TCPDSACKOfoRecv *float64
- TCPAbortOnData *float64
- TCPAbortOnClose *float64
- TCPAbortOnMemory *float64
- TCPAbortOnTimeout *float64
- TCPAbortOnLinger *float64
- TCPAbortFailed *float64
- TCPMemoryPressures *float64
- TCPMemoryPressuresChrono *float64
- TCPSACKDiscard *float64
- TCPDSACKIgnoredOld *float64
- TCPDSACKIgnoredNoUndo *float64
- TCPSpuriousRTOs *float64
- TCPMD5NotFound *float64
- TCPMD5Unexpected *float64
- TCPMD5Failure *float64
- TCPSackShifted *float64
- TCPSackMerged *float64
- TCPSackShiftFallback *float64
- TCPBacklogDrop *float64
- PFMemallocDrop *float64
- TCPMinTTLDrop *float64
- TCPDeferAcceptDrop *float64
- IPReversePathFilter *float64
- TCPTimeWaitOverflow *float64
- TCPReqQFullDoCookies *float64
- TCPReqQFullDrop *float64
- TCPRetransFail *float64
- TCPRcvCoalesce *float64
- TCPRcvQDrop *float64
- TCPOFOQueue *float64
- TCPOFODrop *float64
- TCPOFOMerge *float64
- TCPChallengeACK *float64
- TCPSYNChallenge *float64
- TCPFastOpenActive *float64
- TCPFastOpenActiveFail *float64
- TCPFastOpenPassive *float64
- TCPFastOpenPassiveFail *float64
- TCPFastOpenListenOverflow *float64
- TCPFastOpenCookieReqd *float64
- TCPFastOpenBlackhole *float64
- TCPSpuriousRtxHostQueues *float64
- BusyPollRxPackets *float64
- TCPAutoCorking *float64
- TCPFromZeroWindowAdv *float64
- TCPToZeroWindowAdv *float64
- TCPWantZeroWindowAdv *float64
- TCPSynRetrans *float64
- TCPOrigDataSent *float64
- TCPHystartTrainDetect *float64
- TCPHystartTrainCwnd *float64
- TCPHystartDelayDetect *float64
- TCPHystartDelayCwnd *float64
- TCPACKSkippedSynRecv *float64
- TCPACKSkippedPAWS *float64
- TCPACKSkippedSeq *float64
- TCPACKSkippedFinWait2 *float64
- TCPACKSkippedTimeWait *float64
- TCPACKSkippedChallenge *float64
- TCPWinProbe *float64
- TCPKeepAlive *float64
- TCPMTUPFail *float64
- TCPMTUPSuccess *float64
- TCPWqueueTooBig *float64
-}
-
-type IpExt struct { // nolint:revive
- InNoRoutes *float64
- InTruncatedPkts *float64
- InMcastPkts *float64
- OutMcastPkts *float64
- InBcastPkts *float64
- OutBcastPkts *float64
- InOctets *float64
- OutOctets *float64
- InMcastOctets *float64
- OutMcastOctets *float64
- InBcastOctets *float64
- OutBcastOctets *float64
- InCsumErrors *float64
- InNoECTPkts *float64
- InECT1Pkts *float64
- InECT0Pkts *float64
- InCEPkts *float64
- ReasmOverlaps *float64
-}
-
-func (p Proc) Netstat() (ProcNetstat, error) {
- filename := p.path("net/netstat")
- data, err := util.ReadFileNoStat(filename)
- if err != nil {
- return ProcNetstat{PID: p.PID}, err
- }
- procNetstat, err := parseProcNetstat(bytes.NewReader(data), filename)
- procNetstat.PID = p.PID
- return procNetstat, err
-}
-
-// parseProcNetstat parses the metrics from proc//net/netstat file
-// and returns a ProcNetstat structure.
-func parseProcNetstat(r io.Reader, fileName string) (ProcNetstat, error) {
- var (
- scanner = bufio.NewScanner(r)
- procNetstat = ProcNetstat{}
- )
-
- for scanner.Scan() {
- nameParts := strings.Split(scanner.Text(), " ")
- scanner.Scan()
- valueParts := strings.Split(scanner.Text(), " ")
- // Remove trailing :.
- protocol := strings.TrimSuffix(nameParts[0], ":")
- if len(nameParts) != len(valueParts) {
- return procNetstat, fmt.Errorf("%w: mismatch field count mismatch in %s: %s",
- ErrFileParse, fileName, protocol)
- }
- for i := 1; i < len(nameParts); i++ {
- value, err := strconv.ParseFloat(valueParts[i], 64)
- if err != nil {
- return procNetstat, err
- }
- key := nameParts[i]
-
- switch protocol {
- case "TcpExt":
- switch key {
- case "SyncookiesSent":
- procNetstat.TcpExt.SyncookiesSent = &value
- case "SyncookiesRecv":
- procNetstat.TcpExt.SyncookiesRecv = &value
- case "SyncookiesFailed":
- procNetstat.TcpExt.SyncookiesFailed = &value
- case "EmbryonicRsts":
- procNetstat.TcpExt.EmbryonicRsts = &value
- case "PruneCalled":
- procNetstat.TcpExt.PruneCalled = &value
- case "RcvPruned":
- procNetstat.TcpExt.RcvPruned = &value
- case "OfoPruned":
- procNetstat.TcpExt.OfoPruned = &value
- case "OutOfWindowIcmps":
- procNetstat.TcpExt.OutOfWindowIcmps = &value
- case "LockDroppedIcmps":
- procNetstat.TcpExt.LockDroppedIcmps = &value
- case "ArpFilter":
- procNetstat.TcpExt.ArpFilter = &value
- case "TW":
- procNetstat.TcpExt.TW = &value
- case "TWRecycled":
- procNetstat.TcpExt.TWRecycled = &value
- case "TWKilled":
- procNetstat.TcpExt.TWKilled = &value
- case "PAWSActive":
- procNetstat.TcpExt.PAWSActive = &value
- case "PAWSEstab":
- procNetstat.TcpExt.PAWSEstab = &value
- case "DelayedACKs":
- procNetstat.TcpExt.DelayedACKs = &value
- case "DelayedACKLocked":
- procNetstat.TcpExt.DelayedACKLocked = &value
- case "DelayedACKLost":
- procNetstat.TcpExt.DelayedACKLost = &value
- case "ListenOverflows":
- procNetstat.TcpExt.ListenOverflows = &value
- case "ListenDrops":
- procNetstat.TcpExt.ListenDrops = &value
- case "TCPHPHits":
- procNetstat.TcpExt.TCPHPHits = &value
- case "TCPPureAcks":
- procNetstat.TcpExt.TCPPureAcks = &value
- case "TCPHPAcks":
- procNetstat.TcpExt.TCPHPAcks = &value
- case "TCPRenoRecovery":
- procNetstat.TcpExt.TCPRenoRecovery = &value
- case "TCPSackRecovery":
- procNetstat.TcpExt.TCPSackRecovery = &value
- case "TCPSACKReneging":
- procNetstat.TcpExt.TCPSACKReneging = &value
- case "TCPSACKReorder":
- procNetstat.TcpExt.TCPSACKReorder = &value
- case "TCPRenoReorder":
- procNetstat.TcpExt.TCPRenoReorder = &value
- case "TCPTSReorder":
- procNetstat.TcpExt.TCPTSReorder = &value
- case "TCPFullUndo":
- procNetstat.TcpExt.TCPFullUndo = &value
- case "TCPPartialUndo":
- procNetstat.TcpExt.TCPPartialUndo = &value
- case "TCPDSACKUndo":
- procNetstat.TcpExt.TCPDSACKUndo = &value
- case "TCPLossUndo":
- procNetstat.TcpExt.TCPLossUndo = &value
- case "TCPLostRetransmit":
- procNetstat.TcpExt.TCPLostRetransmit = &value
- case "TCPRenoFailures":
- procNetstat.TcpExt.TCPRenoFailures = &value
- case "TCPSackFailures":
- procNetstat.TcpExt.TCPSackFailures = &value
- case "TCPLossFailures":
- procNetstat.TcpExt.TCPLossFailures = &value
- case "TCPFastRetrans":
- procNetstat.TcpExt.TCPFastRetrans = &value
- case "TCPSlowStartRetrans":
- procNetstat.TcpExt.TCPSlowStartRetrans = &value
- case "TCPTimeouts":
- procNetstat.TcpExt.TCPTimeouts = &value
- case "TCPLossProbes":
- procNetstat.TcpExt.TCPLossProbes = &value
- case "TCPLossProbeRecovery":
- procNetstat.TcpExt.TCPLossProbeRecovery = &value
- case "TCPRenoRecoveryFail":
- procNetstat.TcpExt.TCPRenoRecoveryFail = &value
- case "TCPSackRecoveryFail":
- procNetstat.TcpExt.TCPSackRecoveryFail = &value
- case "TCPRcvCollapsed":
- procNetstat.TcpExt.TCPRcvCollapsed = &value
- case "TCPDSACKOldSent":
- procNetstat.TcpExt.TCPDSACKOldSent = &value
- case "TCPDSACKOfoSent":
- procNetstat.TcpExt.TCPDSACKOfoSent = &value
- case "TCPDSACKRecv":
- procNetstat.TcpExt.TCPDSACKRecv = &value
- case "TCPDSACKOfoRecv":
- procNetstat.TcpExt.TCPDSACKOfoRecv = &value
- case "TCPAbortOnData":
- procNetstat.TcpExt.TCPAbortOnData = &value
- case "TCPAbortOnClose":
- procNetstat.TcpExt.TCPAbortOnClose = &value
- case "TCPDeferAcceptDrop":
- procNetstat.TcpExt.TCPDeferAcceptDrop = &value
- case "IPReversePathFilter":
- procNetstat.TcpExt.IPReversePathFilter = &value
- case "TCPTimeWaitOverflow":
- procNetstat.TcpExt.TCPTimeWaitOverflow = &value
- case "TCPReqQFullDoCookies":
- procNetstat.TcpExt.TCPReqQFullDoCookies = &value
- case "TCPReqQFullDrop":
- procNetstat.TcpExt.TCPReqQFullDrop = &value
- case "TCPRetransFail":
- procNetstat.TcpExt.TCPRetransFail = &value
- case "TCPRcvCoalesce":
- procNetstat.TcpExt.TCPRcvCoalesce = &value
- case "TCPRcvQDrop":
- procNetstat.TcpExt.TCPRcvQDrop = &value
- case "TCPOFOQueue":
- procNetstat.TcpExt.TCPOFOQueue = &value
- case "TCPOFODrop":
- procNetstat.TcpExt.TCPOFODrop = &value
- case "TCPOFOMerge":
- procNetstat.TcpExt.TCPOFOMerge = &value
- case "TCPChallengeACK":
- procNetstat.TcpExt.TCPChallengeACK = &value
- case "TCPSYNChallenge":
- procNetstat.TcpExt.TCPSYNChallenge = &value
- case "TCPFastOpenActive":
- procNetstat.TcpExt.TCPFastOpenActive = &value
- case "TCPFastOpenActiveFail":
- procNetstat.TcpExt.TCPFastOpenActiveFail = &value
- case "TCPFastOpenPassive":
- procNetstat.TcpExt.TCPFastOpenPassive = &value
- case "TCPFastOpenPassiveFail":
- procNetstat.TcpExt.TCPFastOpenPassiveFail = &value
- case "TCPFastOpenListenOverflow":
- procNetstat.TcpExt.TCPFastOpenListenOverflow = &value
- case "TCPFastOpenCookieReqd":
- procNetstat.TcpExt.TCPFastOpenCookieReqd = &value
- case "TCPFastOpenBlackhole":
- procNetstat.TcpExt.TCPFastOpenBlackhole = &value
- case "TCPSpuriousRtxHostQueues":
- procNetstat.TcpExt.TCPSpuriousRtxHostQueues = &value
- case "BusyPollRxPackets":
- procNetstat.TcpExt.BusyPollRxPackets = &value
- case "TCPAutoCorking":
- procNetstat.TcpExt.TCPAutoCorking = &value
- case "TCPFromZeroWindowAdv":
- procNetstat.TcpExt.TCPFromZeroWindowAdv = &value
- case "TCPToZeroWindowAdv":
- procNetstat.TcpExt.TCPToZeroWindowAdv = &value
- case "TCPWantZeroWindowAdv":
- procNetstat.TcpExt.TCPWantZeroWindowAdv = &value
- case "TCPSynRetrans":
- procNetstat.TcpExt.TCPSynRetrans = &value
- case "TCPOrigDataSent":
- procNetstat.TcpExt.TCPOrigDataSent = &value
- case "TCPHystartTrainDetect":
- procNetstat.TcpExt.TCPHystartTrainDetect = &value
- case "TCPHystartTrainCwnd":
- procNetstat.TcpExt.TCPHystartTrainCwnd = &value
- case "TCPHystartDelayDetect":
- procNetstat.TcpExt.TCPHystartDelayDetect = &value
- case "TCPHystartDelayCwnd":
- procNetstat.TcpExt.TCPHystartDelayCwnd = &value
- case "TCPACKSkippedSynRecv":
- procNetstat.TcpExt.TCPACKSkippedSynRecv = &value
- case "TCPACKSkippedPAWS":
- procNetstat.TcpExt.TCPACKSkippedPAWS = &value
- case "TCPACKSkippedSeq":
- procNetstat.TcpExt.TCPACKSkippedSeq = &value
- case "TCPACKSkippedFinWait2":
- procNetstat.TcpExt.TCPACKSkippedFinWait2 = &value
- case "TCPACKSkippedTimeWait":
- procNetstat.TcpExt.TCPACKSkippedTimeWait = &value
- case "TCPACKSkippedChallenge":
- procNetstat.TcpExt.TCPACKSkippedChallenge = &value
- case "TCPWinProbe":
- procNetstat.TcpExt.TCPWinProbe = &value
- case "TCPKeepAlive":
- procNetstat.TcpExt.TCPKeepAlive = &value
- case "TCPMTUPFail":
- procNetstat.TcpExt.TCPMTUPFail = &value
- case "TCPMTUPSuccess":
- procNetstat.TcpExt.TCPMTUPSuccess = &value
- case "TCPWqueueTooBig":
- procNetstat.TcpExt.TCPWqueueTooBig = &value
- }
- case "IpExt":
- switch key {
- case "InNoRoutes":
- procNetstat.IpExt.InNoRoutes = &value
- case "InTruncatedPkts":
- procNetstat.IpExt.InTruncatedPkts = &value
- case "InMcastPkts":
- procNetstat.IpExt.InMcastPkts = &value
- case "OutMcastPkts":
- procNetstat.IpExt.OutMcastPkts = &value
- case "InBcastPkts":
- procNetstat.IpExt.InBcastPkts = &value
- case "OutBcastPkts":
- procNetstat.IpExt.OutBcastPkts = &value
- case "InOctets":
- procNetstat.IpExt.InOctets = &value
- case "OutOctets":
- procNetstat.IpExt.OutOctets = &value
- case "InMcastOctets":
- procNetstat.IpExt.InMcastOctets = &value
- case "OutMcastOctets":
- procNetstat.IpExt.OutMcastOctets = &value
- case "InBcastOctets":
- procNetstat.IpExt.InBcastOctets = &value
- case "OutBcastOctets":
- procNetstat.IpExt.OutBcastOctets = &value
- case "InCsumErrors":
- procNetstat.IpExt.InCsumErrors = &value
- case "InNoECTPkts":
- procNetstat.IpExt.InNoECTPkts = &value
- case "InECT1Pkts":
- procNetstat.IpExt.InECT1Pkts = &value
- case "InECT0Pkts":
- procNetstat.IpExt.InECT0Pkts = &value
- case "InCEPkts":
- procNetstat.IpExt.InCEPkts = &value
- case "ReasmOverlaps":
- procNetstat.IpExt.ReasmOverlaps = &value
- }
- }
- }
- }
- return procNetstat, scanner.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_ns.go b/vendor/github.com/prometheus/procfs/proc_ns.go
deleted file mode 100644
index 0f8f847..0000000
--- a/vendor/github.com/prometheus/procfs/proc_ns.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "fmt"
- "os"
- "strconv"
- "strings"
-)
-
-// Namespace represents a single namespace of a process.
-type Namespace struct {
- Type string // Namespace type.
- Inode uint32 // Inode number of the namespace. If two processes are in the same namespace their inodes will match.
-}
-
-// Namespaces contains all of the namespaces that the process is contained in.
-type Namespaces map[string]Namespace
-
-// Namespaces reads from /proc//ns/* to get the namespaces of which the
-// process is a member.
-func (p Proc) Namespaces() (Namespaces, error) {
- d, err := os.Open(p.path("ns"))
- if err != nil {
- return nil, err
- }
- defer d.Close()
-
- names, err := d.Readdirnames(-1)
- if err != nil {
- return nil, fmt.Errorf("%w: failed to read contents of ns dir: %w", ErrFileRead, err)
- }
-
- ns := make(Namespaces, len(names))
- for _, name := range names {
- target, err := os.Readlink(p.path("ns", name))
- if err != nil {
- return nil, err
- }
-
- fields := strings.SplitN(target, ":", 2)
- if len(fields) != 2 {
- return nil, fmt.Errorf("%w: namespace type and inode from %q", ErrFileParse, target)
- }
-
- typ := fields[0]
- inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32)
- if err != nil {
- return nil, fmt.Errorf("%w: inode from %q: %w", ErrFileParse, fields[1], err)
- }
-
- ns[name] = Namespace{typ, uint32(inode)}
- }
-
- return ns, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_psi.go b/vendor/github.com/prometheus/procfs/proc_psi.go
deleted file mode 100644
index ccd35f1..0000000
--- a/vendor/github.com/prometheus/procfs/proc_psi.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-// The PSI / pressure interface is described at
-// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/accounting/psi.txt
-// Each resource (cpu, io, memory, ...) is exposed as a single file.
-// Each file may contain up to two lines, one for "some" pressure and one for "full" pressure.
-// Each line contains several averages (over n seconds) and a total in µs.
-//
-// Example io pressure file:
-// > some avg10=0.06 avg60=0.21 avg300=0.99 total=8537362
-// > full avg10=0.00 avg60=0.13 avg300=0.96 total=8183134
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-const lineFormat = "avg10=%f avg60=%f avg300=%f total=%d"
-
-// PSILine is a single line of values as returned by `/proc/pressure/*`.
-//
-// The Avg entries are averages over n seconds, as a percentage.
-// The Total line is in microseconds.
-type PSILine struct {
- Avg10 float64
- Avg60 float64
- Avg300 float64
- Total uint64
-}
-
-// PSIStats represent pressure stall information from /proc/pressure/*
-//
-// "Some" indicates the share of time in which at least some tasks are stalled.
-// "Full" indicates the share of time in which all non-idle tasks are stalled simultaneously.
-type PSIStats struct {
- Some *PSILine
- Full *PSILine
-}
-
-// PSIStatsForResource reads pressure stall information for the specified
-// resource from /proc/pressure/. At time of writing this can be
-// either "cpu", "memory" or "io".
-func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) {
- data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource)))
- if err != nil {
- return PSIStats{}, fmt.Errorf("%w: psi_stats: unavailable for %q: %w", ErrFileRead, resource, err)
- }
-
- return parsePSIStats(bytes.NewReader(data))
-}
-
-// parsePSIStats parses the specified file for pressure stall information.
-func parsePSIStats(r io.Reader) (PSIStats, error) {
- psiStats := PSIStats{}
-
- scanner := bufio.NewScanner(r)
- for scanner.Scan() {
- l := scanner.Text()
- prefix := strings.Split(l, " ")[0]
- switch prefix {
- case "some":
- psi := PSILine{}
- _, err := fmt.Sscanf(l, fmt.Sprintf("some %s", lineFormat), &psi.Avg10, &psi.Avg60, &psi.Avg300, &psi.Total)
- if err != nil {
- return PSIStats{}, err
- }
- psiStats.Some = &psi
- case "full":
- psi := PSILine{}
- _, err := fmt.Sscanf(l, fmt.Sprintf("full %s", lineFormat), &psi.Avg10, &psi.Avg60, &psi.Avg300, &psi.Total)
- if err != nil {
- return PSIStats{}, err
- }
- psiStats.Full = &psi
- default:
- // If we encounter a line with an unknown prefix, ignore it and move on
- // Should new measurement types be added in the future we'll simply ignore them instead
- // of erroring on retrieval
- continue
- }
- }
-
- return psiStats, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_smaps.go b/vendor/github.com/prometheus/procfs/proc_smaps.go
deleted file mode 100644
index 09060e8..0000000
--- a/vendor/github.com/prometheus/procfs/proc_smaps.go
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !windows
-// +build !windows
-
-package procfs
-
-import (
- "bufio"
- "errors"
- "fmt"
- "os"
- "regexp"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-var (
- // match the header line before each mapped zone in `/proc/pid/smaps`.
- procSMapsHeaderLine = regexp.MustCompile(`^[a-f0-9].*$`)
-)
-
-type ProcSMapsRollup struct {
- // Amount of the mapping that is currently resident in RAM.
- Rss uint64
- // Process's proportional share of this mapping.
- Pss uint64
- // Size in bytes of clean shared pages.
- SharedClean uint64
- // Size in bytes of dirty shared pages.
- SharedDirty uint64
- // Size in bytes of clean private pages.
- PrivateClean uint64
- // Size in bytes of dirty private pages.
- PrivateDirty uint64
- // Amount of memory currently marked as referenced or accessed.
- Referenced uint64
- // Amount of memory that does not belong to any file.
- Anonymous uint64
- // Amount would-be-anonymous memory currently on swap.
- Swap uint64
- // Process's proportional memory on swap.
- SwapPss uint64
-}
-
-// ProcSMapsRollup reads from /proc/[pid]/smaps_rollup to get summed memory information of the
-// process.
-//
-// If smaps_rollup does not exists (require kernel >= 4.15), the content of /proc/pid/smaps will
-// we read and summed.
-func (p Proc) ProcSMapsRollup() (ProcSMapsRollup, error) {
- data, err := util.ReadFileNoStat(p.path("smaps_rollup"))
- if err != nil && os.IsNotExist(err) {
- return p.procSMapsRollupManual()
- }
- if err != nil {
- return ProcSMapsRollup{}, err
- }
-
- lines := strings.Split(string(data), "\n")
- smaps := ProcSMapsRollup{}
-
- // skip first line which don't contains information we need
- lines = lines[1:]
- for _, line := range lines {
- if line == "" {
- continue
- }
-
- if err := smaps.parseLine(line); err != nil {
- return ProcSMapsRollup{}, err
- }
- }
-
- return smaps, nil
-}
-
-// Read /proc/pid/smaps and do the roll-up in Go code.
-func (p Proc) procSMapsRollupManual() (ProcSMapsRollup, error) {
- file, err := os.Open(p.path("smaps"))
- if err != nil {
- return ProcSMapsRollup{}, err
- }
- defer file.Close()
-
- smaps := ProcSMapsRollup{}
- scan := bufio.NewScanner(file)
-
- for scan.Scan() {
- line := scan.Text()
-
- if procSMapsHeaderLine.MatchString(line) {
- continue
- }
-
- if err := smaps.parseLine(line); err != nil {
- return ProcSMapsRollup{}, err
- }
- }
-
- return smaps, nil
-}
-
-func (s *ProcSMapsRollup) parseLine(line string) error {
- kv := strings.SplitN(line, ":", 2)
- if len(kv) != 2 {
- fmt.Println(line)
- return errors.New("invalid net/dev line, missing colon")
- }
-
- k := kv[0]
- if k == "VmFlags" {
- return nil
- }
-
- v := strings.TrimSpace(kv[1])
- v = strings.TrimSuffix(v, " kB")
-
- vKBytes, err := strconv.ParseUint(v, 10, 64)
- if err != nil {
- return err
- }
- vBytes := vKBytes * 1024
-
- s.addValue(k, vBytes)
-
- return nil
-}
-
-func (s *ProcSMapsRollup) addValue(k string, vUintBytes uint64) {
- switch k {
- case "Rss":
- s.Rss += vUintBytes
- case "Pss":
- s.Pss += vUintBytes
- case "Shared_Clean":
- s.SharedClean += vUintBytes
- case "Shared_Dirty":
- s.SharedDirty += vUintBytes
- case "Private_Clean":
- s.PrivateClean += vUintBytes
- case "Private_Dirty":
- s.PrivateDirty += vUintBytes
- case "Referenced":
- s.Referenced += vUintBytes
- case "Anonymous":
- s.Anonymous += vUintBytes
- case "Swap":
- s.Swap += vUintBytes
- case "SwapPss":
- s.SwapPss += vUintBytes
- }
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_snmp.go b/vendor/github.com/prometheus/procfs/proc_snmp.go
deleted file mode 100644
index b9d2cf6..0000000
--- a/vendor/github.com/prometheus/procfs/proc_snmp.go
+++ /dev/null
@@ -1,353 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// ProcSnmp models the content of /proc//net/snmp.
-type ProcSnmp struct {
- // The process ID.
- PID int
- Ip
- Icmp
- IcmpMsg
- Tcp
- Udp
- UdpLite
-}
-
-type Ip struct { // nolint:revive
- Forwarding *float64
- DefaultTTL *float64
- InReceives *float64
- InHdrErrors *float64
- InAddrErrors *float64
- ForwDatagrams *float64
- InUnknownProtos *float64
- InDiscards *float64
- InDelivers *float64
- OutRequests *float64
- OutDiscards *float64
- OutNoRoutes *float64
- ReasmTimeout *float64
- ReasmReqds *float64
- ReasmOKs *float64
- ReasmFails *float64
- FragOKs *float64
- FragFails *float64
- FragCreates *float64
-}
-
-type Icmp struct { // nolint:revive
- InMsgs *float64
- InErrors *float64
- InCsumErrors *float64
- InDestUnreachs *float64
- InTimeExcds *float64
- InParmProbs *float64
- InSrcQuenchs *float64
- InRedirects *float64
- InEchos *float64
- InEchoReps *float64
- InTimestamps *float64
- InTimestampReps *float64
- InAddrMasks *float64
- InAddrMaskReps *float64
- OutMsgs *float64
- OutErrors *float64
- OutDestUnreachs *float64
- OutTimeExcds *float64
- OutParmProbs *float64
- OutSrcQuenchs *float64
- OutRedirects *float64
- OutEchos *float64
- OutEchoReps *float64
- OutTimestamps *float64
- OutTimestampReps *float64
- OutAddrMasks *float64
- OutAddrMaskReps *float64
-}
-
-type IcmpMsg struct {
- InType3 *float64
- OutType3 *float64
-}
-
-type Tcp struct { // nolint:revive
- RtoAlgorithm *float64
- RtoMin *float64
- RtoMax *float64
- MaxConn *float64
- ActiveOpens *float64
- PassiveOpens *float64
- AttemptFails *float64
- EstabResets *float64
- CurrEstab *float64
- InSegs *float64
- OutSegs *float64
- RetransSegs *float64
- InErrs *float64
- OutRsts *float64
- InCsumErrors *float64
-}
-
-type Udp struct { // nolint:revive
- InDatagrams *float64
- NoPorts *float64
- InErrors *float64
- OutDatagrams *float64
- RcvbufErrors *float64
- SndbufErrors *float64
- InCsumErrors *float64
- IgnoredMulti *float64
-}
-
-type UdpLite struct { // nolint:revive
- InDatagrams *float64
- NoPorts *float64
- InErrors *float64
- OutDatagrams *float64
- RcvbufErrors *float64
- SndbufErrors *float64
- InCsumErrors *float64
- IgnoredMulti *float64
-}
-
-func (p Proc) Snmp() (ProcSnmp, error) {
- filename := p.path("net/snmp")
- data, err := util.ReadFileNoStat(filename)
- if err != nil {
- return ProcSnmp{PID: p.PID}, err
- }
- procSnmp, err := parseSnmp(bytes.NewReader(data), filename)
- procSnmp.PID = p.PID
- return procSnmp, err
-}
-
-// parseSnmp parses the metrics from proc//net/snmp file
-// and returns a map contains those metrics (e.g. {"Ip": {"Forwarding": 2}}).
-func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) {
- var (
- scanner = bufio.NewScanner(r)
- procSnmp = ProcSnmp{}
- )
-
- for scanner.Scan() {
- nameParts := strings.Split(scanner.Text(), " ")
- scanner.Scan()
- valueParts := strings.Split(scanner.Text(), " ")
- // Remove trailing :.
- protocol := strings.TrimSuffix(nameParts[0], ":")
- if len(nameParts) != len(valueParts) {
- return procSnmp, fmt.Errorf("%w: mismatch field count mismatch in %s: %s",
- ErrFileParse, fileName, protocol)
- }
- for i := 1; i < len(nameParts); i++ {
- value, err := strconv.ParseFloat(valueParts[i], 64)
- if err != nil {
- return procSnmp, err
- }
- key := nameParts[i]
-
- switch protocol {
- case "Ip":
- switch key {
- case "Forwarding":
- procSnmp.Ip.Forwarding = &value
- case "DefaultTTL":
- procSnmp.Ip.DefaultTTL = &value
- case "InReceives":
- procSnmp.Ip.InReceives = &value
- case "InHdrErrors":
- procSnmp.Ip.InHdrErrors = &value
- case "InAddrErrors":
- procSnmp.Ip.InAddrErrors = &value
- case "ForwDatagrams":
- procSnmp.Ip.ForwDatagrams = &value
- case "InUnknownProtos":
- procSnmp.Ip.InUnknownProtos = &value
- case "InDiscards":
- procSnmp.Ip.InDiscards = &value
- case "InDelivers":
- procSnmp.Ip.InDelivers = &value
- case "OutRequests":
- procSnmp.Ip.OutRequests = &value
- case "OutDiscards":
- procSnmp.Ip.OutDiscards = &value
- case "OutNoRoutes":
- procSnmp.Ip.OutNoRoutes = &value
- case "ReasmTimeout":
- procSnmp.Ip.ReasmTimeout = &value
- case "ReasmReqds":
- procSnmp.Ip.ReasmReqds = &value
- case "ReasmOKs":
- procSnmp.Ip.ReasmOKs = &value
- case "ReasmFails":
- procSnmp.Ip.ReasmFails = &value
- case "FragOKs":
- procSnmp.Ip.FragOKs = &value
- case "FragFails":
- procSnmp.Ip.FragFails = &value
- case "FragCreates":
- procSnmp.Ip.FragCreates = &value
- }
- case "Icmp":
- switch key {
- case "InMsgs":
- procSnmp.Icmp.InMsgs = &value
- case "InErrors":
- procSnmp.Icmp.InErrors = &value
- case "InCsumErrors":
- procSnmp.Icmp.InCsumErrors = &value
- case "InDestUnreachs":
- procSnmp.Icmp.InDestUnreachs = &value
- case "InTimeExcds":
- procSnmp.Icmp.InTimeExcds = &value
- case "InParmProbs":
- procSnmp.Icmp.InParmProbs = &value
- case "InSrcQuenchs":
- procSnmp.Icmp.InSrcQuenchs = &value
- case "InRedirects":
- procSnmp.Icmp.InRedirects = &value
- case "InEchos":
- procSnmp.Icmp.InEchos = &value
- case "InEchoReps":
- procSnmp.Icmp.InEchoReps = &value
- case "InTimestamps":
- procSnmp.Icmp.InTimestamps = &value
- case "InTimestampReps":
- procSnmp.Icmp.InTimestampReps = &value
- case "InAddrMasks":
- procSnmp.Icmp.InAddrMasks = &value
- case "InAddrMaskReps":
- procSnmp.Icmp.InAddrMaskReps = &value
- case "OutMsgs":
- procSnmp.Icmp.OutMsgs = &value
- case "OutErrors":
- procSnmp.Icmp.OutErrors = &value
- case "OutDestUnreachs":
- procSnmp.Icmp.OutDestUnreachs = &value
- case "OutTimeExcds":
- procSnmp.Icmp.OutTimeExcds = &value
- case "OutParmProbs":
- procSnmp.Icmp.OutParmProbs = &value
- case "OutSrcQuenchs":
- procSnmp.Icmp.OutSrcQuenchs = &value
- case "OutRedirects":
- procSnmp.Icmp.OutRedirects = &value
- case "OutEchos":
- procSnmp.Icmp.OutEchos = &value
- case "OutEchoReps":
- procSnmp.Icmp.OutEchoReps = &value
- case "OutTimestamps":
- procSnmp.Icmp.OutTimestamps = &value
- case "OutTimestampReps":
- procSnmp.Icmp.OutTimestampReps = &value
- case "OutAddrMasks":
- procSnmp.Icmp.OutAddrMasks = &value
- case "OutAddrMaskReps":
- procSnmp.Icmp.OutAddrMaskReps = &value
- }
- case "IcmpMsg":
- switch key {
- case "InType3":
- procSnmp.IcmpMsg.InType3 = &value
- case "OutType3":
- procSnmp.IcmpMsg.OutType3 = &value
- }
- case "Tcp":
- switch key {
- case "RtoAlgorithm":
- procSnmp.Tcp.RtoAlgorithm = &value
- case "RtoMin":
- procSnmp.Tcp.RtoMin = &value
- case "RtoMax":
- procSnmp.Tcp.RtoMax = &value
- case "MaxConn":
- procSnmp.Tcp.MaxConn = &value
- case "ActiveOpens":
- procSnmp.Tcp.ActiveOpens = &value
- case "PassiveOpens":
- procSnmp.Tcp.PassiveOpens = &value
- case "AttemptFails":
- procSnmp.Tcp.AttemptFails = &value
- case "EstabResets":
- procSnmp.Tcp.EstabResets = &value
- case "CurrEstab":
- procSnmp.Tcp.CurrEstab = &value
- case "InSegs":
- procSnmp.Tcp.InSegs = &value
- case "OutSegs":
- procSnmp.Tcp.OutSegs = &value
- case "RetransSegs":
- procSnmp.Tcp.RetransSegs = &value
- case "InErrs":
- procSnmp.Tcp.InErrs = &value
- case "OutRsts":
- procSnmp.Tcp.OutRsts = &value
- case "InCsumErrors":
- procSnmp.Tcp.InCsumErrors = &value
- }
- case "Udp":
- switch key {
- case "InDatagrams":
- procSnmp.Udp.InDatagrams = &value
- case "NoPorts":
- procSnmp.Udp.NoPorts = &value
- case "InErrors":
- procSnmp.Udp.InErrors = &value
- case "OutDatagrams":
- procSnmp.Udp.OutDatagrams = &value
- case "RcvbufErrors":
- procSnmp.Udp.RcvbufErrors = &value
- case "SndbufErrors":
- procSnmp.Udp.SndbufErrors = &value
- case "InCsumErrors":
- procSnmp.Udp.InCsumErrors = &value
- case "IgnoredMulti":
- procSnmp.Udp.IgnoredMulti = &value
- }
- case "UdpLite":
- switch key {
- case "InDatagrams":
- procSnmp.UdpLite.InDatagrams = &value
- case "NoPorts":
- procSnmp.UdpLite.NoPorts = &value
- case "InErrors":
- procSnmp.UdpLite.InErrors = &value
- case "OutDatagrams":
- procSnmp.UdpLite.OutDatagrams = &value
- case "RcvbufErrors":
- procSnmp.UdpLite.RcvbufErrors = &value
- case "SndbufErrors":
- procSnmp.UdpLite.SndbufErrors = &value
- case "InCsumErrors":
- procSnmp.UdpLite.InCsumErrors = &value
- case "IgnoredMulti":
- procSnmp.UdpLite.IgnoredMulti = &value
- }
- }
- }
- }
- return procSnmp, scanner.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_snmp6.go b/vendor/github.com/prometheus/procfs/proc_snmp6.go
deleted file mode 100644
index 3059cc6..0000000
--- a/vendor/github.com/prometheus/procfs/proc_snmp6.go
+++ /dev/null
@@ -1,381 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "errors"
- "io"
- "os"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// ProcSnmp6 models the content of /proc//net/snmp6.
-type ProcSnmp6 struct {
- // The process ID.
- PID int
- Ip6
- Icmp6
- Udp6
- UdpLite6
-}
-
-type Ip6 struct { // nolint:revive
- InReceives *float64
- InHdrErrors *float64
- InTooBigErrors *float64
- InNoRoutes *float64
- InAddrErrors *float64
- InUnknownProtos *float64
- InTruncatedPkts *float64
- InDiscards *float64
- InDelivers *float64
- OutForwDatagrams *float64
- OutRequests *float64
- OutDiscards *float64
- OutNoRoutes *float64
- ReasmTimeout *float64
- ReasmReqds *float64
- ReasmOKs *float64
- ReasmFails *float64
- FragOKs *float64
- FragFails *float64
- FragCreates *float64
- InMcastPkts *float64
- OutMcastPkts *float64
- InOctets *float64
- OutOctets *float64
- InMcastOctets *float64
- OutMcastOctets *float64
- InBcastOctets *float64
- OutBcastOctets *float64
- InNoECTPkts *float64
- InECT1Pkts *float64
- InECT0Pkts *float64
- InCEPkts *float64
-}
-
-type Icmp6 struct {
- InMsgs *float64
- InErrors *float64
- OutMsgs *float64
- OutErrors *float64
- InCsumErrors *float64
- InDestUnreachs *float64
- InPktTooBigs *float64
- InTimeExcds *float64
- InParmProblems *float64
- InEchos *float64
- InEchoReplies *float64
- InGroupMembQueries *float64
- InGroupMembResponses *float64
- InGroupMembReductions *float64
- InRouterSolicits *float64
- InRouterAdvertisements *float64
- InNeighborSolicits *float64
- InNeighborAdvertisements *float64
- InRedirects *float64
- InMLDv2Reports *float64
- OutDestUnreachs *float64
- OutPktTooBigs *float64
- OutTimeExcds *float64
- OutParmProblems *float64
- OutEchos *float64
- OutEchoReplies *float64
- OutGroupMembQueries *float64
- OutGroupMembResponses *float64
- OutGroupMembReductions *float64
- OutRouterSolicits *float64
- OutRouterAdvertisements *float64
- OutNeighborSolicits *float64
- OutNeighborAdvertisements *float64
- OutRedirects *float64
- OutMLDv2Reports *float64
- InType1 *float64
- InType134 *float64
- InType135 *float64
- InType136 *float64
- InType143 *float64
- OutType133 *float64
- OutType135 *float64
- OutType136 *float64
- OutType143 *float64
-}
-
-type Udp6 struct { // nolint:revive
- InDatagrams *float64
- NoPorts *float64
- InErrors *float64
- OutDatagrams *float64
- RcvbufErrors *float64
- SndbufErrors *float64
- InCsumErrors *float64
- IgnoredMulti *float64
-}
-
-type UdpLite6 struct { // nolint:revive
- InDatagrams *float64
- NoPorts *float64
- InErrors *float64
- OutDatagrams *float64
- RcvbufErrors *float64
- SndbufErrors *float64
- InCsumErrors *float64
-}
-
-func (p Proc) Snmp6() (ProcSnmp6, error) {
- filename := p.path("net/snmp6")
- data, err := util.ReadFileNoStat(filename)
- if err != nil {
- // On systems with IPv6 disabled, this file won't exist.
- // Do nothing.
- if errors.Is(err, os.ErrNotExist) {
- return ProcSnmp6{PID: p.PID}, nil
- }
-
- return ProcSnmp6{PID: p.PID}, err
- }
-
- procSnmp6, err := parseSNMP6Stats(bytes.NewReader(data))
- procSnmp6.PID = p.PID
- return procSnmp6, err
-}
-
-// parseSnmp6 parses the metrics from proc//net/snmp6 file
-// and returns a map contains those metrics.
-func parseSNMP6Stats(r io.Reader) (ProcSnmp6, error) {
- var (
- scanner = bufio.NewScanner(r)
- procSnmp6 = ProcSnmp6{}
- )
-
- for scanner.Scan() {
- stat := strings.Fields(scanner.Text())
- if len(stat) < 2 {
- continue
- }
- // Expect to have "6" in metric name, skip line otherwise
- if sixIndex := strings.Index(stat[0], "6"); sixIndex != -1 {
- protocol := stat[0][:sixIndex+1]
- key := stat[0][sixIndex+1:]
- value, err := strconv.ParseFloat(stat[1], 64)
- if err != nil {
- return procSnmp6, err
- }
-
- switch protocol {
- case "Ip6":
- switch key {
- case "InReceives":
- procSnmp6.Ip6.InReceives = &value
- case "InHdrErrors":
- procSnmp6.Ip6.InHdrErrors = &value
- case "InTooBigErrors":
- procSnmp6.Ip6.InTooBigErrors = &value
- case "InNoRoutes":
- procSnmp6.Ip6.InNoRoutes = &value
- case "InAddrErrors":
- procSnmp6.Ip6.InAddrErrors = &value
- case "InUnknownProtos":
- procSnmp6.Ip6.InUnknownProtos = &value
- case "InTruncatedPkts":
- procSnmp6.Ip6.InTruncatedPkts = &value
- case "InDiscards":
- procSnmp6.Ip6.InDiscards = &value
- case "InDelivers":
- procSnmp6.Ip6.InDelivers = &value
- case "OutForwDatagrams":
- procSnmp6.Ip6.OutForwDatagrams = &value
- case "OutRequests":
- procSnmp6.Ip6.OutRequests = &value
- case "OutDiscards":
- procSnmp6.Ip6.OutDiscards = &value
- case "OutNoRoutes":
- procSnmp6.Ip6.OutNoRoutes = &value
- case "ReasmTimeout":
- procSnmp6.Ip6.ReasmTimeout = &value
- case "ReasmReqds":
- procSnmp6.Ip6.ReasmReqds = &value
- case "ReasmOKs":
- procSnmp6.Ip6.ReasmOKs = &value
- case "ReasmFails":
- procSnmp6.Ip6.ReasmFails = &value
- case "FragOKs":
- procSnmp6.Ip6.FragOKs = &value
- case "FragFails":
- procSnmp6.Ip6.FragFails = &value
- case "FragCreates":
- procSnmp6.Ip6.FragCreates = &value
- case "InMcastPkts":
- procSnmp6.Ip6.InMcastPkts = &value
- case "OutMcastPkts":
- procSnmp6.Ip6.OutMcastPkts = &value
- case "InOctets":
- procSnmp6.Ip6.InOctets = &value
- case "OutOctets":
- procSnmp6.Ip6.OutOctets = &value
- case "InMcastOctets":
- procSnmp6.Ip6.InMcastOctets = &value
- case "OutMcastOctets":
- procSnmp6.Ip6.OutMcastOctets = &value
- case "InBcastOctets":
- procSnmp6.Ip6.InBcastOctets = &value
- case "OutBcastOctets":
- procSnmp6.Ip6.OutBcastOctets = &value
- case "InNoECTPkts":
- procSnmp6.Ip6.InNoECTPkts = &value
- case "InECT1Pkts":
- procSnmp6.Ip6.InECT1Pkts = &value
- case "InECT0Pkts":
- procSnmp6.Ip6.InECT0Pkts = &value
- case "InCEPkts":
- procSnmp6.Ip6.InCEPkts = &value
-
- }
- case "Icmp6":
- switch key {
- case "InMsgs":
- procSnmp6.Icmp6.InMsgs = &value
- case "InErrors":
- procSnmp6.Icmp6.InErrors = &value
- case "OutMsgs":
- procSnmp6.Icmp6.OutMsgs = &value
- case "OutErrors":
- procSnmp6.Icmp6.OutErrors = &value
- case "InCsumErrors":
- procSnmp6.Icmp6.InCsumErrors = &value
- case "InDestUnreachs":
- procSnmp6.Icmp6.InDestUnreachs = &value
- case "InPktTooBigs":
- procSnmp6.Icmp6.InPktTooBigs = &value
- case "InTimeExcds":
- procSnmp6.Icmp6.InTimeExcds = &value
- case "InParmProblems":
- procSnmp6.Icmp6.InParmProblems = &value
- case "InEchos":
- procSnmp6.Icmp6.InEchos = &value
- case "InEchoReplies":
- procSnmp6.Icmp6.InEchoReplies = &value
- case "InGroupMembQueries":
- procSnmp6.Icmp6.InGroupMembQueries = &value
- case "InGroupMembResponses":
- procSnmp6.Icmp6.InGroupMembResponses = &value
- case "InGroupMembReductions":
- procSnmp6.Icmp6.InGroupMembReductions = &value
- case "InRouterSolicits":
- procSnmp6.Icmp6.InRouterSolicits = &value
- case "InRouterAdvertisements":
- procSnmp6.Icmp6.InRouterAdvertisements = &value
- case "InNeighborSolicits":
- procSnmp6.Icmp6.InNeighborSolicits = &value
- case "InNeighborAdvertisements":
- procSnmp6.Icmp6.InNeighborAdvertisements = &value
- case "InRedirects":
- procSnmp6.Icmp6.InRedirects = &value
- case "InMLDv2Reports":
- procSnmp6.Icmp6.InMLDv2Reports = &value
- case "OutDestUnreachs":
- procSnmp6.Icmp6.OutDestUnreachs = &value
- case "OutPktTooBigs":
- procSnmp6.Icmp6.OutPktTooBigs = &value
- case "OutTimeExcds":
- procSnmp6.Icmp6.OutTimeExcds = &value
- case "OutParmProblems":
- procSnmp6.Icmp6.OutParmProblems = &value
- case "OutEchos":
- procSnmp6.Icmp6.OutEchos = &value
- case "OutEchoReplies":
- procSnmp6.Icmp6.OutEchoReplies = &value
- case "OutGroupMembQueries":
- procSnmp6.Icmp6.OutGroupMembQueries = &value
- case "OutGroupMembResponses":
- procSnmp6.Icmp6.OutGroupMembResponses = &value
- case "OutGroupMembReductions":
- procSnmp6.Icmp6.OutGroupMembReductions = &value
- case "OutRouterSolicits":
- procSnmp6.Icmp6.OutRouterSolicits = &value
- case "OutRouterAdvertisements":
- procSnmp6.Icmp6.OutRouterAdvertisements = &value
- case "OutNeighborSolicits":
- procSnmp6.Icmp6.OutNeighborSolicits = &value
- case "OutNeighborAdvertisements":
- procSnmp6.Icmp6.OutNeighborAdvertisements = &value
- case "OutRedirects":
- procSnmp6.Icmp6.OutRedirects = &value
- case "OutMLDv2Reports":
- procSnmp6.Icmp6.OutMLDv2Reports = &value
- case "InType1":
- procSnmp6.Icmp6.InType1 = &value
- case "InType134":
- procSnmp6.Icmp6.InType134 = &value
- case "InType135":
- procSnmp6.Icmp6.InType135 = &value
- case "InType136":
- procSnmp6.Icmp6.InType136 = &value
- case "InType143":
- procSnmp6.Icmp6.InType143 = &value
- case "OutType133":
- procSnmp6.Icmp6.OutType133 = &value
- case "OutType135":
- procSnmp6.Icmp6.OutType135 = &value
- case "OutType136":
- procSnmp6.Icmp6.OutType136 = &value
- case "OutType143":
- procSnmp6.Icmp6.OutType143 = &value
- }
- case "Udp6":
- switch key {
- case "InDatagrams":
- procSnmp6.Udp6.InDatagrams = &value
- case "NoPorts":
- procSnmp6.Udp6.NoPorts = &value
- case "InErrors":
- procSnmp6.Udp6.InErrors = &value
- case "OutDatagrams":
- procSnmp6.Udp6.OutDatagrams = &value
- case "RcvbufErrors":
- procSnmp6.Udp6.RcvbufErrors = &value
- case "SndbufErrors":
- procSnmp6.Udp6.SndbufErrors = &value
- case "InCsumErrors":
- procSnmp6.Udp6.InCsumErrors = &value
- case "IgnoredMulti":
- procSnmp6.Udp6.IgnoredMulti = &value
- }
- case "UdpLite6":
- switch key {
- case "InDatagrams":
- procSnmp6.UdpLite6.InDatagrams = &value
- case "NoPorts":
- procSnmp6.UdpLite6.NoPorts = &value
- case "InErrors":
- procSnmp6.UdpLite6.InErrors = &value
- case "OutDatagrams":
- procSnmp6.UdpLite6.OutDatagrams = &value
- case "RcvbufErrors":
- procSnmp6.UdpLite6.RcvbufErrors = &value
- case "SndbufErrors":
- procSnmp6.UdpLite6.SndbufErrors = &value
- case "InCsumErrors":
- procSnmp6.UdpLite6.InCsumErrors = &value
- }
- }
- }
- }
- return procSnmp6, scanner.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_stat.go b/vendor/github.com/prometheus/procfs/proc_stat.go
deleted file mode 100644
index 06a8d93..0000000
--- a/vendor/github.com/prometheus/procfs/proc_stat.go
+++ /dev/null
@@ -1,229 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bytes"
- "fmt"
- "os"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Originally, this USER_HZ value was dynamically retrieved via a sysconf call
-// which required cgo. However, that caused a lot of problems regarding
-// cross-compilation. Alternatives such as running a binary to determine the
-// value, or trying to derive it in some other way were all problematic. After
-// much research it was determined that USER_HZ is actually hardcoded to 100 on
-// all Go-supported platforms as of the time of this writing. This is why we
-// decided to hardcode it here as well. It is not impossible that there could
-// be systems with exceptions, but they should be very exotic edge cases, and
-// in that case, the worst outcome will be two misreported metrics.
-//
-// See also the following discussions:
-//
-// - https://github.com/prometheus/node_exporter/issues/52
-// - https://github.com/prometheus/procfs/pull/2
-// - http://stackoverflow.com/questions/17410841/how-does-user-hz-solve-the-jiffy-scaling-issue
-const userHZ = 100
-
-// ProcStat provides status information about the process,
-// read from /proc/[pid]/stat.
-type ProcStat struct {
- // The process ID.
- PID int
- // The filename of the executable.
- Comm string
- // The process state.
- State string
- // The PID of the parent of this process.
- PPID int
- // The process group ID of the process.
- PGRP int
- // The session ID of the process.
- Session int
- // The controlling terminal of the process.
- TTY int
- // The ID of the foreground process group of the controlling terminal of
- // the process.
- TPGID int
- // The kernel flags word of the process.
- Flags uint
- // The number of minor faults the process has made which have not required
- // loading a memory page from disk.
- MinFlt uint
- // The number of minor faults that the process's waited-for children have
- // made.
- CMinFlt uint
- // The number of major faults the process has made which have required
- // loading a memory page from disk.
- MajFlt uint
- // The number of major faults that the process's waited-for children have
- // made.
- CMajFlt uint
- // Amount of time that this process has been scheduled in user mode,
- // measured in clock ticks.
- UTime uint
- // Amount of time that this process has been scheduled in kernel mode,
- // measured in clock ticks.
- STime uint
- // Amount of time that this process's waited-for children have been
- // scheduled in user mode, measured in clock ticks.
- CUTime int
- // Amount of time that this process's waited-for children have been
- // scheduled in kernel mode, measured in clock ticks.
- CSTime int
- // For processes running a real-time scheduling policy, this is the negated
- // scheduling priority, minus one.
- Priority int
- // The nice value, a value in the range 19 (low priority) to -20 (high
- // priority).
- Nice int
- // Number of threads in this process.
- NumThreads int
- // The time the process started after system boot, the value is expressed
- // in clock ticks.
- Starttime uint64
- // Virtual memory size in bytes.
- VSize uint
- // Resident set size in pages.
- RSS int
- // Soft limit in bytes on the rss of the process.
- RSSLimit uint64
- // CPU number last executed on.
- Processor uint
- // Real-time scheduling priority, a number in the range 1 to 99 for processes
- // scheduled under a real-time policy, or 0, for non-real-time processes.
- RTPriority uint
- // Scheduling policy.
- Policy uint
- // Aggregated block I/O delays, measured in clock ticks (centiseconds).
- DelayAcctBlkIOTicks uint64
- // Guest time of the process (time spent running a virtual CPU for a guest
- // operating system), measured in clock ticks.
- GuestTime int
- // Guest time of the process's children, measured in clock ticks.
- CGuestTime int
-
- proc FS
-}
-
-// NewStat returns the current status information of the process.
-//
-// Deprecated: Use p.Stat() instead.
-func (p Proc) NewStat() (ProcStat, error) {
- return p.Stat()
-}
-
-// Stat returns the current status information of the process.
-func (p Proc) Stat() (ProcStat, error) {
- data, err := util.ReadFileNoStat(p.path("stat"))
- if err != nil {
- return ProcStat{}, err
- }
-
- var (
- ignoreInt64 int64
- ignoreUint64 uint64
-
- s = ProcStat{PID: p.PID, proc: p.fs}
- l = bytes.Index(data, []byte("("))
- r = bytes.LastIndex(data, []byte(")"))
- )
-
- if l < 0 || r < 0 {
- return ProcStat{}, fmt.Errorf("%w: unexpected format, couldn't extract comm %q", ErrFileParse, data)
- }
-
- s.Comm = string(data[l+1 : r])
-
- // Check the following resources for the details about the particular stat
- // fields and their data types:
- // * https://man7.org/linux/man-pages/man5/proc.5.html
- // * https://man7.org/linux/man-pages/man3/scanf.3.html
- _, err = fmt.Fscan(
- bytes.NewBuffer(data[r+2:]),
- &s.State,
- &s.PPID,
- &s.PGRP,
- &s.Session,
- &s.TTY,
- &s.TPGID,
- &s.Flags,
- &s.MinFlt,
- &s.CMinFlt,
- &s.MajFlt,
- &s.CMajFlt,
- &s.UTime,
- &s.STime,
- &s.CUTime,
- &s.CSTime,
- &s.Priority,
- &s.Nice,
- &s.NumThreads,
- &ignoreInt64,
- &s.Starttime,
- &s.VSize,
- &s.RSS,
- &s.RSSLimit,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreUint64,
- &ignoreInt64,
- &s.Processor,
- &s.RTPriority,
- &s.Policy,
- &s.DelayAcctBlkIOTicks,
- &s.GuestTime,
- &s.CGuestTime,
- )
- if err != nil {
- return ProcStat{}, err
- }
-
- return s, nil
-}
-
-// VirtualMemory returns the virtual memory size in bytes.
-func (s ProcStat) VirtualMemory() uint {
- return s.VSize
-}
-
-// ResidentMemory returns the resident memory size in bytes.
-func (s ProcStat) ResidentMemory() int {
- return s.RSS * os.Getpagesize()
-}
-
-// StartTime returns the unix timestamp of the process in seconds.
-func (s ProcStat) StartTime() (float64, error) {
- stat, err := s.proc.Stat()
- if err != nil {
- return 0, err
- }
- return float64(stat.BootTime) + (float64(s.Starttime) / userHZ), nil
-}
-
-// CPUTime returns the total CPU user and system time in seconds.
-func (s ProcStat) CPUTime() float64 {
- return float64(s.UTime+s.STime) / userHZ
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_status.go b/vendor/github.com/prometheus/procfs/proc_status.go
deleted file mode 100644
index a055197..0000000
--- a/vendor/github.com/prometheus/procfs/proc_status.go
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bytes"
- "math/bits"
- "sort"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// ProcStatus provides status information about the process,
-// read from /proc/[pid]/status.
-type ProcStatus struct {
- // The process ID.
- PID int
- // The process name.
- Name string
-
- // Thread group ID.
- TGID int
- // List of Pid namespace.
- NSpids []uint64
-
- // Peak virtual memory size.
- VmPeak uint64 // nolint:revive
- // Virtual memory size.
- VmSize uint64 // nolint:revive
- // Locked memory size.
- VmLck uint64 // nolint:revive
- // Pinned memory size.
- VmPin uint64 // nolint:revive
- // Peak resident set size.
- VmHWM uint64 // nolint:revive
- // Resident set size (sum of RssAnnon RssFile and RssShmem).
- VmRSS uint64 // nolint:revive
- // Size of resident anonymous memory.
- RssAnon uint64 // nolint:revive
- // Size of resident file mappings.
- RssFile uint64 // nolint:revive
- // Size of resident shared memory.
- RssShmem uint64 // nolint:revive
- // Size of data segments.
- VmData uint64 // nolint:revive
- // Size of stack segments.
- VmStk uint64 // nolint:revive
- // Size of text segments.
- VmExe uint64 // nolint:revive
- // Shared library code size.
- VmLib uint64 // nolint:revive
- // Page table entries size.
- VmPTE uint64 // nolint:revive
- // Size of second-level page tables.
- VmPMD uint64 // nolint:revive
- // Swapped-out virtual memory size by anonymous private.
- VmSwap uint64 // nolint:revive
- // Size of hugetlb memory portions
- HugetlbPages uint64
-
- // Number of voluntary context switches.
- VoluntaryCtxtSwitches uint64
- // Number of involuntary context switches.
- NonVoluntaryCtxtSwitches uint64
-
- // UIDs of the process (Real, effective, saved set, and filesystem UIDs)
- UIDs [4]uint64
- // GIDs of the process (Real, effective, saved set, and filesystem GIDs)
- GIDs [4]uint64
-
- // CpusAllowedList: List of cpu cores processes are allowed to run on.
- CpusAllowedList []uint64
-}
-
-// NewStatus returns the current status information of the process.
-func (p Proc) NewStatus() (ProcStatus, error) {
- data, err := util.ReadFileNoStat(p.path("status"))
- if err != nil {
- return ProcStatus{}, err
- }
-
- s := ProcStatus{PID: p.PID}
-
- lines := strings.Split(string(data), "\n")
- for _, line := range lines {
- if !bytes.Contains([]byte(line), []byte(":")) {
- continue
- }
-
- kv := strings.SplitN(line, ":", 2)
-
- // removes spaces
- k := strings.TrimSpace(kv[0])
- v := strings.TrimSpace(kv[1])
- // removes "kB"
- v = strings.TrimSuffix(v, " kB")
-
- // value to int when possible
- // we can skip error check here, 'cause vKBytes is not used when value is a string
- vKBytes, _ := strconv.ParseUint(v, 10, 64)
- // convert kB to B
- vBytes := vKBytes * 1024
-
- err = s.fillStatus(k, v, vKBytes, vBytes)
- if err != nil {
- return ProcStatus{}, err
- }
- }
-
- return s, nil
-}
-
-func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintBytes uint64) error {
- switch k {
- case "Tgid":
- s.TGID = int(vUint)
- case "Name":
- s.Name = vString
- case "Uid":
- var err error
- for i, v := range strings.Split(vString, "\t") {
- s.UIDs[i], err = strconv.ParseUint(v, 10, bits.UintSize)
- if err != nil {
- return err
- }
- }
- case "Gid":
- var err error
- for i, v := range strings.Split(vString, "\t") {
- s.GIDs[i], err = strconv.ParseUint(v, 10, bits.UintSize)
- if err != nil {
- return err
- }
- }
- case "NSpid":
- s.NSpids = calcNSPidsList(vString)
- case "VmPeak":
- s.VmPeak = vUintBytes
- case "VmSize":
- s.VmSize = vUintBytes
- case "VmLck":
- s.VmLck = vUintBytes
- case "VmPin":
- s.VmPin = vUintBytes
- case "VmHWM":
- s.VmHWM = vUintBytes
- case "VmRSS":
- s.VmRSS = vUintBytes
- case "RssAnon":
- s.RssAnon = vUintBytes
- case "RssFile":
- s.RssFile = vUintBytes
- case "RssShmem":
- s.RssShmem = vUintBytes
- case "VmData":
- s.VmData = vUintBytes
- case "VmStk":
- s.VmStk = vUintBytes
- case "VmExe":
- s.VmExe = vUintBytes
- case "VmLib":
- s.VmLib = vUintBytes
- case "VmPTE":
- s.VmPTE = vUintBytes
- case "VmPMD":
- s.VmPMD = vUintBytes
- case "VmSwap":
- s.VmSwap = vUintBytes
- case "HugetlbPages":
- s.HugetlbPages = vUintBytes
- case "voluntary_ctxt_switches":
- s.VoluntaryCtxtSwitches = vUint
- case "nonvoluntary_ctxt_switches":
- s.NonVoluntaryCtxtSwitches = vUint
- case "Cpus_allowed_list":
- s.CpusAllowedList = calcCpusAllowedList(vString)
- }
-
- return nil
-}
-
-// TotalCtxtSwitches returns the total context switch.
-func (s ProcStatus) TotalCtxtSwitches() uint64 {
- return s.VoluntaryCtxtSwitches + s.NonVoluntaryCtxtSwitches
-}
-
-func calcCpusAllowedList(cpuString string) []uint64 {
- s := strings.Split(cpuString, ",")
-
- var g []uint64
-
- for _, cpu := range s {
- // parse cpu ranges, example: 1-3=[1,2,3]
- if l := strings.Split(strings.TrimSpace(cpu), "-"); len(l) > 1 {
- startCPU, _ := strconv.ParseUint(l[0], 10, 64)
- endCPU, _ := strconv.ParseUint(l[1], 10, 64)
-
- for i := startCPU; i <= endCPU; i++ {
- g = append(g, i)
- }
- } else if len(l) == 1 {
- cpu, _ := strconv.ParseUint(l[0], 10, 64)
- g = append(g, cpu)
- }
-
- }
-
- sort.Slice(g, func(i, j int) bool { return g[i] < g[j] })
- return g
-}
-
-func calcNSPidsList(nspidsString string) []uint64 {
- s := strings.Split(nspidsString, " ")
- var nspids []uint64
-
- for _, nspid := range s {
- nspid, _ := strconv.ParseUint(nspid, 10, 64)
- if nspid == 0 {
- continue
- }
- nspids = append(nspids, nspid)
- }
-
- return nspids
-}
diff --git a/vendor/github.com/prometheus/procfs/proc_sys.go b/vendor/github.com/prometheus/procfs/proc_sys.go
deleted file mode 100644
index 5eefbe2..0000000
--- a/vendor/github.com/prometheus/procfs/proc_sys.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "fmt"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-func sysctlToPath(sysctl string) string {
- return strings.Replace(sysctl, ".", "/", -1)
-}
-
-func (fs FS) SysctlStrings(sysctl string) ([]string, error) {
- value, err := util.SysReadFile(fs.proc.Path("sys", sysctlToPath(sysctl)))
- if err != nil {
- return nil, err
- }
- return strings.Fields(value), nil
-
-}
-
-func (fs FS) SysctlInts(sysctl string) ([]int, error) {
- fields, err := fs.SysctlStrings(sysctl)
- if err != nil {
- return nil, err
- }
-
- values := make([]int, len(fields))
- for i, f := range fields {
- vp := util.NewValueParser(f)
- values[i] = vp.Int()
- if err := vp.Err(); err != nil {
- return nil, fmt.Errorf("%w: field %d in sysctl %s is not a valid int: %w", ErrFileParse, i, sysctl, err)
- }
- }
- return values, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/schedstat.go b/vendor/github.com/prometheus/procfs/schedstat.go
deleted file mode 100644
index 5f7f32d..0000000
--- a/vendor/github.com/prometheus/procfs/schedstat.go
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "errors"
- "os"
- "regexp"
- "strconv"
-)
-
-var (
- cpuLineRE = regexp.MustCompile(`cpu(\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)`)
- procLineRE = regexp.MustCompile(`(\d+) (\d+) (\d+)`)
-)
-
-// Schedstat contains scheduler statistics from /proc/schedstat
-//
-// See
-// https://www.kernel.org/doc/Documentation/scheduler/sched-stats.txt
-// for a detailed description of what these numbers mean.
-//
-// Note the current kernel documentation claims some of the time units are in
-// jiffies when they are actually in nanoseconds since 2.6.23 with the
-// introduction of CFS. A fix to the documentation is pending. See
-// https://lore.kernel.org/patchwork/project/lkml/list/?series=403473
-type Schedstat struct {
- CPUs []*SchedstatCPU
-}
-
-// SchedstatCPU contains the values from one "cpu" line.
-type SchedstatCPU struct {
- CPUNum string
-
- RunningNanoseconds uint64
- WaitingNanoseconds uint64
- RunTimeslices uint64
-}
-
-// ProcSchedstat contains the values from `/proc//schedstat`.
-type ProcSchedstat struct {
- RunningNanoseconds uint64
- WaitingNanoseconds uint64
- RunTimeslices uint64
-}
-
-// Schedstat reads data from `/proc/schedstat`.
-func (fs FS) Schedstat() (*Schedstat, error) {
- file, err := os.Open(fs.proc.Path("schedstat"))
- if err != nil {
- return nil, err
- }
- defer file.Close()
-
- stats := &Schedstat{}
- scanner := bufio.NewScanner(file)
-
- for scanner.Scan() {
- match := cpuLineRE.FindStringSubmatch(scanner.Text())
- if match != nil {
- cpu := &SchedstatCPU{}
- cpu.CPUNum = match[1]
-
- cpu.RunningNanoseconds, err = strconv.ParseUint(match[8], 10, 64)
- if err != nil {
- continue
- }
-
- cpu.WaitingNanoseconds, err = strconv.ParseUint(match[9], 10, 64)
- if err != nil {
- continue
- }
-
- cpu.RunTimeslices, err = strconv.ParseUint(match[10], 10, 64)
- if err != nil {
- continue
- }
-
- stats.CPUs = append(stats.CPUs, cpu)
- }
- }
-
- return stats, nil
-}
-
-func parseProcSchedstat(contents string) (ProcSchedstat, error) {
- var (
- stats ProcSchedstat
- err error
- )
- match := procLineRE.FindStringSubmatch(contents)
-
- if match != nil {
- stats.RunningNanoseconds, err = strconv.ParseUint(match[1], 10, 64)
- if err != nil {
- return stats, err
- }
-
- stats.WaitingNanoseconds, err = strconv.ParseUint(match[2], 10, 64)
- if err != nil {
- return stats, err
- }
-
- stats.RunTimeslices, err = strconv.ParseUint(match[3], 10, 64)
- return stats, err
- }
-
- return stats, errors.New("could not parse schedstat")
-}
diff --git a/vendor/github.com/prometheus/procfs/slab.go b/vendor/github.com/prometheus/procfs/slab.go
deleted file mode 100644
index 8611c90..0000000
--- a/vendor/github.com/prometheus/procfs/slab.go
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2020 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "regexp"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-var (
- slabSpace = regexp.MustCompile(`\s+`)
- slabVer = regexp.MustCompile(`slabinfo -`)
- slabHeader = regexp.MustCompile(`# name`)
-)
-
-// Slab represents a slab pool in the kernel.
-type Slab struct {
- Name string
- ObjActive int64
- ObjNum int64
- ObjSize int64
- ObjPerSlab int64
- PagesPerSlab int64
- // tunables
- Limit int64
- Batch int64
- SharedFactor int64
- SlabActive int64
- SlabNum int64
- SharedAvail int64
-}
-
-// SlabInfo represents info for all slabs.
-type SlabInfo struct {
- Slabs []*Slab
-}
-
-func shouldParseSlab(line string) bool {
- if slabVer.MatchString(line) {
- return false
- }
- if slabHeader.MatchString(line) {
- return false
- }
- return true
-}
-
-// parseV21SlabEntry is used to parse a line from /proc/slabinfo version 2.1.
-func parseV21SlabEntry(line string) (*Slab, error) {
- // First cleanup whitespace.
- l := slabSpace.ReplaceAllString(line, " ")
- s := strings.Split(l, " ")
- if len(s) != 16 {
- return nil, fmt.Errorf("%w: unable to parse: %q", ErrFileParse, line)
- }
- var err error
- i := &Slab{Name: s[0]}
- i.ObjActive, err = strconv.ParseInt(s[1], 10, 64)
- if err != nil {
- return nil, err
- }
- i.ObjNum, err = strconv.ParseInt(s[2], 10, 64)
- if err != nil {
- return nil, err
- }
- i.ObjSize, err = strconv.ParseInt(s[3], 10, 64)
- if err != nil {
- return nil, err
- }
- i.ObjPerSlab, err = strconv.ParseInt(s[4], 10, 64)
- if err != nil {
- return nil, err
- }
- i.PagesPerSlab, err = strconv.ParseInt(s[5], 10, 64)
- if err != nil {
- return nil, err
- }
- i.Limit, err = strconv.ParseInt(s[8], 10, 64)
- if err != nil {
- return nil, err
- }
- i.Batch, err = strconv.ParseInt(s[9], 10, 64)
- if err != nil {
- return nil, err
- }
- i.SharedFactor, err = strconv.ParseInt(s[10], 10, 64)
- if err != nil {
- return nil, err
- }
- i.SlabActive, err = strconv.ParseInt(s[13], 10, 64)
- if err != nil {
- return nil, err
- }
- i.SlabNum, err = strconv.ParseInt(s[14], 10, 64)
- if err != nil {
- return nil, err
- }
- i.SharedAvail, err = strconv.ParseInt(s[15], 10, 64)
- if err != nil {
- return nil, err
- }
- return i, nil
-}
-
-// parseSlabInfo21 is used to parse a slabinfo 2.1 file.
-func parseSlabInfo21(r *bytes.Reader) (SlabInfo, error) {
- scanner := bufio.NewScanner(r)
- s := SlabInfo{Slabs: []*Slab{}}
- for scanner.Scan() {
- line := scanner.Text()
- if !shouldParseSlab(line) {
- continue
- }
- slab, err := parseV21SlabEntry(line)
- if err != nil {
- return s, err
- }
- s.Slabs = append(s.Slabs, slab)
- }
- return s, nil
-}
-
-// SlabInfo reads data from `/proc/slabinfo`.
-func (fs FS) SlabInfo() (SlabInfo, error) {
- // TODO: Consider passing options to allow for parsing different
- // slabinfo versions. However, slabinfo 2.1 has been stable since
- // kernel 2.6.10 and later.
- data, err := util.ReadFileNoStat(fs.proc.Path("slabinfo"))
- if err != nil {
- return SlabInfo{}, err
- }
-
- return parseSlabInfo21(bytes.NewReader(data))
-}
diff --git a/vendor/github.com/prometheus/procfs/softirqs.go b/vendor/github.com/prometheus/procfs/softirqs.go
deleted file mode 100644
index 28708e0..0000000
--- a/vendor/github.com/prometheus/procfs/softirqs.go
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Softirqs represents the softirq statistics.
-type Softirqs struct {
- Hi []uint64
- Timer []uint64
- NetTx []uint64
- NetRx []uint64
- Block []uint64
- IRQPoll []uint64
- Tasklet []uint64
- Sched []uint64
- HRTimer []uint64
- RCU []uint64
-}
-
-func (fs FS) Softirqs() (Softirqs, error) {
- fileName := fs.proc.Path("softirqs")
- data, err := util.ReadFileNoStat(fileName)
- if err != nil {
- return Softirqs{}, err
- }
-
- reader := bytes.NewReader(data)
-
- return parseSoftirqs(reader)
-}
-
-func parseSoftirqs(r io.Reader) (Softirqs, error) {
- var (
- softirqs = Softirqs{}
- scanner = bufio.NewScanner(r)
- )
-
- if !scanner.Scan() {
- return Softirqs{}, fmt.Errorf("%w: softirqs empty", ErrFileRead)
- }
-
- for scanner.Scan() {
- parts := strings.Fields(scanner.Text())
- var err error
-
- // require at least one cpu
- if len(parts) < 2 {
- continue
- }
- switch {
- case parts[0] == "HI:":
- perCPU := parts[1:]
- softirqs.Hi = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.Hi[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (HI%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "TIMER:":
- perCPU := parts[1:]
- softirqs.Timer = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.Timer[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (TIMER%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "NET_TX:":
- perCPU := parts[1:]
- softirqs.NetTx = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.NetTx[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (NET_TX%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "NET_RX:":
- perCPU := parts[1:]
- softirqs.NetRx = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.NetRx[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (NET_RX%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "BLOCK:":
- perCPU := parts[1:]
- softirqs.Block = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.Block[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (BLOCK%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "IRQ_POLL:":
- perCPU := parts[1:]
- softirqs.IRQPoll = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.IRQPoll[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (IRQ_POLL%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "TASKLET:":
- perCPU := parts[1:]
- softirqs.Tasklet = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.Tasklet[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (TASKLET%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "SCHED:":
- perCPU := parts[1:]
- softirqs.Sched = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.Sched[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (SCHED%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "HRTIMER:":
- perCPU := parts[1:]
- softirqs.HRTimer = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.HRTimer[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (HRTIMER%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "RCU:":
- perCPU := parts[1:]
- softirqs.RCU = make([]uint64, len(perCPU))
- for i, count := range perCPU {
- if softirqs.RCU[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse %q (RCU%d): %w", ErrFileParse, count, i, err)
- }
- }
- }
- }
-
- if err := scanner.Err(); err != nil {
- return Softirqs{}, fmt.Errorf("%w: couldn't parse softirqs: %w", ErrFileParse, err)
- }
-
- return softirqs, scanner.Err()
-}
diff --git a/vendor/github.com/prometheus/procfs/stat.go b/vendor/github.com/prometheus/procfs/stat.go
deleted file mode 100644
index e36b41c..0000000
--- a/vendor/github.com/prometheus/procfs/stat.go
+++ /dev/null
@@ -1,258 +0,0 @@
-// Copyright 2018 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "io"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/fs"
- "github.com/prometheus/procfs/internal/util"
-)
-
-// CPUStat shows how much time the cpu spend in various stages.
-type CPUStat struct {
- User float64
- Nice float64
- System float64
- Idle float64
- Iowait float64
- IRQ float64
- SoftIRQ float64
- Steal float64
- Guest float64
- GuestNice float64
-}
-
-// SoftIRQStat represent the softirq statistics as exported in the procfs stat file.
-// A nice introduction can be found at https://0xax.gitbooks.io/linux-insides/content/interrupts/interrupts-9.html
-// It is possible to get per-cpu stats by reading `/proc/softirqs`.
-type SoftIRQStat struct {
- Hi uint64
- Timer uint64
- NetTx uint64
- NetRx uint64
- Block uint64
- BlockIoPoll uint64
- Tasklet uint64
- Sched uint64
- Hrtimer uint64
- Rcu uint64
-}
-
-// Stat represents kernel/system statistics.
-type Stat struct {
- // Boot time in seconds since the Epoch.
- BootTime uint64
- // Summed up cpu statistics.
- CPUTotal CPUStat
- // Per-CPU statistics.
- CPU map[int64]CPUStat
- // Number of times interrupts were handled, which contains numbered and unnumbered IRQs.
- IRQTotal uint64
- // Number of times a numbered IRQ was triggered.
- IRQ []uint64
- // Number of times a context switch happened.
- ContextSwitches uint64
- // Number of times a process was created.
- ProcessCreated uint64
- // Number of processes currently running.
- ProcessesRunning uint64
- // Number of processes currently blocked (waiting for IO).
- ProcessesBlocked uint64
- // Number of times a softirq was scheduled.
- SoftIRQTotal uint64
- // Detailed softirq statistics.
- SoftIRQ SoftIRQStat
-}
-
-// Parse a cpu statistics line and returns the CPUStat struct plus the cpu id (or -1 for the overall sum).
-func parseCPUStat(line string) (CPUStat, int64, error) {
- cpuStat := CPUStat{}
- var cpu string
-
- count, err := fmt.Sscanf(line, "%s %f %f %f %f %f %f %f %f %f %f",
- &cpu,
- &cpuStat.User, &cpuStat.Nice, &cpuStat.System, &cpuStat.Idle,
- &cpuStat.Iowait, &cpuStat.IRQ, &cpuStat.SoftIRQ, &cpuStat.Steal,
- &cpuStat.Guest, &cpuStat.GuestNice)
-
- if err != nil && err != io.EOF {
- return CPUStat{}, -1, fmt.Errorf("%w: couldn't parse %q (cpu): %w", ErrFileParse, line, err)
- }
- if count == 0 {
- return CPUStat{}, -1, fmt.Errorf("%w: couldn't parse %q (cpu): 0 elements parsed", ErrFileParse, line)
- }
-
- cpuStat.User /= userHZ
- cpuStat.Nice /= userHZ
- cpuStat.System /= userHZ
- cpuStat.Idle /= userHZ
- cpuStat.Iowait /= userHZ
- cpuStat.IRQ /= userHZ
- cpuStat.SoftIRQ /= userHZ
- cpuStat.Steal /= userHZ
- cpuStat.Guest /= userHZ
- cpuStat.GuestNice /= userHZ
-
- if cpu == "cpu" {
- return cpuStat, -1, nil
- }
-
- cpuID, err := strconv.ParseInt(cpu[3:], 10, 64)
- if err != nil {
- return CPUStat{}, -1, fmt.Errorf("%w: couldn't parse %q (cpu/cpuid): %w", ErrFileParse, line, err)
- }
-
- return cpuStat, cpuID, nil
-}
-
-// Parse a softirq line.
-func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) {
- softIRQStat := SoftIRQStat{}
- var total uint64
- var prefix string
-
- _, err := fmt.Sscanf(line, "%s %d %d %d %d %d %d %d %d %d %d %d",
- &prefix, &total,
- &softIRQStat.Hi, &softIRQStat.Timer, &softIRQStat.NetTx, &softIRQStat.NetRx,
- &softIRQStat.Block, &softIRQStat.BlockIoPoll,
- &softIRQStat.Tasklet, &softIRQStat.Sched,
- &softIRQStat.Hrtimer, &softIRQStat.Rcu)
-
- if err != nil {
- return SoftIRQStat{}, 0, fmt.Errorf("%w: couldn't parse %q (softirq): %w", ErrFileParse, line, err)
- }
-
- return softIRQStat, total, nil
-}
-
-// NewStat returns information about current cpu/process statistics.
-// See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
-//
-// Deprecated: Use fs.Stat() instead.
-func NewStat() (Stat, error) {
- fs, err := NewFS(fs.DefaultProcMountPoint)
- if err != nil {
- return Stat{}, err
- }
- return fs.Stat()
-}
-
-// NewStat returns information about current cpu/process statistics.
-// See: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
-//
-// Deprecated: Use fs.Stat() instead.
-func (fs FS) NewStat() (Stat, error) {
- return fs.Stat()
-}
-
-// Stat returns information about current cpu/process statistics.
-// See: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
-func (fs FS) Stat() (Stat, error) {
- fileName := fs.proc.Path("stat")
- data, err := util.ReadFileNoStat(fileName)
- if err != nil {
- return Stat{}, err
- }
- procStat, err := parseStat(bytes.NewReader(data), fileName)
- if err != nil {
- return Stat{}, err
- }
- return procStat, nil
-}
-
-// parseStat parses the metrics from /proc/[pid]/stat.
-func parseStat(r io.Reader, fileName string) (Stat, error) {
- var (
- scanner = bufio.NewScanner(r)
- stat = Stat{
- CPU: make(map[int64]CPUStat),
- }
- err error
- )
-
- // Increase default scanner buffer to handle very long `intr` lines.
- buf := make([]byte, 0, 8*1024)
- scanner.Buffer(buf, 1024*1024)
-
- for scanner.Scan() {
- line := scanner.Text()
- parts := strings.Fields(scanner.Text())
- // require at least
- if len(parts) < 2 {
- continue
- }
- switch {
- case parts[0] == "btime":
- if stat.BootTime, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
- return Stat{}, fmt.Errorf("%w: couldn't parse %q (btime): %w", ErrFileParse, parts[1], err)
- }
- case parts[0] == "intr":
- if stat.IRQTotal, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
- return Stat{}, fmt.Errorf("%w: couldn't parse %q (intr): %w", ErrFileParse, parts[1], err)
- }
- numberedIRQs := parts[2:]
- stat.IRQ = make([]uint64, len(numberedIRQs))
- for i, count := range numberedIRQs {
- if stat.IRQ[i], err = strconv.ParseUint(count, 10, 64); err != nil {
- return Stat{}, fmt.Errorf("%w: couldn't parse %q (intr%d): %w", ErrFileParse, count, i, err)
- }
- }
- case parts[0] == "ctxt":
- if stat.ContextSwitches, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
- return Stat{}, fmt.Errorf("%w: couldn't parse %q (ctxt): %w", ErrFileParse, parts[1], err)
- }
- case parts[0] == "processes":
- if stat.ProcessCreated, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
- return Stat{}, fmt.Errorf("%w: couldn't parse %q (processes): %w", ErrFileParse, parts[1], err)
- }
- case parts[0] == "procs_running":
- if stat.ProcessesRunning, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
- return Stat{}, fmt.Errorf("%w: couldn't parse %q (procs_running): %w", ErrFileParse, parts[1], err)
- }
- case parts[0] == "procs_blocked":
- if stat.ProcessesBlocked, err = strconv.ParseUint(parts[1], 10, 64); err != nil {
- return Stat{}, fmt.Errorf("%w: couldn't parse %q (procs_blocked): %w", ErrFileParse, parts[1], err)
- }
- case parts[0] == "softirq":
- softIRQStats, total, err := parseSoftIRQStat(line)
- if err != nil {
- return Stat{}, err
- }
- stat.SoftIRQTotal = total
- stat.SoftIRQ = softIRQStats
- case strings.HasPrefix(parts[0], "cpu"):
- cpuStat, cpuID, err := parseCPUStat(line)
- if err != nil {
- return Stat{}, err
- }
- if cpuID == -1 {
- stat.CPUTotal = cpuStat
- } else {
- stat.CPU[cpuID] = cpuStat
- }
- }
- }
-
- if err := scanner.Err(); err != nil {
- return Stat{}, fmt.Errorf("%w: couldn't parse %q: %w", ErrFileParse, fileName, err)
- }
-
- return stat, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/swaps.go b/vendor/github.com/prometheus/procfs/swaps.go
deleted file mode 100644
index 65fec83..0000000
--- a/vendor/github.com/prometheus/procfs/swaps.go
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "strconv"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Swap represents an entry in /proc/swaps.
-type Swap struct {
- Filename string
- Type string
- Size int
- Used int
- Priority int
-}
-
-// Swaps returns a slice of all configured swap devices on the system.
-func (fs FS) Swaps() ([]*Swap, error) {
- data, err := util.ReadFileNoStat(fs.proc.Path("swaps"))
- if err != nil {
- return nil, err
- }
- return parseSwaps(data)
-}
-
-func parseSwaps(info []byte) ([]*Swap, error) {
- swaps := []*Swap{}
- scanner := bufio.NewScanner(bytes.NewReader(info))
- scanner.Scan() // ignore header line
- for scanner.Scan() {
- swapString := scanner.Text()
- parsedSwap, err := parseSwapString(swapString)
- if err != nil {
- return nil, err
- }
- swaps = append(swaps, parsedSwap)
- }
-
- err := scanner.Err()
- return swaps, err
-}
-
-func parseSwapString(swapString string) (*Swap, error) {
- var err error
-
- swapFields := strings.Fields(swapString)
- swapLength := len(swapFields)
- if swapLength < 5 {
- return nil, fmt.Errorf("%w: too few fields in swap string: %s", ErrFileParse, swapString)
- }
-
- swap := &Swap{
- Filename: swapFields[0],
- Type: swapFields[1],
- }
-
- swap.Size, err = strconv.Atoi(swapFields[2])
- if err != nil {
- return nil, fmt.Errorf("%w: invalid swap size: %s: %w", ErrFileParse, swapFields[2], err)
- }
- swap.Used, err = strconv.Atoi(swapFields[3])
- if err != nil {
- return nil, fmt.Errorf("%w: invalid swap used: %s: %w", ErrFileParse, swapFields[3], err)
- }
- swap.Priority, err = strconv.Atoi(swapFields[4])
- if err != nil {
- return nil, fmt.Errorf("%w: invalid swap priority: %s: %w", ErrFileParse, swapFields[4], err)
- }
-
- return swap, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/thread.go b/vendor/github.com/prometheus/procfs/thread.go
deleted file mode 100644
index 80e0e94..0000000
--- a/vendor/github.com/prometheus/procfs/thread.go
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2022 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package procfs
-
-import (
- "fmt"
- "os"
- "strconv"
-
- fsi "github.com/prometheus/procfs/internal/fs"
-)
-
-// Provide access to /proc/PID/task/TID files, for thread specific values. Since
-// such files have the same structure as /proc/PID/ ones, the data structures
-// and the parsers for the latter may be reused.
-
-// AllThreads returns a list of all currently available threads under /proc/PID.
-func AllThreads(pid int) (Procs, error) {
- fs, err := NewFS(DefaultMountPoint)
- if err != nil {
- return Procs{}, err
- }
- return fs.AllThreads(pid)
-}
-
-// AllThreads returns a list of all currently available threads for PID.
-func (fs FS) AllThreads(pid int) (Procs, error) {
- taskPath := fs.proc.Path(strconv.Itoa(pid), "task")
- d, err := os.Open(taskPath)
- if err != nil {
- return Procs{}, err
- }
- defer d.Close()
-
- names, err := d.Readdirnames(-1)
- if err != nil {
- return Procs{}, fmt.Errorf("%w: could not read %q: %w", ErrFileRead, d.Name(), err)
- }
-
- t := Procs{}
- for _, n := range names {
- tid, err := strconv.ParseInt(n, 10, 64)
- if err != nil {
- continue
- }
-
- t = append(t, Proc{PID: int(tid), fs: FS{fsi.FS(taskPath), fs.isReal}})
- }
-
- return t, nil
-}
-
-// Thread returns a process for a given PID, TID.
-func (fs FS) Thread(pid, tid int) (Proc, error) {
- taskPath := fs.proc.Path(strconv.Itoa(pid), "task")
- if _, err := os.Stat(taskPath); err != nil {
- return Proc{}, err
- }
- return Proc{PID: tid, fs: FS{fsi.FS(taskPath), fs.isReal}}, nil
-}
-
-// Thread returns a process for a given TID of Proc.
-func (proc Proc) Thread(tid int) (Proc, error) {
- tfs := FS{fsi.FS(proc.path("task")), proc.fs.isReal}
- if _, err := os.Stat(tfs.proc.Path(strconv.Itoa(tid))); err != nil {
- return Proc{}, err
- }
- return Proc{PID: tid, fs: tfs}, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/ttar b/vendor/github.com/prometheus/procfs/ttar
deleted file mode 100644
index 19ef02b..0000000
--- a/vendor/github.com/prometheus/procfs/ttar
+++ /dev/null
@@ -1,413 +0,0 @@
-#!/usr/bin/env bash
-
-# Purpose: plain text tar format
-# Limitations: - only suitable for text files, directories, and symlinks
-# - stores only filename, content, and mode
-# - not designed for untrusted input
-#
-# Note: must work with bash version 3.2 (macOS)
-
-# Copyright 2017 Roger Luethi
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -o errexit -o nounset
-
-# Sanitize environment (for instance, standard sorting of glob matches)
-export LC_ALL=C
-
-path=""
-CMD=""
-ARG_STRING="$*"
-
-#------------------------------------------------------------------------------
-# Not all sed implementations can work on null bytes. In order to make ttar
-# work out of the box on macOS, use Python as a stream editor.
-
-USE_PYTHON=0
-
-PYTHON_CREATE_FILTER=$(cat << 'PCF'
-#!/usr/bin/env python
-
-import re
-import sys
-
-for line in sys.stdin:
- line = re.sub(r'EOF', r'\EOF', line)
- line = re.sub(r'NULLBYTE', r'\NULLBYTE', line)
- line = re.sub('\x00', r'NULLBYTE', line)
- sys.stdout.write(line)
-PCF
-)
-
-PYTHON_EXTRACT_FILTER=$(cat << 'PEF'
-#!/usr/bin/env python
-
-import re
-import sys
-
-for line in sys.stdin:
- line = re.sub(r'(?/dev/null; then
- echo "ERROR Python not found. Aborting."
- exit 2
- fi
- USE_PYTHON=1
- fi
-}
-
-#------------------------------------------------------------------------------
-
-function usage {
- bname=$(basename "$0")
- cat << USAGE
-Usage: $bname [-C ] -c -f (create archive)
- $bname -t -f (list archive contents)
- $bname [-C ] -x -f (extract archive)
-
-Options:
- -C (change directory)
- -v (verbose)
- --recursive-unlink (recursively delete existing directory if path
- collides with file or directory to extract)
-
-Example: Change to sysfs directory, create ttar file from fixtures directory
- $bname -C sysfs -c -f sysfs/fixtures.ttar fixtures/
-USAGE
-exit "$1"
-}
-
-function vecho {
- if [ "${VERBOSE:-}" == "yes" ]; then
- echo >&7 "$@"
- fi
-}
-
-function set_cmd {
- if [ -n "$CMD" ]; then
- echo "ERROR: more than one command given"
- echo
- usage 2
- fi
- CMD=$1
-}
-
-unset VERBOSE
-unset RECURSIVE_UNLINK
-
-while getopts :cf:-:htxvC: opt; do
- case $opt in
- c)
- set_cmd "create"
- ;;
- f)
- ARCHIVE=$OPTARG
- ;;
- h)
- usage 0
- ;;
- t)
- set_cmd "list"
- ;;
- x)
- set_cmd "extract"
- ;;
- v)
- VERBOSE=yes
- exec 7>&1
- ;;
- C)
- CDIR=$OPTARG
- ;;
- -)
- case $OPTARG in
- recursive-unlink)
- RECURSIVE_UNLINK="yes"
- ;;
- *)
- echo -e "Error: invalid option -$OPTARG"
- echo
- usage 1
- ;;
- esac
- ;;
- *)
- echo >&2 "ERROR: invalid option -$OPTARG"
- echo
- usage 1
- ;;
- esac
-done
-
-# Remove processed options from arguments
-shift $(( OPTIND - 1 ));
-
-if [ "${CMD:-}" == "" ]; then
- echo >&2 "ERROR: no command given"
- echo
- usage 1
-elif [ "${ARCHIVE:-}" == "" ]; then
- echo >&2 "ERROR: no archive name given"
- echo
- usage 1
-fi
-
-function list {
- local path=""
- local size=0
- local line_no=0
- local ttar_file=$1
- if [ -n "${2:-}" ]; then
- echo >&2 "ERROR: too many arguments."
- echo
- usage 1
- fi
- if [ ! -e "$ttar_file" ]; then
- echo >&2 "ERROR: file not found ($ttar_file)"
- echo
- usage 1
- fi
- while read -r line; do
- line_no=$(( line_no + 1 ))
- if [ $size -gt 0 ]; then
- size=$(( size - 1 ))
- continue
- fi
- if [[ $line =~ ^Path:\ (.*)$ ]]; then
- path=${BASH_REMATCH[1]}
- elif [[ $line =~ ^Lines:\ (.*)$ ]]; then
- size=${BASH_REMATCH[1]}
- echo "$path"
- elif [[ $line =~ ^Directory:\ (.*)$ ]]; then
- path=${BASH_REMATCH[1]}
- echo "$path/"
- elif [[ $line =~ ^SymlinkTo:\ (.*)$ ]]; then
- echo "$path -> ${BASH_REMATCH[1]}"
- fi
- done < "$ttar_file"
-}
-
-function extract {
- local path=""
- local size=0
- local line_no=0
- local ttar_file=$1
- if [ -n "${2:-}" ]; then
- echo >&2 "ERROR: too many arguments."
- echo
- usage 1
- fi
- if [ ! -e "$ttar_file" ]; then
- echo >&2 "ERROR: file not found ($ttar_file)"
- echo
- usage 1
- fi
- while IFS= read -r line; do
- line_no=$(( line_no + 1 ))
- local eof_without_newline
- if [ "$size" -gt 0 ]; then
- if [[ "$line" =~ [^\\]EOF ]]; then
- # An EOF not preceded by a backslash indicates that the line
- # does not end with a newline
- eof_without_newline=1
- else
- eof_without_newline=0
- fi
- # Replace NULLBYTE with null byte if at beginning of line
- # Replace NULLBYTE with null byte unless preceded by backslash
- # Remove one backslash in front of NULLBYTE (if any)
- # Remove EOF unless preceded by backslash
- # Remove one backslash in front of EOF
- if [ $USE_PYTHON -eq 1 ]; then
- echo -n "$line" | python -c "$PYTHON_EXTRACT_FILTER" >> "$path"
- else
- # The repeated pattern makes up for sed's lack of negative
- # lookbehind assertions (for consecutive null bytes).
- echo -n "$line" | \
- sed -e 's/^NULLBYTE/\x0/g;
- s/\([^\\]\)NULLBYTE/\1\x0/g;
- s/\([^\\]\)NULLBYTE/\1\x0/g;
- s/\\NULLBYTE/NULLBYTE/g;
- s/\([^\\]\)EOF/\1/g;
- s/\\EOF/EOF/g;
- ' >> "$path"
- fi
- if [[ "$eof_without_newline" -eq 0 ]]; then
- echo >> "$path"
- fi
- size=$(( size - 1 ))
- continue
- fi
- if [[ $line =~ ^Path:\ (.*)$ ]]; then
- path=${BASH_REMATCH[1]}
- if [ -L "$path" ]; then
- rm "$path"
- elif [ -d "$path" ]; then
- if [ "${RECURSIVE_UNLINK:-}" == "yes" ]; then
- rm -r "$path"
- else
- # Safe because symlinks to directories are dealt with above
- rmdir "$path"
- fi
- elif [ -e "$path" ]; then
- rm "$path"
- fi
- elif [[ $line =~ ^Lines:\ (.*)$ ]]; then
- size=${BASH_REMATCH[1]}
- # Create file even if it is zero-length.
- touch "$path"
- vecho " $path"
- elif [[ $line =~ ^Mode:\ (.*)$ ]]; then
- mode=${BASH_REMATCH[1]}
- chmod "$mode" "$path"
- vecho "$mode"
- elif [[ $line =~ ^Directory:\ (.*)$ ]]; then
- path=${BASH_REMATCH[1]}
- mkdir -p "$path"
- vecho " $path/"
- elif [[ $line =~ ^SymlinkTo:\ (.*)$ ]]; then
- ln -s "${BASH_REMATCH[1]}" "$path"
- vecho " $path -> ${BASH_REMATCH[1]}"
- elif [[ $line =~ ^# ]]; then
- # Ignore comments between files
- continue
- else
- echo >&2 "ERROR: Unknown keyword on line $line_no: $line"
- exit 1
- fi
- done < "$ttar_file"
-}
-
-function div {
- echo "# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" \
- "- - - - - -"
-}
-
-function get_mode {
- local mfile=$1
- if [ -z "${STAT_OPTION:-}" ]; then
- if stat -c '%a' "$mfile" >/dev/null 2>&1; then
- # GNU stat
- STAT_OPTION='-c'
- STAT_FORMAT='%a'
- else
- # BSD stat
- STAT_OPTION='-f'
- # Octal output, user/group/other (omit file type, sticky bit)
- STAT_FORMAT='%OLp'
- fi
- fi
- stat "${STAT_OPTION}" "${STAT_FORMAT}" "$mfile"
-}
-
-function _create {
- shopt -s nullglob
- local mode
- local eof_without_newline
- while (( "$#" )); do
- file=$1
- if [ -L "$file" ]; then
- echo "Path: $file"
- symlinkTo=$(readlink "$file")
- echo "SymlinkTo: $symlinkTo"
- vecho " $file -> $symlinkTo"
- div
- elif [ -d "$file" ]; then
- # Strip trailing slash (if there is one)
- file=${file%/}
- echo "Directory: $file"
- mode=$(get_mode "$file")
- echo "Mode: $mode"
- vecho "$mode $file/"
- div
- # Find all files and dirs, including hidden/dot files
- for x in "$file/"{*,.[^.]*}; do
- _create "$x"
- done
- elif [ -f "$file" ]; then
- echo "Path: $file"
- lines=$(wc -l "$file"|awk '{print $1}')
- eof_without_newline=0
- if [[ "$(wc -c "$file"|awk '{print $1}')" -gt 0 ]] && \
- [[ "$(tail -c 1 "$file" | wc -l)" -eq 0 ]]; then
- eof_without_newline=1
- lines=$((lines+1))
- fi
- echo "Lines: $lines"
- # Add backslash in front of EOF
- # Add backslash in front of NULLBYTE
- # Replace null byte with NULLBYTE
- if [ $USE_PYTHON -eq 1 ]; then
- < "$file" python -c "$PYTHON_CREATE_FILTER"
- else
- < "$file" \
- sed 's/EOF/\\EOF/g;
- s/NULLBYTE/\\NULLBYTE/g;
- s/\x0/NULLBYTE/g;
- '
- fi
- if [[ "$eof_without_newline" -eq 1 ]]; then
- # Finish line with EOF to indicate that the original line did
- # not end with a linefeed
- echo "EOF"
- fi
- mode=$(get_mode "$file")
- echo "Mode: $mode"
- vecho "$mode $file"
- div
- else
- echo >&2 "ERROR: file not found ($file in $(pwd))"
- exit 2
- fi
- shift
- done
-}
-
-function create {
- ttar_file=$1
- shift
- if [ -z "${1:-}" ]; then
- echo >&2 "ERROR: missing arguments."
- echo
- usage 1
- fi
- if [ -e "$ttar_file" ]; then
- rm "$ttar_file"
- fi
- exec > "$ttar_file"
- echo "# Archive created by ttar $ARG_STRING"
- _create "$@"
-}
-
-test_environment
-
-if [ -n "${CDIR:-}" ]; then
- if [[ "$ARCHIVE" != /* ]]; then
- # Relative path: preserve the archive's location before changing
- # directory
- ARCHIVE="$(pwd)/$ARCHIVE"
- fi
- cd "$CDIR"
-fi
-
-"$CMD" "$ARCHIVE" "$@"
diff --git a/vendor/github.com/prometheus/procfs/vm.go b/vendor/github.com/prometheus/procfs/vm.go
deleted file mode 100644
index 51c49d8..0000000
--- a/vendor/github.com/prometheus/procfs/vm.go
+++ /dev/null
@@ -1,212 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !windows
-// +build !windows
-
-package procfs
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// The VM interface is described at
-//
-// https://www.kernel.org/doc/Documentation/sysctl/vm.txt
-//
-// Each setting is exposed as a single file.
-// Each file contains one line with a single numerical value, except lowmem_reserve_ratio which holds an array
-// and numa_zonelist_order (deprecated) which is a string.
-type VM struct {
- AdminReserveKbytes *int64 // /proc/sys/vm/admin_reserve_kbytes
- BlockDump *int64 // /proc/sys/vm/block_dump
- CompactUnevictableAllowed *int64 // /proc/sys/vm/compact_unevictable_allowed
- DirtyBackgroundBytes *int64 // /proc/sys/vm/dirty_background_bytes
- DirtyBackgroundRatio *int64 // /proc/sys/vm/dirty_background_ratio
- DirtyBytes *int64 // /proc/sys/vm/dirty_bytes
- DirtyExpireCentisecs *int64 // /proc/sys/vm/dirty_expire_centisecs
- DirtyRatio *int64 // /proc/sys/vm/dirty_ratio
- DirtytimeExpireSeconds *int64 // /proc/sys/vm/dirtytime_expire_seconds
- DirtyWritebackCentisecs *int64 // /proc/sys/vm/dirty_writeback_centisecs
- DropCaches *int64 // /proc/sys/vm/drop_caches
- ExtfragThreshold *int64 // /proc/sys/vm/extfrag_threshold
- HugetlbShmGroup *int64 // /proc/sys/vm/hugetlb_shm_group
- LaptopMode *int64 // /proc/sys/vm/laptop_mode
- LegacyVaLayout *int64 // /proc/sys/vm/legacy_va_layout
- LowmemReserveRatio []*int64 // /proc/sys/vm/lowmem_reserve_ratio
- MaxMapCount *int64 // /proc/sys/vm/max_map_count
- MemoryFailureEarlyKill *int64 // /proc/sys/vm/memory_failure_early_kill
- MemoryFailureRecovery *int64 // /proc/sys/vm/memory_failure_recovery
- MinFreeKbytes *int64 // /proc/sys/vm/min_free_kbytes
- MinSlabRatio *int64 // /proc/sys/vm/min_slab_ratio
- MinUnmappedRatio *int64 // /proc/sys/vm/min_unmapped_ratio
- MmapMinAddr *int64 // /proc/sys/vm/mmap_min_addr
- NrHugepages *int64 // /proc/sys/vm/nr_hugepages
- NrHugepagesMempolicy *int64 // /proc/sys/vm/nr_hugepages_mempolicy
- NrOvercommitHugepages *int64 // /proc/sys/vm/nr_overcommit_hugepages
- NumaStat *int64 // /proc/sys/vm/numa_stat
- NumaZonelistOrder string // /proc/sys/vm/numa_zonelist_order
- OomDumpTasks *int64 // /proc/sys/vm/oom_dump_tasks
- OomKillAllocatingTask *int64 // /proc/sys/vm/oom_kill_allocating_task
- OvercommitKbytes *int64 // /proc/sys/vm/overcommit_kbytes
- OvercommitMemory *int64 // /proc/sys/vm/overcommit_memory
- OvercommitRatio *int64 // /proc/sys/vm/overcommit_ratio
- PageCluster *int64 // /proc/sys/vm/page-cluster
- PanicOnOom *int64 // /proc/sys/vm/panic_on_oom
- PercpuPagelistFraction *int64 // /proc/sys/vm/percpu_pagelist_fraction
- StatInterval *int64 // /proc/sys/vm/stat_interval
- Swappiness *int64 // /proc/sys/vm/swappiness
- UserReserveKbytes *int64 // /proc/sys/vm/user_reserve_kbytes
- VfsCachePressure *int64 // /proc/sys/vm/vfs_cache_pressure
- WatermarkBoostFactor *int64 // /proc/sys/vm/watermark_boost_factor
- WatermarkScaleFactor *int64 // /proc/sys/vm/watermark_scale_factor
- ZoneReclaimMode *int64 // /proc/sys/vm/zone_reclaim_mode
-}
-
-// VM reads the VM statistics from the specified `proc` filesystem.
-func (fs FS) VM() (*VM, error) {
- path := fs.proc.Path("sys/vm")
- file, err := os.Stat(path)
- if err != nil {
- return nil, err
- }
- if !file.Mode().IsDir() {
- return nil, fmt.Errorf("%w: %s is not a directory", ErrFileRead, path)
- }
-
- files, err := os.ReadDir(path)
- if err != nil {
- return nil, err
- }
-
- var vm VM
- for _, f := range files {
- if f.IsDir() {
- continue
- }
-
- name := filepath.Join(path, f.Name())
- // ignore errors on read, as there are some write only
- // in /proc/sys/vm
- value, err := util.SysReadFile(name)
- if err != nil {
- continue
- }
- vp := util.NewValueParser(value)
-
- switch f.Name() {
- case "admin_reserve_kbytes":
- vm.AdminReserveKbytes = vp.PInt64()
- case "block_dump":
- vm.BlockDump = vp.PInt64()
- case "compact_unevictable_allowed":
- vm.CompactUnevictableAllowed = vp.PInt64()
- case "dirty_background_bytes":
- vm.DirtyBackgroundBytes = vp.PInt64()
- case "dirty_background_ratio":
- vm.DirtyBackgroundRatio = vp.PInt64()
- case "dirty_bytes":
- vm.DirtyBytes = vp.PInt64()
- case "dirty_expire_centisecs":
- vm.DirtyExpireCentisecs = vp.PInt64()
- case "dirty_ratio":
- vm.DirtyRatio = vp.PInt64()
- case "dirtytime_expire_seconds":
- vm.DirtytimeExpireSeconds = vp.PInt64()
- case "dirty_writeback_centisecs":
- vm.DirtyWritebackCentisecs = vp.PInt64()
- case "drop_caches":
- vm.DropCaches = vp.PInt64()
- case "extfrag_threshold":
- vm.ExtfragThreshold = vp.PInt64()
- case "hugetlb_shm_group":
- vm.HugetlbShmGroup = vp.PInt64()
- case "laptop_mode":
- vm.LaptopMode = vp.PInt64()
- case "legacy_va_layout":
- vm.LegacyVaLayout = vp.PInt64()
- case "lowmem_reserve_ratio":
- stringSlice := strings.Fields(value)
- pint64Slice := make([]*int64, 0, len(stringSlice))
- for _, value := range stringSlice {
- vp := util.NewValueParser(value)
- pint64Slice = append(pint64Slice, vp.PInt64())
- }
- vm.LowmemReserveRatio = pint64Slice
- case "max_map_count":
- vm.MaxMapCount = vp.PInt64()
- case "memory_failure_early_kill":
- vm.MemoryFailureEarlyKill = vp.PInt64()
- case "memory_failure_recovery":
- vm.MemoryFailureRecovery = vp.PInt64()
- case "min_free_kbytes":
- vm.MinFreeKbytes = vp.PInt64()
- case "min_slab_ratio":
- vm.MinSlabRatio = vp.PInt64()
- case "min_unmapped_ratio":
- vm.MinUnmappedRatio = vp.PInt64()
- case "mmap_min_addr":
- vm.MmapMinAddr = vp.PInt64()
- case "nr_hugepages":
- vm.NrHugepages = vp.PInt64()
- case "nr_hugepages_mempolicy":
- vm.NrHugepagesMempolicy = vp.PInt64()
- case "nr_overcommit_hugepages":
- vm.NrOvercommitHugepages = vp.PInt64()
- case "numa_stat":
- vm.NumaStat = vp.PInt64()
- case "numa_zonelist_order":
- vm.NumaZonelistOrder = value
- case "oom_dump_tasks":
- vm.OomDumpTasks = vp.PInt64()
- case "oom_kill_allocating_task":
- vm.OomKillAllocatingTask = vp.PInt64()
- case "overcommit_kbytes":
- vm.OvercommitKbytes = vp.PInt64()
- case "overcommit_memory":
- vm.OvercommitMemory = vp.PInt64()
- case "overcommit_ratio":
- vm.OvercommitRatio = vp.PInt64()
- case "page-cluster":
- vm.PageCluster = vp.PInt64()
- case "panic_on_oom":
- vm.PanicOnOom = vp.PInt64()
- case "percpu_pagelist_fraction":
- vm.PercpuPagelistFraction = vp.PInt64()
- case "stat_interval":
- vm.StatInterval = vp.PInt64()
- case "swappiness":
- vm.Swappiness = vp.PInt64()
- case "user_reserve_kbytes":
- vm.UserReserveKbytes = vp.PInt64()
- case "vfs_cache_pressure":
- vm.VfsCachePressure = vp.PInt64()
- case "watermark_boost_factor":
- vm.WatermarkBoostFactor = vp.PInt64()
- case "watermark_scale_factor":
- vm.WatermarkScaleFactor = vp.PInt64()
- case "zone_reclaim_mode":
- vm.ZoneReclaimMode = vp.PInt64()
- }
- if err := vp.Err(); err != nil {
- return nil, err
- }
- }
-
- return &vm, nil
-}
diff --git a/vendor/github.com/prometheus/procfs/zoneinfo.go b/vendor/github.com/prometheus/procfs/zoneinfo.go
deleted file mode 100644
index e54d94b..0000000
--- a/vendor/github.com/prometheus/procfs/zoneinfo.go
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright 2019 The Prometheus Authors
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//go:build !windows
-// +build !windows
-
-package procfs
-
-import (
- "bytes"
- "fmt"
- "os"
- "regexp"
- "strings"
-
- "github.com/prometheus/procfs/internal/util"
-)
-
-// Zoneinfo holds info parsed from /proc/zoneinfo.
-type Zoneinfo struct {
- Node string
- Zone string
- NrFreePages *int64
- Min *int64
- Low *int64
- High *int64
- Scanned *int64
- Spanned *int64
- Present *int64
- Managed *int64
- NrActiveAnon *int64
- NrInactiveAnon *int64
- NrIsolatedAnon *int64
- NrAnonPages *int64
- NrAnonTransparentHugepages *int64
- NrActiveFile *int64
- NrInactiveFile *int64
- NrIsolatedFile *int64
- NrFilePages *int64
- NrSlabReclaimable *int64
- NrSlabUnreclaimable *int64
- NrMlockStack *int64
- NrKernelStack *int64
- NrMapped *int64
- NrDirty *int64
- NrWriteback *int64
- NrUnevictable *int64
- NrShmem *int64
- NrDirtied *int64
- NrWritten *int64
- NumaHit *int64
- NumaMiss *int64
- NumaForeign *int64
- NumaInterleave *int64
- NumaLocal *int64
- NumaOther *int64
- Protection []*int64
-}
-
-var nodeZoneRE = regexp.MustCompile(`(\d+), zone\s+(\w+)`)
-
-// Zoneinfo parses an zoneinfo-file (/proc/zoneinfo) and returns a slice of
-// structs containing the relevant info. More information available here:
-// https://www.kernel.org/doc/Documentation/sysctl/vm.txt
-func (fs FS) Zoneinfo() ([]Zoneinfo, error) {
- data, err := os.ReadFile(fs.proc.Path("zoneinfo"))
- if err != nil {
- return nil, fmt.Errorf("%w: error reading zoneinfo %q: %w", ErrFileRead, fs.proc.Path("zoneinfo"), err)
- }
- zoneinfo, err := parseZoneinfo(data)
- if err != nil {
- return nil, fmt.Errorf("%w: error parsing zoneinfo %q: %w", ErrFileParse, fs.proc.Path("zoneinfo"), err)
- }
- return zoneinfo, nil
-}
-
-func parseZoneinfo(zoneinfoData []byte) ([]Zoneinfo, error) {
-
- zoneinfo := []Zoneinfo{}
-
- zoneinfoBlocks := bytes.Split(zoneinfoData, []byte("\nNode"))
- for _, block := range zoneinfoBlocks {
- var zoneinfoElement Zoneinfo
- lines := strings.Split(string(block), "\n")
- for _, line := range lines {
-
- if nodeZone := nodeZoneRE.FindStringSubmatch(line); nodeZone != nil {
- zoneinfoElement.Node = nodeZone[1]
- zoneinfoElement.Zone = nodeZone[2]
- continue
- }
- if strings.HasPrefix(strings.TrimSpace(line), "per-node stats") {
- continue
- }
- parts := strings.Fields(strings.TrimSpace(line))
- if len(parts) < 2 {
- continue
- }
- vp := util.NewValueParser(parts[1])
- switch parts[0] {
- case "nr_free_pages":
- zoneinfoElement.NrFreePages = vp.PInt64()
- case "min":
- zoneinfoElement.Min = vp.PInt64()
- case "low":
- zoneinfoElement.Low = vp.PInt64()
- case "high":
- zoneinfoElement.High = vp.PInt64()
- case "scanned":
- zoneinfoElement.Scanned = vp.PInt64()
- case "spanned":
- zoneinfoElement.Spanned = vp.PInt64()
- case "present":
- zoneinfoElement.Present = vp.PInt64()
- case "managed":
- zoneinfoElement.Managed = vp.PInt64()
- case "nr_active_anon":
- zoneinfoElement.NrActiveAnon = vp.PInt64()
- case "nr_inactive_anon":
- zoneinfoElement.NrInactiveAnon = vp.PInt64()
- case "nr_isolated_anon":
- zoneinfoElement.NrIsolatedAnon = vp.PInt64()
- case "nr_anon_pages":
- zoneinfoElement.NrAnonPages = vp.PInt64()
- case "nr_anon_transparent_hugepages":
- zoneinfoElement.NrAnonTransparentHugepages = vp.PInt64()
- case "nr_active_file":
- zoneinfoElement.NrActiveFile = vp.PInt64()
- case "nr_inactive_file":
- zoneinfoElement.NrInactiveFile = vp.PInt64()
- case "nr_isolated_file":
- zoneinfoElement.NrIsolatedFile = vp.PInt64()
- case "nr_file_pages":
- zoneinfoElement.NrFilePages = vp.PInt64()
- case "nr_slab_reclaimable":
- zoneinfoElement.NrSlabReclaimable = vp.PInt64()
- case "nr_slab_unreclaimable":
- zoneinfoElement.NrSlabUnreclaimable = vp.PInt64()
- case "nr_mlock_stack":
- zoneinfoElement.NrMlockStack = vp.PInt64()
- case "nr_kernel_stack":
- zoneinfoElement.NrKernelStack = vp.PInt64()
- case "nr_mapped":
- zoneinfoElement.NrMapped = vp.PInt64()
- case "nr_dirty":
- zoneinfoElement.NrDirty = vp.PInt64()
- case "nr_writeback":
- zoneinfoElement.NrWriteback = vp.PInt64()
- case "nr_unevictable":
- zoneinfoElement.NrUnevictable = vp.PInt64()
- case "nr_shmem":
- zoneinfoElement.NrShmem = vp.PInt64()
- case "nr_dirtied":
- zoneinfoElement.NrDirtied = vp.PInt64()
- case "nr_written":
- zoneinfoElement.NrWritten = vp.PInt64()
- case "numa_hit":
- zoneinfoElement.NumaHit = vp.PInt64()
- case "numa_miss":
- zoneinfoElement.NumaMiss = vp.PInt64()
- case "numa_foreign":
- zoneinfoElement.NumaForeign = vp.PInt64()
- case "numa_interleave":
- zoneinfoElement.NumaInterleave = vp.PInt64()
- case "numa_local":
- zoneinfoElement.NumaLocal = vp.PInt64()
- case "numa_other":
- zoneinfoElement.NumaOther = vp.PInt64()
- case "protection:":
- protectionParts := strings.Split(line, ":")
- protectionValues := strings.Replace(protectionParts[1], "(", "", 1)
- protectionValues = strings.Replace(protectionValues, ")", "", 1)
- protectionValues = strings.TrimSpace(protectionValues)
- protectionStringMap := strings.Split(protectionValues, ", ")
- val, err := util.ParsePInt64s(protectionStringMap)
- if err == nil {
- zoneinfoElement.Protection = val
- }
- }
-
- }
-
- zoneinfo = append(zoneinfo, zoneinfoElement)
- }
- return zoneinfo, nil
-}
diff --git a/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE
deleted file mode 100644
index 2a7cf70..0000000
--- a/vendor/golang.org/x/sys/LICENSE
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright 2009 The Go Authors.
-
-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 LLC 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.
diff --git a/vendor/golang.org/x/sys/PATENTS b/vendor/golang.org/x/sys/PATENTS
deleted file mode 100644
index 7330990..0000000
--- a/vendor/golang.org/x/sys/PATENTS
+++ /dev/null
@@ -1,22 +0,0 @@
-Additional IP Rights Grant (Patents)
-
-"This implementation" means the copyrightable works distributed by
-Google as part of the Go project.
-
-Google hereby grants to You a perpetual, worldwide, non-exclusive,
-no-charge, royalty-free, irrevocable (except as stated in this section)
-patent license to make, have made, use, offer to sell, sell, import,
-transfer and otherwise run, modify and propagate the contents of this
-implementation of Go, where such license applies only to those patent
-claims, both currently owned or controlled by Google and acquired in
-the future, licensable by Google that are necessarily infringed by this
-implementation of Go. This grant does not include claims that would be
-infringed only as a consequence of further modification of this
-implementation. If you or your agent or exclusive licensee institute or
-order or agree to the institution of patent litigation against any
-entity (including a cross-claim or counterclaim in a lawsuit) alleging
-that this implementation of Go or any code incorporated within this
-implementation of Go constitutes direct or contributory patent
-infringement, or inducement of patent infringement, then any patent
-rights granted to you under this License for this implementation of Go
-shall terminate as of the date such litigation is filed.
diff --git a/vendor/golang.org/x/sys/unix/.gitignore b/vendor/golang.org/x/sys/unix/.gitignore
deleted file mode 100644
index e3e0fc6..0000000
--- a/vendor/golang.org/x/sys/unix/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-_obj/
-unix.test
diff --git a/vendor/golang.org/x/sys/unix/README.md b/vendor/golang.org/x/sys/unix/README.md
deleted file mode 100644
index 7d3c060..0000000
--- a/vendor/golang.org/x/sys/unix/README.md
+++ /dev/null
@@ -1,184 +0,0 @@
-# Building `sys/unix`
-
-The sys/unix package provides access to the raw system call interface of the
-underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
-
-Porting Go to a new architecture/OS combination or adding syscalls, types, or
-constants to an existing architecture/OS pair requires some manual effort;
-however, there are tools that automate much of the process.
-
-## Build Systems
-
-There are currently two ways we generate the necessary files. We are currently
-migrating the build system to use containers so the builds are reproducible.
-This is being done on an OS-by-OS basis. Please update this documentation as
-components of the build system change.
-
-### Old Build System (currently for `GOOS != "linux"`)
-
-The old build system generates the Go files based on the C header files
-present on your system. This means that files
-for a given GOOS/GOARCH pair must be generated on a system with that OS and
-architecture. This also means that the generated code can differ from system
-to system, based on differences in the header files.
-
-To avoid this, if you are using the old build system, only generate the Go
-files on an installation with unmodified header files. It is also important to
-keep track of which version of the OS the files were generated from (ex.
-Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
-and have each OS upgrade correspond to a single change.
-
-To build the files for your current OS and architecture, make sure GOOS and
-GOARCH are set correctly and run `mkall.sh`. This will generate the files for
-your specific system. Running `mkall.sh -n` shows the commands that will be run.
-
-Requirements: bash, go
-
-### New Build System (currently for `GOOS == "linux"`)
-
-The new build system uses a Docker container to generate the go files directly
-from source checkouts of the kernel and various system libraries. This means
-that on any platform that supports Docker, all the files using the new build
-system can be generated at once, and generated files will not change based on
-what the person running the scripts has installed on their computer.
-
-The OS specific files for the new build system are located in the `${GOOS}`
-directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
-the kernel or system library updates, modify the Dockerfile at
-`${GOOS}/Dockerfile` to checkout the new release of the source.
-
-To build all the files under the new build system, you must be on an amd64/Linux
-system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
-then generate all of the files for all of the GOOS/GOARCH pairs in the new build
-system. Running `mkall.sh -n` shows the commands that will be run.
-
-Requirements: bash, go, docker
-
-## Component files
-
-This section describes the various files used in the code generation process.
-It also contains instructions on how to modify these files to add a new
-architecture/OS or to add additional syscalls, types, or constants. Note that
-if you are using the new build system, the scripts/programs cannot be called normally.
-They must be called from within the docker container.
-
-### asm files
-
-The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
-call dispatch. There are three entry points:
-```
- func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
- func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
- func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
-```
-The first and second are the standard ones; they differ only in how many
-arguments can be passed to the kernel. The third is for low-level use by the
-ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
-let it know that a system call is running.
-
-When porting Go to a new architecture/OS, this file must be implemented for
-each GOOS/GOARCH pair.
-
-### mksysnum
-
-Mksysnum is a Go program located at `${GOOS}/mksysnum.go` (or `mksysnum_${GOOS}.go`
-for the old system). This program takes in a list of header files containing the
-syscall number declarations and parses them to produce the corresponding list of
-Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
-constants.
-
-Adding new syscall numbers is mostly done by running the build on a sufficiently
-new installation of the target OS (or updating the source checkouts for the
-new build system). However, depending on the OS, you may need to update the
-parsing in mksysnum.
-
-### mksyscall.go
-
-The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
-hand-written Go files which implement system calls (for unix, the specific OS,
-or the specific OS/Architecture pair respectively) that need special handling
-and list `//sys` comments giving prototypes for ones that can be generated.
-
-The mksyscall.go program takes the `//sys` and `//sysnb` comments and converts
-them into syscalls. This requires the name of the prototype in the comment to
-match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
-prototype can be exported (capitalized) or not.
-
-Adding a new syscall often just requires adding a new `//sys` function prototype
-with the desired arguments and a capitalized name so it is exported. However, if
-you want the interface to the syscall to be different, often one will make an
-unexported `//sys` prototype, and then write a custom wrapper in
-`syscall_${GOOS}.go`.
-
-### types files
-
-For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
-`types_${GOOS}.go` on the old system). This file includes standard C headers and
-creates Go type aliases to the corresponding C types. The file is then fed
-through godef to get the Go compatible definitions. Finally, the generated code
-is fed though mkpost.go to format the code correctly and remove any hidden or
-private identifiers. This cleaned-up code is written to
-`ztypes_${GOOS}_${GOARCH}.go`.
-
-The hardest part about preparing this file is figuring out which headers to
-include and which symbols need to be `#define`d to get the actual data
-structures that pass through to the kernel system calls. Some C libraries
-preset alternate versions for binary compatibility and translate them on the
-way in and out of system calls, but there is almost always a `#define` that can
-get the real ones.
-See `types_darwin.go` and `linux/types.go` for examples.
-
-To add a new type, add in the necessary include statement at the top of the
-file (if it is not already there) and add in a type alias line. Note that if
-your type is significantly different on different architectures, you may need
-some `#if/#elif` macros in your include statements.
-
-### mkerrors.sh
-
-This script is used to generate the system's various constants. This doesn't
-just include the error numbers and error strings, but also the signal numbers
-and a wide variety of miscellaneous constants. The constants come from the list
-of include files in the `includes_${uname}` variable. A regex then picks out
-the desired `#define` statements, and generates the corresponding Go constants.
-The error numbers and strings are generated from `#include `, and the
-signal numbers and strings are generated from `#include `. All of
-these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
-`_errors.c`, which prints out all the constants.
-
-To add a constant, add the header that includes it to the appropriate variable.
-Then, edit the regex (if necessary) to match the desired constant. Avoid making
-the regex too broad to avoid matching unintended constants.
-
-### internal/mkmerge
-
-This program is used to extract duplicate const, func, and type declarations
-from the generated architecture-specific files listed below, and merge these
-into a common file for each OS.
-
-The merge is performed in the following steps:
-1. Construct the set of common code that is idential in all architecture-specific files.
-2. Write this common code to the merged file.
-3. Remove the common code from all architecture-specific files.
-
-
-## Generated files
-
-### `zerrors_${GOOS}_${GOARCH}.go`
-
-A file containing all of the system's generated error numbers, error strings,
-signal numbers, and constants. Generated by `mkerrors.sh` (see above).
-
-### `zsyscall_${GOOS}_${GOARCH}.go`
-
-A file containing all the generated syscalls for a specific GOOS and GOARCH.
-Generated by `mksyscall.go` (see above).
-
-### `zsysnum_${GOOS}_${GOARCH}.go`
-
-A list of numeric constants for all the syscall number of the specific GOOS
-and GOARCH. Generated by mksysnum (see above).
-
-### `ztypes_${GOOS}_${GOARCH}.go`
-
-A file containing Go types for passing into (or returning from) syscalls.
-Generated by godefs and the types file (see above).
diff --git a/vendor/golang.org/x/sys/unix/affinity_linux.go b/vendor/golang.org/x/sys/unix/affinity_linux.go
deleted file mode 100644
index 6e5c81a..0000000
--- a/vendor/golang.org/x/sys/unix/affinity_linux.go
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2018 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.
-
-// CPU affinity functions
-
-package unix
-
-import (
- "math/bits"
- "unsafe"
-)
-
-const cpuSetSize = _CPU_SETSIZE / _NCPUBITS
-
-// CPUSet represents a CPU affinity mask.
-type CPUSet [cpuSetSize]cpuMask
-
-func schedAffinity(trap uintptr, pid int, set *CPUSet) error {
- _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set)))
- if e != 0 {
- return errnoErr(e)
- }
- return nil
-}
-
-// SchedGetaffinity gets the CPU affinity mask of the thread specified by pid.
-// If pid is 0 the calling thread is used.
-func SchedGetaffinity(pid int, set *CPUSet) error {
- return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set)
-}
-
-// SchedSetaffinity sets the CPU affinity mask of the thread specified by pid.
-// If pid is 0 the calling thread is used.
-func SchedSetaffinity(pid int, set *CPUSet) error {
- return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set)
-}
-
-// Zero clears the set s, so that it contains no CPUs.
-func (s *CPUSet) Zero() {
- for i := range s {
- s[i] = 0
- }
-}
-
-func cpuBitsIndex(cpu int) int {
- return cpu / _NCPUBITS
-}
-
-func cpuBitsMask(cpu int) cpuMask {
- return cpuMask(1 << (uint(cpu) % _NCPUBITS))
-}
-
-// Set adds cpu to the set s.
-func (s *CPUSet) Set(cpu int) {
- i := cpuBitsIndex(cpu)
- if i < len(s) {
- s[i] |= cpuBitsMask(cpu)
- }
-}
-
-// Clear removes cpu from the set s.
-func (s *CPUSet) Clear(cpu int) {
- i := cpuBitsIndex(cpu)
- if i < len(s) {
- s[i] &^= cpuBitsMask(cpu)
- }
-}
-
-// IsSet reports whether cpu is in the set s.
-func (s *CPUSet) IsSet(cpu int) bool {
- i := cpuBitsIndex(cpu)
- if i < len(s) {
- return s[i]&cpuBitsMask(cpu) != 0
- }
- return false
-}
-
-// Count returns the number of CPUs in the set s.
-func (s *CPUSet) Count() int {
- c := 0
- for _, b := range s {
- c += bits.OnesCount64(uint64(b))
- }
- return c
-}
diff --git a/vendor/golang.org/x/sys/unix/aliases.go b/vendor/golang.org/x/sys/unix/aliases.go
deleted file mode 100644
index b0e4198..0000000
--- a/vendor/golang.org/x/sys/unix/aliases.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2018 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.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-package unix
-
-import "syscall"
-
-type Signal = syscall.Signal
-type Errno = syscall.Errno
-type SysProcAttr = syscall.SysProcAttr
diff --git a/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s b/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
deleted file mode 100644
index 269e173..0000000
--- a/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2018 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.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for ppc64, AIX are implemented in runtime/syscall_aix.go
-//
-
-TEXT ·syscall6(SB),NOSPLIT,$0-88
- JMP syscall·syscall6(SB)
-
-TEXT ·rawSyscall6(SB),NOSPLIT,$0-88
- JMP syscall·rawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_386.s b/vendor/golang.org/x/sys/unix/asm_bsd_386.s
deleted file mode 100644
index a4fcef0..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_386.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 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.
-
-//go:build (freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for 386 BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-52
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s b/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s
deleted file mode 100644
index 1e63615..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_amd64.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 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.
-
-//go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for AMD64 BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_arm.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm.s
deleted file mode 100644
index 6496c31..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_arm.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 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.
-
-//go:build (freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for ARM BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- B syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- B syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-52
- B syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- B syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- B syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s b/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s
deleted file mode 100644
index 4fd1f54..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_arm64.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 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.
-
-//go:build (darwin || freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for ARM64 BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s b/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s
deleted file mode 100644
index 42f7eb9..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2022 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.
-
-//go:build (darwin || freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-//
-// System call support for ppc64, BSD
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s b/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s
deleted file mode 100644
index f890266..0000000
--- a/vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2021 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.
-
-//go:build (darwin || freebsd || netbsd || openbsd) && gc
-
-#include "textflag.h"
-
-// System call support for RISCV64 BSD
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_386.s b/vendor/golang.org/x/sys/unix/asm_linux_386.s
deleted file mode 100644
index 3b47348..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_386.s
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2009 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.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for 386, Linux
-//
-
-// See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
-// instead of the glibc-specific "CALL 0x10(GS)".
-#define INVOKE_SYSCALL INT $0x80
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
- CALL runtime·entersyscall(SB)
- MOVL trap+0(FP), AX // syscall entry
- MOVL a1+4(FP), BX
- MOVL a2+8(FP), CX
- MOVL a3+12(FP), DX
- MOVL $0, SI
- MOVL $0, DI
- INVOKE_SYSCALL
- MOVL AX, r1+16(FP)
- MOVL DX, r2+20(FP)
- CALL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
- MOVL trap+0(FP), AX // syscall entry
- MOVL a1+4(FP), BX
- MOVL a2+8(FP), CX
- MOVL a3+12(FP), DX
- MOVL $0, SI
- MOVL $0, DI
- INVOKE_SYSCALL
- MOVL AX, r1+16(FP)
- MOVL DX, r2+20(FP)
- RET
-
-TEXT ·socketcall(SB),NOSPLIT,$0-36
- JMP syscall·socketcall(SB)
-
-TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
- JMP syscall·rawsocketcall(SB)
-
-TEXT ·seek(SB),NOSPLIT,$0-28
- JMP syscall·seek(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_amd64.s b/vendor/golang.org/x/sys/unix/asm_linux_amd64.s
deleted file mode 100644
index 67e29f3..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_amd64.s
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2009 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.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for AMD64, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- CALL runtime·entersyscall(SB)
- MOVQ a1+8(FP), DI
- MOVQ a2+16(FP), SI
- MOVQ a3+24(FP), DX
- MOVQ $0, R10
- MOVQ $0, R8
- MOVQ $0, R9
- MOVQ trap+0(FP), AX // syscall entry
- SYSCALL
- MOVQ AX, r1+32(FP)
- MOVQ DX, r2+40(FP)
- CALL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVQ a1+8(FP), DI
- MOVQ a2+16(FP), SI
- MOVQ a3+24(FP), DX
- MOVQ $0, R10
- MOVQ $0, R8
- MOVQ $0, R9
- MOVQ trap+0(FP), AX // syscall entry
- SYSCALL
- MOVQ AX, r1+32(FP)
- MOVQ DX, r2+40(FP)
- RET
-
-TEXT ·gettimeofday(SB),NOSPLIT,$0-16
- JMP syscall·gettimeofday(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm.s b/vendor/golang.org/x/sys/unix/asm_linux_arm.s
deleted file mode 100644
index d6ae269..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_arm.s
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2009 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.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for arm, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- B syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- B syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
- BL runtime·entersyscall(SB)
- MOVW trap+0(FP), R7
- MOVW a1+4(FP), R0
- MOVW a2+8(FP), R1
- MOVW a3+12(FP), R2
- MOVW $0, R3
- MOVW $0, R4
- MOVW $0, R5
- SWI $0
- MOVW R0, r1+16(FP)
- MOVW $0, R0
- MOVW R0, r2+20(FP)
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- B syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- B syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
- MOVW trap+0(FP), R7 // syscall entry
- MOVW a1+4(FP), R0
- MOVW a2+8(FP), R1
- MOVW a3+12(FP), R2
- SWI $0
- MOVW R0, r1+16(FP)
- MOVW $0, R0
- MOVW R0, r2+20(FP)
- RET
-
-TEXT ·seek(SB),NOSPLIT,$0-28
- B syscall·seek(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_arm64.s b/vendor/golang.org/x/sys/unix/asm_linux_arm64.s
deleted file mode 100644
index 01e5e25..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_arm64.s
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2015 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.
-
-//go:build linux && arm64 && gc
-
-#include "textflag.h"
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- B syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- B syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R0
- MOVD a2+16(FP), R1
- MOVD a3+24(FP), R2
- MOVD $0, R3
- MOVD $0, R4
- MOVD $0, R5
- MOVD trap+0(FP), R8 // syscall entry
- SVC
- MOVD R0, r1+32(FP) // r1
- MOVD R1, r2+40(FP) // r2
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- B syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- B syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVD a1+8(FP), R0
- MOVD a2+16(FP), R1
- MOVD a3+24(FP), R2
- MOVD $0, R3
- MOVD $0, R4
- MOVD $0, R5
- MOVD trap+0(FP), R8 // syscall entry
- SVC
- MOVD R0, r1+32(FP)
- MOVD R1, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_loong64.s b/vendor/golang.org/x/sys/unix/asm_linux_loong64.s
deleted file mode 100644
index 2abf12f..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_loong64.s
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2022 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.
-
-//go:build linux && loong64 && gc
-
-#include "textflag.h"
-
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- JAL runtime·entersyscall(SB)
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV R0, R7
- MOVV R0, R8
- MOVV R0, R9
- MOVV trap+0(FP), R11 // syscall entry
- SYSCALL
- MOVV R4, r1+32(FP)
- MOVV R0, r2+40(FP) // r2 is not used. Always set to 0
- JAL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV R0, R7
- MOVV R0, R8
- MOVV R0, R9
- MOVV trap+0(FP), R11 // syscall entry
- SYSCALL
- MOVV R4, r1+32(FP)
- MOVV R0, r2+40(FP) // r2 is not used. Always set to 0
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s b/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
deleted file mode 100644
index f84bae7..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2015 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.
-
-//go:build linux && (mips64 || mips64le) && gc
-
-#include "textflag.h"
-
-//
-// System calls for mips64, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- JAL runtime·entersyscall(SB)
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV R0, R7
- MOVV R0, R8
- MOVV R0, R9
- MOVV trap+0(FP), R2 // syscall entry
- SYSCALL
- MOVV R2, r1+32(FP)
- MOVV R3, r2+40(FP)
- JAL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVV a1+8(FP), R4
- MOVV a2+16(FP), R5
- MOVV a3+24(FP), R6
- MOVV R0, R7
- MOVV R0, R8
- MOVV R0, R9
- MOVV trap+0(FP), R2 // syscall entry
- SYSCALL
- MOVV R2, r1+32(FP)
- MOVV R3, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s b/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
deleted file mode 100644
index f08f628..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2016 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.
-
-//go:build linux && (mips || mipsle) && gc
-
-#include "textflag.h"
-
-//
-// System calls for mips, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-28
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-40
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-52
- JMP syscall·Syscall9(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
- JAL runtime·entersyscall(SB)
- MOVW a1+4(FP), R4
- MOVW a2+8(FP), R5
- MOVW a3+12(FP), R6
- MOVW R0, R7
- MOVW trap+0(FP), R2 // syscall entry
- SYSCALL
- MOVW R2, r1+16(FP) // r1
- MOVW R3, r2+20(FP) // r2
- JAL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-28
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
- MOVW a1+4(FP), R4
- MOVW a2+8(FP), R5
- MOVW a3+12(FP), R6
- MOVW trap+0(FP), R2 // syscall entry
- SYSCALL
- MOVW R2, r1+16(FP)
- MOVW R3, r2+20(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
deleted file mode 100644
index bdfc024..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2014 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.
-
-//go:build linux && (ppc64 || ppc64le) && gc
-
-#include "textflag.h"
-
-//
-// System calls for ppc64, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R3
- MOVD a2+16(FP), R4
- MOVD a3+24(FP), R5
- MOVD R0, R6
- MOVD R0, R7
- MOVD R0, R8
- MOVD trap+0(FP), R9 // syscall entry
- SYSCALL R9
- MOVD R3, r1+32(FP)
- MOVD R4, r2+40(FP)
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVD a1+8(FP), R3
- MOVD a2+16(FP), R4
- MOVD a3+24(FP), R5
- MOVD R0, R6
- MOVD R0, R7
- MOVD R0, R8
- MOVD trap+0(FP), R9 // syscall entry
- SYSCALL R9
- MOVD R3, r1+32(FP)
- MOVD R4, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s b/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
deleted file mode 100644
index 2e8c996..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2019 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.
-
-//go:build riscv64 && gc
-
-#include "textflag.h"
-
-//
-// System calls for linux/riscv64.
-//
-// Where available, just jump to package syscall's implementation of
-// these functions.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- CALL runtime·entersyscall(SB)
- MOV a1+8(FP), A0
- MOV a2+16(FP), A1
- MOV a3+24(FP), A2
- MOV trap+0(FP), A7 // syscall entry
- ECALL
- MOV A0, r1+32(FP) // r1
- MOV A1, r2+40(FP) // r2
- CALL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOV a1+8(FP), A0
- MOV a2+16(FP), A1
- MOV a3+24(FP), A2
- MOV trap+0(FP), A7 // syscall entry
- ECALL
- MOV A0, r1+32(FP)
- MOV A1, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_s390x.s b/vendor/golang.org/x/sys/unix/asm_linux_s390x.s
deleted file mode 100644
index 2c394b1..0000000
--- a/vendor/golang.org/x/sys/unix/asm_linux_s390x.s
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2016 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.
-
-//go:build linux && s390x && gc
-
-#include "textflag.h"
-
-//
-// System calls for s390x, Linux
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- BR syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- BR syscall·Syscall6(SB)
-
-TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
- BL runtime·entersyscall(SB)
- MOVD a1+8(FP), R2
- MOVD a2+16(FP), R3
- MOVD a3+24(FP), R4
- MOVD $0, R5
- MOVD $0, R6
- MOVD $0, R7
- MOVD trap+0(FP), R1 // syscall entry
- SYSCALL
- MOVD R2, r1+32(FP)
- MOVD R3, r2+40(FP)
- BL runtime·exitsyscall(SB)
- RET
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- BR syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- BR syscall·RawSyscall6(SB)
-
-TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
- MOVD a1+8(FP), R2
- MOVD a2+16(FP), R3
- MOVD a3+24(FP), R4
- MOVD $0, R5
- MOVD $0, R6
- MOVD $0, R7
- MOVD trap+0(FP), R1 // syscall entry
- SYSCALL
- MOVD R2, r1+32(FP)
- MOVD R3, r2+40(FP)
- RET
diff --git a/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
deleted file mode 100644
index fab586a..0000000
--- a/vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2019 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.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System call support for mips64, OpenBSD
-//
-
-// Just jump to package syscall's implementation for all these functions.
-// The runtime may know about them.
-
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- JMP syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- JMP syscall·Syscall6(SB)
-
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
- JMP syscall·Syscall9(SB)
-
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- JMP syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- JMP syscall·RawSyscall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s b/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
deleted file mode 100644
index f949ec5..0000000
--- a/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2014 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.
-
-//go:build gc
-
-#include "textflag.h"
-
-//
-// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
-//
-
-TEXT ·sysvicall6(SB),NOSPLIT,$0-88
- JMP syscall·sysvicall6(SB)
-
-TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
- JMP syscall·rawSysvicall6(SB)
diff --git a/vendor/golang.org/x/sys/unix/asm_zos_s390x.s b/vendor/golang.org/x/sys/unix/asm_zos_s390x.s
deleted file mode 100644
index 813dfad..0000000
--- a/vendor/golang.org/x/sys/unix/asm_zos_s390x.s
+++ /dev/null
@@ -1,382 +0,0 @@
-// Copyright 2020 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.
-
-//go:build zos && s390x && gc
-
-#include "textflag.h"
-
-#define PSALAA 1208(R0)
-#define GTAB64(x) 80(x)
-#define LCA64(x) 88(x)
-#define SAVSTACK_ASYNC(x) 336(x) // in the LCA
-#define CAA(x) 8(x)
-#define CEECAATHDID(x) 976(x) // in the CAA
-#define EDCHPXV(x) 1016(x) // in the CAA
-#define GOCB(x) 1104(x) // in the CAA
-
-// SS_*, where x=SAVSTACK_ASYNC
-#define SS_LE(x) 0(x)
-#define SS_GO(x) 8(x)
-#define SS_ERRNO(x) 16(x)
-#define SS_ERRNOJR(x) 20(x)
-
-// Function Descriptor Offsets
-#define __errno 0x156*16
-#define __err2ad 0x16C*16
-
-// Call Instructions
-#define LE_CALL BYTE $0x0D; BYTE $0x76 // BL R7, R6
-#define SVC_LOAD BYTE $0x0A; BYTE $0x08 // SVC 08 LOAD
-#define SVC_DELETE BYTE $0x0A; BYTE $0x09 // SVC 09 DELETE
-
-DATA zosLibVec<>(SB)/8, $0
-GLOBL zosLibVec<>(SB), NOPTR, $8
-
-TEXT ·initZosLibVec(SB), NOSPLIT|NOFRAME, $0-0
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
- MOVD CAA(R8), R8
- MOVD EDCHPXV(R8), R8
- MOVD R8, zosLibVec<>(SB)
- RET
-
-TEXT ·GetZosLibVec(SB), NOSPLIT|NOFRAME, $0-0
- MOVD zosLibVec<>(SB), R8
- MOVD R8, ret+0(FP)
- RET
-
-TEXT ·clearErrno(SB), NOSPLIT, $0-0
- BL addrerrno<>(SB)
- MOVD $0, 0(R3)
- RET
-
-// Returns the address of errno in R3.
-TEXT addrerrno<>(SB), NOSPLIT|NOFRAME, $0-0
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get __errno FuncDesc.
- MOVD CAA(R8), R9
- MOVD EDCHPXV(R9), R9
- ADD $(__errno), R9
- LMG 0(R9), R5, R6
-
- // Switch to saved LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R4
- MOVD $0, 0(R9)
-
- // Call __errno function.
- LE_CALL
- NOPH
-
- // Switch back to Go stack.
- XOR R0, R0 // Restore R0 to $0.
- MOVD R4, 0(R9) // Save stack pointer.
- RET
-
-// func svcCall(fnptr unsafe.Pointer, argv *unsafe.Pointer, dsa *uint64)
-TEXT ·svcCall(SB), NOSPLIT, $0
- BL runtime·save_g(SB) // Save g and stack pointer
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD R15, 0(R9)
-
- MOVD argv+8(FP), R1 // Move function arguments into registers
- MOVD dsa+16(FP), g
- MOVD fnptr+0(FP), R15
-
- BYTE $0x0D // Branch to function
- BYTE $0xEF
-
- BL runtime·load_g(SB) // Restore g and stack pointer
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
- MOVD SAVSTACK_ASYNC(R8), R9
- MOVD 0(R9), R15
-
- RET
-
-// func svcLoad(name *byte) unsafe.Pointer
-TEXT ·svcLoad(SB), NOSPLIT, $0
- MOVD R15, R2 // Save go stack pointer
- MOVD name+0(FP), R0 // Move SVC args into registers
- MOVD $0x80000000, R1
- MOVD $0, R15
- SVC_LOAD
- MOVW R15, R3 // Save return code from SVC
- MOVD R2, R15 // Restore go stack pointer
- CMP R3, $0 // Check SVC return code
- BNE error
-
- MOVD $-2, R3 // Reset last bit of entry point to zero
- AND R0, R3
- MOVD R3, ret+8(FP) // Return entry point returned by SVC
- CMP R0, R3 // Check if last bit of entry point was set
- BNE done
-
- MOVD R15, R2 // Save go stack pointer
- MOVD $0, R15 // Move SVC args into registers (entry point still in r0 from SVC 08)
- SVC_DELETE
- MOVD R2, R15 // Restore go stack pointer
-
-error:
- MOVD $0, ret+8(FP) // Return 0 on failure
-
-done:
- XOR R0, R0 // Reset r0 to 0
- RET
-
-// func svcUnload(name *byte, fnptr unsafe.Pointer) int64
-TEXT ·svcUnload(SB), NOSPLIT, $0
- MOVD R15, R2 // Save go stack pointer
- MOVD name+0(FP), R0 // Move SVC args into registers
- MOVD fnptr+8(FP), R15
- SVC_DELETE
- XOR R0, R0 // Reset r0 to 0
- MOVD R15, R1 // Save SVC return code
- MOVD R2, R15 // Restore go stack pointer
- MOVD R1, ret+16(FP) // Return SVC return code
- RET
-
-// func gettid() uint64
-TEXT ·gettid(SB), NOSPLIT, $0
- // Get library control area (LCA).
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
-
- // Get CEECAATHDID
- MOVD CAA(R8), R9
- MOVD CEECAATHDID(R9), R9
- MOVD R9, ret+0(FP)
-
- RET
-
-//
-// Call LE function, if the return is -1
-// errno and errno2 is retrieved
-//
-TEXT ·CallLeFuncWithErr(SB), NOSPLIT, $0
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
- MOVD CAA(R8), R9
- MOVD g, GOCB(R9)
-
- // Restore LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9 // R9-> LE stack frame saving address
- MOVD 0(R9), R4 // R4-> restore previously saved stack frame pointer
-
- MOVD parms_base+8(FP), R7 // R7 -> argument array
- MOVD parms_len+16(FP), R8 // R8 number of arguments
-
- // arg 1 ---> R1
- CMP R8, $0
- BEQ docall
- SUB $1, R8
- MOVD 0(R7), R1
-
- // arg 2 ---> R2
- CMP R8, $0
- BEQ docall
- SUB $1, R8
- ADD $8, R7
- MOVD 0(R7), R2
-
- // arg 3 --> R3
- CMP R8, $0
- BEQ docall
- SUB $1, R8
- ADD $8, R7
- MOVD 0(R7), R3
-
- CMP R8, $0
- BEQ docall
- MOVD $2176+16, R6 // starting LE stack address-8 to store 4th argument
-
-repeat:
- ADD $8, R7
- MOVD 0(R7), R0 // advance arg pointer by 8 byte
- ADD $8, R6 // advance LE argument address by 8 byte
- MOVD R0, (R4)(R6*1) // copy argument from go-slice to le-frame
- SUB $1, R8
- CMP R8, $0
- BNE repeat
-
-docall:
- MOVD funcdesc+0(FP), R8 // R8-> function descriptor
- LMG 0(R8), R5, R6
- MOVD $0, 0(R9) // R9 address of SAVSTACK_ASYNC
- LE_CALL // balr R7, R6 (return #1)
- NOPH
- MOVD R3, ret+32(FP)
- CMP R3, $-1 // compare result to -1
- BNE done
-
- // retrieve errno and errno2
- MOVD zosLibVec<>(SB), R8
- ADD $(__errno), R8
- LMG 0(R8), R5, R6
- LE_CALL // balr R7, R6 __errno (return #3)
- NOPH
- MOVWZ 0(R3), R3
- MOVD R3, err+48(FP)
- MOVD zosLibVec<>(SB), R8
- ADD $(__err2ad), R8
- LMG 0(R8), R5, R6
- LE_CALL // balr R7, R6 __err2ad (return #2)
- NOPH
- MOVW (R3), R2 // retrieve errno2
- MOVD R2, errno2+40(FP) // store in return area
-
-done:
- MOVD R4, 0(R9) // Save stack pointer.
- RET
-
-//
-// Call LE function, if the return is 0
-// errno and errno2 is retrieved
-//
-TEXT ·CallLeFuncWithPtrReturn(SB), NOSPLIT, $0
- MOVW PSALAA, R8
- MOVD LCA64(R8), R8
- MOVD CAA(R8), R9
- MOVD g, GOCB(R9)
-
- // Restore LE stack.
- MOVD SAVSTACK_ASYNC(R8), R9 // R9-> LE stack frame saving address
- MOVD 0(R9), R4 // R4-> restore previously saved stack frame pointer
-
- MOVD parms_base+8(FP), R7 // R7 -> argument array
- MOVD parms_len+16(FP), R8 // R8 number of arguments
-
- // arg 1 ---> R1
- CMP R8, $0
- BEQ docall
- SUB $1, R8
- MOVD 0(R7), R1
-
- // arg 2 ---> R2
- CMP R8, $0
- BEQ docall
- SUB $1, R8
- ADD $8, R7
- MOVD 0(R7), R2
-
- // arg 3 --> R3
- CMP R8, $0
- BEQ docall
- SUB $1, R8
- ADD $8, R7
- MOVD 0(R7), R3
-
- CMP R8, $0
- BEQ docall
- MOVD $2176+16, R6 // starting LE stack address-8 to store 4th argument
-
-repeat:
- ADD $8, R7
- MOVD 0(R7), R0 // advance arg pointer by 8 byte
- ADD $8, R6 // advance LE argument address by 8 byte
- MOVD R0, (R4)(R6*1) // copy argument from go-slice to le-frame
- SUB $1, R8
- CMP R8, $0
- BNE repeat
-
-docall:
- MOVD funcdesc+0(FP), R8 // R8-> function descriptor
- LMG 0(R8), R5, R6
- MOVD $0, 0(R9) // R9 address of SAVSTACK_ASYNC
- LE_CALL // balr R7, R6 (return #1)
- NOPH
- MOVD R3, ret+32(FP)
- CMP R3, $0 // compare result to 0
- BNE done
-
- // retrieve errno and errno2
- MOVD zosLibVec<>(SB), R8
- ADD $(__errno), R8
- LMG 0(R8), R5, R6
- LE_CALL // balr R7, R6 __errno (return #3)
- NOPH
- MOVWZ 0(R3), R3
- MOVD R3, err+48(FP)
- MOVD zosLibVec<>(SB), R8
- ADD $(__err2ad), R8
- LMG 0(R8), R5, R6
- LE_CALL // balr R7, R6 __err2ad (return #2)
- NOPH
- MOVW (R3), R2 // retrieve errno2
- MOVD R2, errno2+40(FP) // store in return area
- XOR R2, R2
- MOVWZ R2, (R3) // clear errno2
-
-done:
- MOVD R4, 0(R9) // Save stack pointer.
- RET
-
-//
-// function to test if a pointer can be safely dereferenced (content read)
-// return 0 for succces
-//
-TEXT ·ptrtest(SB), NOSPLIT, $0-16
- MOVD arg+0(FP), R10 // test pointer in R10
-
- // set up R2 to point to CEECAADMC
- BYTE $0xE3; BYTE $0x20; BYTE $0x04; BYTE $0xB8; BYTE $0x00; BYTE $0x17 // llgt 2,1208
- BYTE $0xB9; BYTE $0x17; BYTE $0x00; BYTE $0x22 // llgtr 2,2
- BYTE $0xA5; BYTE $0x26; BYTE $0x7F; BYTE $0xFF // nilh 2,32767
- BYTE $0xE3; BYTE $0x22; BYTE $0x00; BYTE $0x58; BYTE $0x00; BYTE $0x04 // lg 2,88(2)
- BYTE $0xE3; BYTE $0x22; BYTE $0x00; BYTE $0x08; BYTE $0x00; BYTE $0x04 // lg 2,8(2)
- BYTE $0x41; BYTE $0x22; BYTE $0x03; BYTE $0x68 // la 2,872(2)
-
- // set up R5 to point to the "shunt" path which set 1 to R3 (failure)
- BYTE $0xB9; BYTE $0x82; BYTE $0x00; BYTE $0x33 // xgr 3,3
- BYTE $0xA7; BYTE $0x55; BYTE $0x00; BYTE $0x04 // bras 5,lbl1
- BYTE $0xA7; BYTE $0x39; BYTE $0x00; BYTE $0x01 // lghi 3,1
-
- // if r3 is not zero (failed) then branch to finish
- BYTE $0xB9; BYTE $0x02; BYTE $0x00; BYTE $0x33 // lbl1 ltgr 3,3
- BYTE $0xA7; BYTE $0x74; BYTE $0x00; BYTE $0x08 // brc b'0111',lbl2
-
- // stomic store shunt address in R5 into CEECAADMC
- BYTE $0xE3; BYTE $0x52; BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x24 // stg 5,0(2)
-
- // now try reading from the test pointer in R10, if it fails it branches to the "lghi" instruction above
- BYTE $0xE3; BYTE $0x9A; BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x04 // lg 9,0(10)
-
- // finish here, restore 0 into CEECAADMC
- BYTE $0xB9; BYTE $0x82; BYTE $0x00; BYTE $0x99 // lbl2 xgr 9,9
- BYTE $0xE3; BYTE $0x92; BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x24 // stg 9,0(2)
- MOVD R3, ret+8(FP) // result in R3
- RET
-
-//
-// function to test if a untptr can be loaded from a pointer
-// return 1: the 8-byte content
-// 2: 0 for success, 1 for failure
-//
-// func safeload(ptr uintptr) ( value uintptr, error uintptr)
-TEXT ·safeload(SB), NOSPLIT, $0-24
- MOVD ptr+0(FP), R10 // test pointer in R10
- MOVD $0x0, R6
- BYTE $0xE3; BYTE $0x20; BYTE $0x04; BYTE $0xB8; BYTE $0x00; BYTE $0x17 // llgt 2,1208
- BYTE $0xB9; BYTE $0x17; BYTE $0x00; BYTE $0x22 // llgtr 2,2
- BYTE $0xA5; BYTE $0x26; BYTE $0x7F; BYTE $0xFF // nilh 2,32767
- BYTE $0xE3; BYTE $0x22; BYTE $0x00; BYTE $0x58; BYTE $0x00; BYTE $0x04 // lg 2,88(2)
- BYTE $0xE3; BYTE $0x22; BYTE $0x00; BYTE $0x08; BYTE $0x00; BYTE $0x04 // lg 2,8(2)
- BYTE $0x41; BYTE $0x22; BYTE $0x03; BYTE $0x68 // la 2,872(2)
- BYTE $0xB9; BYTE $0x82; BYTE $0x00; BYTE $0x33 // xgr 3,3
- BYTE $0xA7; BYTE $0x55; BYTE $0x00; BYTE $0x04 // bras 5,lbl1
- BYTE $0xA7; BYTE $0x39; BYTE $0x00; BYTE $0x01 // lghi 3,1
- BYTE $0xB9; BYTE $0x02; BYTE $0x00; BYTE $0x33 // lbl1 ltgr 3,3
- BYTE $0xA7; BYTE $0x74; BYTE $0x00; BYTE $0x08 // brc b'0111',lbl2
- BYTE $0xE3; BYTE $0x52; BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x24 // stg 5,0(2)
- BYTE $0xE3; BYTE $0x6A; BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x04 // lg 6,0(10)
- BYTE $0xB9; BYTE $0x82; BYTE $0x00; BYTE $0x99 // lbl2 xgr 9,9
- BYTE $0xE3; BYTE $0x92; BYTE $0x00; BYTE $0x00; BYTE $0x00; BYTE $0x24 // stg 9,0(2)
- MOVD R6, value+8(FP) // result in R6
- MOVD R3, error+16(FP) // error in R3
- RET
diff --git a/vendor/golang.org/x/sys/unix/bluetooth_linux.go b/vendor/golang.org/x/sys/unix/bluetooth_linux.go
deleted file mode 100644
index a178a61..0000000
--- a/vendor/golang.org/x/sys/unix/bluetooth_linux.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2016 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.
-
-// Bluetooth sockets and messages
-
-package unix
-
-// Bluetooth Protocols
-const (
- BTPROTO_L2CAP = 0
- BTPROTO_HCI = 1
- BTPROTO_SCO = 2
- BTPROTO_RFCOMM = 3
- BTPROTO_BNEP = 4
- BTPROTO_CMTP = 5
- BTPROTO_HIDP = 6
- BTPROTO_AVDTP = 7
-)
-
-const (
- HCI_CHANNEL_RAW = 0
- HCI_CHANNEL_USER = 1
- HCI_CHANNEL_MONITOR = 2
- HCI_CHANNEL_CONTROL = 3
- HCI_CHANNEL_LOGGING = 4
-)
-
-// Socketoption Level
-const (
- SOL_BLUETOOTH = 0x112
- SOL_HCI = 0x0
- SOL_L2CAP = 0x6
- SOL_RFCOMM = 0x12
- SOL_SCO = 0x11
-)
diff --git a/vendor/golang.org/x/sys/unix/bpxsvc_zos.go b/vendor/golang.org/x/sys/unix/bpxsvc_zos.go
deleted file mode 100644
index 39d647d..0000000
--- a/vendor/golang.org/x/sys/unix/bpxsvc_zos.go
+++ /dev/null
@@ -1,657 +0,0 @@
-// Copyright 2024 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.
-
-//go:build zos
-
-package unix
-
-import (
- "bytes"
- "fmt"
- "unsafe"
-)
-
-//go:noescape
-func bpxcall(plist []unsafe.Pointer, bpx_offset int64)
-
-//go:noescape
-func A2e([]byte)
-
-//go:noescape
-func E2a([]byte)
-
-const (
- BPX4STA = 192 // stat
- BPX4FST = 104 // fstat
- BPX4LST = 132 // lstat
- BPX4OPN = 156 // open
- BPX4CLO = 72 // close
- BPX4CHR = 500 // chattr
- BPX4FCR = 504 // fchattr
- BPX4LCR = 1180 // lchattr
- BPX4CTW = 492 // cond_timed_wait
- BPX4GTH = 1056 // __getthent
- BPX4PTQ = 412 // pthread_quiesc
- BPX4PTR = 320 // ptrace
-)
-
-const (
- //options
- //byte1
- BPX_OPNFHIGH = 0x80
- //byte2
- BPX_OPNFEXEC = 0x80
- //byte3
- BPX_O_NOLARGEFILE = 0x08
- BPX_O_LARGEFILE = 0x04
- BPX_O_ASYNCSIG = 0x02
- BPX_O_SYNC = 0x01
- //byte4
- BPX_O_CREXCL = 0xc0
- BPX_O_CREAT = 0x80
- BPX_O_EXCL = 0x40
- BPX_O_NOCTTY = 0x20
- BPX_O_TRUNC = 0x10
- BPX_O_APPEND = 0x08
- BPX_O_NONBLOCK = 0x04
- BPX_FNDELAY = 0x04
- BPX_O_RDWR = 0x03
- BPX_O_RDONLY = 0x02
- BPX_O_WRONLY = 0x01
- BPX_O_ACCMODE = 0x03
- BPX_O_GETFL = 0x0f
-
- //mode
- // byte1 (file type)
- BPX_FT_DIR = 1
- BPX_FT_CHARSPEC = 2
- BPX_FT_REGFILE = 3
- BPX_FT_FIFO = 4
- BPX_FT_SYMLINK = 5
- BPX_FT_SOCKET = 6
- //byte3
- BPX_S_ISUID = 0x08
- BPX_S_ISGID = 0x04
- BPX_S_ISVTX = 0x02
- BPX_S_IRWXU1 = 0x01
- BPX_S_IRUSR = 0x01
- //byte4
- BPX_S_IRWXU2 = 0xc0
- BPX_S_IWUSR = 0x80
- BPX_S_IXUSR = 0x40
- BPX_S_IRWXG = 0x38
- BPX_S_IRGRP = 0x20
- BPX_S_IWGRP = 0x10
- BPX_S_IXGRP = 0x08
- BPX_S_IRWXOX = 0x07
- BPX_S_IROTH = 0x04
- BPX_S_IWOTH = 0x02
- BPX_S_IXOTH = 0x01
-
- CW_INTRPT = 1
- CW_CONDVAR = 32
- CW_TIMEOUT = 64
-
- PGTHA_NEXT = 2
- PGTHA_CURRENT = 1
- PGTHA_FIRST = 0
- PGTHA_LAST = 3
- PGTHA_PROCESS = 0x80
- PGTHA_CONTTY = 0x40
- PGTHA_PATH = 0x20
- PGTHA_COMMAND = 0x10
- PGTHA_FILEDATA = 0x08
- PGTHA_THREAD = 0x04
- PGTHA_PTAG = 0x02
- PGTHA_COMMANDLONG = 0x01
- PGTHA_THREADFAST = 0x80
- PGTHA_FILEPATH = 0x40
- PGTHA_THDSIGMASK = 0x20
- // thread quiece mode
- QUIESCE_TERM int32 = 1
- QUIESCE_FORCE int32 = 2
- QUIESCE_QUERY int32 = 3
- QUIESCE_FREEZE int32 = 4
- QUIESCE_UNFREEZE int32 = 5
- FREEZE_THIS_THREAD int32 = 6
- FREEZE_EXIT int32 = 8
- QUIESCE_SRB int32 = 9
-)
-
-type Pgtha struct {
- Pid uint32 // 0
- Tid0 uint32 // 4
- Tid1 uint32
- Accesspid byte // C
- Accesstid byte // D
- Accessasid uint16 // E
- Loginname [8]byte // 10
- Flag1 byte // 18
- Flag1b2 byte // 19
-}
-
-type Bpxystat_t struct { // DSECT BPXYSTAT
- St_id [4]uint8 // 0
- St_length uint16 // 0x4
- St_version uint16 // 0x6
- St_mode uint32 // 0x8
- St_ino uint32 // 0xc
- St_dev uint32 // 0x10
- St_nlink uint32 // 0x14
- St_uid uint32 // 0x18
- St_gid uint32 // 0x1c
- St_size uint64 // 0x20
- St_atime uint32 // 0x28
- St_mtime uint32 // 0x2c
- St_ctime uint32 // 0x30
- St_rdev uint32 // 0x34
- St_auditoraudit uint32 // 0x38
- St_useraudit uint32 // 0x3c
- St_blksize uint32 // 0x40
- St_createtime uint32 // 0x44
- St_auditid [4]uint32 // 0x48
- St_res01 uint32 // 0x58
- Ft_ccsid uint16 // 0x5c
- Ft_flags uint16 // 0x5e
- St_res01a [2]uint32 // 0x60
- St_res02 uint32 // 0x68
- St_blocks uint32 // 0x6c
- St_opaque [3]uint8 // 0x70
- St_visible uint8 // 0x73
- St_reftime uint32 // 0x74
- St_fid uint64 // 0x78
- St_filefmt uint8 // 0x80
- St_fspflag2 uint8 // 0x81
- St_res03 [2]uint8 // 0x82
- St_ctimemsec uint32 // 0x84
- St_seclabel [8]uint8 // 0x88
- St_res04 [4]uint8 // 0x90
- // end of version 1
- _ uint32 // 0x94
- St_atime64 uint64 // 0x98
- St_mtime64 uint64 // 0xa0
- St_ctime64 uint64 // 0xa8
- St_createtime64 uint64 // 0xb0
- St_reftime64 uint64 // 0xb8
- _ uint64 // 0xc0
- St_res05 [16]uint8 // 0xc8
- // end of version 2
-}
-
-type BpxFilestatus struct {
- Oflag1 byte
- Oflag2 byte
- Oflag3 byte
- Oflag4 byte
-}
-
-type BpxMode struct {
- Ftype byte
- Mode1 byte
- Mode2 byte
- Mode3 byte
-}
-
-// Thr attribute structure for extended attributes
-type Bpxyatt_t struct { // DSECT BPXYATT
- Att_id [4]uint8
- Att_version uint16
- Att_res01 [2]uint8
- Att_setflags1 uint8
- Att_setflags2 uint8
- Att_setflags3 uint8
- Att_setflags4 uint8
- Att_mode uint32
- Att_uid uint32
- Att_gid uint32
- Att_opaquemask [3]uint8
- Att_visblmaskres uint8
- Att_opaque [3]uint8
- Att_visibleres uint8
- Att_size_h uint32
- Att_size_l uint32
- Att_atime uint32
- Att_mtime uint32
- Att_auditoraudit uint32
- Att_useraudit uint32
- Att_ctime uint32
- Att_reftime uint32
- // end of version 1
- Att_filefmt uint8
- Att_res02 [3]uint8
- Att_filetag uint32
- Att_res03 [8]uint8
- // end of version 2
- Att_atime64 uint64
- Att_mtime64 uint64
- Att_ctime64 uint64
- Att_reftime64 uint64
- Att_seclabel [8]uint8
- Att_ver3res02 [8]uint8
- // end of version 3
-}
-
-func BpxOpen(name string, options *BpxFilestatus, mode *BpxMode) (rv int32, rc int32, rn int32) {
- if len(name) < 1024 {
- var namebuf [1024]byte
- sz := int32(copy(namebuf[:], name))
- A2e(namebuf[:sz])
- var parms [7]unsafe.Pointer
- parms[0] = unsafe.Pointer(&sz)
- parms[1] = unsafe.Pointer(&namebuf[0])
- parms[2] = unsafe.Pointer(options)
- parms[3] = unsafe.Pointer(mode)
- parms[4] = unsafe.Pointer(&rv)
- parms[5] = unsafe.Pointer(&rc)
- parms[6] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4OPN)
- return rv, rc, rn
- }
- return -1, -1, -1
-}
-
-func BpxClose(fd int32) (rv int32, rc int32, rn int32) {
- var parms [4]unsafe.Pointer
- parms[0] = unsafe.Pointer(&fd)
- parms[1] = unsafe.Pointer(&rv)
- parms[2] = unsafe.Pointer(&rc)
- parms[3] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4CLO)
- return rv, rc, rn
-}
-
-func BpxFileFStat(fd int32, st *Bpxystat_t) (rv int32, rc int32, rn int32) {
- st.St_id = [4]uint8{0xe2, 0xe3, 0xc1, 0xe3}
- st.St_version = 2
- stat_sz := uint32(unsafe.Sizeof(*st))
- var parms [6]unsafe.Pointer
- parms[0] = unsafe.Pointer(&fd)
- parms[1] = unsafe.Pointer(&stat_sz)
- parms[2] = unsafe.Pointer(st)
- parms[3] = unsafe.Pointer(&rv)
- parms[4] = unsafe.Pointer(&rc)
- parms[5] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4FST)
- return rv, rc, rn
-}
-
-func BpxFileStat(name string, st *Bpxystat_t) (rv int32, rc int32, rn int32) {
- if len(name) < 1024 {
- var namebuf [1024]byte
- sz := int32(copy(namebuf[:], name))
- A2e(namebuf[:sz])
- st.St_id = [4]uint8{0xe2, 0xe3, 0xc1, 0xe3}
- st.St_version = 2
- stat_sz := uint32(unsafe.Sizeof(*st))
- var parms [7]unsafe.Pointer
- parms[0] = unsafe.Pointer(&sz)
- parms[1] = unsafe.Pointer(&namebuf[0])
- parms[2] = unsafe.Pointer(&stat_sz)
- parms[3] = unsafe.Pointer(st)
- parms[4] = unsafe.Pointer(&rv)
- parms[5] = unsafe.Pointer(&rc)
- parms[6] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4STA)
- return rv, rc, rn
- }
- return -1, -1, -1
-}
-
-func BpxFileLStat(name string, st *Bpxystat_t) (rv int32, rc int32, rn int32) {
- if len(name) < 1024 {
- var namebuf [1024]byte
- sz := int32(copy(namebuf[:], name))
- A2e(namebuf[:sz])
- st.St_id = [4]uint8{0xe2, 0xe3, 0xc1, 0xe3}
- st.St_version = 2
- stat_sz := uint32(unsafe.Sizeof(*st))
- var parms [7]unsafe.Pointer
- parms[0] = unsafe.Pointer(&sz)
- parms[1] = unsafe.Pointer(&namebuf[0])
- parms[2] = unsafe.Pointer(&stat_sz)
- parms[3] = unsafe.Pointer(st)
- parms[4] = unsafe.Pointer(&rv)
- parms[5] = unsafe.Pointer(&rc)
- parms[6] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4LST)
- return rv, rc, rn
- }
- return -1, -1, -1
-}
-
-func BpxChattr(path string, attr *Bpxyatt_t) (rv int32, rc int32, rn int32) {
- if len(path) >= 1024 {
- return -1, -1, -1
- }
- var namebuf [1024]byte
- sz := int32(copy(namebuf[:], path))
- A2e(namebuf[:sz])
- attr_sz := uint32(unsafe.Sizeof(*attr))
- var parms [7]unsafe.Pointer
- parms[0] = unsafe.Pointer(&sz)
- parms[1] = unsafe.Pointer(&namebuf[0])
- parms[2] = unsafe.Pointer(&attr_sz)
- parms[3] = unsafe.Pointer(attr)
- parms[4] = unsafe.Pointer(&rv)
- parms[5] = unsafe.Pointer(&rc)
- parms[6] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4CHR)
- return rv, rc, rn
-}
-
-func BpxLchattr(path string, attr *Bpxyatt_t) (rv int32, rc int32, rn int32) {
- if len(path) >= 1024 {
- return -1, -1, -1
- }
- var namebuf [1024]byte
- sz := int32(copy(namebuf[:], path))
- A2e(namebuf[:sz])
- attr_sz := uint32(unsafe.Sizeof(*attr))
- var parms [7]unsafe.Pointer
- parms[0] = unsafe.Pointer(&sz)
- parms[1] = unsafe.Pointer(&namebuf[0])
- parms[2] = unsafe.Pointer(&attr_sz)
- parms[3] = unsafe.Pointer(attr)
- parms[4] = unsafe.Pointer(&rv)
- parms[5] = unsafe.Pointer(&rc)
- parms[6] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4LCR)
- return rv, rc, rn
-}
-
-func BpxFchattr(fd int32, attr *Bpxyatt_t) (rv int32, rc int32, rn int32) {
- attr_sz := uint32(unsafe.Sizeof(*attr))
- var parms [6]unsafe.Pointer
- parms[0] = unsafe.Pointer(&fd)
- parms[1] = unsafe.Pointer(&attr_sz)
- parms[2] = unsafe.Pointer(attr)
- parms[3] = unsafe.Pointer(&rv)
- parms[4] = unsafe.Pointer(&rc)
- parms[5] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4FCR)
- return rv, rc, rn
-}
-
-func BpxCondTimedWait(sec uint32, nsec uint32, events uint32, secrem *uint32, nsecrem *uint32) (rv int32, rc int32, rn int32) {
- var parms [8]unsafe.Pointer
- parms[0] = unsafe.Pointer(&sec)
- parms[1] = unsafe.Pointer(&nsec)
- parms[2] = unsafe.Pointer(&events)
- parms[3] = unsafe.Pointer(secrem)
- parms[4] = unsafe.Pointer(nsecrem)
- parms[5] = unsafe.Pointer(&rv)
- parms[6] = unsafe.Pointer(&rc)
- parms[7] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4CTW)
- return rv, rc, rn
-}
-func BpxGetthent(in *Pgtha, outlen *uint32, out unsafe.Pointer) (rv int32, rc int32, rn int32) {
- var parms [7]unsafe.Pointer
- inlen := uint32(26) // nothing else will work. Go says Pgtha is 28-byte because of alignment, but Pgtha is "packed" and must be 26-byte
- parms[0] = unsafe.Pointer(&inlen)
- parms[1] = unsafe.Pointer(&in)
- parms[2] = unsafe.Pointer(outlen)
- parms[3] = unsafe.Pointer(&out)
- parms[4] = unsafe.Pointer(&rv)
- parms[5] = unsafe.Pointer(&rc)
- parms[6] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4GTH)
- return rv, rc, rn
-}
-func ZosJobname() (jobname string, err error) {
- var pgtha Pgtha
- pgtha.Pid = uint32(Getpid())
- pgtha.Accesspid = PGTHA_CURRENT
- pgtha.Flag1 = PGTHA_PROCESS
- var out [256]byte
- var outlen uint32
- outlen = 256
- rv, rc, rn := BpxGetthent(&pgtha, &outlen, unsafe.Pointer(&out[0]))
- if rv == 0 {
- gthc := []byte{0x87, 0xa3, 0x88, 0x83} // 'gthc' in ebcdic
- ix := bytes.Index(out[:], gthc)
- if ix == -1 {
- err = fmt.Errorf("BPX4GTH: gthc return data not found")
- return
- }
- jn := out[ix+80 : ix+88] // we didn't declare Pgthc, but jobname is 8-byte at offset 80
- E2a(jn)
- jobname = string(bytes.TrimRight(jn, " "))
-
- } else {
- err = fmt.Errorf("BPX4GTH: rc=%d errno=%d reason=code=0x%x", rv, rc, rn)
- }
- return
-}
-func Bpx4ptq(code int32, data string) (rv int32, rc int32, rn int32) {
- var userdata [8]byte
- var parms [5]unsafe.Pointer
- copy(userdata[:], data+" ")
- A2e(userdata[:])
- parms[0] = unsafe.Pointer(&code)
- parms[1] = unsafe.Pointer(&userdata[0])
- parms[2] = unsafe.Pointer(&rv)
- parms[3] = unsafe.Pointer(&rc)
- parms[4] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4PTQ)
- return rv, rc, rn
-}
-
-const (
- PT_TRACE_ME = 0 // Debug this process
- PT_READ_I = 1 // Read a full word
- PT_READ_D = 2 // Read a full word
- PT_READ_U = 3 // Read control info
- PT_WRITE_I = 4 //Write a full word
- PT_WRITE_D = 5 //Write a full word
- PT_CONTINUE = 7 //Continue the process
- PT_KILL = 8 //Terminate the process
- PT_READ_GPR = 11 // Read GPR, CR, PSW
- PT_READ_FPR = 12 // Read FPR
- PT_READ_VR = 13 // Read VR
- PT_WRITE_GPR = 14 // Write GPR, CR, PSW
- PT_WRITE_FPR = 15 // Write FPR
- PT_WRITE_VR = 16 // Write VR
- PT_READ_BLOCK = 17 // Read storage
- PT_WRITE_BLOCK = 19 // Write storage
- PT_READ_GPRH = 20 // Read GPRH
- PT_WRITE_GPRH = 21 // Write GPRH
- PT_REGHSET = 22 // Read all GPRHs
- PT_ATTACH = 30 // Attach to a process
- PT_DETACH = 31 // Detach from a process
- PT_REGSET = 32 // Read all GPRs
- PT_REATTACH = 33 // Reattach to a process
- PT_LDINFO = 34 // Read loader info
- PT_MULTI = 35 // Multi process mode
- PT_LD64INFO = 36 // RMODE64 Info Area
- PT_BLOCKREQ = 40 // Block request
- PT_THREAD_INFO = 60 // Read thread info
- PT_THREAD_MODIFY = 61
- PT_THREAD_READ_FOCUS = 62
- PT_THREAD_WRITE_FOCUS = 63
- PT_THREAD_HOLD = 64
- PT_THREAD_SIGNAL = 65
- PT_EXPLAIN = 66
- PT_EVENTS = 67
- PT_THREAD_INFO_EXTENDED = 68
- PT_REATTACH2 = 71
- PT_CAPTURE = 72
- PT_UNCAPTURE = 73
- PT_GET_THREAD_TCB = 74
- PT_GET_ALET = 75
- PT_SWAPIN = 76
- PT_EXTENDED_EVENT = 98
- PT_RECOVER = 99 // Debug a program check
- PT_GPR0 = 0 // General purpose register 0
- PT_GPR1 = 1 // General purpose register 1
- PT_GPR2 = 2 // General purpose register 2
- PT_GPR3 = 3 // General purpose register 3
- PT_GPR4 = 4 // General purpose register 4
- PT_GPR5 = 5 // General purpose register 5
- PT_GPR6 = 6 // General purpose register 6
- PT_GPR7 = 7 // General purpose register 7
- PT_GPR8 = 8 // General purpose register 8
- PT_GPR9 = 9 // General purpose register 9
- PT_GPR10 = 10 // General purpose register 10
- PT_GPR11 = 11 // General purpose register 11
- PT_GPR12 = 12 // General purpose register 12
- PT_GPR13 = 13 // General purpose register 13
- PT_GPR14 = 14 // General purpose register 14
- PT_GPR15 = 15 // General purpose register 15
- PT_FPR0 = 16 // Floating point register 0
- PT_FPR1 = 17 // Floating point register 1
- PT_FPR2 = 18 // Floating point register 2
- PT_FPR3 = 19 // Floating point register 3
- PT_FPR4 = 20 // Floating point register 4
- PT_FPR5 = 21 // Floating point register 5
- PT_FPR6 = 22 // Floating point register 6
- PT_FPR7 = 23 // Floating point register 7
- PT_FPR8 = 24 // Floating point register 8
- PT_FPR9 = 25 // Floating point register 9
- PT_FPR10 = 26 // Floating point register 10
- PT_FPR11 = 27 // Floating point register 11
- PT_FPR12 = 28 // Floating point register 12
- PT_FPR13 = 29 // Floating point register 13
- PT_FPR14 = 30 // Floating point register 14
- PT_FPR15 = 31 // Floating point register 15
- PT_FPC = 32 // Floating point control register
- PT_PSW = 40 // PSW
- PT_PSW0 = 40 // Left half of the PSW
- PT_PSW1 = 41 // Right half of the PSW
- PT_CR0 = 42 // Control register 0
- PT_CR1 = 43 // Control register 1
- PT_CR2 = 44 // Control register 2
- PT_CR3 = 45 // Control register 3
- PT_CR4 = 46 // Control register 4
- PT_CR5 = 47 // Control register 5
- PT_CR6 = 48 // Control register 6
- PT_CR7 = 49 // Control register 7
- PT_CR8 = 50 // Control register 8
- PT_CR9 = 51 // Control register 9
- PT_CR10 = 52 // Control register 10
- PT_CR11 = 53 // Control register 11
- PT_CR12 = 54 // Control register 12
- PT_CR13 = 55 // Control register 13
- PT_CR14 = 56 // Control register 14
- PT_CR15 = 57 // Control register 15
- PT_GPRH0 = 58 // GP High register 0
- PT_GPRH1 = 59 // GP High register 1
- PT_GPRH2 = 60 // GP High register 2
- PT_GPRH3 = 61 // GP High register 3
- PT_GPRH4 = 62 // GP High register 4
- PT_GPRH5 = 63 // GP High register 5
- PT_GPRH6 = 64 // GP High register 6
- PT_GPRH7 = 65 // GP High register 7
- PT_GPRH8 = 66 // GP High register 8
- PT_GPRH9 = 67 // GP High register 9
- PT_GPRH10 = 68 // GP High register 10
- PT_GPRH11 = 69 // GP High register 11
- PT_GPRH12 = 70 // GP High register 12
- PT_GPRH13 = 71 // GP High register 13
- PT_GPRH14 = 72 // GP High register 14
- PT_GPRH15 = 73 // GP High register 15
- PT_VR0 = 74 // Vector register 0
- PT_VR1 = 75 // Vector register 1
- PT_VR2 = 76 // Vector register 2
- PT_VR3 = 77 // Vector register 3
- PT_VR4 = 78 // Vector register 4
- PT_VR5 = 79 // Vector register 5
- PT_VR6 = 80 // Vector register 6
- PT_VR7 = 81 // Vector register 7
- PT_VR8 = 82 // Vector register 8
- PT_VR9 = 83 // Vector register 9
- PT_VR10 = 84 // Vector register 10
- PT_VR11 = 85 // Vector register 11
- PT_VR12 = 86 // Vector register 12
- PT_VR13 = 87 // Vector register 13
- PT_VR14 = 88 // Vector register 14
- PT_VR15 = 89 // Vector register 15
- PT_VR16 = 90 // Vector register 16
- PT_VR17 = 91 // Vector register 17
- PT_VR18 = 92 // Vector register 18
- PT_VR19 = 93 // Vector register 19
- PT_VR20 = 94 // Vector register 20
- PT_VR21 = 95 // Vector register 21
- PT_VR22 = 96 // Vector register 22
- PT_VR23 = 97 // Vector register 23
- PT_VR24 = 98 // Vector register 24
- PT_VR25 = 99 // Vector register 25
- PT_VR26 = 100 // Vector register 26
- PT_VR27 = 101 // Vector register 27
- PT_VR28 = 102 // Vector register 28
- PT_VR29 = 103 // Vector register 29
- PT_VR30 = 104 // Vector register 30
- PT_VR31 = 105 // Vector register 31
- PT_PSWG = 106 // PSWG
- PT_PSWG0 = 106 // Bytes 0-3
- PT_PSWG1 = 107 // Bytes 4-7
- PT_PSWG2 = 108 // Bytes 8-11 (IA high word)
- PT_PSWG3 = 109 // Bytes 12-15 (IA low word)
-)
-
-func Bpx4ptr(request int32, pid int32, addr unsafe.Pointer, data unsafe.Pointer, buffer unsafe.Pointer) (rv int32, rc int32, rn int32) {
- var parms [8]unsafe.Pointer
- parms[0] = unsafe.Pointer(&request)
- parms[1] = unsafe.Pointer(&pid)
- parms[2] = unsafe.Pointer(&addr)
- parms[3] = unsafe.Pointer(&data)
- parms[4] = unsafe.Pointer(&buffer)
- parms[5] = unsafe.Pointer(&rv)
- parms[6] = unsafe.Pointer(&rc)
- parms[7] = unsafe.Pointer(&rn)
- bpxcall(parms[:], BPX4PTR)
- return rv, rc, rn
-}
-
-func copyU8(val uint8, dest []uint8) int {
- if len(dest) < 1 {
- return 0
- }
- dest[0] = val
- return 1
-}
-
-func copyU8Arr(src, dest []uint8) int {
- if len(dest) < len(src) {
- return 0
- }
- for i, v := range src {
- dest[i] = v
- }
- return len(src)
-}
-
-func copyU16(val uint16, dest []uint16) int {
- if len(dest) < 1 {
- return 0
- }
- dest[0] = val
- return 1
-}
-
-func copyU32(val uint32, dest []uint32) int {
- if len(dest) < 1 {
- return 0
- }
- dest[0] = val
- return 1
-}
-
-func copyU32Arr(src, dest []uint32) int {
- if len(dest) < len(src) {
- return 0
- }
- for i, v := range src {
- dest[i] = v
- }
- return len(src)
-}
-
-func copyU64(val uint64, dest []uint64) int {
- if len(dest) < 1 {
- return 0
- }
- dest[0] = val
- return 1
-}
diff --git a/vendor/golang.org/x/sys/unix/bpxsvc_zos.s b/vendor/golang.org/x/sys/unix/bpxsvc_zos.s
deleted file mode 100644
index 4bd4a17..0000000
--- a/vendor/golang.org/x/sys/unix/bpxsvc_zos.s
+++ /dev/null
@@ -1,192 +0,0 @@
-// Copyright 2024 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.
-
-#include "go_asm.h"
-#include "textflag.h"
-
-// function to call USS assembly language services
-//
-// doc: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_3.1.0/com.ibm.zos.v3r1.bpxb100/bit64env.htm
-//
-// arg1 unsafe.Pointer array that ressembles an OS PLIST
-//
-// arg2 function offset as in
-// doc: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_3.1.0/com.ibm.zos.v3r1.bpxb100/bpx2cr_List_of_offsets.htm
-//
-// func bpxcall(plist []unsafe.Pointer, bpx_offset int64)
-
-TEXT ·bpxcall(SB), NOSPLIT|NOFRAME, $0
- MOVD plist_base+0(FP), R1 // r1 points to plist
- MOVD bpx_offset+24(FP), R2 // r2 offset to BPX vector table
- MOVD R14, R7 // save r14
- MOVD R15, R8 // save r15
- MOVWZ 16(R0), R9
- MOVWZ 544(R9), R9
- MOVWZ 24(R9), R9 // call vector in r9
- ADD R2, R9 // add offset to vector table
- MOVWZ (R9), R9 // r9 points to entry point
- BYTE $0x0D // BL R14,R9 --> basr r14,r9
- BYTE $0xE9 // clobbers 0,1,14,15
- MOVD R8, R15 // restore 15
- JMP R7 // return via saved return address
-
-// func A2e(arr [] byte)
-// code page conversion from 819 to 1047
-TEXT ·A2e(SB), NOSPLIT|NOFRAME, $0
- MOVD arg_base+0(FP), R2 // pointer to arry of characters
- MOVD arg_len+8(FP), R3 // count
- XOR R0, R0
- XOR R1, R1
- BYTE $0xA7; BYTE $0x15; BYTE $0x00; BYTE $0x82 // BRAS 1,(2+(256/2))
-
- // ASCII -> EBCDIC conversion table:
- BYTE $0x00; BYTE $0x01; BYTE $0x02; BYTE $0x03
- BYTE $0x37; BYTE $0x2d; BYTE $0x2e; BYTE $0x2f
- BYTE $0x16; BYTE $0x05; BYTE $0x15; BYTE $0x0b
- BYTE $0x0c; BYTE $0x0d; BYTE $0x0e; BYTE $0x0f
- BYTE $0x10; BYTE $0x11; BYTE $0x12; BYTE $0x13
- BYTE $0x3c; BYTE $0x3d; BYTE $0x32; BYTE $0x26
- BYTE $0x18; BYTE $0x19; BYTE $0x3f; BYTE $0x27
- BYTE $0x1c; BYTE $0x1d; BYTE $0x1e; BYTE $0x1f
- BYTE $0x40; BYTE $0x5a; BYTE $0x7f; BYTE $0x7b
- BYTE $0x5b; BYTE $0x6c; BYTE $0x50; BYTE $0x7d
- BYTE $0x4d; BYTE $0x5d; BYTE $0x5c; BYTE $0x4e
- BYTE $0x6b; BYTE $0x60; BYTE $0x4b; BYTE $0x61
- BYTE $0xf0; BYTE $0xf1; BYTE $0xf2; BYTE $0xf3
- BYTE $0xf4; BYTE $0xf5; BYTE $0xf6; BYTE $0xf7
- BYTE $0xf8; BYTE $0xf9; BYTE $0x7a; BYTE $0x5e
- BYTE $0x4c; BYTE $0x7e; BYTE $0x6e; BYTE $0x6f
- BYTE $0x7c; BYTE $0xc1; BYTE $0xc2; BYTE $0xc3
- BYTE $0xc4; BYTE $0xc5; BYTE $0xc6; BYTE $0xc7
- BYTE $0xc8; BYTE $0xc9; BYTE $0xd1; BYTE $0xd2
- BYTE $0xd3; BYTE $0xd4; BYTE $0xd5; BYTE $0xd6
- BYTE $0xd7; BYTE $0xd8; BYTE $0xd9; BYTE $0xe2
- BYTE $0xe3; BYTE $0xe4; BYTE $0xe5; BYTE $0xe6
- BYTE $0xe7; BYTE $0xe8; BYTE $0xe9; BYTE $0xad
- BYTE $0xe0; BYTE $0xbd; BYTE $0x5f; BYTE $0x6d
- BYTE $0x79; BYTE $0x81; BYTE $0x82; BYTE $0x83
- BYTE $0x84; BYTE $0x85; BYTE $0x86; BYTE $0x87
- BYTE $0x88; BYTE $0x89; BYTE $0x91; BYTE $0x92
- BYTE $0x93; BYTE $0x94; BYTE $0x95; BYTE $0x96
- BYTE $0x97; BYTE $0x98; BYTE $0x99; BYTE $0xa2
- BYTE $0xa3; BYTE $0xa4; BYTE $0xa5; BYTE $0xa6
- BYTE $0xa7; BYTE $0xa8; BYTE $0xa9; BYTE $0xc0
- BYTE $0x4f; BYTE $0xd0; BYTE $0xa1; BYTE $0x07
- BYTE $0x20; BYTE $0x21; BYTE $0x22; BYTE $0x23
- BYTE $0x24; BYTE $0x25; BYTE $0x06; BYTE $0x17
- BYTE $0x28; BYTE $0x29; BYTE $0x2a; BYTE $0x2b
- BYTE $0x2c; BYTE $0x09; BYTE $0x0a; BYTE $0x1b
- BYTE $0x30; BYTE $0x31; BYTE $0x1a; BYTE $0x33
- BYTE $0x34; BYTE $0x35; BYTE $0x36; BYTE $0x08
- BYTE $0x38; BYTE $0x39; BYTE $0x3a; BYTE $0x3b
- BYTE $0x04; BYTE $0x14; BYTE $0x3e; BYTE $0xff
- BYTE $0x41; BYTE $0xaa; BYTE $0x4a; BYTE $0xb1
- BYTE $0x9f; BYTE $0xb2; BYTE $0x6a; BYTE $0xb5
- BYTE $0xbb; BYTE $0xb4; BYTE $0x9a; BYTE $0x8a
- BYTE $0xb0; BYTE $0xca; BYTE $0xaf; BYTE $0xbc
- BYTE $0x90; BYTE $0x8f; BYTE $0xea; BYTE $0xfa
- BYTE $0xbe; BYTE $0xa0; BYTE $0xb6; BYTE $0xb3
- BYTE $0x9d; BYTE $0xda; BYTE $0x9b; BYTE $0x8b
- BYTE $0xb7; BYTE $0xb8; BYTE $0xb9; BYTE $0xab
- BYTE $0x64; BYTE $0x65; BYTE $0x62; BYTE $0x66
- BYTE $0x63; BYTE $0x67; BYTE $0x9e; BYTE $0x68
- BYTE $0x74; BYTE $0x71; BYTE $0x72; BYTE $0x73
- BYTE $0x78; BYTE $0x75; BYTE $0x76; BYTE $0x77
- BYTE $0xac; BYTE $0x69; BYTE $0xed; BYTE $0xee
- BYTE $0xeb; BYTE $0xef; BYTE $0xec; BYTE $0xbf
- BYTE $0x80; BYTE $0xfd; BYTE $0xfe; BYTE $0xfb
- BYTE $0xfc; BYTE $0xba; BYTE $0xae; BYTE $0x59
- BYTE $0x44; BYTE $0x45; BYTE $0x42; BYTE $0x46
- BYTE $0x43; BYTE $0x47; BYTE $0x9c; BYTE $0x48
- BYTE $0x54; BYTE $0x51; BYTE $0x52; BYTE $0x53
- BYTE $0x58; BYTE $0x55; BYTE $0x56; BYTE $0x57
- BYTE $0x8c; BYTE $0x49; BYTE $0xcd; BYTE $0xce
- BYTE $0xcb; BYTE $0xcf; BYTE $0xcc; BYTE $0xe1
- BYTE $0x70; BYTE $0xdd; BYTE $0xde; BYTE $0xdb
- BYTE $0xdc; BYTE $0x8d; BYTE $0x8e; BYTE $0xdf
-
-retry:
- WORD $0xB9931022 // TROO 2,2,b'0001'
- BVS retry
- RET
-
-// func e2a(arr [] byte)
-// code page conversion from 1047 to 819
-TEXT ·E2a(SB), NOSPLIT|NOFRAME, $0
- MOVD arg_base+0(FP), R2 // pointer to arry of characters
- MOVD arg_len+8(FP), R3 // count
- XOR R0, R0
- XOR R1, R1
- BYTE $0xA7; BYTE $0x15; BYTE $0x00; BYTE $0x82 // BRAS 1,(2+(256/2))
-
- // EBCDIC -> ASCII conversion table:
- BYTE $0x00; BYTE $0x01; BYTE $0x02; BYTE $0x03
- BYTE $0x9c; BYTE $0x09; BYTE $0x86; BYTE $0x7f
- BYTE $0x97; BYTE $0x8d; BYTE $0x8e; BYTE $0x0b
- BYTE $0x0c; BYTE $0x0d; BYTE $0x0e; BYTE $0x0f
- BYTE $0x10; BYTE $0x11; BYTE $0x12; BYTE $0x13
- BYTE $0x9d; BYTE $0x0a; BYTE $0x08; BYTE $0x87
- BYTE $0x18; BYTE $0x19; BYTE $0x92; BYTE $0x8f
- BYTE $0x1c; BYTE $0x1d; BYTE $0x1e; BYTE $0x1f
- BYTE $0x80; BYTE $0x81; BYTE $0x82; BYTE $0x83
- BYTE $0x84; BYTE $0x85; BYTE $0x17; BYTE $0x1b
- BYTE $0x88; BYTE $0x89; BYTE $0x8a; BYTE $0x8b
- BYTE $0x8c; BYTE $0x05; BYTE $0x06; BYTE $0x07
- BYTE $0x90; BYTE $0x91; BYTE $0x16; BYTE $0x93
- BYTE $0x94; BYTE $0x95; BYTE $0x96; BYTE $0x04
- BYTE $0x98; BYTE $0x99; BYTE $0x9a; BYTE $0x9b
- BYTE $0x14; BYTE $0x15; BYTE $0x9e; BYTE $0x1a
- BYTE $0x20; BYTE $0xa0; BYTE $0xe2; BYTE $0xe4
- BYTE $0xe0; BYTE $0xe1; BYTE $0xe3; BYTE $0xe5
- BYTE $0xe7; BYTE $0xf1; BYTE $0xa2; BYTE $0x2e
- BYTE $0x3c; BYTE $0x28; BYTE $0x2b; BYTE $0x7c
- BYTE $0x26; BYTE $0xe9; BYTE $0xea; BYTE $0xeb
- BYTE $0xe8; BYTE $0xed; BYTE $0xee; BYTE $0xef
- BYTE $0xec; BYTE $0xdf; BYTE $0x21; BYTE $0x24
- BYTE $0x2a; BYTE $0x29; BYTE $0x3b; BYTE $0x5e
- BYTE $0x2d; BYTE $0x2f; BYTE $0xc2; BYTE $0xc4
- BYTE $0xc0; BYTE $0xc1; BYTE $0xc3; BYTE $0xc5
- BYTE $0xc7; BYTE $0xd1; BYTE $0xa6; BYTE $0x2c
- BYTE $0x25; BYTE $0x5f; BYTE $0x3e; BYTE $0x3f
- BYTE $0xf8; BYTE $0xc9; BYTE $0xca; BYTE $0xcb
- BYTE $0xc8; BYTE $0xcd; BYTE $0xce; BYTE $0xcf
- BYTE $0xcc; BYTE $0x60; BYTE $0x3a; BYTE $0x23
- BYTE $0x40; BYTE $0x27; BYTE $0x3d; BYTE $0x22
- BYTE $0xd8; BYTE $0x61; BYTE $0x62; BYTE $0x63
- BYTE $0x64; BYTE $0x65; BYTE $0x66; BYTE $0x67
- BYTE $0x68; BYTE $0x69; BYTE $0xab; BYTE $0xbb
- BYTE $0xf0; BYTE $0xfd; BYTE $0xfe; BYTE $0xb1
- BYTE $0xb0; BYTE $0x6a; BYTE $0x6b; BYTE $0x6c
- BYTE $0x6d; BYTE $0x6e; BYTE $0x6f; BYTE $0x70
- BYTE $0x71; BYTE $0x72; BYTE $0xaa; BYTE $0xba
- BYTE $0xe6; BYTE $0xb8; BYTE $0xc6; BYTE $0xa4
- BYTE $0xb5; BYTE $0x7e; BYTE $0x73; BYTE $0x74
- BYTE $0x75; BYTE $0x76; BYTE $0x77; BYTE $0x78
- BYTE $0x79; BYTE $0x7a; BYTE $0xa1; BYTE $0xbf
- BYTE $0xd0; BYTE $0x5b; BYTE $0xde; BYTE $0xae
- BYTE $0xac; BYTE $0xa3; BYTE $0xa5; BYTE $0xb7
- BYTE $0xa9; BYTE $0xa7; BYTE $0xb6; BYTE $0xbc
- BYTE $0xbd; BYTE $0xbe; BYTE $0xdd; BYTE $0xa8
- BYTE $0xaf; BYTE $0x5d; BYTE $0xb4; BYTE $0xd7
- BYTE $0x7b; BYTE $0x41; BYTE $0x42; BYTE $0x43
- BYTE $0x44; BYTE $0x45; BYTE $0x46; BYTE $0x47
- BYTE $0x48; BYTE $0x49; BYTE $0xad; BYTE $0xf4
- BYTE $0xf6; BYTE $0xf2; BYTE $0xf3; BYTE $0xf5
- BYTE $0x7d; BYTE $0x4a; BYTE $0x4b; BYTE $0x4c
- BYTE $0x4d; BYTE $0x4e; BYTE $0x4f; BYTE $0x50
- BYTE $0x51; BYTE $0x52; BYTE $0xb9; BYTE $0xfb
- BYTE $0xfc; BYTE $0xf9; BYTE $0xfa; BYTE $0xff
- BYTE $0x5c; BYTE $0xf7; BYTE $0x53; BYTE $0x54
- BYTE $0x55; BYTE $0x56; BYTE $0x57; BYTE $0x58
- BYTE $0x59; BYTE $0x5a; BYTE $0xb2; BYTE $0xd4
- BYTE $0xd6; BYTE $0xd2; BYTE $0xd3; BYTE $0xd5
- BYTE $0x30; BYTE $0x31; BYTE $0x32; BYTE $0x33
- BYTE $0x34; BYTE $0x35; BYTE $0x36; BYTE $0x37
- BYTE $0x38; BYTE $0x39; BYTE $0xb3; BYTE $0xdb
- BYTE $0xdc; BYTE $0xd9; BYTE $0xda; BYTE $0x9f
-
-retry:
- WORD $0xB9931022 // TROO 2,2,b'0001'
- BVS retry
- RET
diff --git a/vendor/golang.org/x/sys/unix/cap_freebsd.go b/vendor/golang.org/x/sys/unix/cap_freebsd.go
deleted file mode 100644
index a086578..0000000
--- a/vendor/golang.org/x/sys/unix/cap_freebsd.go
+++ /dev/null
@@ -1,195 +0,0 @@
-// Copyright 2017 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.
-
-//go:build freebsd
-
-package unix
-
-import (
- "errors"
- "fmt"
-)
-
-// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
-
-const (
- // This is the version of CapRights this package understands. See C implementation for parallels.
- capRightsGoVersion = CAP_RIGHTS_VERSION_00
- capArSizeMin = CAP_RIGHTS_VERSION_00 + 2
- capArSizeMax = capRightsGoVersion + 2
-)
-
-var (
- bit2idx = []int{
- -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
- 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- }
-)
-
-func capidxbit(right uint64) int {
- return int((right >> 57) & 0x1f)
-}
-
-func rightToIndex(right uint64) (int, error) {
- idx := capidxbit(right)
- if idx < 0 || idx >= len(bit2idx) {
- return -2, fmt.Errorf("index for right 0x%x out of range", right)
- }
- return bit2idx[idx], nil
-}
-
-func caprver(right uint64) int {
- return int(right >> 62)
-}
-
-func capver(rights *CapRights) int {
- return caprver(rights.Rights[0])
-}
-
-func caparsize(rights *CapRights) int {
- return capver(rights) + 2
-}
-
-// CapRightsSet sets the permissions in setrights in rights.
-func CapRightsSet(rights *CapRights, setrights []uint64) error {
- // This is essentially a copy of cap_rights_vset()
- if capver(rights) != CAP_RIGHTS_VERSION_00 {
- return fmt.Errorf("bad rights version %d", capver(rights))
- }
-
- n := caparsize(rights)
- if n < capArSizeMin || n > capArSizeMax {
- return errors.New("bad rights size")
- }
-
- for _, right := range setrights {
- if caprver(right) != CAP_RIGHTS_VERSION_00 {
- return errors.New("bad right version")
- }
- i, err := rightToIndex(right)
- if err != nil {
- return err
- }
- if i >= n {
- return errors.New("index overflow")
- }
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return errors.New("index mismatch")
- }
- rights.Rights[i] |= right
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return errors.New("index mismatch (after assign)")
- }
- }
-
- return nil
-}
-
-// CapRightsClear clears the permissions in clearrights from rights.
-func CapRightsClear(rights *CapRights, clearrights []uint64) error {
- // This is essentially a copy of cap_rights_vclear()
- if capver(rights) != CAP_RIGHTS_VERSION_00 {
- return fmt.Errorf("bad rights version %d", capver(rights))
- }
-
- n := caparsize(rights)
- if n < capArSizeMin || n > capArSizeMax {
- return errors.New("bad rights size")
- }
-
- for _, right := range clearrights {
- if caprver(right) != CAP_RIGHTS_VERSION_00 {
- return errors.New("bad right version")
- }
- i, err := rightToIndex(right)
- if err != nil {
- return err
- }
- if i >= n {
- return errors.New("index overflow")
- }
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return errors.New("index mismatch")
- }
- rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return errors.New("index mismatch (after assign)")
- }
- }
-
- return nil
-}
-
-// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
-func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
- // This is essentially a copy of cap_rights_is_vset()
- if capver(rights) != CAP_RIGHTS_VERSION_00 {
- return false, fmt.Errorf("bad rights version %d", capver(rights))
- }
-
- n := caparsize(rights)
- if n < capArSizeMin || n > capArSizeMax {
- return false, errors.New("bad rights size")
- }
-
- for _, right := range setrights {
- if caprver(right) != CAP_RIGHTS_VERSION_00 {
- return false, errors.New("bad right version")
- }
- i, err := rightToIndex(right)
- if err != nil {
- return false, err
- }
- if i >= n {
- return false, errors.New("index overflow")
- }
- if capidxbit(rights.Rights[i]) != capidxbit(right) {
- return false, errors.New("index mismatch")
- }
- if (rights.Rights[i] & right) != right {
- return false, nil
- }
- }
-
- return true, nil
-}
-
-func capright(idx uint64, bit uint64) uint64 {
- return ((1 << (57 + idx)) | bit)
-}
-
-// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
-// See man cap_rights_init(3) and rights(4).
-func CapRightsInit(rights []uint64) (*CapRights, error) {
- var r CapRights
- r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
- r.Rights[1] = capright(1, 0)
-
- err := CapRightsSet(&r, rights)
- if err != nil {
- return nil, err
- }
- return &r, nil
-}
-
-// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
-// The capability rights on fd can never be increased by CapRightsLimit.
-// See man cap_rights_limit(2) and rights(4).
-func CapRightsLimit(fd uintptr, rights *CapRights) error {
- return capRightsLimit(int(fd), rights)
-}
-
-// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
-// See man cap_rights_get(3) and rights(4).
-func CapRightsGet(fd uintptr) (*CapRights, error) {
- r, err := CapRightsInit(nil)
- if err != nil {
- return nil, err
- }
- err = capRightsGet(capRightsGoVersion, int(fd), r)
- if err != nil {
- return nil, err
- }
- return r, nil
-}
diff --git a/vendor/golang.org/x/sys/unix/constants.go b/vendor/golang.org/x/sys/unix/constants.go
deleted file mode 100644
index 6fb7cb7..0000000
--- a/vendor/golang.org/x/sys/unix/constants.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2015 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.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-package unix
-
-const (
- R_OK = 0x4
- W_OK = 0x2
- X_OK = 0x1
-)
diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc.go
deleted file mode 100644
index d785134..0000000
--- a/vendor/golang.org/x/sys/unix/dev_aix_ppc.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2018 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.
-
-//go:build aix && ppc
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used by AIX.
-
-package unix
-
-// Major returns the major component of a Linux device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 16) & 0xffff)
-}
-
-// Minor returns the minor component of a Linux device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0xffff)
-}
-
-// Mkdev returns a Linux device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- return uint64(((major) << 16) | (minor))
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go b/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
deleted file mode 100644
index 623a5e6..0000000
--- a/vendor/golang.org/x/sys/unix/dev_aix_ppc64.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2018 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.
-
-//go:build aix && ppc64
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used AIX.
-
-package unix
-
-// Major returns the major component of a Linux device number.
-func Major(dev uint64) uint32 {
- return uint32((dev & 0x3fffffff00000000) >> 32)
-}
-
-// Minor returns the minor component of a Linux device number.
-func Minor(dev uint64) uint32 {
- return uint32((dev & 0x00000000ffffffff) >> 0)
-}
-
-// Mkdev returns a Linux device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- var DEVNO64 uint64
- DEVNO64 = 0x8000000000000000
- return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64)
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_darwin.go b/vendor/golang.org/x/sys/unix/dev_darwin.go
deleted file mode 100644
index 8d1dc0f..0000000
--- a/vendor/golang.org/x/sys/unix/dev_darwin.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2017 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.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in Darwin's sys/types.h header.
-
-package unix
-
-// Major returns the major component of a Darwin device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 24) & 0xff)
-}
-
-// Minor returns the minor component of a Darwin device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0xffffff)
-}
-
-// Mkdev returns a Darwin device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- return (uint64(major) << 24) | uint64(minor)
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_dragonfly.go b/vendor/golang.org/x/sys/unix/dev_dragonfly.go
deleted file mode 100644
index 8502f20..0000000
--- a/vendor/golang.org/x/sys/unix/dev_dragonfly.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2017 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.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in Dragonfly's sys/types.h header.
-//
-// The information below is extracted and adapted from sys/types.h:
-//
-// Minor gives a cookie instead of an index since in order to avoid changing the
-// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
-// devices that don't use them.
-
-package unix
-
-// Major returns the major component of a DragonFlyBSD device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 8) & 0xff)
-}
-
-// Minor returns the minor component of a DragonFlyBSD device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0xffff00ff)
-}
-
-// Mkdev returns a DragonFlyBSD device number generated from the given major and
-// minor components.
-func Mkdev(major, minor uint32) uint64 {
- return (uint64(major) << 8) | uint64(minor)
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_freebsd.go b/vendor/golang.org/x/sys/unix/dev_freebsd.go
deleted file mode 100644
index eba3b4b..0000000
--- a/vendor/golang.org/x/sys/unix/dev_freebsd.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2017 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.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in FreeBSD's sys/types.h header.
-//
-// The information below is extracted and adapted from sys/types.h:
-//
-// Minor gives a cookie instead of an index since in order to avoid changing the
-// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
-// devices that don't use them.
-
-package unix
-
-// Major returns the major component of a FreeBSD device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 8) & 0xff)
-}
-
-// Minor returns the minor component of a FreeBSD device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0xffff00ff)
-}
-
-// Mkdev returns a FreeBSD device number generated from the given major and
-// minor components.
-func Mkdev(major, minor uint32) uint64 {
- return (uint64(major) << 8) | uint64(minor)
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_linux.go b/vendor/golang.org/x/sys/unix/dev_linux.go
deleted file mode 100644
index d165d6f..0000000
--- a/vendor/golang.org/x/sys/unix/dev_linux.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2017 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.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used by the Linux kernel and glibc.
-//
-// The information below is extracted and adapted from bits/sysmacros.h in the
-// glibc sources:
-//
-// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
-// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
-// number and m is a hex digit of the minor number. This is backward compatible
-// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
-// backward compatible with the Linux kernel, which for some architectures uses
-// 32-bit dev_t, encoded as mmmM MMmm.
-
-package unix
-
-// Major returns the major component of a Linux device number.
-func Major(dev uint64) uint32 {
- major := uint32((dev & 0x00000000000fff00) >> 8)
- major |= uint32((dev & 0xfffff00000000000) >> 32)
- return major
-}
-
-// Minor returns the minor component of a Linux device number.
-func Minor(dev uint64) uint32 {
- minor := uint32((dev & 0x00000000000000ff) >> 0)
- minor |= uint32((dev & 0x00000ffffff00000) >> 12)
- return minor
-}
-
-// Mkdev returns a Linux device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- dev := (uint64(major) & 0x00000fff) << 8
- dev |= (uint64(major) & 0xfffff000) << 32
- dev |= (uint64(minor) & 0x000000ff) << 0
- dev |= (uint64(minor) & 0xffffff00) << 12
- return dev
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_netbsd.go b/vendor/golang.org/x/sys/unix/dev_netbsd.go
deleted file mode 100644
index b4a203d..0000000
--- a/vendor/golang.org/x/sys/unix/dev_netbsd.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 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.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in NetBSD's sys/types.h header.
-
-package unix
-
-// Major returns the major component of a NetBSD device number.
-func Major(dev uint64) uint32 {
- return uint32((dev & 0x000fff00) >> 8)
-}
-
-// Minor returns the minor component of a NetBSD device number.
-func Minor(dev uint64) uint32 {
- minor := uint32((dev & 0x000000ff) >> 0)
- minor |= uint32((dev & 0xfff00000) >> 12)
- return minor
-}
-
-// Mkdev returns a NetBSD device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- dev := (uint64(major) << 8) & 0x000fff00
- dev |= (uint64(minor) << 12) & 0xfff00000
- dev |= (uint64(minor) << 0) & 0x000000ff
- return dev
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_openbsd.go b/vendor/golang.org/x/sys/unix/dev_openbsd.go
deleted file mode 100644
index f3430c4..0000000
--- a/vendor/golang.org/x/sys/unix/dev_openbsd.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 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.
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used in OpenBSD's sys/types.h header.
-
-package unix
-
-// Major returns the major component of an OpenBSD device number.
-func Major(dev uint64) uint32 {
- return uint32((dev & 0x0000ff00) >> 8)
-}
-
-// Minor returns the minor component of an OpenBSD device number.
-func Minor(dev uint64) uint32 {
- minor := uint32((dev & 0x000000ff) >> 0)
- minor |= uint32((dev & 0xffff0000) >> 8)
- return minor
-}
-
-// Mkdev returns an OpenBSD device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- dev := (uint64(major) << 8) & 0x0000ff00
- dev |= (uint64(minor) << 8) & 0xffff0000
- dev |= (uint64(minor) << 0) & 0x000000ff
- return dev
-}
diff --git a/vendor/golang.org/x/sys/unix/dev_zos.go b/vendor/golang.org/x/sys/unix/dev_zos.go
deleted file mode 100644
index bb6a64f..0000000
--- a/vendor/golang.org/x/sys/unix/dev_zos.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2020 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.
-
-//go:build zos && s390x
-
-// Functions to access/create device major and minor numbers matching the
-// encoding used by z/OS.
-//
-// The information below is extracted and adapted from macros.
-
-package unix
-
-// Major returns the major component of a z/OS device number.
-func Major(dev uint64) uint32 {
- return uint32((dev >> 16) & 0x0000FFFF)
-}
-
-// Minor returns the minor component of a z/OS device number.
-func Minor(dev uint64) uint32 {
- return uint32(dev & 0x0000FFFF)
-}
-
-// Mkdev returns a z/OS device number generated from the given major and minor
-// components.
-func Mkdev(major, minor uint32) uint64 {
- return (uint64(major) << 16) | uint64(minor)
-}
diff --git a/vendor/golang.org/x/sys/unix/dirent.go b/vendor/golang.org/x/sys/unix/dirent.go
deleted file mode 100644
index 1ebf117..0000000
--- a/vendor/golang.org/x/sys/unix/dirent.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2009 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.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-package unix
-
-import "unsafe"
-
-// readInt returns the size-bytes unsigned integer in native byte order at offset off.
-func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
- if len(b) < int(off+size) {
- return 0, false
- }
- if isBigEndian {
- return readIntBE(b[off:], size), true
- }
- return readIntLE(b[off:], size), true
-}
-
-func readIntBE(b []byte, size uintptr) uint64 {
- switch size {
- case 1:
- return uint64(b[0])
- case 2:
- _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[1]) | uint64(b[0])<<8
- case 4:
- _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
- case 8:
- _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
- uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
- default:
- panic("syscall: readInt with unsupported size")
- }
-}
-
-func readIntLE(b []byte, size uintptr) uint64 {
- switch size {
- case 1:
- return uint64(b[0])
- case 2:
- _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[0]) | uint64(b[1])<<8
- case 4:
- _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
- case 8:
- _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
- return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
- uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
- default:
- panic("syscall: readInt with unsupported size")
- }
-}
-
-// ParseDirent parses up to max directory entries in buf,
-// appending the names to names. It returns the number of
-// bytes consumed from buf, the number of entries added
-// to names, and the new names slice.
-func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
- origlen := len(buf)
- count = 0
- for max != 0 && len(buf) > 0 {
- reclen, ok := direntReclen(buf)
- if !ok || reclen > uint64(len(buf)) {
- return origlen, count, names
- }
- rec := buf[:reclen]
- buf = buf[reclen:]
- ino, ok := direntIno(rec)
- if !ok {
- break
- }
- if ino == 0 { // File absent in directory.
- continue
- }
- const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
- namlen, ok := direntNamlen(rec)
- if !ok || namoff+namlen > uint64(len(rec)) {
- break
- }
- name := rec[namoff : namoff+namlen]
- for i, c := range name {
- if c == 0 {
- name = name[:i]
- break
- }
- }
- // Check for useless names before allocating a string.
- if string(name) == "." || string(name) == ".." {
- continue
- }
- max--
- count++
- names = append(names, string(name))
- }
- return origlen - len(buf), count, names
-}
diff --git a/vendor/golang.org/x/sys/unix/endian_big.go b/vendor/golang.org/x/sys/unix/endian_big.go
deleted file mode 100644
index 1095fd3..0000000
--- a/vendor/golang.org/x/sys/unix/endian_big.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2016 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.
-//
-//go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64
-
-package unix
-
-const isBigEndian = true
diff --git a/vendor/golang.org/x/sys/unix/endian_little.go b/vendor/golang.org/x/sys/unix/endian_little.go
deleted file mode 100644
index b9f0e27..0000000
--- a/vendor/golang.org/x/sys/unix/endian_little.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2016 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.
-//
-//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh
-
-package unix
-
-const isBigEndian = false
diff --git a/vendor/golang.org/x/sys/unix/env_unix.go b/vendor/golang.org/x/sys/unix/env_unix.go
deleted file mode 100644
index a96da71..0000000
--- a/vendor/golang.org/x/sys/unix/env_unix.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2010 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.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-// Unix environment variables.
-
-package unix
-
-import "syscall"
-
-func Getenv(key string) (value string, found bool) {
- return syscall.Getenv(key)
-}
-
-func Setenv(key, value string) error {
- return syscall.Setenv(key, value)
-}
-
-func Clearenv() {
- syscall.Clearenv()
-}
-
-func Environ() []string {
- return syscall.Environ()
-}
-
-func Unsetenv(key string) error {
- return syscall.Unsetenv(key)
-}
diff --git a/vendor/golang.org/x/sys/unix/fcntl.go b/vendor/golang.org/x/sys/unix/fcntl.go
deleted file mode 100644
index 6200876..0000000
--- a/vendor/golang.org/x/sys/unix/fcntl.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2014 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.
-
-//go:build dragonfly || freebsd || linux || netbsd
-
-package unix
-
-import "unsafe"
-
-// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
-// systems by fcntl_linux_32bit.go to be SYS_FCNTL64.
-var fcntl64Syscall uintptr = SYS_FCNTL
-
-func fcntl(fd int, cmd, arg int) (int, error) {
- valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))
- var err error
- if errno != 0 {
- err = errno
- }
- return int(valptr), err
-}
-
-// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
-func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
- return fcntl(int(fd), cmd, arg)
-}
-
-// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
-func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
- _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
- if errno == 0 {
- return nil
- }
- return errno
-}
diff --git a/vendor/golang.org/x/sys/unix/fcntl_darwin.go b/vendor/golang.org/x/sys/unix/fcntl_darwin.go
deleted file mode 100644
index a9911c7..0000000
--- a/vendor/golang.org/x/sys/unix/fcntl_darwin.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2019 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.
-
-package unix
-
-import "unsafe"
-
-// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
-func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
- return fcntl(int(fd), cmd, arg)
-}
-
-// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
-func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
- _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
- return err
-}
-
-// FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command.
-func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error {
- _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore))))
- return err
-}
diff --git a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
deleted file mode 100644
index 13b4acd..0000000
--- a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2014 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.
-
-//go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc)
-
-package unix
-
-func init() {
- // On 32-bit Linux systems, the fcntl syscall that matches Go's
- // Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
- fcntl64Syscall = SYS_FCNTL64
-}
diff --git a/vendor/golang.org/x/sys/unix/fdset.go b/vendor/golang.org/x/sys/unix/fdset.go
deleted file mode 100644
index 9e83d18..0000000
--- a/vendor/golang.org/x/sys/unix/fdset.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2019 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.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
-
-package unix
-
-// Set adds fd to the set fds.
-func (fds *FdSet) Set(fd int) {
- fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
-}
-
-// Clear removes fd from the set fds.
-func (fds *FdSet) Clear(fd int) {
- fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS))
-}
-
-// IsSet returns whether fd is in the set fds.
-func (fds *FdSet) IsSet(fd int) bool {
- return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0
-}
-
-// Zero clears the set fds.
-func (fds *FdSet) Zero() {
- for i := range fds.Bits {
- fds.Bits[i] = 0
- }
-}
diff --git a/vendor/golang.org/x/sys/unix/gccgo.go b/vendor/golang.org/x/sys/unix/gccgo.go
deleted file mode 100644
index aca5721..0000000
--- a/vendor/golang.org/x/sys/unix/gccgo.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2015 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.
-
-//go:build gccgo && !aix && !hurd
-
-package unix
-
-import "syscall"
-
-// We can't use the gc-syntax .s files for gccgo. On the plus side
-// much of the functionality can be written directly in Go.
-
-func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
-
-func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
-
-func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
- syscall.Entersyscall()
- r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
- syscall.Exitsyscall()
- return r, 0
-}
-
-func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- syscall.Entersyscall()
- r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
- syscall.Exitsyscall()
- return r, 0, syscall.Errno(errno)
-}
-
-func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- syscall.Entersyscall()
- r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
- syscall.Exitsyscall()
- return r, 0, syscall.Errno(errno)
-}
-
-func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- syscall.Entersyscall()
- r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
- syscall.Exitsyscall()
- return r, 0, syscall.Errno(errno)
-}
-
-func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
- r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
- return r, 0
-}
-
-func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
- return r, 0, syscall.Errno(errno)
-}
-
-func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
- r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
- return r, 0, syscall.Errno(errno)
-}
diff --git a/vendor/golang.org/x/sys/unix/gccgo_c.c b/vendor/golang.org/x/sys/unix/gccgo_c.c
deleted file mode 100644
index d468b7b..0000000
--- a/vendor/golang.org/x/sys/unix/gccgo_c.c
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2015 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.
-
-//go:build gccgo && !aix && !hurd
-
-#include
-#include
-#include
-
-#define _STRINGIFY2_(x) #x
-#define _STRINGIFY_(x) _STRINGIFY2_(x)
-#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
-
-// Call syscall from C code because the gccgo support for calling from
-// Go to C does not support varargs functions.
-
-struct ret {
- uintptr_t r;
- uintptr_t err;
-};
-
-struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
- __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall");
-
-struct ret
-gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
-{
- struct ret r;
-
- errno = 0;
- r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
- r.err = errno;
- return r;
-}
-
-uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
- __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError");
-
-uintptr_t
-gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
-{
- return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
-}
diff --git a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go b/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
deleted file mode 100644
index 972d61b..0000000
--- a/vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2015 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.
-
-//go:build gccgo && linux && amd64
-
-package unix
-
-import "syscall"
-
-//extern gettimeofday
-func realGettimeofday(*Timeval, *byte) int32
-
-func gettimeofday(tv *Timeval) (err syscall.Errno) {
- r := realGettimeofday(tv, nil)
- if r < 0 {
- return syscall.GetErrno()
- }
- return 0
-}
diff --git a/vendor/golang.org/x/sys/unix/ifreq_linux.go b/vendor/golang.org/x/sys/unix/ifreq_linux.go
deleted file mode 100644
index 848840a..0000000
--- a/vendor/golang.org/x/sys/unix/ifreq_linux.go
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2021 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.
-
-//go:build linux
-
-package unix
-
-import (
- "unsafe"
-)
-
-// Helpers for dealing with ifreq since it contains a union and thus requires a
-// lot of unsafe.Pointer casts to use properly.
-
-// An Ifreq is a type-safe wrapper around the raw ifreq struct. An Ifreq
-// contains an interface name and a union of arbitrary data which can be
-// accessed using the Ifreq's methods. To create an Ifreq, use the NewIfreq
-// function.
-//
-// Use the Name method to access the stored interface name. The union data
-// fields can be get and set using the following methods:
-// - Uint16/SetUint16: flags
-// - Uint32/SetUint32: ifindex, metric, mtu
-type Ifreq struct{ raw ifreq }
-
-// NewIfreq creates an Ifreq with the input network interface name after
-// validating the name does not exceed IFNAMSIZ-1 (trailing NULL required)
-// bytes.
-func NewIfreq(name string) (*Ifreq, error) {
- // Leave room for terminating NULL byte.
- if len(name) >= IFNAMSIZ {
- return nil, EINVAL
- }
-
- var ifr ifreq
- copy(ifr.Ifrn[:], name)
-
- return &Ifreq{raw: ifr}, nil
-}
-
-// TODO(mdlayher): get/set methods for hardware address sockaddr, char array, etc.
-
-// Name returns the interface name associated with the Ifreq.
-func (ifr *Ifreq) Name() string {
- return ByteSliceToString(ifr.raw.Ifrn[:])
-}
-
-// According to netdevice(7), only AF_INET addresses are returned for numerous
-// sockaddr ioctls. For convenience, we expose these as Inet4Addr since the Port
-// field and other data is always empty.
-
-// Inet4Addr returns the Ifreq union data from an embedded sockaddr as a C
-// in_addr/Go []byte (4-byte IPv4 address) value. If the sockaddr family is not
-// AF_INET, an error is returned.
-func (ifr *Ifreq) Inet4Addr() ([]byte, error) {
- raw := *(*RawSockaddrInet4)(unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]))
- if raw.Family != AF_INET {
- // Cannot safely interpret raw.Addr bytes as an IPv4 address.
- return nil, EINVAL
- }
-
- return raw.Addr[:], nil
-}
-
-// SetInet4Addr sets a C in_addr/Go []byte (4-byte IPv4 address) value in an
-// embedded sockaddr within the Ifreq's union data. v must be 4 bytes in length
-// or an error will be returned.
-func (ifr *Ifreq) SetInet4Addr(v []byte) error {
- if len(v) != 4 {
- return EINVAL
- }
-
- var addr [4]byte
- copy(addr[:], v)
-
- ifr.clear()
- *(*RawSockaddrInet4)(
- unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]),
- ) = RawSockaddrInet4{
- // Always set IP family as ioctls would require it anyway.
- Family: AF_INET,
- Addr: addr,
- }
-
- return nil
-}
-
-// Uint16 returns the Ifreq union data as a C short/Go uint16 value.
-func (ifr *Ifreq) Uint16() uint16 {
- return *(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0]))
-}
-
-// SetUint16 sets a C short/Go uint16 value as the Ifreq's union data.
-func (ifr *Ifreq) SetUint16(v uint16) {
- ifr.clear()
- *(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0])) = v
-}
-
-// Uint32 returns the Ifreq union data as a C int/Go uint32 value.
-func (ifr *Ifreq) Uint32() uint32 {
- return *(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0]))
-}
-
-// SetUint32 sets a C int/Go uint32 value as the Ifreq's union data.
-func (ifr *Ifreq) SetUint32(v uint32) {
- ifr.clear()
- *(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0])) = v
-}
-
-// clear zeroes the ifreq's union field to prevent trailing garbage data from
-// being sent to the kernel if an ifreq is reused.
-func (ifr *Ifreq) clear() {
- for i := range ifr.raw.Ifru {
- ifr.raw.Ifru[i] = 0
- }
-}
-
-// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
-// IoctlGetEthtoolDrvinfo which use these APIs under the hood.
-
-// An ifreqData is an Ifreq which carries pointer data. To produce an ifreqData,
-// use the Ifreq.withData method.
-type ifreqData struct {
- name [IFNAMSIZ]byte
- // A type separate from ifreq is required in order to comply with the
- // unsafe.Pointer rules since the "pointer-ness" of data would not be
- // preserved if it were cast into the byte array of a raw ifreq.
- data unsafe.Pointer
- // Pad to the same size as ifreq.
- _ [len(ifreq{}.Ifru) - SizeofPtr]byte
-}
-
-// withData produces an ifreqData with the pointer p set for ioctls which require
-// arbitrary pointer data.
-func (ifr Ifreq) withData(p unsafe.Pointer) ifreqData {
- return ifreqData{
- name: ifr.raw.Ifrn,
- data: p,
- }
-}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_linux.go b/vendor/golang.org/x/sys/unix/ioctl_linux.go
deleted file mode 100644
index dbe680e..0000000
--- a/vendor/golang.org/x/sys/unix/ioctl_linux.go
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright 2021 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.
-
-package unix
-
-import "unsafe"
-
-// IoctlRetInt performs an ioctl operation specified by req on a device
-// associated with opened file descriptor fd, and returns a non-negative
-// integer that is returned by the ioctl syscall.
-func IoctlRetInt(fd int, req uint) (int, error) {
- ret, _, err := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), 0)
- if err != 0 {
- return 0, err
- }
- return int(ret), nil
-}
-
-func IoctlGetUint32(fd int, req uint) (uint32, error) {
- var value uint32
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return value, err
-}
-
-func IoctlGetRTCTime(fd int) (*RTCTime, error) {
- var value RTCTime
- err := ioctlPtr(fd, RTC_RD_TIME, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlSetRTCTime(fd int, value *RTCTime) error {
- return ioctlPtr(fd, RTC_SET_TIME, unsafe.Pointer(value))
-}
-
-func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
- var value RTCWkAlrm
- err := ioctlPtr(fd, RTC_WKALM_RD, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlSetRTCWkAlrm(fd int, value *RTCWkAlrm) error {
- return ioctlPtr(fd, RTC_WKALM_SET, unsafe.Pointer(value))
-}
-
-// IoctlGetEthtoolDrvinfo fetches ethtool driver information for the network
-// device specified by ifname.
-func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
- ifr, err := NewIfreq(ifname)
- if err != nil {
- return nil, err
- }
-
- value := EthtoolDrvinfo{Cmd: ETHTOOL_GDRVINFO}
- ifrd := ifr.withData(unsafe.Pointer(&value))
-
- err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd)
- return &value, err
-}
-
-// IoctlGetWatchdogInfo fetches information about a watchdog device from the
-// Linux watchdog API. For more information, see:
-// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
-func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) {
- var value WatchdogInfo
- err := ioctlPtr(fd, WDIOC_GETSUPPORT, unsafe.Pointer(&value))
- return &value, err
-}
-
-// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
-// more information, see:
-// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
-func IoctlWatchdogKeepalive(fd int) error {
- // arg is ignored and not a pointer, so ioctl is fine instead of ioctlPtr.
- return ioctl(fd, WDIOC_KEEPALIVE, 0)
-}
-
-// IoctlFileCloneRange performs an FICLONERANGE ioctl operation to clone the
-// range of data conveyed in value to the file associated with the file
-// descriptor destFd. See the ioctl_ficlonerange(2) man page for details.
-func IoctlFileCloneRange(destFd int, value *FileCloneRange) error {
- return ioctlPtr(destFd, FICLONERANGE, unsafe.Pointer(value))
-}
-
-// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file
-// associated with the file description srcFd to the file associated with the
-// file descriptor destFd. See the ioctl_ficlone(2) man page for details.
-func IoctlFileClone(destFd, srcFd int) error {
- return ioctl(destFd, FICLONE, uintptr(srcFd))
-}
-
-type FileDedupeRange struct {
- Src_offset uint64
- Src_length uint64
- Reserved1 uint16
- Reserved2 uint32
- Info []FileDedupeRangeInfo
-}
-
-type FileDedupeRangeInfo struct {
- Dest_fd int64
- Dest_offset uint64
- Bytes_deduped uint64
- Status int32
- Reserved uint32
-}
-
-// IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the
-// range of data conveyed in value from the file associated with the file
-// descriptor srcFd to the value.Info destinations. See the
-// ioctl_fideduperange(2) man page for details.
-func IoctlFileDedupeRange(srcFd int, value *FileDedupeRange) error {
- buf := make([]byte, SizeofRawFileDedupeRange+
- len(value.Info)*SizeofRawFileDedupeRangeInfo)
- rawrange := (*RawFileDedupeRange)(unsafe.Pointer(&buf[0]))
- rawrange.Src_offset = value.Src_offset
- rawrange.Src_length = value.Src_length
- rawrange.Dest_count = uint16(len(value.Info))
- rawrange.Reserved1 = value.Reserved1
- rawrange.Reserved2 = value.Reserved2
-
- for i := range value.Info {
- rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
- uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
- uintptr(i*SizeofRawFileDedupeRangeInfo)))
- rawinfo.Dest_fd = value.Info[i].Dest_fd
- rawinfo.Dest_offset = value.Info[i].Dest_offset
- rawinfo.Bytes_deduped = value.Info[i].Bytes_deduped
- rawinfo.Status = value.Info[i].Status
- rawinfo.Reserved = value.Info[i].Reserved
- }
-
- err := ioctlPtr(srcFd, FIDEDUPERANGE, unsafe.Pointer(&buf[0]))
-
- // Output
- for i := range value.Info {
- rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer(
- uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) +
- uintptr(i*SizeofRawFileDedupeRangeInfo)))
- value.Info[i].Dest_fd = rawinfo.Dest_fd
- value.Info[i].Dest_offset = rawinfo.Dest_offset
- value.Info[i].Bytes_deduped = rawinfo.Bytes_deduped
- value.Info[i].Status = rawinfo.Status
- value.Info[i].Reserved = rawinfo.Reserved
- }
-
- return err
-}
-
-func IoctlHIDGetDesc(fd int, value *HIDRawReportDescriptor) error {
- return ioctlPtr(fd, HIDIOCGRDESC, unsafe.Pointer(value))
-}
-
-func IoctlHIDGetRawInfo(fd int) (*HIDRawDevInfo, error) {
- var value HIDRawDevInfo
- err := ioctlPtr(fd, HIDIOCGRAWINFO, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlHIDGetRawName(fd int) (string, error) {
- var value [_HIDIOCGRAWNAME_LEN]byte
- err := ioctlPtr(fd, _HIDIOCGRAWNAME, unsafe.Pointer(&value[0]))
- return ByteSliceToString(value[:]), err
-}
-
-func IoctlHIDGetRawPhys(fd int) (string, error) {
- var value [_HIDIOCGRAWPHYS_LEN]byte
- err := ioctlPtr(fd, _HIDIOCGRAWPHYS, unsafe.Pointer(&value[0]))
- return ByteSliceToString(value[:]), err
-}
-
-func IoctlHIDGetRawUniq(fd int) (string, error) {
- var value [_HIDIOCGRAWUNIQ_LEN]byte
- err := ioctlPtr(fd, _HIDIOCGRAWUNIQ, unsafe.Pointer(&value[0]))
- return ByteSliceToString(value[:]), err
-}
-
-// IoctlIfreq performs an ioctl using an Ifreq structure for input and/or
-// output. See the netdevice(7) man page for details.
-func IoctlIfreq(fd int, req uint, value *Ifreq) error {
- // It is possible we will add more fields to *Ifreq itself later to prevent
- // misuse, so pass the raw *ifreq directly.
- return ioctlPtr(fd, req, unsafe.Pointer(&value.raw))
-}
-
-// TODO(mdlayher): export if and when IfreqData is exported.
-
-// ioctlIfreqData performs an ioctl using an ifreqData structure for input
-// and/or output. See the netdevice(7) man page for details.
-func ioctlIfreqData(fd int, req uint, value *ifreqData) error {
- // The memory layout of IfreqData (type-safe) and ifreq (not type-safe) are
- // identical so pass *IfreqData directly.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlKCMClone attaches a new file descriptor to a multiplexor by cloning an
-// existing KCM socket, returning a structure containing the file descriptor of
-// the new socket.
-func IoctlKCMClone(fd int) (*KCMClone, error) {
- var info KCMClone
- if err := ioctlPtr(fd, SIOCKCMCLONE, unsafe.Pointer(&info)); err != nil {
- return nil, err
- }
-
- return &info, nil
-}
-
-// IoctlKCMAttach attaches a TCP socket and associated BPF program file
-// descriptor to a multiplexor.
-func IoctlKCMAttach(fd int, info KCMAttach) error {
- return ioctlPtr(fd, SIOCKCMATTACH, unsafe.Pointer(&info))
-}
-
-// IoctlKCMUnattach unattaches a TCP socket file descriptor from a multiplexor.
-func IoctlKCMUnattach(fd int, info KCMUnattach) error {
- return ioctlPtr(fd, SIOCKCMUNATTACH, unsafe.Pointer(&info))
-}
-
-// IoctlLoopGetStatus64 gets the status of the loop device associated with the
-// file descriptor fd using the LOOP_GET_STATUS64 operation.
-func IoctlLoopGetStatus64(fd int) (*LoopInfo64, error) {
- var value LoopInfo64
- if err := ioctlPtr(fd, LOOP_GET_STATUS64, unsafe.Pointer(&value)); err != nil {
- return nil, err
- }
- return &value, nil
-}
-
-// IoctlLoopSetStatus64 sets the status of the loop device associated with the
-// file descriptor fd using the LOOP_SET_STATUS64 operation.
-func IoctlLoopSetStatus64(fd int, value *LoopInfo64) error {
- return ioctlPtr(fd, LOOP_SET_STATUS64, unsafe.Pointer(value))
-}
-
-// IoctlLoopConfigure configures all loop device parameters in a single step
-func IoctlLoopConfigure(fd int, value *LoopConfig) error {
- return ioctlPtr(fd, LOOP_CONFIGURE, unsafe.Pointer(value))
-}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_signed.go b/vendor/golang.org/x/sys/unix/ioctl_signed.go
deleted file mode 100644
index 5b0759b..0000000
--- a/vendor/golang.org/x/sys/unix/ioctl_signed.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2018 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.
-
-//go:build aix || solaris
-
-package unix
-
-import (
- "unsafe"
-)
-
-// ioctl itself should not be exposed directly, but additional get/set
-// functions for specific types are permissible.
-
-// IoctlSetInt performs an ioctl operation which sets an integer value
-// on fd, using the specified request number.
-func IoctlSetInt(fd int, req int, value int) error {
- return ioctl(fd, req, uintptr(value))
-}
-
-// IoctlSetPointerInt performs an ioctl operation which sets an
-// integer value on fd, using the specified request number. The ioctl
-// argument is called with a pointer to the integer value, rather than
-// passing the integer value directly.
-func IoctlSetPointerInt(fd int, req int, value int) error {
- v := int32(value)
- return ioctlPtr(fd, req, unsafe.Pointer(&v))
-}
-
-// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
-//
-// To change fd's window size, the req argument should be TIOCSWINSZ.
-func IoctlSetWinsize(fd int, req int, value *Winsize) error {
- // TODO: if we get the chance, remove the req parameter and
- // hardcode TIOCSWINSZ.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlSetTermios performs an ioctl on fd with a *Termios.
-//
-// The req value will usually be TCSETA or TIOCSETA.
-func IoctlSetTermios(fd int, req int, value *Termios) error {
- // TODO: if we get the chance, remove the req parameter.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlGetInt performs an ioctl operation which gets an integer value
-// from fd, using the specified request number.
-//
-// A few ioctl requests use the return value as an output parameter;
-// for those, IoctlRetInt should be used instead of this function.
-func IoctlGetInt(fd int, req int) (int, error) {
- var value int
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return value, err
-}
-
-func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
- var value Winsize
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlGetTermios(fd int, req int) (*Termios, error) {
- var value Termios
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_unsigned.go b/vendor/golang.org/x/sys/unix/ioctl_unsigned.go
deleted file mode 100644
index 20f470b..0000000
--- a/vendor/golang.org/x/sys/unix/ioctl_unsigned.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2018 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.
-
-//go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd
-
-package unix
-
-import (
- "unsafe"
-)
-
-// ioctl itself should not be exposed directly, but additional get/set
-// functions for specific types are permissible.
-
-// IoctlSetInt performs an ioctl operation which sets an integer value
-// on fd, using the specified request number.
-func IoctlSetInt(fd int, req uint, value int) error {
- return ioctl(fd, req, uintptr(value))
-}
-
-// IoctlSetPointerInt performs an ioctl operation which sets an
-// integer value on fd, using the specified request number. The ioctl
-// argument is called with a pointer to the integer value, rather than
-// passing the integer value directly.
-func IoctlSetPointerInt(fd int, req uint, value int) error {
- v := int32(value)
- return ioctlPtr(fd, req, unsafe.Pointer(&v))
-}
-
-// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
-//
-// To change fd's window size, the req argument should be TIOCSWINSZ.
-func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
- // TODO: if we get the chance, remove the req parameter and
- // hardcode TIOCSWINSZ.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlSetTermios performs an ioctl on fd with a *Termios.
-//
-// The req value will usually be TCSETA or TIOCSETA.
-func IoctlSetTermios(fd int, req uint, value *Termios) error {
- // TODO: if we get the chance, remove the req parameter.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlGetInt performs an ioctl operation which gets an integer value
-// from fd, using the specified request number.
-//
-// A few ioctl requests use the return value as an output parameter;
-// for those, IoctlRetInt should be used instead of this function.
-func IoctlGetInt(fd int, req uint) (int, error) {
- var value int
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return value, err
-}
-
-func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
- var value Winsize
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
-
-func IoctlGetTermios(fd int, req uint) (*Termios, error) {
- var value Termios
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
diff --git a/vendor/golang.org/x/sys/unix/ioctl_zos.go b/vendor/golang.org/x/sys/unix/ioctl_zos.go
deleted file mode 100644
index c8b2a75..0000000
--- a/vendor/golang.org/x/sys/unix/ioctl_zos.go
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2020 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.
-
-//go:build zos && s390x
-
-package unix
-
-import (
- "runtime"
- "unsafe"
-)
-
-// ioctl itself should not be exposed directly, but additional get/set
-// functions for specific types are permissible.
-
-// IoctlSetInt performs an ioctl operation which sets an integer value
-// on fd, using the specified request number.
-func IoctlSetInt(fd int, req int, value int) error {
- return ioctl(fd, req, uintptr(value))
-}
-
-// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
-//
-// To change fd's window size, the req argument should be TIOCSWINSZ.
-func IoctlSetWinsize(fd int, req int, value *Winsize) error {
- // TODO: if we get the chance, remove the req parameter and
- // hardcode TIOCSWINSZ.
- return ioctlPtr(fd, req, unsafe.Pointer(value))
-}
-
-// IoctlSetTermios performs an ioctl on fd with a *Termios.
-//
-// The req value is expected to be TCSETS, TCSETSW, or TCSETSF
-func IoctlSetTermios(fd int, req int, value *Termios) error {
- if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
- return ENOSYS
- }
- err := Tcsetattr(fd, int(req), value)
- runtime.KeepAlive(value)
- return err
-}
-
-// IoctlGetInt performs an ioctl operation which gets an integer value
-// from fd, using the specified request number.
-//
-// A few ioctl requests use the return value as an output parameter;
-// for those, IoctlRetInt should be used instead of this function.
-func IoctlGetInt(fd int, req int) (int, error) {
- var value int
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return value, err
-}
-
-func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
- var value Winsize
- err := ioctlPtr(fd, req, unsafe.Pointer(&value))
- return &value, err
-}
-
-// IoctlGetTermios performs an ioctl on fd with a *Termios.
-//
-// The req value is expected to be TCGETS
-func IoctlGetTermios(fd int, req int) (*Termios, error) {
- var value Termios
- if req != TCGETS {
- return &value, ENOSYS
- }
- err := Tcgetattr(fd, &value)
- return &value, err
-}
diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh
deleted file mode 100644
index e6f31d3..0000000
--- a/vendor/golang.org/x/sys/unix/mkall.sh
+++ /dev/null
@@ -1,249 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2009 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.
-
-# This script runs or (given -n) prints suggested commands to generate files for
-# the Architecture/OS specified by the GOARCH and GOOS environment variables.
-# See README.md for more information about how the build system works.
-
-GOOSARCH="${GOOS}_${GOARCH}"
-
-# defaults
-mksyscall="go run mksyscall.go"
-mkerrors="./mkerrors.sh"
-zerrors="zerrors_$GOOSARCH.go"
-mksysctl=""
-zsysctl="zsysctl_$GOOSARCH.go"
-mksysnum=
-mktypes=
-mkasm=
-run="sh"
-cmd=""
-
-case "$1" in
--syscalls)
- for i in zsyscall*go
- do
- # Run the command line that appears in the first line
- # of the generated file to regenerate it.
- sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
- rm _$i
- done
- exit 0
- ;;
--n)
- run="cat"
- cmd="echo"
- shift
-esac
-
-case "$#" in
-0)
- ;;
-*)
- echo 'usage: mkall.sh [-n]' 1>&2
- exit 2
-esac
-
-if [[ "$GOOS" = "linux" ]]; then
- # Use the Docker-based build system
- # Files generated through docker (use $cmd so you can Ctl-C the build or run)
- $cmd docker build --tag generate:$GOOS $GOOS
- $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS
- exit
-fi
-
-GOOSARCH_in=syscall_$GOOSARCH.go
-case "$GOOSARCH" in
-_* | *_ | _)
- echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
- exit 1
- ;;
-aix_ppc)
- mkerrors="$mkerrors -maix32"
- mksyscall="go run mksyscall_aix_ppc.go -aix"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-aix_ppc64)
- mkerrors="$mkerrors -maix64"
- mksyscall="go run mksyscall_aix_ppc64.go -aix"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-darwin_amd64)
- mkerrors="$mkerrors -m64"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- mkasm="go run mkasm.go"
- ;;
-darwin_arm64)
- mkerrors="$mkerrors -m64"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- mkasm="go run mkasm.go"
- ;;
-dragonfly_amd64)
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -dragonfly"
- mksysnum="go run mksysnum.go 'https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_386)
- mkerrors="$mkerrors -m32"
- mksyscall="go run mksyscall.go -l32"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_amd64)
- mkerrors="$mkerrors -m64"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-freebsd_arm)
- mkerrors="$mkerrors"
- mksyscall="go run mksyscall.go -l32 -arm"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-freebsd_arm64)
- mkerrors="$mkerrors -m64"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-freebsd_riscv64)
- mkerrors="$mkerrors -m64"
- mksysnum="go run mksysnum.go 'https://cgit.freebsd.org/src/plain/sys/kern/syscalls.master?h=stable/12'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-netbsd_386)
- mkerrors="$mkerrors -m32"
- mksyscall="go run mksyscall.go -l32 -netbsd"
- mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-netbsd_amd64)
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -netbsd"
- mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-netbsd_arm)
- mkerrors="$mkerrors"
- mksyscall="go run mksyscall.go -l32 -netbsd -arm"
- mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-netbsd_arm64)
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -netbsd"
- mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-openbsd_386)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m32"
- mksyscall="go run mksyscall.go -l32 -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-openbsd_amd64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-openbsd_arm)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors"
- mksyscall="go run mksyscall.go -l32 -openbsd -arm -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-openbsd_arm64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-openbsd_mips64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-openbsd_ppc64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-openbsd_riscv64)
- mkasm="go run mkasm.go"
- mkerrors="$mkerrors -m64"
- mksyscall="go run mksyscall.go -openbsd -libc"
- mksysctl="go run mksysctl_openbsd.go"
- # Let the type of C char be signed for making the bare syscall
- # API consistent across platforms.
- mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
- ;;
-solaris_amd64)
- mksyscall="go run mksyscall_solaris.go"
- mkerrors="$mkerrors -m64"
- mksysnum=
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-illumos_amd64)
- mksyscall="go run mksyscall_solaris.go"
- mkerrors=
- mksysnum=
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
-*)
- echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
- exit 1
- ;;
-esac
-
-(
- if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >$zerrors"; fi
- case "$GOOS" in
- *)
- syscall_goos="syscall_$GOOS.go"
- case "$GOOS" in
- darwin | dragonfly | freebsd | netbsd | openbsd)
- syscall_goos="syscall_bsd.go $syscall_goos"
- ;;
- esac
- if [ -n "$mksyscall" ]; then
- if [ "$GOOSARCH" == "aix_ppc64" ]; then
- # aix/ppc64 script generates files instead of writing to stdin.
- echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
- elif [ "$GOOS" == "illumos" ]; then
- # illumos code generation requires a --illumos switch
- echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go";
- # illumos implies solaris, so solaris code generation is also required
- echo "$mksyscall -tags solaris,$GOARCH syscall_solaris.go syscall_solaris_$GOARCH.go |gofmt >zsyscall_solaris_$GOARCH.go";
- else
- echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
- fi
- fi
- esac
- if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
- if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
- if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi
- if [ -n "$mkasm" ]; then echo "$mkasm $GOOS $GOARCH"; fi
-) | $run
diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh
deleted file mode 100644
index d07dd09..0000000
--- a/vendor/golang.org/x/sys/unix/mkerrors.sh
+++ /dev/null
@@ -1,792 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2009 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.
-
-# Generate Go code listing errors and other #defined constant
-# values (ENAMETOOLONG etc.), by asking the preprocessor
-# about the definitions.
-
-unset LANG
-export LC_ALL=C
-export LC_CTYPE=C
-
-if test -z "$GOARCH" -o -z "$GOOS"; then
- echo 1>&2 "GOARCH or GOOS not defined in environment"
- exit 1
-fi
-
-# Check that we are using the new build system if we should
-if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
- echo 1>&2 "In the Docker based build system, mkerrors should not be called directly."
- echo 1>&2 "See README.md"
- exit 1
-fi
-
-if [[ "$GOOS" = "aix" ]]; then
- CC=${CC:-gcc}
-else
- CC=${CC:-cc}
-fi
-
-if [[ "$GOOS" = "solaris" ]]; then
- # Assumes GNU versions of utilities in PATH.
- export PATH=/usr/gnu/bin:$PATH
-fi
-
-uname=$(uname)
-
-includes_AIX='
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define AF_LOCAL AF_UNIX
-'
-
-includes_Darwin='
-#define _DARWIN_C_SOURCE
-#define KERNEL 1
-#define _DARWIN_USE_64_BIT_INODE
-#define __APPLE_USE_RFC_3542
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// for backwards compatibility because moved TIOCREMOTE to Kernel.framework after MacOSX12.0.sdk.
-#define TIOCREMOTE 0x80047469
-'
-
-includes_DragonFly='
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-'
-
-includes_FreeBSD='
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#if __FreeBSD__ >= 10
-#define IFT_CARP 0xf8 // IFT_CARP is deprecated in FreeBSD 10
-#undef SIOCAIFADDR
-#define SIOCAIFADDR _IOW(105, 26, struct oifaliasreq) // ifaliasreq contains if_data
-#undef SIOCSIFPHYADDR
-#define SIOCSIFPHYADDR _IOW(105, 70, struct oifaliasreq) // ifaliasreq contains if_data
-#endif
-'
-
-includes_Linux='
-#define _LARGEFILE_SOURCE
-#define _LARGEFILE64_SOURCE
-#ifndef __LP64__
-#define _FILE_OFFSET_BITS 64
-#endif
-#define _GNU_SOURCE
-
-// is broken on powerpc64, as it fails to include definitions of
-// these structures. We just include them copied from .
-#if defined(__powerpc__)
-struct sgttyb {
- char sg_ispeed;
- char sg_ospeed;
- char sg_erase;
- char sg_kill;
- short sg_flags;
-};
-
-struct tchars {
- char t_intrc;
- char t_quitc;
- char t_startc;
- char t_stopc;
- char t_eofc;
- char t_brkc;
-};
-
-struct ltchars {
- char t_suspc;
- char t_dsuspc;
- char t_rprntc;
- char t_flushc;
- char t_werasc;
- char t_lnextc;
-};
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#if defined(__sparc__)
-// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the
-// definition in glibc. As only the error constants are needed here, include the
-// generic termibits.h (which is included by termbits.h on sparc).
-#include
-#else
-#include
-#endif
-
-#ifndef PTRACE_GETREGS
-#define PTRACE_GETREGS 0xc
-#endif
-
-#ifndef PTRACE_SETREGS
-#define PTRACE_SETREGS 0xd
-#endif
-
-#ifdef SOL_BLUETOOTH
-// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h
-// but it is already in bluetooth_linux.go
-#undef SOL_BLUETOOTH
-#endif
-
-// Certain constants are missing from the fs/crypto UAPI
-#define FS_KEY_DESC_PREFIX "fscrypt:"
-#define FS_KEY_DESC_PREFIX_SIZE 8
-#define FS_MAX_KEY_SIZE 64
-
-// The code generator produces -0x1 for (~0), but an unsigned value is necessary
-// for the tipc_subscr timeout __u32 field.
-#undef TIPC_WAIT_FOREVER
-#define TIPC_WAIT_FOREVER 0xffffffff
-
-// Copied from linux/netfilter/nf_nat.h
-// Including linux/netfilter/nf_nat.h here causes conflicts between linux/in.h
-// and netinet/in.h.
-#define NF_NAT_RANGE_MAP_IPS (1 << 0)
-#define NF_NAT_RANGE_PROTO_SPECIFIED (1 << 1)
-#define NF_NAT_RANGE_PROTO_RANDOM (1 << 2)
-#define NF_NAT_RANGE_PERSISTENT (1 << 3)
-#define NF_NAT_RANGE_PROTO_RANDOM_FULLY (1 << 4)
-#define NF_NAT_RANGE_PROTO_OFFSET (1 << 5)
-#define NF_NAT_RANGE_NETMAP (1 << 6)
-#define NF_NAT_RANGE_PROTO_RANDOM_ALL \
- (NF_NAT_RANGE_PROTO_RANDOM | NF_NAT_RANGE_PROTO_RANDOM_FULLY)
-#define NF_NAT_RANGE_MASK \
- (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED | \
- NF_NAT_RANGE_PROTO_RANDOM | NF_NAT_RANGE_PERSISTENT | \
- NF_NAT_RANGE_PROTO_RANDOM_FULLY | NF_NAT_RANGE_PROTO_OFFSET | \
- NF_NAT_RANGE_NETMAP)
-
-// Copied from linux/hid.h.
-// Keep in sync with the size of the referenced fields.
-#define _HIDIOCGRAWNAME_LEN 128 // sizeof_field(struct hid_device, name)
-#define _HIDIOCGRAWPHYS_LEN 64 // sizeof_field(struct hid_device, phys)
-#define _HIDIOCGRAWUNIQ_LEN 64 // sizeof_field(struct hid_device, uniq)
-
-#define _HIDIOCGRAWNAME HIDIOCGRAWNAME(_HIDIOCGRAWNAME_LEN)
-#define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN)
-#define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN)
-
-'
-
-includes_NetBSD='
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// Needed since refers to it...
-#define schedppq 1
-'
-
-includes_OpenBSD='
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include