TUN-8456: Update quic-go to 0.45 and collect mtu and congestion control metrics
This commit is contained in:
		
							parent
							
								
									cb6e5999e1
								
							
						
					
					
						commit
						0b62d45738
					
				| 
						 | 
					@ -47,7 +47,12 @@ class TestTail:
 | 
				
			||||||
            url = cfd_cli.get_management_wsurl("logs", config, config_path)
 | 
					            url = cfd_cli.get_management_wsurl("logs", config, config_path)
 | 
				
			||||||
            async with connect(url, open_timeout=5, close_timeout=5) as websocket:
 | 
					            async with connect(url, open_timeout=5, close_timeout=5) as websocket:
 | 
				
			||||||
                # send start_streaming
 | 
					                # send start_streaming
 | 
				
			||||||
                await websocket.send('{"type": "start_streaming"}')
 | 
					                await websocket.send(json.dumps({
 | 
				
			||||||
 | 
					                    "type": "start_streaming",
 | 
				
			||||||
 | 
					                    "filters": {
 | 
				
			||||||
 | 
					                        "events": ["http"]
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }))
 | 
				
			||||||
                # send some http requests to the tunnel to trigger some logs
 | 
					                # send some http requests to the tunnel to trigger some logs
 | 
				
			||||||
                await generate_and_validate_http_events(websocket, config.get_url(), 10)
 | 
					                await generate_and_validate_http_events(websocket, config.get_url(), 10)
 | 
				
			||||||
                # send stop_streaming
 | 
					                # send stop_streaming
 | 
				
			||||||
| 
						 | 
					@ -99,7 +104,8 @@ class TestTail:
 | 
				
			||||||
                await websocket.send(json.dumps({
 | 
					                await websocket.send(json.dumps({
 | 
				
			||||||
                    "type": "start_streaming",
 | 
					                    "type": "start_streaming",
 | 
				
			||||||
                    "filters": {
 | 
					                    "filters": {
 | 
				
			||||||
                        "sampling": 0.5
 | 
					                        "sampling": 0.5,
 | 
				
			||||||
 | 
					                        "events": ["http"]
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }))
 | 
					                }))
 | 
				
			||||||
                # don't expect any http logs
 | 
					                # don't expect any http logs
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										18
									
								
								go.mod
								
								
								
								
							| 
						 | 
					@ -23,9 +23,9 @@ require (
 | 
				
			||||||
	github.com/miekg/dns v1.1.50
 | 
						github.com/miekg/dns v1.1.50
 | 
				
			||||||
	github.com/mitchellh/go-homedir v1.1.0
 | 
						github.com/mitchellh/go-homedir v1.1.0
 | 
				
			||||||
	github.com/pkg/errors v0.9.1
 | 
						github.com/pkg/errors v0.9.1
 | 
				
			||||||
	github.com/prometheus/client_golang v1.13.0
 | 
						github.com/prometheus/client_golang v1.19.1
 | 
				
			||||||
	github.com/prometheus/client_model v0.2.0
 | 
						github.com/prometheus/client_model v0.5.0
 | 
				
			||||||
	github.com/quic-go/quic-go v0.42.0
 | 
						github.com/quic-go/quic-go v0.45.0
 | 
				
			||||||
	github.com/rs/zerolog v1.20.0
 | 
						github.com/rs/zerolog v1.20.0
 | 
				
			||||||
	github.com/stretchr/testify v1.9.0
 | 
						github.com/stretchr/testify v1.9.0
 | 
				
			||||||
	github.com/urfave/cli/v2 v2.3.0
 | 
						github.com/urfave/cli/v2 v2.3.0
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@ require (
 | 
				
			||||||
	go.uber.org/automaxprocs v1.4.0
 | 
						go.uber.org/automaxprocs v1.4.0
 | 
				
			||||||
	golang.org/x/crypto v0.23.0
 | 
						golang.org/x/crypto v0.23.0
 | 
				
			||||||
	golang.org/x/net v0.25.0
 | 
						golang.org/x/net v0.25.0
 | 
				
			||||||
	golang.org/x/sync v0.6.0
 | 
						golang.org/x/sync v0.7.0
 | 
				
			||||||
	golang.org/x/sys v0.20.0
 | 
						golang.org/x/sys v0.20.0
 | 
				
			||||||
	golang.org/x/term v0.20.0
 | 
						golang.org/x/term v0.20.0
 | 
				
			||||||
	google.golang.org/protobuf v1.34.1
 | 
						google.golang.org/protobuf v1.34.1
 | 
				
			||||||
| 
						 | 
					@ -80,16 +80,16 @@ require (
 | 
				
			||||||
	github.com/onsi/ginkgo/v2 v2.9.5 // indirect
 | 
						github.com/onsi/ginkgo/v2 v2.9.5 // indirect
 | 
				
			||||||
	github.com/opentracing/opentracing-go v1.2.0 // indirect
 | 
						github.com/opentracing/opentracing-go v1.2.0 // indirect
 | 
				
			||||||
	github.com/pmezard/go-difflib v1.0.0 // indirect
 | 
						github.com/pmezard/go-difflib v1.0.0 // indirect
 | 
				
			||||||
	github.com/prometheus/common v0.37.0 // indirect
 | 
						github.com/prometheus/common v0.48.0 // indirect
 | 
				
			||||||
	github.com/prometheus/procfs v0.8.0 // indirect
 | 
						github.com/prometheus/procfs v0.12.0 // indirect
 | 
				
			||||||
	github.com/russross/blackfriday/v2 v2.1.0 // indirect
 | 
						github.com/russross/blackfriday/v2 v2.1.0 // indirect
 | 
				
			||||||
	go.opentelemetry.io/otel/metric v1.26.0 // indirect
 | 
						go.opentelemetry.io/otel/metric v1.26.0 // indirect
 | 
				
			||||||
	go.uber.org/mock v0.4.0 // indirect
 | 
						go.uber.org/mock v0.4.0 // indirect
 | 
				
			||||||
	golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
 | 
						golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
 | 
				
			||||||
	golang.org/x/mod v0.11.0 // indirect
 | 
						golang.org/x/mod v0.17.0 // indirect
 | 
				
			||||||
	golang.org/x/oauth2 v0.17.0 // indirect
 | 
						golang.org/x/oauth2 v0.17.0 // indirect
 | 
				
			||||||
	golang.org/x/text v0.15.0 // indirect
 | 
						golang.org/x/text v0.15.0 // indirect
 | 
				
			||||||
	golang.org/x/tools v0.9.1 // indirect
 | 
						golang.org/x/tools v0.21.0 // indirect
 | 
				
			||||||
	google.golang.org/appengine v1.6.8 // indirect
 | 
						google.golang.org/appengine v1.6.8 // indirect
 | 
				
			||||||
	google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
 | 
						google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
 | 
				
			||||||
	google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
 | 
						google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										432
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										432
									
								
								go.sum
								
								
								
								
							| 
						 | 
					@ -1,61 +1,15 @@
 | 
				
			||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
 | 
					 | 
				
			||||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
 | 
					 | 
				
			||||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
 | 
					 | 
				
			||||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
 | 
					 | 
				
			||||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
 | 
					 | 
				
			||||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
 | 
					 | 
				
			||||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
 | 
					 | 
				
			||||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
 | 
					 | 
				
			||||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
 | 
					 | 
				
			||||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
 | 
					 | 
				
			||||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
 | 
					 | 
				
			||||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
 | 
					 | 
				
			||||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
 | 
					 | 
				
			||||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
 | 
					 | 
				
			||||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
 | 
					 | 
				
			||||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
 | 
					 | 
				
			||||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
 | 
					 | 
				
			||||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
 | 
					 | 
				
			||||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
 | 
					 | 
				
			||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
 | 
					 | 
				
			||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 | 
					github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 | 
				
			||||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
 | 
					github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
 | 
				
			||||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
 | 
					github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
 | 
				
			||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
 | 
					 | 
				
			||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 | 
					 | 
				
			||||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
 | 
					 | 
				
			||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
 | 
					 | 
				
			||||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
 | 
					 | 
				
			||||||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
 | 
					 | 
				
			||||||
github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU=
 | 
					github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU=
 | 
				
			||||||
github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
 | 
					github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
 | 
				
			||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
 | 
					 | 
				
			||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
 | 
					 | 
				
			||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
 | 
					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/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
 | 
				
			||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
 | 
					 | 
				
			||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
					 | 
				
			||||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
					 | 
				
			||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
 | 
					github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
 | 
				
			||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
					github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
 | 
				
			||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
 | 
					github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
 | 
				
			||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
 | 
					github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
 | 
				
			||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
 | 
					github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
 | 
				
			||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 | 
					 | 
				
			||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
 | 
					 | 
				
			||||||
github.com/coredns/caddy v1.1.1 h1:2eYKZT7i6yxIfGP3qLJoJ7HAsDJqYB+X68g4NYjSrE0=
 | 
					github.com/coredns/caddy v1.1.1 h1:2eYKZT7i6yxIfGP3qLJoJ7HAsDJqYB+X68g4NYjSrE0=
 | 
				
			||||||
github.com/coredns/caddy v1.1.1/go.mod h1:A6ntJQlAWuQfFlsd9hvigKbo2WS0VUs2l1e2F+BawD4=
 | 
					github.com/coredns/caddy v1.1.1/go.mod h1:A6ntJQlAWuQfFlsd9hvigKbo2WS0VUs2l1e2F+BawD4=
 | 
				
			||||||
github.com/coredns/coredns v1.10.0 h1:jCfuWsBjTs0dapkkhISfPCzn5LqvSRtrFtaf/Tjj4DI=
 | 
					github.com/coredns/coredns v1.10.0 h1:jCfuWsBjTs0dapkkhISfPCzn5LqvSRtrFtaf/Tjj4DI=
 | 
				
			||||||
| 
						 | 
					@ -72,10 +26,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
 | 
				
			||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
					github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
				
			||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 | 
					github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 | 
				
			||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
					github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
				
			||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
 | 
					 | 
				
			||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
 | 
					 | 
				
			||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
 | 
					 | 
				
			||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
 | 
					 | 
				
			||||||
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
 | 
					github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
 | 
				
			||||||
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
 | 
					github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
 | 
				
			||||||
github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9 h1:wWke/RUCl7VRjQhwPlR/v0glZXNYzBHdNUzf/Am2Nmg=
 | 
					github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9 h1:wWke/RUCl7VRjQhwPlR/v0glZXNYzBHdNUzf/Am2Nmg=
 | 
				
			||||||
| 
						 | 
					@ -105,19 +55,8 @@ github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
 | 
				
			||||||
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
 | 
					github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
 | 
				
			||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
 | 
					github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
 | 
				
			||||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
 | 
					github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
 | 
				
			||||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
 | 
					 | 
				
			||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
 | 
					 | 
				
			||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
 | 
					 | 
				
			||||||
github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U=
 | 
					github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U=
 | 
				
			||||||
github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
 | 
					github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
 | 
				
			||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
 | 
					 | 
				
			||||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
 | 
					 | 
				
			||||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
 | 
					 | 
				
			||||||
github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
 | 
					 | 
				
			||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
 | 
					 | 
				
			||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
 | 
					 | 
				
			||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
 | 
					 | 
				
			||||||
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
 | 
					 | 
				
			||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
 | 
					github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
 | 
				
			||||||
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
 | 
					github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
 | 
				
			||||||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
 | 
					github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
 | 
				
			||||||
| 
						 | 
					@ -133,7 +72,6 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl
 | 
				
			||||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
 | 
					github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
 | 
				
			||||||
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
 | 
					github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
 | 
				
			||||||
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
 | 
					github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
 | 
				
			||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
 | 
					 | 
				
			||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
 | 
					github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
 | 
				
			||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
 | 
					github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
 | 
				
			||||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
 | 
					github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
 | 
				
			||||||
| 
						 | 
					@ -148,48 +86,15 @@ github.com/gobwas/ws v1.0.4/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E
 | 
				
			||||||
github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
 | 
					github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
 | 
				
			||||||
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 | 
					github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 | 
				
			||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
 | 
					github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
 | 
				
			||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
 | 
					 | 
				
			||||||
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4=
 | 
					github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4=
 | 
				
			||||||
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3/go.mod h1:nPpo7qLxd6XL3hWJG/O60sR8ZKfMCiIoNap5GvD12KU=
 | 
					github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3/go.mod h1:nPpo7qLxd6XL3hWJG/O60sR8ZKfMCiIoNap5GvD12KU=
 | 
				
			||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
 | 
					 | 
				
			||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
 | 
					 | 
				
			||||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
 | 
					 | 
				
			||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
 | 
					 | 
				
			||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 | 
					 | 
				
			||||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
 | 
					 | 
				
			||||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
 | 
					 | 
				
			||||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
 | 
					 | 
				
			||||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
 | 
					 | 
				
			||||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
 | 
					 | 
				
			||||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
 | 
					github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
 | 
				
			||||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
 | 
					github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
 | 
				
			||||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
 | 
					 | 
				
			||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
 | 
					github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
 | 
				
			||||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
 | 
					github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
 | 
				
			||||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
 | 
					github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
 | 
				
			||||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
 | 
					github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
 | 
				
			||||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 | 
					 | 
				
			||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
 | 
					 | 
				
			||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
 | 
					 | 
				
			||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 | 
					 | 
				
			||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
 | 
					 | 
				
			||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
					github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
				
			||||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
					 | 
				
			||||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
					 | 
				
			||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
					 | 
				
			||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
					 | 
				
			||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
					github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
				
			||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
					github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 | 
				
			||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 | 
					github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 | 
				
			||||||
| 
						 | 
					@ -197,23 +102,11 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
 | 
				
			||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 | 
					github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 | 
				
			||||||
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
 | 
					github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
 | 
				
			||||||
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
 | 
					github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
 | 
				
			||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
 | 
					 | 
				
			||||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
 | 
					 | 
				
			||||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
 | 
					 | 
				
			||||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
 | 
					 | 
				
			||||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
 | 
					 | 
				
			||||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
 | 
					 | 
				
			||||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
 | 
					 | 
				
			||||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
 | 
					 | 
				
			||||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
 | 
					 | 
				
			||||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
 | 
					github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
 | 
				
			||||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
 | 
					github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
 | 
				
			||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
 | 
					 | 
				
			||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 | 
					github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 | 
				
			||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 | 
					github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
 | 
				
			||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 | 
					github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 | 
				
			||||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
 | 
					 | 
				
			||||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
 | 
					 | 
				
			||||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 | 
					github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 | 
				
			||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
 | 
					github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
 | 
				
			||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 | 
					github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
 | 
				
			||||||
| 
						 | 
					@ -221,30 +114,15 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0Q
 | 
				
			||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
 | 
					github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
 | 
				
			||||||
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU=
 | 
					github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU=
 | 
				
			||||||
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw=
 | 
					github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw=
 | 
				
			||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 | 
					 | 
				
			||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
 | 
					 | 
				
			||||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 | 
					 | 
				
			||||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 | 
					github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
 | 
				
			||||||
github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d h1:PRDnysJ9dF1vUMmEzBu6aHQeUluSQy4eWH3RsSSy/vI=
 | 
					github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d h1:PRDnysJ9dF1vUMmEzBu6aHQeUluSQy4eWH3RsSSy/vI=
 | 
				
			||||||
github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
 | 
					github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
 | 
				
			||||||
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
 | 
					 | 
				
			||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
 | 
					 | 
				
			||||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 | 
					github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 | 
				
			||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 | 
					 | 
				
			||||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 | 
					 | 
				
			||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 | 
					github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 | 
				
			||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
 | 
					github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
 | 
				
			||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
 | 
					 | 
				
			||||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
 | 
					 | 
				
			||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
 | 
					 | 
				
			||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
 | 
					 | 
				
			||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 | 
					 | 
				
			||||||
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
 | 
					github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
 | 
				
			||||||
github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
 | 
					github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
 | 
				
			||||||
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
 | 
					github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
 | 
				
			||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
					 | 
				
			||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 | 
					 | 
				
			||||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
 | 
					 | 
				
			||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 | 
					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 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
 | 
				
			||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
 | 
					github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
 | 
				
			||||||
| 
						 | 
					@ -272,11 +150,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
 | 
				
			||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
 | 
					github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
 | 
				
			||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 | 
					github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 | 
				
			||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 | 
					github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 | 
				
			||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 | 
					 | 
				
			||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
 | 
					github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
 | 
				
			||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
 | 
					github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
 | 
				
			||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
 | 
					 | 
				
			||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
 | 
					 | 
				
			||||||
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
 | 
					github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
 | 
				
			||||||
github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k=
 | 
					github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k=
 | 
				
			||||||
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
 | 
					github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
 | 
				
			||||||
| 
						 | 
					@ -289,40 +164,21 @@ github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ=
 | 
				
			||||||
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
 | 
					github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
 | 
				
			||||||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
 | 
					github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
 | 
				
			||||||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
 | 
					github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
 | 
				
			||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
					 | 
				
			||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
					github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
				
			||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
 | 
					github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
 | 
				
			||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
					github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 | 
				
			||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 | 
					github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 | 
				
			||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
					github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 | 
				
			||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
 | 
					github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
 | 
				
			||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
 | 
					github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
 | 
				
			||||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
 | 
					github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
 | 
				
			||||||
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
 | 
					github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
 | 
				
			||||||
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
 | 
					github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
 | 
				
			||||||
github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU=
 | 
					github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
 | 
				
			||||||
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
 | 
					github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
 | 
				
			||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
 | 
					github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
 | 
				
			||||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 | 
					github.com/quic-go/quic-go v0.45.0 h1:OHmkQGM37luZITyTSu6ff03HP/2IrwDX1ZFiNEhSFUE=
 | 
				
			||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 | 
					github.com/quic-go/quic-go v0.45.0/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI=
 | 
				
			||||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
 | 
					 | 
				
			||||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 | 
					 | 
				
			||||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
 | 
					 | 
				
			||||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
 | 
					 | 
				
			||||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
 | 
					 | 
				
			||||||
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
 | 
					 | 
				
			||||||
github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE=
 | 
					 | 
				
			||||||
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
 | 
					 | 
				
			||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
 | 
					 | 
				
			||||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
 | 
					 | 
				
			||||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
 | 
					 | 
				
			||||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
 | 
					 | 
				
			||||||
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
 | 
					 | 
				
			||||||
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
 | 
					 | 
				
			||||||
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
 | 
					 | 
				
			||||||
github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM=
 | 
					 | 
				
			||||||
github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M=
 | 
					 | 
				
			||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 | 
					 | 
				
			||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
 | 
					github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
 | 
				
			||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
 | 
					github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
 | 
				
			||||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
 | 
					github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
 | 
				
			||||||
| 
						 | 
					@ -332,12 +188,7 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
 | 
				
			||||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
 | 
					github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
 | 
				
			||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 | 
					github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 | 
				
			||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 | 
					github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 | 
				
			||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
 | 
					 | 
				
			||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
 | 
					 | 
				
			||||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
 | 
					 | 
				
			||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
					github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
				
			||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 | 
					 | 
				
			||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 | 
					 | 
				
			||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 | 
					github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 | 
				
			||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 | 
					github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 | 
				
			||||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
					github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
 | 
				
			||||||
| 
						 | 
					@ -351,16 +202,8 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM
 | 
				
			||||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
 | 
					github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
 | 
				
			||||||
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
 | 
					github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
 | 
				
			||||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
 | 
					github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
 | 
				
			||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
					 | 
				
			||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
					 | 
				
			||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 | 
					 | 
				
			||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 | 
					github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
 | 
				
			||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
 | 
					github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
 | 
				
			||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
 | 
					 | 
				
			||||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
 | 
					 | 
				
			||||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 | 
					 | 
				
			||||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 | 
					 | 
				
			||||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
 | 
					 | 
				
			||||||
go.opentelemetry.io/contrib/propagators v0.22.0 h1:KGdv58M2//veiYLIhb31mofaI2LgkIPXXAZVeYVyfd8=
 | 
					go.opentelemetry.io/contrib/propagators v0.22.0 h1:KGdv58M2//veiYLIhb31mofaI2LgkIPXXAZVeYVyfd8=
 | 
				
			||||||
go.opentelemetry.io/contrib/propagators v0.22.0/go.mod h1:xGOuXr6lLIF9BXipA4pm6UuOSI0M98U6tsI3khbOiwU=
 | 
					go.opentelemetry.io/contrib/propagators v0.22.0/go.mod h1:xGOuXr6lLIF9BXipA4pm6UuOSI0M98U6tsI3khbOiwU=
 | 
				
			||||||
go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM=
 | 
					go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM=
 | 
				
			||||||
| 
						 | 
					@ -381,153 +224,45 @@ go.uber.org/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0=
 | 
				
			||||||
go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q=
 | 
					go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q=
 | 
				
			||||||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
 | 
					go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
 | 
				
			||||||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
 | 
					go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 | 
					 | 
				
			||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 | 
					golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 | 
					 | 
				
			||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 | 
					 | 
				
			||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 | 
					golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 | 
				
			||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 | 
					 | 
				
			||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 | 
					golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 | 
				
			||||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
 | 
					golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
 | 
				
			||||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
 | 
					golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
 | 
				
			||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 | 
					golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
 | 
				
			||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 | 
					golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
 | 
				
			||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o=
 | 
					 | 
				
			||||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
 | 
					 | 
				
			||||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
 | 
					 | 
				
			||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 | 
					 | 
				
			||||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 | 
					golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
 | 
				
			||||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
 | 
					 | 
				
			||||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
 | 
					 | 
				
			||||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
 | 
					 | 
				
			||||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
 | 
					 | 
				
			||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
 | 
					golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
 | 
				
			||||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
 | 
					 | 
				
			||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 | 
					 | 
				
			||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 | 
					 | 
				
			||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 | 
					golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 | 
				
			||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
 | 
					golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
 | 
				
			||||||
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
 | 
					golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
 | 
				
			||||||
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 | 
					golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
 | 
				
			||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 | 
					golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 | 
				
			||||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
				
			||||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 | 
					golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 | 
				
			||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
 | 
					golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
 | 
				
			||||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 | 
					golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 | 
				
			||||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
 | 
					 | 
				
			||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 | 
					golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 | 
				
			||||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
 | 
					golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
 | 
				
			||||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
 | 
					golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
 | 
				
			||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 | 
					 | 
				
			||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 | 
					 | 
				
			||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 | 
					 | 
				
			||||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 | 
					 | 
				
			||||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 | 
					 | 
				
			||||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
 | 
					 | 
				
			||||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
 | 
					 | 
				
			||||||
golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
 | 
					golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
 | 
				
			||||||
golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
 | 
					golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
 | 
				
			||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					 | 
				
			||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					 | 
				
			||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					 | 
				
			||||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					 | 
				
			||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
				
			||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					 | 
				
			||||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					 | 
				
			||||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					 | 
				
			||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					 | 
				
			||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
				
			||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
					golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 | 
				
			||||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
 | 
					golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
 | 
				
			||||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 | 
					golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/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.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
					golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					 | 
				
			||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
					golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 | 
				
			||||||
| 
						 | 
					@ -537,9 +272,7 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
 | 
				
			||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 | 
					golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 | 
				
			||||||
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
 | 
					golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
 | 
				
			||||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
 | 
					golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
 | 
				
			||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
					 | 
				
			||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
					golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
				
			||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
					 | 
				
			||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
 | 
					golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
 | 
				
			||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
					golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
				
			||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
					golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 | 
				
			||||||
| 
						 | 
					@ -547,178 +280,49 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 | 
				
			||||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
 | 
					golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
 | 
				
			||||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
 | 
					golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
 | 
				
			||||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
 | 
					golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
 | 
				
			||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
					 | 
				
			||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
					 | 
				
			||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
					golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 | 
				
			||||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
 | 
					golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
 | 
				
			||||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
 | 
					golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
					golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
				
			||||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
 | 
					 | 
				
			||||||
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 | 
					golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 | 
				
			||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
 | 
					golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
 | 
				
			||||||
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
 | 
					golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
 | 
				
			||||||
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
 | 
					golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
				
			||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
					golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 | 
				
			||||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
 | 
					 | 
				
			||||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
 | 
					 | 
				
			||||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
 | 
					 | 
				
			||||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
 | 
					 | 
				
			||||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
 | 
					 | 
				
			||||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
 | 
					 | 
				
			||||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
 | 
					 | 
				
			||||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
 | 
					 | 
				
			||||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
 | 
					 | 
				
			||||||
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
 | 
					 | 
				
			||||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
 | 
					 | 
				
			||||||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
 | 
					 | 
				
			||||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
 | 
					 | 
				
			||||||
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
 | 
					 | 
				
			||||||
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
 | 
					 | 
				
			||||||
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
 | 
					 | 
				
			||||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 | 
					 | 
				
			||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
 | 
					 | 
				
			||||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
 | 
					 | 
				
			||||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
 | 
					 | 
				
			||||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
 | 
					 | 
				
			||||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
 | 
					 | 
				
			||||||
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
 | 
					google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
 | 
				
			||||||
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
 | 
					google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
 | 
				
			||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
 | 
					 | 
				
			||||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY=
 | 
					google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY=
 | 
				
			||||||
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
 | 
					google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
 | 
				
			||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0=
 | 
					google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0=
 | 
				
			||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8=
 | 
					google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8=
 | 
				
			||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
 | 
					google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
 | 
				
			||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
 | 
					google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
 | 
				
			||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
 | 
					 | 
				
			||||||
google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8=
 | 
					google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8=
 | 
				
			||||||
google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
 | 
					google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
 | 
				
			||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
 | 
					 | 
				
			||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
 | 
					google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
 | 
				
			||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
 | 
					google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
 | 
				
			||||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
 | 
					google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
 | 
				
			||||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
 | 
					google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
 | 
				
			||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
 | 
					 | 
				
			||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
					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-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
				
			||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 | 
					 | 
				
			||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
 | 
					gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
 | 
				
			||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
 | 
					gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
 | 
				
			||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
 | 
					 | 
				
			||||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
 | 
					gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
 | 
				
			||||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
 | 
					gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
 | 
				
			||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
					 | 
				
			||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
					gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
				
			||||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
					gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
				
			||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
					 | 
				
			||||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
					 | 
				
			||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
					gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
				
			||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 | 
					 | 
				
			||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
 | 
					gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
 | 
				
			||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 | 
					gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 | 
				
			||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 | 
					gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 | 
				
			||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
					gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 | 
				
			||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
					 | 
				
			||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
					 | 
				
			||||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
					 | 
				
			||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
 | 
					 | 
				
			||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 | 
					 | 
				
			||||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 | 
					 | 
				
			||||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 | 
					 | 
				
			||||||
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
 | 
					nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
 | 
				
			||||||
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
 | 
					nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
 | 
				
			||||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
 | 
					 | 
				
			||||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 | 
					 | 
				
			||||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
 | 
					 | 
				
			||||||
zombiezen.com/go/capnproto2 v2.18.0+incompatible h1:mwfXZniffG5mXokQGHUJWGnqIBggoPfT/CEwon9Yess=
 | 
					zombiezen.com/go/capnproto2 v2.18.0+incompatible h1:mwfXZniffG5mXokQGHUJWGnqIBggoPfT/CEwon9Yess=
 | 
				
			||||||
zombiezen.com/go/capnproto2 v2.18.0+incompatible/go.mod h1:XO5Pr2SbXgqZwn0m0Ru54QBqpOf4K5AYBO+8LAOBQEQ=
 | 
					zombiezen.com/go/capnproto2 v2.18.0+incompatible/go.mod h1:XO5Pr2SbXgqZwn0m0Ru54QBqpOf4K5AYBO+8LAOBQEQ=
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,6 +30,9 @@ var (
 | 
				
			||||||
		minRTT            *prometheus.GaugeVec
 | 
							minRTT            *prometheus.GaugeVec
 | 
				
			||||||
		latestRTT         *prometheus.GaugeVec
 | 
							latestRTT         *prometheus.GaugeVec
 | 
				
			||||||
		smoothedRTT       *prometheus.GaugeVec
 | 
							smoothedRTT       *prometheus.GaugeVec
 | 
				
			||||||
 | 
							mtu               *prometheus.GaugeVec
 | 
				
			||||||
 | 
							congestionWindow  *prometheus.GaugeVec
 | 
				
			||||||
 | 
							congestionState   *prometheus.GaugeVec
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		totalConnections: prometheus.NewCounter(
 | 
							totalConnections: prometheus.NewCounter(
 | 
				
			||||||
			prometheus.CounterOpts{
 | 
								prometheus.CounterOpts{
 | 
				
			||||||
| 
						 | 
					@ -146,6 +149,33 @@ var (
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			clientConnLabels,
 | 
								clientConnLabels,
 | 
				
			||||||
		),
 | 
							),
 | 
				
			||||||
 | 
							mtu: prometheus.NewGaugeVec(
 | 
				
			||||||
 | 
								prometheus.GaugeOpts{
 | 
				
			||||||
 | 
									Namespace: namespace,
 | 
				
			||||||
 | 
									Subsystem: "client",
 | 
				
			||||||
 | 
									Name:      "mtu",
 | 
				
			||||||
 | 
									Help:      "Current maximum transmission unit (MTU) of a connection",
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								clientConnLabels,
 | 
				
			||||||
 | 
							),
 | 
				
			||||||
 | 
							congestionWindow: prometheus.NewGaugeVec(
 | 
				
			||||||
 | 
								prometheus.GaugeOpts{
 | 
				
			||||||
 | 
									Namespace: namespace,
 | 
				
			||||||
 | 
									Subsystem: "client",
 | 
				
			||||||
 | 
									Name:      "congestion_window",
 | 
				
			||||||
 | 
									Help:      "Current congestion window size",
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								clientConnLabels,
 | 
				
			||||||
 | 
							),
 | 
				
			||||||
 | 
							congestionState: prometheus.NewGaugeVec(
 | 
				
			||||||
 | 
								prometheus.GaugeOpts{
 | 
				
			||||||
 | 
									Namespace: namespace,
 | 
				
			||||||
 | 
									Subsystem: "client",
 | 
				
			||||||
 | 
									Name:      "congestion_state",
 | 
				
			||||||
 | 
									Help:      "Current congestion control state. See https://pkg.go.dev/github.com/quic-go/quic-go@v0.45.0/logging#CongestionState for what each value maps to",
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								clientConnLabels,
 | 
				
			||||||
 | 
							),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	registerClient = sync.Once{}
 | 
						registerClient = sync.Once{}
 | 
				
			||||||
| 
						 | 
					@ -179,6 +209,9 @@ func newClientCollector(index string, logger *zerolog.Logger) *clientCollector {
 | 
				
			||||||
			clientMetrics.minRTT,
 | 
								clientMetrics.minRTT,
 | 
				
			||||||
			clientMetrics.latestRTT,
 | 
								clientMetrics.latestRTT,
 | 
				
			||||||
			clientMetrics.smoothedRTT,
 | 
								clientMetrics.smoothedRTT,
 | 
				
			||||||
 | 
								clientMetrics.mtu,
 | 
				
			||||||
 | 
								clientMetrics.congestionWindow,
 | 
				
			||||||
 | 
								clientMetrics.congestionState,
 | 
				
			||||||
			packetTooBigDropped,
 | 
								packetTooBigDropped,
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
| 
						 | 
					@ -232,6 +265,19 @@ func (cc *clientCollector) updatedRTT(rtt *logging.RTTStats) {
 | 
				
			||||||
	clientMetrics.smoothedRTT.WithLabelValues(cc.index).Set(durationToPromGauge(rtt.SmoothedRTT()))
 | 
						clientMetrics.smoothedRTT.WithLabelValues(cc.index).Set(durationToPromGauge(rtt.SmoothedRTT()))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (cc *clientCollector) updateCongestionWindow(size logging.ByteCount) {
 | 
				
			||||||
 | 
						clientMetrics.congestionWindow.WithLabelValues(cc.index).Set(float64(size))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (cc *clientCollector) updatedCongestionState(state logging.CongestionState) {
 | 
				
			||||||
 | 
						clientMetrics.congestionState.WithLabelValues(cc.index).Set(float64(state))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (cc *clientCollector) updateMTU(mtu logging.ByteCount) {
 | 
				
			||||||
 | 
						clientMetrics.mtu.WithLabelValues(cc.index).Set(float64(mtu))
 | 
				
			||||||
 | 
						cc.logger.Debug().Msgf("QUIC MTU updated to %d", mtu)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (cc *clientCollector) collectPackets(size logging.ByteCount, frames []logging.Frame, counter, bandwidth *prometheus.CounterVec, direction direction) {
 | 
					func (cc *clientCollector) collectPackets(size logging.ByteCount, frames []logging.Frame, counter, bandwidth *prometheus.CounterVec, direction direction) {
 | 
				
			||||||
	for _, frame := range frames {
 | 
						for _, frame := range frames {
 | 
				
			||||||
		switch f := frame.(type) {
 | 
							switch f := frame.(type) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +47,8 @@ func newConnTracer(metricsCollector *clientCollector) *logging.ConnectionTracer
 | 
				
			||||||
		DroppedPacket:               tracer.DroppedPacket,
 | 
							DroppedPacket:               tracer.DroppedPacket,
 | 
				
			||||||
		UpdatedMetrics:              tracer.UpdatedMetrics,
 | 
							UpdatedMetrics:              tracer.UpdatedMetrics,
 | 
				
			||||||
		LostPacket:                  tracer.LostPacket,
 | 
							LostPacket:                  tracer.LostPacket,
 | 
				
			||||||
 | 
							UpdatedMTU:                  tracer.UpdatedMTU,
 | 
				
			||||||
 | 
							UpdatedCongestionState:      tracer.UpdatedCongestionState,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,6 +78,7 @@ func (ct *connTracer) LostPacket(level logging.EncryptionLevel, number logging.P
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ct *connTracer) UpdatedMetrics(rttStats *logging.RTTStats, cwnd, bytesInFlight logging.ByteCount, packetsInFlight int) {
 | 
					func (ct *connTracer) UpdatedMetrics(rttStats *logging.RTTStats, cwnd, bytesInFlight logging.ByteCount, packetsInFlight int) {
 | 
				
			||||||
	ct.metricsCollector.updatedRTT(rttStats)
 | 
						ct.metricsCollector.updatedRTT(rttStats)
 | 
				
			||||||
 | 
						ct.metricsCollector.updateCongestionWindow(cwnd)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ct *connTracer) SentLongHeaderPacket(hdr *logging.ExtendedHeader, size logging.ByteCount, ecn logging.ECN, ack *logging.AckFrame, frames []logging.Frame) {
 | 
					func (ct *connTracer) SentLongHeaderPacket(hdr *logging.ExtendedHeader, size logging.ByteCount, ecn logging.ECN, ack *logging.AckFrame, frames []logging.Frame) {
 | 
				
			||||||
| 
						 | 
					@ -93,3 +96,11 @@ func (ct *connTracer) ReceivedLongHeaderPacket(hdr *logging.ExtendedHeader, size
 | 
				
			||||||
func (ct *connTracer) ReceivedShortHeaderPacket(hdr *logging.ShortHeader, size logging.ByteCount, ecn logging.ECN, frames []logging.Frame) {
 | 
					func (ct *connTracer) ReceivedShortHeaderPacket(hdr *logging.ShortHeader, size logging.ByteCount, ecn logging.ECN, frames []logging.Frame) {
 | 
				
			||||||
	ct.metricsCollector.receivedPackets(size, frames)
 | 
						ct.metricsCollector.receivedPackets(size, frames)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (ct *connTracer) UpdatedMTU(mtu logging.ByteCount, done bool) {
 | 
				
			||||||
 | 
						ct.metricsCollector.updateMTU(mtu)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (ct *connTracer) UpdatedCongestionState(state logging.CongestionState) {
 | 
				
			||||||
 | 
						ct.metricsCollector.updatedCongestionState(state)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -569,6 +569,13 @@ func (e *EdgeTunnelServer) serveQUIC(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tlsConfig.CurvePreferences = curvePref
 | 
						tlsConfig.CurvePreferences = curvePref
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// quic-go 0.44 increases the initial packet size to 1280 by default. That breaks anyone running tunnel through WARP
 | 
				
			||||||
 | 
						// because WARP MTU is 1280.
 | 
				
			||||||
 | 
						var initialPacketSize uint16 = 1252
 | 
				
			||||||
 | 
						if edgeAddr.IP.To4() == nil {
 | 
				
			||||||
 | 
							initialPacketSize = 1232
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	quicConfig := &quic.Config{
 | 
						quicConfig := &quic.Config{
 | 
				
			||||||
		HandshakeIdleTimeout:       quicpogs.HandshakeIdleTimeout,
 | 
							HandshakeIdleTimeout:       quicpogs.HandshakeIdleTimeout,
 | 
				
			||||||
		MaxIdleTimeout:             quicpogs.MaxIdleTimeout,
 | 
							MaxIdleTimeout:             quicpogs.MaxIdleTimeout,
 | 
				
			||||||
| 
						 | 
					@ -580,6 +587,7 @@ func (e *EdgeTunnelServer) serveQUIC(
 | 
				
			||||||
		DisablePathMTUDiscovery:    e.config.DisableQUICPathMTUDiscovery,
 | 
							DisablePathMTUDiscovery:    e.config.DisableQUICPathMTUDiscovery,
 | 
				
			||||||
		MaxConnectionReceiveWindow: e.config.QUICConnectionLevelFlowControlLimit,
 | 
							MaxConnectionReceiveWindow: e.config.QUICConnectionLevelFlowControlLimit,
 | 
				
			||||||
		MaxStreamReceiveWindow:     e.config.QUICStreamLevelFlowControlLimit,
 | 
							MaxStreamReceiveWindow:     e.config.QUICStreamLevelFlowControlLimit,
 | 
				
			||||||
 | 
							InitialPacketSize:          initialPacketSize,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	quicConn, err := connection.NewQUICConnection(
 | 
						quicConn, err := connection.NewQUICConnection(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,64 +0,0 @@
 | 
				
			||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
 | 
					 | 
				
			||||||
// source: github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
package timestamp
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Symbols defined in public import of google/protobuf/timestamp.proto.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type Timestamp = timestamppb.Timestamp
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto protoreflect.FileDescriptor
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc = []byte{
 | 
					 | 
				
			||||||
	0x0a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 | 
					 | 
				
			||||||
	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
 | 
					 | 
				
			||||||
	0x70, 0x65, 0x73, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x74, 0x69,
 | 
					 | 
				
			||||||
	0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 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, 0x42, 0x37,
 | 
					 | 
				
			||||||
	0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
 | 
					 | 
				
			||||||
	0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
 | 
					 | 
				
			||||||
	0x70, 0x65, 0x73, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x3b, 0x74, 0x69,
 | 
					 | 
				
			||||||
	0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
 | 
					 | 
				
			||||||
	0x33,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes = []interface{}{}
 | 
					 | 
				
			||||||
var file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs = []int32{
 | 
					 | 
				
			||||||
	0, // [0:0] is the sub-list for method output_type
 | 
					 | 
				
			||||||
	0, // [0:0] is the sub-list for method input_type
 | 
					 | 
				
			||||||
	0, // [0:0] is the sub-list for extension type_name
 | 
					 | 
				
			||||||
	0, // [0:0] is the sub-list for extension extendee
 | 
					 | 
				
			||||||
	0, // [0:0] is the sub-list for field type_name
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func init() { file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_init() }
 | 
					 | 
				
			||||||
func file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_init() {
 | 
					 | 
				
			||||||
	if File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto != nil {
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	type x struct{}
 | 
					 | 
				
			||||||
	out := protoimpl.TypeBuilder{
 | 
					 | 
				
			||||||
		File: protoimpl.DescBuilder{
 | 
					 | 
				
			||||||
			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 | 
					 | 
				
			||||||
			RawDescriptor: file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc,
 | 
					 | 
				
			||||||
			NumEnums:      0,
 | 
					 | 
				
			||||||
			NumMessages:   0,
 | 
					 | 
				
			||||||
			NumExtensions: 0,
 | 
					 | 
				
			||||||
			NumServices:   0,
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
		GoTypes:           file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes,
 | 
					 | 
				
			||||||
		DependencyIndexes: file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs,
 | 
					 | 
				
			||||||
	}.Build()
 | 
					 | 
				
			||||||
	File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto = out.File
 | 
					 | 
				
			||||||
	file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc = nil
 | 
					 | 
				
			||||||
	file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes = nil
 | 
					 | 
				
			||||||
	file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs = nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,7 @@ import (
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
						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
 | 
					// Counter is a Metric that represents a single numerical value that only ever
 | 
				
			||||||
| 
						 | 
					@ -59,6 +60,18 @@ type ExemplarAdder interface {
 | 
				
			||||||
// CounterOpts is an alias for Opts. See there for doc comments.
 | 
					// CounterOpts is an alias for Opts. See there for doc comments.
 | 
				
			||||||
type CounterOpts Opts
 | 
					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.
 | 
					// NewCounter creates a new Counter based on the provided CounterOpts.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// The returned implementation also implements ExemplarAdder. It is safe to
 | 
					// The returned implementation also implements ExemplarAdder. It is safe to
 | 
				
			||||||
| 
						 | 
					@ -78,8 +91,12 @@ func NewCounter(opts CounterOpts) Counter {
 | 
				
			||||||
		nil,
 | 
							nil,
 | 
				
			||||||
		opts.ConstLabels,
 | 
							opts.ConstLabels,
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	result := &counter{desc: desc, labelPairs: desc.constLabelPairs, now: time.Now}
 | 
						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.init(result) // Init self-collection.
 | 
				
			||||||
 | 
						result.createdTs = timestamppb.New(opts.now())
 | 
				
			||||||
	return result
 | 
						return result
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,10 +111,12 @@ type counter struct {
 | 
				
			||||||
	selfCollector
 | 
						selfCollector
 | 
				
			||||||
	desc *Desc
 | 
						desc *Desc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						createdTs  *timestamppb.Timestamp
 | 
				
			||||||
	labelPairs []*dto.LabelPair
 | 
						labelPairs []*dto.LabelPair
 | 
				
			||||||
	exemplar   atomic.Value // Containing nil or a *dto.Exemplar.
 | 
						exemplar   atomic.Value // Containing nil or a *dto.Exemplar.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	now func() time.Time // To mock out time.Now() for testing.
 | 
						// now is for testing purposes, by default it's time.Now.
 | 
				
			||||||
 | 
						now func() time.Time
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *counter) Desc() *Desc {
 | 
					func (c *counter) Desc() *Desc {
 | 
				
			||||||
| 
						 | 
					@ -140,14 +159,14 @@ func (c *counter) get() float64 {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *counter) Write(out *dto.Metric) error {
 | 
					func (c *counter) Write(out *dto.Metric) error {
 | 
				
			||||||
	val := c.get()
 | 
						// 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
 | 
						var exemplar *dto.Exemplar
 | 
				
			||||||
	if e := c.exemplar.Load(); e != nil {
 | 
						if e := c.exemplar.Load(); e != nil {
 | 
				
			||||||
		exemplar = e.(*dto.Exemplar)
 | 
							exemplar = e.(*dto.Exemplar)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						val := c.get()
 | 
				
			||||||
	return populateMetric(CounterValue, val, c.labelPairs, exemplar, out)
 | 
						return populateMetric(CounterValue, val, c.labelPairs, exemplar, out, c.createdTs)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *counter) updateExemplar(v float64, l Labels) {
 | 
					func (c *counter) updateExemplar(v float64, l Labels) {
 | 
				
			||||||
| 
						 | 
					@ -173,19 +192,31 @@ type CounterVec struct {
 | 
				
			||||||
// NewCounterVec creates a new CounterVec based on the provided CounterOpts and
 | 
					// NewCounterVec creates a new CounterVec based on the provided CounterOpts and
 | 
				
			||||||
// partitioned by the given label names.
 | 
					// partitioned by the given label names.
 | 
				
			||||||
func NewCounterVec(opts CounterOpts, labelNames []string) *CounterVec {
 | 
					func NewCounterVec(opts CounterOpts, labelNames []string) *CounterVec {
 | 
				
			||||||
	desc := NewDesc(
 | 
						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),
 | 
							BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
 | 
				
			||||||
		opts.Help,
 | 
							opts.Help,
 | 
				
			||||||
		labelNames,
 | 
							opts.VariableLabels,
 | 
				
			||||||
		opts.ConstLabels,
 | 
							opts.ConstLabels,
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
						if opts.now == nil {
 | 
				
			||||||
 | 
							opts.now = time.Now
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return &CounterVec{
 | 
						return &CounterVec{
 | 
				
			||||||
		MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
 | 
							MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
 | 
				
			||||||
			if len(lvs) != len(desc.variableLabels) {
 | 
								if len(lvs) != len(desc.variableLabels.names) {
 | 
				
			||||||
				panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs))
 | 
									panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.names, lvs))
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			result := &counter{desc: desc, labelPairs: MakeLabelPairs(desc, lvs), now: time.Now}
 | 
								result := &counter{desc: desc, labelPairs: MakeLabelPairs(desc, lvs), now: opts.now}
 | 
				
			||||||
			result.init(result) // Init self-collection.
 | 
								result.init(result) // Init self-collection.
 | 
				
			||||||
 | 
								result.createdTs = timestamppb.New(opts.now())
 | 
				
			||||||
			return result
 | 
								return result
 | 
				
			||||||
		}),
 | 
							}),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -245,7 +276,8 @@ func (v *CounterVec) GetMetricWith(labels Labels) (Counter, error) {
 | 
				
			||||||
// WithLabelValues works as GetMetricWithLabelValues, but panics where
 | 
					// WithLabelValues works as GetMetricWithLabelValues, but panics where
 | 
				
			||||||
// GetMetricWithLabelValues would have returned an error. Not returning an
 | 
					// GetMetricWithLabelValues would have returned an error. Not returning an
 | 
				
			||||||
// error allows shortcuts like
 | 
					// error allows shortcuts like
 | 
				
			||||||
//     myVec.WithLabelValues("404", "GET").Add(42)
 | 
					//
 | 
				
			||||||
 | 
					//	myVec.WithLabelValues("404", "GET").Add(42)
 | 
				
			||||||
func (v *CounterVec) WithLabelValues(lvs ...string) Counter {
 | 
					func (v *CounterVec) WithLabelValues(lvs ...string) Counter {
 | 
				
			||||||
	c, err := v.GetMetricWithLabelValues(lvs...)
 | 
						c, err := v.GetMetricWithLabelValues(lvs...)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -256,7 +288,8 @@ func (v *CounterVec) WithLabelValues(lvs ...string) Counter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// With works as GetMetricWith, but panics where GetMetricWithLabels would have
 | 
					// With works as GetMetricWith, but panics where GetMetricWithLabels would have
 | 
				
			||||||
// returned an error. Not returning an error allows shortcuts like
 | 
					// returned an error. Not returning an error allows shortcuts like
 | 
				
			||||||
//     myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42)
 | 
					//
 | 
				
			||||||
 | 
					//	myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42)
 | 
				
			||||||
func (v *CounterVec) With(labels Labels) Counter {
 | 
					func (v *CounterVec) With(labels Labels) Counter {
 | 
				
			||||||
	c, err := v.GetMetricWith(labels)
 | 
						c, err := v.GetMetricWith(labels)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,20 +14,16 @@
 | 
				
			||||||
package prometheus
 | 
					package prometheus
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
					 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/cespare/xxhash/v2"
 | 
						"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"
 | 
						"github.com/prometheus/client_golang/prometheus/internal"
 | 
				
			||||||
 | 
					 | 
				
			||||||
	//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
					 | 
				
			||||||
	"github.com/golang/protobuf/proto"
 | 
					 | 
				
			||||||
	"github.com/prometheus/common/model"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Desc is the descriptor used by every Prometheus Metric. It is essentially
 | 
					// Desc is the descriptor used by every Prometheus Metric. It is essentially
 | 
				
			||||||
| 
						 | 
					@ -54,9 +50,9 @@ type Desc struct {
 | 
				
			||||||
	// constLabelPairs contains precalculated DTO label pairs based on
 | 
						// constLabelPairs contains precalculated DTO label pairs based on
 | 
				
			||||||
	// the constant labels.
 | 
						// the constant labels.
 | 
				
			||||||
	constLabelPairs []*dto.LabelPair
 | 
						constLabelPairs []*dto.LabelPair
 | 
				
			||||||
	// variableLabels contains names of labels for which the metric
 | 
						// variableLabels contains names of labels and normalization function for
 | 
				
			||||||
	// maintains variable values.
 | 
						// which the metric maintains variable values.
 | 
				
			||||||
	variableLabels []string
 | 
						variableLabels *compiledLabels
 | 
				
			||||||
	// id is a hash of the values of the ConstLabels and fqName. This
 | 
						// id is a hash of the values of the ConstLabels and fqName. This
 | 
				
			||||||
	// must be unique among all registered descriptors and can therefore be
 | 
						// must be unique among all registered descriptors and can therefore be
 | 
				
			||||||
	// used as an identifier of the descriptor.
 | 
						// used as an identifier of the descriptor.
 | 
				
			||||||
| 
						 | 
					@ -80,10 +76,24 @@ type Desc struct {
 | 
				
			||||||
// For constLabels, the label values are constant. Therefore, they are fully
 | 
					// For constLabels, the label values are constant. Therefore, they are fully
 | 
				
			||||||
// specified in the Desc. See the Collector example for a usage pattern.
 | 
					// specified in the Desc. See the Collector example for a usage pattern.
 | 
				
			||||||
func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *Desc {
 | 
					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{
 | 
						d := &Desc{
 | 
				
			||||||
		fqName:         fqName,
 | 
							fqName:         fqName,
 | 
				
			||||||
		help:           help,
 | 
							help:           help,
 | 
				
			||||||
		variableLabels: variableLabels,
 | 
							variableLabels: variableLabels.compile(),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if !model.IsValidMetricName(model.LabelValue(fqName)) {
 | 
						if !model.IsValidMetricName(model.LabelValue(fqName)) {
 | 
				
			||||||
		d.err = fmt.Errorf("%q is not a valid metric name", fqName)
 | 
							d.err = fmt.Errorf("%q is not a valid metric name", fqName)
 | 
				
			||||||
| 
						 | 
					@ -93,7 +103,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
 | 
				
			||||||
	// their sorted label names) plus the fqName (at position 0).
 | 
						// their sorted label names) plus the fqName (at position 0).
 | 
				
			||||||
	labelValues := make([]string, 1, len(constLabels)+1)
 | 
						labelValues := make([]string, 1, len(constLabels)+1)
 | 
				
			||||||
	labelValues[0] = fqName
 | 
						labelValues[0] = fqName
 | 
				
			||||||
	labelNames := make([]string, 0, len(constLabels)+len(variableLabels))
 | 
						labelNames := make([]string, 0, len(constLabels)+len(d.variableLabels.names))
 | 
				
			||||||
	labelNameSet := map[string]struct{}{}
 | 
						labelNameSet := map[string]struct{}{}
 | 
				
			||||||
	// First add only the const label names and sort them...
 | 
						// First add only the const label names and sort them...
 | 
				
			||||||
	for labelName := range constLabels {
 | 
						for labelName := range constLabels {
 | 
				
			||||||
| 
						 | 
					@ -118,16 +128,16 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
 | 
				
			||||||
	// Now add the variable label names, but prefix them with something that
 | 
						// Now add the variable label names, but prefix them with something that
 | 
				
			||||||
	// cannot be in a regular label name. That prevents matching the label
 | 
						// cannot be in a regular label name. That prevents matching the label
 | 
				
			||||||
	// dimension with a different mix between preset and variable labels.
 | 
						// dimension with a different mix between preset and variable labels.
 | 
				
			||||||
	for _, labelName := range variableLabels {
 | 
						for _, label := range d.variableLabels.names {
 | 
				
			||||||
		if !checkLabelName(labelName) {
 | 
							if !checkLabelName(label) {
 | 
				
			||||||
			d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName)
 | 
								d.err = fmt.Errorf("%q is not a valid label name for metric %q", label, fqName)
 | 
				
			||||||
			return d
 | 
								return d
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		labelNames = append(labelNames, "$"+labelName)
 | 
							labelNames = append(labelNames, "$"+label)
 | 
				
			||||||
		labelNameSet[labelName] = struct{}{}
 | 
							labelNameSet[label] = struct{}{}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(labelNames) != len(labelNameSet) {
 | 
						if len(labelNames) != len(labelNameSet) {
 | 
				
			||||||
		d.err = errors.New("duplicate label names")
 | 
							d.err = fmt.Errorf("duplicate label names in constant and variable labels for metric %q", fqName)
 | 
				
			||||||
		return d
 | 
							return d
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,11 +189,19 @@ func (d *Desc) String() string {
 | 
				
			||||||
			fmt.Sprintf("%s=%q", lp.GetName(), lp.GetValue()),
 | 
								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(
 | 
						return fmt.Sprintf(
 | 
				
			||||||
		"Desc{fqName: %q, help: %q, constLabels: {%s}, variableLabels: %v}",
 | 
							"Desc{fqName: %q, help: %q, constLabels: {%s}, variableLabels: {%s}}",
 | 
				
			||||||
		d.fqName,
 | 
							d.fqName,
 | 
				
			||||||
		d.help,
 | 
							d.help,
 | 
				
			||||||
		strings.Join(lpStrings, ","),
 | 
							strings.Join(lpStrings, ","),
 | 
				
			||||||
		d.variableLabels,
 | 
							strings.Join(vlStrings, ","),
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,55 +21,66 @@
 | 
				
			||||||
// All exported functions and methods are safe to be used concurrently unless
 | 
					// All exported functions and methods are safe to be used concurrently unless
 | 
				
			||||||
// specified otherwise.
 | 
					// specified otherwise.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// A Basic Example
 | 
					// # A Basic Example
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// As a starting point, a very basic usage example:
 | 
					// As a starting point, a very basic usage example:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    package main
 | 
					//	package main
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    import (
 | 
					//	import (
 | 
				
			||||||
//    	"log"
 | 
					//		"log"
 | 
				
			||||||
//    	"net/http"
 | 
					//		"net/http"
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    	"github.com/prometheus/client_golang/prometheus"
 | 
					//		"github.com/prometheus/client_golang/prometheus"
 | 
				
			||||||
//    	"github.com/prometheus/client_golang/prometheus/promhttp"
 | 
					//		"github.com/prometheus/client_golang/prometheus/promhttp"
 | 
				
			||||||
//    )
 | 
					//	)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    var (
 | 
					//	type metrics struct {
 | 
				
			||||||
//    	cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{
 | 
					//		cpuTemp  prometheus.Gauge
 | 
				
			||||||
//    		Name: "cpu_temperature_celsius",
 | 
					//		hdFailures *prometheus.CounterVec
 | 
				
			||||||
//    		Help: "Current temperature of the CPU.",
 | 
					//	}
 | 
				
			||||||
//    	})
 | 
					 | 
				
			||||||
//    	hdFailures = prometheus.NewCounterVec(
 | 
					 | 
				
			||||||
//    		prometheus.CounterOpts{
 | 
					 | 
				
			||||||
//    			Name: "hd_errors_total",
 | 
					 | 
				
			||||||
//    			Help: "Number of hard-disk errors.",
 | 
					 | 
				
			||||||
//    		},
 | 
					 | 
				
			||||||
//    		[]string{"device"},
 | 
					 | 
				
			||||||
//    	)
 | 
					 | 
				
			||||||
//    )
 | 
					 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    func init() {
 | 
					//	func NewMetrics(reg prometheus.Registerer) *metrics {
 | 
				
			||||||
//    	// Metrics have to be registered to be exposed:
 | 
					//		m := &metrics{
 | 
				
			||||||
//    	prometheus.MustRegister(cpuTemp)
 | 
					//			cpuTemp: prometheus.NewGauge(prometheus.GaugeOpts{
 | 
				
			||||||
//    	prometheus.MustRegister(hdFailures)
 | 
					//				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() {
 | 
					//	func main() {
 | 
				
			||||||
//    	cpuTemp.Set(65.3)
 | 
					//		// Create a non-global registry.
 | 
				
			||||||
//    	hdFailures.With(prometheus.Labels{"device":"/dev/sda"}).Inc()
 | 
					//		reg := prometheus.NewRegistry()
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    	// The Handler function provides a default handler to expose metrics
 | 
					//		// Create new metrics and register them using the custom registry.
 | 
				
			||||||
//    	// via an HTTP server. "/metrics" is the usual endpoint for that.
 | 
					//		m := NewMetrics(reg)
 | 
				
			||||||
//    	http.Handle("/metrics", promhttp.Handler())
 | 
					//		// Set values for the new created metrics.
 | 
				
			||||||
//    	log.Fatal(http.ListenAndServe(":8080", nil))
 | 
					//		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,
 | 
					// 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.
 | 
					// 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
 | 
					// # Metrics
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// The number of exported identifiers in this package might appear a bit
 | 
					// The number of exported identifiers in this package might appear a bit
 | 
				
			||||||
// overwhelming. However, in addition to the basic plumbing shown in the example
 | 
					// overwhelming. However, in addition to the basic plumbing shown in the example
 | 
				
			||||||
| 
						 | 
					@ -100,7 +111,7 @@
 | 
				
			||||||
// To create instances of Metrics and their vector versions, you need a suitable
 | 
					// To create instances of Metrics and their vector versions, you need a suitable
 | 
				
			||||||
// …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, or HistogramOpts.
 | 
					// …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, or HistogramOpts.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Custom Collectors and constant Metrics
 | 
					// # Custom Collectors and constant Metrics
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// While you could create your own implementations of Metric, most likely you
 | 
					// 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
 | 
					// will only ever implement the Collector interface on your own. At a first
 | 
				
			||||||
| 
						 | 
					@ -141,7 +152,7 @@
 | 
				
			||||||
// a metric, GaugeFunc, CounterFunc, or UntypedFunc might be interesting
 | 
					// a metric, GaugeFunc, CounterFunc, or UntypedFunc might be interesting
 | 
				
			||||||
// shortcuts.
 | 
					// shortcuts.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Advanced Uses of the Registry
 | 
					// # Advanced Uses of the Registry
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// While MustRegister is the by far most common way of registering a Collector,
 | 
					// 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.
 | 
					// sometimes you might want to handle the errors the registration might cause.
 | 
				
			||||||
| 
						 | 
					@ -176,23 +187,23 @@
 | 
				
			||||||
// NewProcessCollector). With a custom registry, you are in control and decide
 | 
					// NewProcessCollector). With a custom registry, you are in control and decide
 | 
				
			||||||
// yourself about the Collectors to register.
 | 
					// yourself about the Collectors to register.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// HTTP Exposition
 | 
					// # HTTP Exposition
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// The Registry implements the Gatherer interface. The caller of the Gather
 | 
					// The Registry implements the Gatherer interface. The caller of the Gather
 | 
				
			||||||
// method can then expose the gathered metrics in some way. Usually, the metrics
 | 
					// 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
 | 
					// 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.
 | 
					// above. The tools to expose metrics via HTTP are in the promhttp sub-package.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Pushing to the Pushgateway
 | 
					// # Pushing to the Pushgateway
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Function for pushing to the Pushgateway can be found in the push sub-package.
 | 
					// Function for pushing to the Pushgateway can be found in the push sub-package.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Graphite Bridge
 | 
					// # Graphite Bridge
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Functions and examples to push metrics from a Gatherer to Graphite can be
 | 
					// Functions and examples to push metrics from a Gatherer to Graphite can be
 | 
				
			||||||
// found in the graphite sub-package.
 | 
					// found in the graphite sub-package.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Other Means of Exposition
 | 
					// # Other Means of Exposition
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// More ways of exposing metrics can easily be added by following the approaches
 | 
					// More ways of exposing metrics can easily be added by following the approaches
 | 
				
			||||||
// of the existing implementations.
 | 
					// of the existing implementations.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ func (e *expvarCollector) Collect(ch chan<- Metric) {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		var v interface{}
 | 
							var v interface{}
 | 
				
			||||||
		labels := make([]string, len(desc.variableLabels))
 | 
							labels := make([]string, len(desc.variableLabels.names))
 | 
				
			||||||
		if err := json.Unmarshal([]byte(expVar.String()), &v); err != nil {
 | 
							if err := json.Unmarshal([]byte(expVar.String()), &v); err != nil {
 | 
				
			||||||
			ch <- NewInvalidMetric(desc, err)
 | 
								ch <- NewInvalidMetric(desc, err)
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,6 +55,18 @@ type Gauge interface {
 | 
				
			||||||
// GaugeOpts is an alias for Opts. See there for doc comments.
 | 
					// GaugeOpts is an alias for Opts. See there for doc comments.
 | 
				
			||||||
type GaugeOpts Opts
 | 
					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.
 | 
					// NewGauge creates a new Gauge based on the provided GaugeOpts.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// The returned implementation is optimized for a fast Set method. If you have a
 | 
					// The returned implementation is optimized for a fast Set method. If you have a
 | 
				
			||||||
| 
						 | 
					@ -123,7 +135,7 @@ func (g *gauge) Sub(val float64) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (g *gauge) Write(out *dto.Metric) error {
 | 
					func (g *gauge) Write(out *dto.Metric) error {
 | 
				
			||||||
	val := math.Float64frombits(atomic.LoadUint64(&g.valBits))
 | 
						val := math.Float64frombits(atomic.LoadUint64(&g.valBits))
 | 
				
			||||||
	return populateMetric(GaugeValue, val, g.labelPairs, nil, out)
 | 
						return populateMetric(GaugeValue, val, g.labelPairs, nil, out, nil)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GaugeVec is a Collector that bundles a set of Gauges that all share the same
 | 
					// GaugeVec is a Collector that bundles a set of Gauges that all share the same
 | 
				
			||||||
| 
						 | 
					@ -138,16 +150,24 @@ type GaugeVec struct {
 | 
				
			||||||
// NewGaugeVec creates a new GaugeVec based on the provided GaugeOpts and
 | 
					// NewGaugeVec creates a new GaugeVec based on the provided GaugeOpts and
 | 
				
			||||||
// partitioned by the given label names.
 | 
					// partitioned by the given label names.
 | 
				
			||||||
func NewGaugeVec(opts GaugeOpts, labelNames []string) *GaugeVec {
 | 
					func NewGaugeVec(opts GaugeOpts, labelNames []string) *GaugeVec {
 | 
				
			||||||
	desc := NewDesc(
 | 
						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),
 | 
							BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
 | 
				
			||||||
		opts.Help,
 | 
							opts.Help,
 | 
				
			||||||
		labelNames,
 | 
							opts.VariableLabels,
 | 
				
			||||||
		opts.ConstLabels,
 | 
							opts.ConstLabels,
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	return &GaugeVec{
 | 
						return &GaugeVec{
 | 
				
			||||||
		MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
 | 
							MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
 | 
				
			||||||
			if len(lvs) != len(desc.variableLabels) {
 | 
								if len(lvs) != len(desc.variableLabels.names) {
 | 
				
			||||||
				panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs))
 | 
									panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.names, lvs))
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			result := &gauge{desc: desc, labelPairs: MakeLabelPairs(desc, lvs)}
 | 
								result := &gauge{desc: desc, labelPairs: MakeLabelPairs(desc, lvs)}
 | 
				
			||||||
			result.init(result) // Init self-collection.
 | 
								result.init(result) // Init self-collection.
 | 
				
			||||||
| 
						 | 
					@ -210,7 +230,8 @@ func (v *GaugeVec) GetMetricWith(labels Labels) (Gauge, error) {
 | 
				
			||||||
// WithLabelValues works as GetMetricWithLabelValues, but panics where
 | 
					// WithLabelValues works as GetMetricWithLabelValues, but panics where
 | 
				
			||||||
// GetMetricWithLabelValues would have returned an error. Not returning an
 | 
					// GetMetricWithLabelValues would have returned an error. Not returning an
 | 
				
			||||||
// error allows shortcuts like
 | 
					// error allows shortcuts like
 | 
				
			||||||
//     myVec.WithLabelValues("404", "GET").Add(42)
 | 
					//
 | 
				
			||||||
 | 
					//	myVec.WithLabelValues("404", "GET").Add(42)
 | 
				
			||||||
func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge {
 | 
					func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge {
 | 
				
			||||||
	g, err := v.GetMetricWithLabelValues(lvs...)
 | 
						g, err := v.GetMetricWithLabelValues(lvs...)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -221,7 +242,8 @@ func (v *GaugeVec) WithLabelValues(lvs ...string) Gauge {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// With works as GetMetricWith, but panics where GetMetricWithLabels would have
 | 
					// With works as GetMetricWith, but panics where GetMetricWithLabels would have
 | 
				
			||||||
// returned an error. Not returning an error allows shortcuts like
 | 
					// returned an error. Not returning an error allows shortcuts like
 | 
				
			||||||
//     myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42)
 | 
					//
 | 
				
			||||||
 | 
					//	myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Add(42)
 | 
				
			||||||
func (v *GaugeVec) With(labels Labels) Gauge {
 | 
					func (v *GaugeVec) With(labels Labels) Gauge {
 | 
				
			||||||
	g, err := v.GetMetricWith(labels)
 | 
						g, err := v.GetMetricWith(labels)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,11 +23,10 @@ import (
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
					 | 
				
			||||||
	"github.com/golang/protobuf/proto"
 | 
					 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus/internal"
 | 
						"github.com/prometheus/client_golang/prometheus/internal"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dto "github.com/prometheus/client_model/go"
 | 
				
			||||||
 | 
						"google.golang.org/protobuf/proto"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										60
									
								
								vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go
								
								
									generated
								
								
									vendored
								
								
									Normal file
								
							
							
						
						
									
										60
									
								
								vendor/github.com/prometheus/client_golang/prometheus/internal/almost_equal.go
								
								
									generated
								
								
									vendored
								
								
									Normal file
								
							| 
						 | 
					@ -0,0 +1,60 @@
 | 
				
			||||||
 | 
					// 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@
 | 
				
			||||||
// It provides tools to compare sequences of strings and generate textual diffs.
 | 
					// It provides tools to compare sequences of strings and generate textual diffs.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Maintaining `GetUnifiedDiffString` here because original repository
 | 
					// Maintaining `GetUnifiedDiffString` here because original repository
 | 
				
			||||||
// (https://github.com/pmezard/go-difflib) is no loger maintained.
 | 
					// (https://github.com/pmezard/go-difflib) is no longer maintained.
 | 
				
			||||||
package internal
 | 
					package internal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
| 
						 | 
					@ -201,12 +201,15 @@ func (m *SequenceMatcher) isBJunk(s string) bool {
 | 
				
			||||||
// If IsJunk is not defined:
 | 
					// If IsJunk is not defined:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
 | 
					// 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
 | 
					//	alo <= i <= i+k <= ahi
 | 
				
			||||||
 | 
					//	blo <= j <= j+k <= bhi
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
// and for all (i',j',k') meeting those conditions,
 | 
					// and for all (i',j',k') meeting those conditions,
 | 
				
			||||||
//     k >= k'
 | 
					//
 | 
				
			||||||
//     i <= i'
 | 
					//	k >= k'
 | 
				
			||||||
//     and if i == i', j <= j'
 | 
					//	i <= i'
 | 
				
			||||||
 | 
					//	and if i == i', j <= j'
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// In other words, of all maximal matching blocks, return one that
 | 
					// In other words, of all maximal matching blocks, return one that
 | 
				
			||||||
// starts earliest in a, and of all those maximal matching blocks that
 | 
					// starts earliest in a, and of all those maximal matching blocks that
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,12 +25,111 @@ import (
 | 
				
			||||||
// Labels represents a collection of label name -> value mappings. This type is
 | 
					// Labels represents a collection of label name -> value mappings. This type is
 | 
				
			||||||
// commonly used with the With(Labels) and GetMetricWith(Labels) methods of
 | 
					// commonly used with the With(Labels) and GetMetricWith(Labels) methods of
 | 
				
			||||||
// metric vector Collectors, e.g.:
 | 
					// metric vector Collectors, e.g.:
 | 
				
			||||||
//     myVec.With(Labels{"code": "404", "method": "GET"}).Add(42)
 | 
					//
 | 
				
			||||||
 | 
					//	myVec.With(Labels{"code": "404", "method": "GET"}).Add(42)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// The other use-case is the specification of constant label pairs in Opts or to
 | 
					// The other use-case is the specification of constant label pairs in Opts or to
 | 
				
			||||||
// create a Desc.
 | 
					// create a Desc.
 | 
				
			||||||
type Labels map[string]string
 | 
					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
 | 
					// reservedLabelPrefix is a prefix which is not legal in user-supplied
 | 
				
			||||||
// label names.
 | 
					// label names.
 | 
				
			||||||
const reservedLabelPrefix = "__"
 | 
					const reservedLabelPrefix = "__"
 | 
				
			||||||
| 
						 | 
					@ -66,6 +165,8 @@ func validateValuesInLabels(labels Labels, expectedNumberOfValues int) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func validateLabelValues(vals []string, expectedNumberOfValues int) error {
 | 
					func validateLabelValues(vals []string, expectedNumberOfValues int) error {
 | 
				
			||||||
	if len(vals) != expectedNumberOfValues {
 | 
						if len(vals) != expectedNumberOfValues {
 | 
				
			||||||
 | 
							// The call below makes vals escape, copy them to avoid that.
 | 
				
			||||||
 | 
							vals := append([]string(nil), vals...)
 | 
				
			||||||
		return fmt.Errorf(
 | 
							return fmt.Errorf(
 | 
				
			||||||
			"%w: expected %d label values but got %d in %#v",
 | 
								"%w: expected %d label values but got %d in %#v",
 | 
				
			||||||
			errInconsistentCardinality, expectedNumberOfValues,
 | 
								errInconsistentCardinality, expectedNumberOfValues,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,11 +20,9 @@ import (
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
					 | 
				
			||||||
	"github.com/golang/protobuf/proto"
 | 
					 | 
				
			||||||
	"github.com/prometheus/common/model"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
						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.
 | 
					var separatorByteSlice = []byte{model.SeparatorByte} // For convenient use with xxhash.
 | 
				
			||||||
| 
						 | 
					@ -94,6 +92,9 @@ type Opts struct {
 | 
				
			||||||
	// machine_role metric). See also
 | 
						// machine_role metric). See also
 | 
				
			||||||
	// https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels
 | 
						// https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels
 | 
				
			||||||
	ConstLabels 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
 | 
					// BuildFQName joins the given three name components by "_". Empty name
 | 
				
			||||||
| 
						 | 
					@ -187,7 +188,7 @@ func (m *withExemplarsMetric) Write(pb *dto.Metric) error {
 | 
				
			||||||
			} else {
 | 
								} 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.
 | 
									// 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{
 | 
									b := &dto.Bucket{
 | 
				
			||||||
					CumulativeCount: proto.Uint64(pb.Histogram.Bucket[len(pb.Histogram.GetBucket())-1].GetCumulativeCount()),
 | 
										CumulativeCount: proto.Uint64(pb.Histogram.GetSampleCount()),
 | 
				
			||||||
					UpperBound:      proto.Float64(math.Inf(1)),
 | 
										UpperBound:      proto.Float64(math.Inf(1)),
 | 
				
			||||||
					Exemplar:        e,
 | 
										Exemplar:        e,
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										4
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
								
								
									generated
								
								
									vendored
								
								
							
							
						
						
									
										4
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
								
								
									generated
								
								
									vendored
								
								
							| 
						 | 
					@ -11,8 +11,8 @@
 | 
				
			||||||
// See the License for the specific language governing permissions and
 | 
					// See the License for the specific language governing permissions and
 | 
				
			||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//go:build !windows && !js
 | 
					//go:build !windows && !js && !wasip1
 | 
				
			||||||
// +build !windows,!js
 | 
					// +build !windows,!js,!wasip1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package prometheus
 | 
					package prometheus
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										26
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_wasip1.go
								
								
									generated
								
								
									vendored
								
								
									Normal file
								
							
							
						
						
									
										26
									
								
								vendor/github.com/prometheus/client_golang/prometheus/process_collector_wasip1.go
								
								
									generated
								
								
									vendored
								
								
									Normal file
								
							| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					// 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -14,114 +14,114 @@
 | 
				
			||||||
// Package promauto provides alternative constructors for the fundamental
 | 
					// Package promauto provides alternative constructors for the fundamental
 | 
				
			||||||
// Prometheus metric types and their …Vec and …Func variants. The difference to
 | 
					// Prometheus metric types and their …Vec and …Func variants. The difference to
 | 
				
			||||||
// their counterparts in the prometheus package is that the promauto
 | 
					// their counterparts in the prometheus package is that the promauto
 | 
				
			||||||
// constructors return Collectors that are already registered with a
 | 
					// constructors register the Collectors with a registry before returning them.
 | 
				
			||||||
// registry. There are two sets of constructors. The constructors in the first
 | 
					// There are two sets of constructors. The constructors in the first set are
 | 
				
			||||||
// set are top-level functions, while the constructors in the other set are
 | 
					// top-level functions, while the constructors in the other set are methods of
 | 
				
			||||||
// methods of the Factory type. The top-level function return Collectors
 | 
					// the Factory type. The top-level functions return Collectors registered with
 | 
				
			||||||
// registered with the global registry (prometheus.DefaultRegisterer), while the
 | 
					// the global registry (prometheus.DefaultRegisterer), while the methods return
 | 
				
			||||||
// methods return Collectors registered with the registry the Factory was
 | 
					// Collectors registered with the registry the Factory was constructed with. All
 | 
				
			||||||
// constructed with. All constructors panic if the registration fails.
 | 
					// constructors panic if the registration fails.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// The following example is a complete program to create a histogram of normally
 | 
					// The following example is a complete program to create a histogram of normally
 | 
				
			||||||
// distributed random numbers from the math/rand package:
 | 
					// distributed random numbers from the math/rand package:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      package main
 | 
					//	package main
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      import (
 | 
					//	import (
 | 
				
			||||||
//              "math/rand"
 | 
					//		"math/rand"
 | 
				
			||||||
//              "net/http"
 | 
					//		"net/http"
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//              "github.com/prometheus/client_golang/prometheus"
 | 
					//		"github.com/prometheus/client_golang/prometheus"
 | 
				
			||||||
//              "github.com/prometheus/client_golang/prometheus/promauto"
 | 
					//		"github.com/prometheus/client_golang/prometheus/promauto"
 | 
				
			||||||
//              "github.com/prometheus/client_golang/prometheus/promhttp"
 | 
					//		"github.com/prometheus/client_golang/prometheus/promhttp"
 | 
				
			||||||
//      )
 | 
					//	)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      var histogram = promauto.NewHistogram(prometheus.HistogramOpts{
 | 
					//	var histogram = promauto.NewHistogram(prometheus.HistogramOpts{
 | 
				
			||||||
//              Name:    "random_numbers",
 | 
					//		Name:    "random_numbers",
 | 
				
			||||||
//              Help:    "A histogram of normally distributed random numbers.",
 | 
					//		Help:    "A histogram of normally distributed random numbers.",
 | 
				
			||||||
//              Buckets: prometheus.LinearBuckets(-3, .1, 61),
 | 
					//		Buckets: prometheus.LinearBuckets(-3, .1, 61),
 | 
				
			||||||
//      })
 | 
					//	})
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      func Random() {
 | 
					//	func Random() {
 | 
				
			||||||
//              for {
 | 
					//		for {
 | 
				
			||||||
//                      histogram.Observe(rand.NormFloat64())
 | 
					//			histogram.Observe(rand.NormFloat64())
 | 
				
			||||||
//              }
 | 
					//		}
 | 
				
			||||||
//      }
 | 
					//	}
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      func main() {
 | 
					//	func main() {
 | 
				
			||||||
//              go Random()
 | 
					//		go Random()
 | 
				
			||||||
//              http.Handle("/metrics", promhttp.Handler())
 | 
					//		http.Handle("/metrics", promhttp.Handler())
 | 
				
			||||||
//              http.ListenAndServe(":1971", nil)
 | 
					//		http.ListenAndServe(":1971", nil)
 | 
				
			||||||
//      }
 | 
					//	}
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Prometheus's version of a minimal hello-world program:
 | 
					// Prometheus's version of a minimal hello-world program:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      package main
 | 
					//	package main
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      import (
 | 
					//	import (
 | 
				
			||||||
//      	"fmt"
 | 
					//		"fmt"
 | 
				
			||||||
//      	"net/http"
 | 
					//		"net/http"
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      	"github.com/prometheus/client_golang/prometheus"
 | 
					//		"github.com/prometheus/client_golang/prometheus"
 | 
				
			||||||
//      	"github.com/prometheus/client_golang/prometheus/promauto"
 | 
					//		"github.com/prometheus/client_golang/prometheus/promauto"
 | 
				
			||||||
//      	"github.com/prometheus/client_golang/prometheus/promhttp"
 | 
					//		"github.com/prometheus/client_golang/prometheus/promhttp"
 | 
				
			||||||
//      )
 | 
					//	)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//      func main() {
 | 
					//	func main() {
 | 
				
			||||||
//      	http.Handle("/", promhttp.InstrumentHandlerCounter(
 | 
					//		http.Handle("/", promhttp.InstrumentHandlerCounter(
 | 
				
			||||||
//      		promauto.NewCounterVec(
 | 
					//			promauto.NewCounterVec(
 | 
				
			||||||
//      			prometheus.CounterOpts{
 | 
					//				prometheus.CounterOpts{
 | 
				
			||||||
//      				Name: "hello_requests_total",
 | 
					//					Name: "hello_requests_total",
 | 
				
			||||||
//      				Help: "Total number of hello-world requests by HTTP code.",
 | 
					//					Help: "Total number of hello-world requests by HTTP code.",
 | 
				
			||||||
//      			},
 | 
					//				},
 | 
				
			||||||
//      			[]string{"code"},
 | 
					//				[]string{"code"},
 | 
				
			||||||
//      		),
 | 
					//			),
 | 
				
			||||||
//      		http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 | 
					//			http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
//      			fmt.Fprint(w, "Hello, world!")
 | 
					//				fmt.Fprint(w, "Hello, world!")
 | 
				
			||||||
//      		}),
 | 
					//			}),
 | 
				
			||||||
//      	))
 | 
					//		))
 | 
				
			||||||
//      	http.Handle("/metrics", promhttp.Handler())
 | 
					//		http.Handle("/metrics", promhttp.Handler())
 | 
				
			||||||
//      	http.ListenAndServe(":1971", nil)
 | 
					//		http.ListenAndServe(":1971", nil)
 | 
				
			||||||
//      }
 | 
					//	}
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// A Factory is created with the With(prometheus.Registerer) function, which
 | 
					// A Factory is created with the With(prometheus.Registerer) function, which
 | 
				
			||||||
// enables two usage pattern. With(prometheus.Registerer) can be called once per
 | 
					// enables two usage patterns. With(prometheus.Registerer) can be called once per
 | 
				
			||||||
// line:
 | 
					// line:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//        var (
 | 
					//	var (
 | 
				
			||||||
//        	reg           = prometheus.NewRegistry()
 | 
					//		reg           = prometheus.NewRegistry()
 | 
				
			||||||
//        	randomNumbers = promauto.With(reg).NewHistogram(prometheus.HistogramOpts{
 | 
					//		randomNumbers = promauto.With(reg).NewHistogram(prometheus.HistogramOpts{
 | 
				
			||||||
//        		Name:    "random_numbers",
 | 
					//			Name:    "random_numbers",
 | 
				
			||||||
//        		Help:    "A histogram of normally distributed random numbers.",
 | 
					//			Help:    "A histogram of normally distributed random numbers.",
 | 
				
			||||||
//        		Buckets: prometheus.LinearBuckets(-3, .1, 61),
 | 
					//			Buckets: prometheus.LinearBuckets(-3, .1, 61),
 | 
				
			||||||
//        	})
 | 
					//		})
 | 
				
			||||||
//        	requestCount = promauto.With(reg).NewCounterVec(
 | 
					//		requestCount = promauto.With(reg).NewCounterVec(
 | 
				
			||||||
//        		prometheus.CounterOpts{
 | 
					//			prometheus.CounterOpts{
 | 
				
			||||||
//        			Name: "http_requests_total",
 | 
					//				Name: "http_requests_total",
 | 
				
			||||||
//        			Help: "Total number of HTTP requests by status code and method.",
 | 
					//				Help: "Total number of HTTP requests by status code and method.",
 | 
				
			||||||
//        		},
 | 
					//			},
 | 
				
			||||||
//        		[]string{"code", "method"},
 | 
					//			[]string{"code", "method"},
 | 
				
			||||||
//        	)
 | 
					//		)
 | 
				
			||||||
//        )
 | 
					//	)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Or it can be used to create a Factory once to be used multiple times:
 | 
					// Or it can be used to create a Factory once to be used multiple times:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//        var (
 | 
					//	var (
 | 
				
			||||||
//        	reg           = prometheus.NewRegistry()
 | 
					//		reg           = prometheus.NewRegistry()
 | 
				
			||||||
//        	factory       = promauto.With(reg)
 | 
					//		factory       = promauto.With(reg)
 | 
				
			||||||
//        	randomNumbers = factory.NewHistogram(prometheus.HistogramOpts{
 | 
					//		randomNumbers = factory.NewHistogram(prometheus.HistogramOpts{
 | 
				
			||||||
//        		Name:    "random_numbers",
 | 
					//			Name:    "random_numbers",
 | 
				
			||||||
//        		Help:    "A histogram of normally distributed random numbers.",
 | 
					//			Help:    "A histogram of normally distributed random numbers.",
 | 
				
			||||||
//        		Buckets: prometheus.LinearBuckets(-3, .1, 61),
 | 
					//			Buckets: prometheus.LinearBuckets(-3, .1, 61),
 | 
				
			||||||
//        	})
 | 
					//		})
 | 
				
			||||||
//        	requestCount = factory.NewCounterVec(
 | 
					//		requestCount = factory.NewCounterVec(
 | 
				
			||||||
//        		prometheus.CounterOpts{
 | 
					//			prometheus.CounterOpts{
 | 
				
			||||||
//        			Name: "http_requests_total",
 | 
					//				Name: "http_requests_total",
 | 
				
			||||||
//        			Help: "Total number of HTTP requests by status code and method.",
 | 
					//				Help: "Total number of HTTP requests by status code and method.",
 | 
				
			||||||
//        		},
 | 
					//			},
 | 
				
			||||||
//        		[]string{"code", "method"},
 | 
					//			[]string{"code", "method"},
 | 
				
			||||||
//        	)
 | 
					//		)
 | 
				
			||||||
//        )
 | 
					//	)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// This appears very handy. So why are these constructors locked away in a
 | 
					// This appears very handy. So why are these constructors locked away in a
 | 
				
			||||||
// separate package?
 | 
					// separate package?
 | 
				
			||||||
| 
						 | 
					@ -153,7 +153,7 @@
 | 
				
			||||||
// importing a package.
 | 
					// importing a package.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// A separate package allows conservative users to entirely ignore it. And
 | 
					// 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
 | 
					// whoever wants to use it will do so explicitly, with an opportunity to read
 | 
				
			||||||
// this warning.
 | 
					// this warning.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Enjoy promauto responsibly!
 | 
					// Enjoy promauto responsibly!
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,6 +37,7 @@ import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
| 
						 | 
					@ -47,9 +48,10 @@ import (
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	contentTypeHeader     = "Content-Type"
 | 
						contentTypeHeader      = "Content-Type"
 | 
				
			||||||
	contentEncodingHeader = "Content-Encoding"
 | 
						contentEncodingHeader  = "Content-Encoding"
 | 
				
			||||||
	acceptEncodingHeader  = "Accept-Encoding"
 | 
						acceptEncodingHeader   = "Accept-Encoding"
 | 
				
			||||||
 | 
						processStartTimeHeader = "Process-Start-Time-Unix"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var gzipPool = sync.Pool{
 | 
					var gzipPool = sync.Pool{
 | 
				
			||||||
| 
						 | 
					@ -121,6 +123,9 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h := http.HandlerFunc(func(rsp http.ResponseWriter, req *http.Request) {
 | 
						h := http.HandlerFunc(func(rsp http.ResponseWriter, req *http.Request) {
 | 
				
			||||||
 | 
							if !opts.ProcessStartTime.IsZero() {
 | 
				
			||||||
 | 
								rsp.Header().Set(processStartTimeHeader, strconv.FormatInt(opts.ProcessStartTime.Unix(), 10))
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if inFlightSem != nil {
 | 
							if inFlightSem != nil {
 | 
				
			||||||
			select {
 | 
								select {
 | 
				
			||||||
			case inFlightSem <- struct{}{}: // All good, carry on.
 | 
								case inFlightSem <- struct{}{}: // All good, carry on.
 | 
				
			||||||
| 
						 | 
					@ -366,6 +371,14 @@ type HandlerOpts struct {
 | 
				
			||||||
	// (which changes the identity of the resulting series on the Prometheus
 | 
						// (which changes the identity of the resulting series on the Prometheus
 | 
				
			||||||
	// server).
 | 
						// server).
 | 
				
			||||||
	EnableOpenMetrics bool
 | 
						EnableOpenMetrics bool
 | 
				
			||||||
 | 
						// ProcessStartTime allows setting process start timevalue that will be exposed
 | 
				
			||||||
 | 
						// with "Process-Start-Time-Unix" response header along with the metrics
 | 
				
			||||||
 | 
						// payload. This allow callers to have efficient transformations to cumulative
 | 
				
			||||||
 | 
						// counters (e.g. OpenTelemetry) or generally _created timestamp estimation per
 | 
				
			||||||
 | 
						// scrape target.
 | 
				
			||||||
 | 
						// NOTE: This feature is experimental and not covered by OpenMetrics or Prometheus
 | 
				
			||||||
 | 
						// exposition format.
 | 
				
			||||||
 | 
						ProcessStartTime time.Time
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// gzipAccepted returns whether the client will accept gzip-encoded content.
 | 
					// gzipAccepted returns whether the client will accept gzip-encoded content.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										27
									
								
								vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go
								
								
									generated
								
								
									vendored
								
								
							
							
						
						
									
										27
									
								
								vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_client.go
								
								
									generated
								
								
									vendored
								
								
							| 
						 | 
					@ -68,17 +68,17 @@ func InstrumentRoundTripperCounter(counter *prometheus.CounterVec, next http.Rou
 | 
				
			||||||
		o.apply(rtOpts)
 | 
							o.apply(rtOpts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	code, method := checkLabels(counter)
 | 
						// Curry the counter with dynamic labels before checking the remaining labels.
 | 
				
			||||||
 | 
						code, method := checkLabels(counter.MustCurryWith(rtOpts.emptyDynamicLabels()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return func(r *http.Request) (*http.Response, error) {
 | 
						return func(r *http.Request) (*http.Response, error) {
 | 
				
			||||||
		resp, err := next.RoundTrip(r)
 | 
							resp, err := next.RoundTrip(r)
 | 
				
			||||||
		if err == nil {
 | 
							if err == nil {
 | 
				
			||||||
			exemplarAdd(
 | 
								l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)
 | 
				
			||||||
				counter.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)),
 | 
								for label, resolve := range rtOpts.extraLabelsFromCtx {
 | 
				
			||||||
				1,
 | 
									l[label] = resolve(resp.Request.Context())
 | 
				
			||||||
				rtOpts.getExemplarFn(r.Context()),
 | 
								}
 | 
				
			||||||
			)
 | 
								addWithExemplar(counter.With(l), 1, rtOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
			counter.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)).Inc()
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return resp, err
 | 
							return resp, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -111,17 +111,18 @@ func InstrumentRoundTripperDuration(obs prometheus.ObserverVec, next http.RoundT
 | 
				
			||||||
		o.apply(rtOpts)
 | 
							o.apply(rtOpts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	code, method := checkLabels(obs)
 | 
						// Curry the observer with dynamic labels before checking the remaining labels.
 | 
				
			||||||
 | 
						code, method := checkLabels(obs.MustCurryWith(rtOpts.emptyDynamicLabels()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return func(r *http.Request) (*http.Response, error) {
 | 
						return func(r *http.Request) (*http.Response, error) {
 | 
				
			||||||
		start := time.Now()
 | 
							start := time.Now()
 | 
				
			||||||
		resp, err := next.RoundTrip(r)
 | 
							resp, err := next.RoundTrip(r)
 | 
				
			||||||
		if err == nil {
 | 
							if err == nil {
 | 
				
			||||||
			exemplarObserve(
 | 
								l := labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)
 | 
				
			||||||
				obs.With(labels(code, method, r.Method, resp.StatusCode, rtOpts.extraMethods...)),
 | 
								for label, resolve := range rtOpts.extraLabelsFromCtx {
 | 
				
			||||||
				time.Since(start).Seconds(),
 | 
									l[label] = resolve(resp.Request.Context())
 | 
				
			||||||
				rtOpts.getExemplarFn(r.Context()),
 | 
								}
 | 
				
			||||||
			)
 | 
								observeWithExemplar(obs.With(l), time.Since(start).Seconds(), rtOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return resp, err
 | 
							return resp, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										120
									
								
								vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go
								
								
									generated
								
								
									vendored
								
								
							
							
						
						
									
										120
									
								
								vendor/github.com/prometheus/client_golang/prometheus/promhttp/instrument_server.go
								
								
									generated
								
								
									vendored
								
								
							| 
						 | 
					@ -28,7 +28,9 @@ import (
 | 
				
			||||||
// magicString is used for the hacky label test in checkLabels. Remove once fixed.
 | 
					// magicString is used for the hacky label test in checkLabels. Remove once fixed.
 | 
				
			||||||
const magicString = "zZgWfBxLqvG8kc8IMv3POi2Bb0tZI3vAnBx+gBaFi9FyPzB/CzKUer1yufDa"
 | 
					const magicString = "zZgWfBxLqvG8kc8IMv3POi2Bb0tZI3vAnBx+gBaFi9FyPzB/CzKUer1yufDa"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func exemplarObserve(obs prometheus.Observer, val float64, labels map[string]string) {
 | 
					// observeWithExemplar is a wrapper for [prometheus.ExemplarAdder.ExemplarObserver],
 | 
				
			||||||
 | 
					// which falls back to [prometheus.Observer.Observe] if no labels are provided.
 | 
				
			||||||
 | 
					func observeWithExemplar(obs prometheus.Observer, val float64, labels map[string]string) {
 | 
				
			||||||
	if labels == nil {
 | 
						if labels == nil {
 | 
				
			||||||
		obs.Observe(val)
 | 
							obs.Observe(val)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
| 
						 | 
					@ -36,7 +38,9 @@ func exemplarObserve(obs prometheus.Observer, val float64, labels map[string]str
 | 
				
			||||||
	obs.(prometheus.ExemplarObserver).ObserveWithExemplar(val, labels)
 | 
						obs.(prometheus.ExemplarObserver).ObserveWithExemplar(val, labels)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func exemplarAdd(obs prometheus.Counter, val float64, labels map[string]string) {
 | 
					// addWithExemplar is a wrapper for [prometheus.ExemplarAdder.AddWithExemplar],
 | 
				
			||||||
 | 
					// which falls back to [prometheus.Counter.Add] if no labels are provided.
 | 
				
			||||||
 | 
					func addWithExemplar(obs prometheus.Counter, val float64, labels map[string]string) {
 | 
				
			||||||
	if labels == nil {
 | 
						if labels == nil {
 | 
				
			||||||
		obs.Add(val)
 | 
							obs.Add(val)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
| 
						 | 
					@ -83,7 +87,8 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op
 | 
				
			||||||
		o.apply(hOpts)
 | 
							o.apply(hOpts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	code, method := checkLabels(obs)
 | 
						// Curry the observer with dynamic labels before checking the remaining labels.
 | 
				
			||||||
 | 
						code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if code {
 | 
						if code {
 | 
				
			||||||
		return func(w http.ResponseWriter, r *http.Request) {
 | 
							return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
| 
						 | 
					@ -91,23 +96,22 @@ func InstrumentHandlerDuration(obs prometheus.ObserverVec, next http.Handler, op
 | 
				
			||||||
			d := newDelegator(w, nil)
 | 
								d := newDelegator(w, nil)
 | 
				
			||||||
			next.ServeHTTP(d, r)
 | 
								next.ServeHTTP(d, r)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			exemplarObserve(
 | 
								l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)
 | 
				
			||||||
				obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)),
 | 
								for label, resolve := range hOpts.extraLabelsFromCtx {
 | 
				
			||||||
				time.Since(now).Seconds(),
 | 
									l[label] = resolve(r.Context())
 | 
				
			||||||
				hOpts.getExemplarFn(r.Context()),
 | 
								}
 | 
				
			||||||
			)
 | 
								observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
						return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
		now := time.Now()
 | 
							now := time.Now()
 | 
				
			||||||
		next.ServeHTTP(w, r)
 | 
							next.ServeHTTP(w, r)
 | 
				
			||||||
 | 
							l := labels(code, method, r.Method, 0, hOpts.extraMethods...)
 | 
				
			||||||
		exemplarObserve(
 | 
							for label, resolve := range hOpts.extraLabelsFromCtx {
 | 
				
			||||||
			obs.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)),
 | 
								l[label] = resolve(r.Context())
 | 
				
			||||||
			time.Since(now).Seconds(),
 | 
							}
 | 
				
			||||||
			hOpts.getExemplarFn(r.Context()),
 | 
							observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
		)
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -134,28 +138,30 @@ func InstrumentHandlerCounter(counter *prometheus.CounterVec, next http.Handler,
 | 
				
			||||||
		o.apply(hOpts)
 | 
							o.apply(hOpts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	code, method := checkLabels(counter)
 | 
						// Curry the counter with dynamic labels before checking the remaining labels.
 | 
				
			||||||
 | 
						code, method := checkLabels(counter.MustCurryWith(hOpts.emptyDynamicLabels()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if code {
 | 
						if code {
 | 
				
			||||||
		return func(w http.ResponseWriter, r *http.Request) {
 | 
							return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
			d := newDelegator(w, nil)
 | 
								d := newDelegator(w, nil)
 | 
				
			||||||
			next.ServeHTTP(d, r)
 | 
								next.ServeHTTP(d, r)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			exemplarAdd(
 | 
								l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)
 | 
				
			||||||
				counter.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)),
 | 
								for label, resolve := range hOpts.extraLabelsFromCtx {
 | 
				
			||||||
				1,
 | 
									l[label] = resolve(r.Context())
 | 
				
			||||||
				hOpts.getExemplarFn(r.Context()),
 | 
								}
 | 
				
			||||||
			)
 | 
								addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
						return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
		next.ServeHTTP(w, r)
 | 
							next.ServeHTTP(w, r)
 | 
				
			||||||
		exemplarAdd(
 | 
					
 | 
				
			||||||
			counter.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)),
 | 
							l := labels(code, method, r.Method, 0, hOpts.extraMethods...)
 | 
				
			||||||
			1,
 | 
							for label, resolve := range hOpts.extraLabelsFromCtx {
 | 
				
			||||||
			hOpts.getExemplarFn(r.Context()),
 | 
								l[label] = resolve(r.Context())
 | 
				
			||||||
		)
 | 
							}
 | 
				
			||||||
 | 
							addWithExemplar(counter.With(l), 1, hOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -187,16 +193,17 @@ func InstrumentHandlerTimeToWriteHeader(obs prometheus.ObserverVec, next http.Ha
 | 
				
			||||||
		o.apply(hOpts)
 | 
							o.apply(hOpts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	code, method := checkLabels(obs)
 | 
						// Curry the observer with dynamic labels before checking the remaining labels.
 | 
				
			||||||
 | 
						code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
						return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
		now := time.Now()
 | 
							now := time.Now()
 | 
				
			||||||
		d := newDelegator(w, func(status int) {
 | 
							d := newDelegator(w, func(status int) {
 | 
				
			||||||
			exemplarObserve(
 | 
								l := labels(code, method, r.Method, status, hOpts.extraMethods...)
 | 
				
			||||||
				obs.With(labels(code, method, r.Method, status, hOpts.extraMethods...)),
 | 
								for label, resolve := range hOpts.extraLabelsFromCtx {
 | 
				
			||||||
				time.Since(now).Seconds(),
 | 
									l[label] = resolve(r.Context())
 | 
				
			||||||
				hOpts.getExemplarFn(r.Context()),
 | 
								}
 | 
				
			||||||
			)
 | 
								observeWithExemplar(obs.With(l), time.Since(now).Seconds(), hOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		next.ServeHTTP(d, r)
 | 
							next.ServeHTTP(d, r)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -227,28 +234,32 @@ func InstrumentHandlerRequestSize(obs prometheus.ObserverVec, next http.Handler,
 | 
				
			||||||
		o.apply(hOpts)
 | 
							o.apply(hOpts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	code, method := checkLabels(obs)
 | 
						// Curry the observer with dynamic labels before checking the remaining labels.
 | 
				
			||||||
 | 
						code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if code {
 | 
						if code {
 | 
				
			||||||
		return func(w http.ResponseWriter, r *http.Request) {
 | 
							return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
			d := newDelegator(w, nil)
 | 
								d := newDelegator(w, nil)
 | 
				
			||||||
			next.ServeHTTP(d, r)
 | 
								next.ServeHTTP(d, r)
 | 
				
			||||||
			size := computeApproximateRequestSize(r)
 | 
								size := computeApproximateRequestSize(r)
 | 
				
			||||||
			exemplarObserve(
 | 
					
 | 
				
			||||||
				obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)),
 | 
								l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)
 | 
				
			||||||
				float64(size),
 | 
								for label, resolve := range hOpts.extraLabelsFromCtx {
 | 
				
			||||||
				hOpts.getExemplarFn(r.Context()),
 | 
									l[label] = resolve(r.Context())
 | 
				
			||||||
			)
 | 
								}
 | 
				
			||||||
 | 
								observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
						return func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
		next.ServeHTTP(w, r)
 | 
							next.ServeHTTP(w, r)
 | 
				
			||||||
		size := computeApproximateRequestSize(r)
 | 
							size := computeApproximateRequestSize(r)
 | 
				
			||||||
		exemplarObserve(
 | 
					
 | 
				
			||||||
			obs.With(labels(code, method, r.Method, 0, hOpts.extraMethods...)),
 | 
							l := labels(code, method, r.Method, 0, hOpts.extraMethods...)
 | 
				
			||||||
			float64(size),
 | 
							for label, resolve := range hOpts.extraLabelsFromCtx {
 | 
				
			||||||
			hOpts.getExemplarFn(r.Context()),
 | 
								l[label] = resolve(r.Context())
 | 
				
			||||||
		)
 | 
							}
 | 
				
			||||||
 | 
							observeWithExemplar(obs.With(l), float64(size), hOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -277,16 +288,18 @@ func InstrumentHandlerResponseSize(obs prometheus.ObserverVec, next http.Handler
 | 
				
			||||||
		o.apply(hOpts)
 | 
							o.apply(hOpts)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	code, method := checkLabels(obs)
 | 
						// Curry the observer with dynamic labels before checking the remaining labels.
 | 
				
			||||||
 | 
						code, method := checkLabels(obs.MustCurryWith(hOpts.emptyDynamicLabels()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 | 
						return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 | 
				
			||||||
		d := newDelegator(w, nil)
 | 
							d := newDelegator(w, nil)
 | 
				
			||||||
		next.ServeHTTP(d, r)
 | 
							next.ServeHTTP(d, r)
 | 
				
			||||||
		exemplarObserve(
 | 
					
 | 
				
			||||||
			obs.With(labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)),
 | 
							l := labels(code, method, r.Method, d.Status(), hOpts.extraMethods...)
 | 
				
			||||||
			float64(d.Written()),
 | 
							for label, resolve := range hOpts.extraLabelsFromCtx {
 | 
				
			||||||
			hOpts.getExemplarFn(r.Context()),
 | 
								l[label] = resolve(r.Context())
 | 
				
			||||||
		)
 | 
							}
 | 
				
			||||||
 | 
							observeWithExemplar(obs.With(l), float64(d.Written()), hOpts.getExemplarFn(r.Context()))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -376,16 +389,13 @@ func isLabelCurried(c prometheus.Collector, label string) bool {
 | 
				
			||||||
	return true
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// emptyLabels is a one-time allocation for non-partitioned metrics to avoid
 | 
					 | 
				
			||||||
// unnecessary allocations on each request.
 | 
					 | 
				
			||||||
var emptyLabels = prometheus.Labels{}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func labels(code, method bool, reqMethod string, status int, extraMethods ...string) prometheus.Labels {
 | 
					func labels(code, method bool, reqMethod string, status int, extraMethods ...string) prometheus.Labels {
 | 
				
			||||||
	if !(code || method) {
 | 
					 | 
				
			||||||
		return emptyLabels
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	labels := prometheus.Labels{}
 | 
						labels := prometheus.Labels{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if !(code || method) {
 | 
				
			||||||
 | 
							return labels
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if code {
 | 
						if code {
 | 
				
			||||||
		labels["code"] = sanitizeCode(status)
 | 
							labels["code"] = sanitizeCode(status)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,14 +24,32 @@ type Option interface {
 | 
				
			||||||
	apply(*options)
 | 
						apply(*options)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// LabelValueFromCtx are used to compute the label value from request context.
 | 
				
			||||||
 | 
					// Context can be filled with values from request through middleware.
 | 
				
			||||||
 | 
					type LabelValueFromCtx func(ctx context.Context) string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// options store options for both a handler or round tripper.
 | 
					// options store options for both a handler or round tripper.
 | 
				
			||||||
type options struct {
 | 
					type options struct {
 | 
				
			||||||
	extraMethods  []string
 | 
						extraMethods       []string
 | 
				
			||||||
	getExemplarFn func(requestCtx context.Context) prometheus.Labels
 | 
						getExemplarFn      func(requestCtx context.Context) prometheus.Labels
 | 
				
			||||||
 | 
						extraLabelsFromCtx map[string]LabelValueFromCtx
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func defaultOptions() *options {
 | 
					func defaultOptions() *options {
 | 
				
			||||||
	return &options{getExemplarFn: func(ctx context.Context) prometheus.Labels { return nil }}
 | 
						return &options{
 | 
				
			||||||
 | 
							getExemplarFn:      func(ctx context.Context) prometheus.Labels { return nil },
 | 
				
			||||||
 | 
							extraLabelsFromCtx: map[string]LabelValueFromCtx{},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (o *options) emptyDynamicLabels() prometheus.Labels {
 | 
				
			||||||
 | 
						labels := prometheus.Labels{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for label := range o.extraLabelsFromCtx {
 | 
				
			||||||
 | 
							labels[label] = ""
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return labels
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type optionApplyFunc func(*options)
 | 
					type optionApplyFunc func(*options)
 | 
				
			||||||
| 
						 | 
					@ -48,11 +66,19 @@ func WithExtraMethods(methods ...string) Option {
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WithExemplarFromContext adds allows to put a hook to all counter and histogram metrics.
 | 
					// WithExemplarFromContext allows to inject function that will get exemplar from context that will be put to counter and histogram metrics.
 | 
				
			||||||
// If the hook function returns non-nil labels, exemplars will be added for that request, otherwise metric
 | 
					// If the function returns nil labels or the metric does not support exemplars, no exemplar will be added (noop), but
 | 
				
			||||||
// will get instrumented without exemplar.
 | 
					// metric will continue to observe/increment.
 | 
				
			||||||
func WithExemplarFromContext(getExemplarFn func(requestCtx context.Context) prometheus.Labels) Option {
 | 
					func WithExemplarFromContext(getExemplarFn func(requestCtx context.Context) prometheus.Labels) Option {
 | 
				
			||||||
	return optionApplyFunc(func(o *options) {
 | 
						return optionApplyFunc(func(o *options) {
 | 
				
			||||||
		o.getExemplarFn = getExemplarFn
 | 
							o.getExemplarFn = getExemplarFn
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// WithLabelFromCtx registers a label for dynamic resolution with access to context.
 | 
				
			||||||
 | 
					// See the example for ExampleInstrumentHandlerWithLabelResolver for example usage
 | 
				
			||||||
 | 
					func WithLabelFromCtx(name string, valueFn LabelValueFromCtx) Option {
 | 
				
			||||||
 | 
						return optionApplyFunc(func(o *options) {
 | 
				
			||||||
 | 
							o.extraLabelsFromCtx[name] = valueFn
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,18 +21,17 @@ import (
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"runtime"
 | 
						"runtime"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
	"unicode/utf8"
 | 
						"unicode/utf8"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/cespare/xxhash/v2"
 | 
					 | 
				
			||||||
	//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
					 | 
				
			||||||
	"github.com/golang/protobuf/proto"
 | 
					 | 
				
			||||||
	"github.com/prometheus/common/expfmt"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus/internal"
 | 
						"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 (
 | 
					const (
 | 
				
			||||||
| 
						 | 
					@ -252,9 +251,12 @@ func (errs MultiError) MaybeUnwrap() error {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Registry registers Prometheus collectors, collects their metrics, and gathers
 | 
					// Registry registers Prometheus collectors, collects their metrics, and gathers
 | 
				
			||||||
// them into MetricFamilies for exposition. It implements both Registerer and
 | 
					// them into MetricFamilies for exposition. It implements Registerer, Gatherer,
 | 
				
			||||||
// Gatherer. The zero value is not usable. Create instances with NewRegistry or
 | 
					// and Collector. The zero value is not usable. Create instances with
 | 
				
			||||||
// NewPedanticRegistry.
 | 
					// 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 {
 | 
					type Registry struct {
 | 
				
			||||||
	mtx                   sync.RWMutex
 | 
						mtx                   sync.RWMutex
 | 
				
			||||||
	collectorsByID        map[uint64]Collector // ID is a hash of the descIDs.
 | 
						collectorsByID        map[uint64]Collector // ID is a hash of the descIDs.
 | 
				
			||||||
| 
						 | 
					@ -546,7 +548,7 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) {
 | 
				
			||||||
			goroutineBudget--
 | 
								goroutineBudget--
 | 
				
			||||||
			runtime.Gosched()
 | 
								runtime.Gosched()
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Once both checkedMetricChan and uncheckdMetricChan are closed
 | 
							// Once both checkedMetricChan and uncheckedMetricChan are closed
 | 
				
			||||||
		// and drained, the contraption above will nil out cmc and umc,
 | 
							// and drained, the contraption above will nil out cmc and umc,
 | 
				
			||||||
		// and then we can leave the collect loop here.
 | 
							// and then we can leave the collect loop here.
 | 
				
			||||||
		if cmc == nil && umc == nil {
 | 
							if cmc == nil && umc == nil {
 | 
				
			||||||
| 
						 | 
					@ -556,6 +558,31 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) {
 | 
				
			||||||
	return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap()
 | 
						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
 | 
					// 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
 | 
					// Prometheus text format, and writes it to a temporary file. Upon success, the
 | 
				
			||||||
// temporary file is renamed to the provided filename.
 | 
					// temporary file is renamed to the provided filename.
 | 
				
			||||||
| 
						 | 
					@ -905,6 +932,10 @@ func checkMetricConsistency(
 | 
				
			||||||
		h.WriteString(lp.GetValue())
 | 
							h.WriteString(lp.GetValue())
 | 
				
			||||||
		h.Write(separatorByteSlice)
 | 
							h.Write(separatorByteSlice)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if dtoMetric.TimestampMs != nil {
 | 
				
			||||||
 | 
							h.WriteString(strconv.FormatInt(*(dtoMetric.TimestampMs), 10))
 | 
				
			||||||
 | 
							h.Write(separatorByteSlice)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	hSum := h.Sum64()
 | 
						hSum := h.Sum64()
 | 
				
			||||||
	if _, exists := metricHashes[hSum]; exists {
 | 
						if _, exists := metricHashes[hSum]; exists {
 | 
				
			||||||
		return fmt.Errorf(
 | 
							return fmt.Errorf(
 | 
				
			||||||
| 
						 | 
					@ -932,7 +963,7 @@ func checkDescConsistency(
 | 
				
			||||||
	// Is the desc consistent with the content of the metric?
 | 
						// Is the desc consistent with the content of the metric?
 | 
				
			||||||
	lpsFromDesc := make([]*dto.LabelPair, len(desc.constLabelPairs), len(dtoMetric.Label))
 | 
						lpsFromDesc := make([]*dto.LabelPair, len(desc.constLabelPairs), len(dtoMetric.Label))
 | 
				
			||||||
	copy(lpsFromDesc, desc.constLabelPairs)
 | 
						copy(lpsFromDesc, desc.constLabelPairs)
 | 
				
			||||||
	for _, l := range desc.variableLabels {
 | 
						for _, l := range desc.variableLabels.names {
 | 
				
			||||||
		lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{
 | 
							lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{
 | 
				
			||||||
			Name: proto.String(l),
 | 
								Name: proto.String(l),
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,11 +22,11 @@ import (
 | 
				
			||||||
	"sync/atomic"
 | 
						"sync/atomic"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/beorn7/perks/quantile"
 | 
					 | 
				
			||||||
	//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
					 | 
				
			||||||
	"github.com/golang/protobuf/proto"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
						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
 | 
					// quantileLabel is used for the label that defines the quantile in a
 | 
				
			||||||
| 
						 | 
					@ -146,6 +146,21 @@ type SummaryOpts struct {
 | 
				
			||||||
	// is the internal buffer size of the underlying package
 | 
						// is the internal buffer size of the underlying package
 | 
				
			||||||
	// "github.com/bmizerany/perks/quantile").
 | 
						// "github.com/bmizerany/perks/quantile").
 | 
				
			||||||
	BufCap uint32
 | 
						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
 | 
					// Problem with the sliding-window decay algorithm... The Merge method of
 | 
				
			||||||
| 
						 | 
					@ -177,11 +192,11 @@ func NewSummary(opts SummaryOpts) Summary {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
 | 
					func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
 | 
				
			||||||
	if len(desc.variableLabels) != len(labelValues) {
 | 
						if len(desc.variableLabels.names) != len(labelValues) {
 | 
				
			||||||
		panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues))
 | 
							panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.names, labelValues))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, n := range desc.variableLabels {
 | 
						for _, n := range desc.variableLabels.names {
 | 
				
			||||||
		if n == quantileLabel {
 | 
							if n == quantileLabel {
 | 
				
			||||||
			panic(errQuantileLabelNotAllowed)
 | 
								panic(errQuantileLabelNotAllowed)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -211,6 +226,9 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
 | 
				
			||||||
		opts.BufCap = DefBufCap
 | 
							opts.BufCap = DefBufCap
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if opts.now == nil {
 | 
				
			||||||
 | 
							opts.now = time.Now
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if len(opts.Objectives) == 0 {
 | 
						if len(opts.Objectives) == 0 {
 | 
				
			||||||
		// Use the lock-free implementation of a Summary without objectives.
 | 
							// Use the lock-free implementation of a Summary without objectives.
 | 
				
			||||||
		s := &noObjectivesSummary{
 | 
							s := &noObjectivesSummary{
 | 
				
			||||||
| 
						 | 
					@ -219,6 +237,7 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
 | 
				
			||||||
			counts:     [2]*summaryCounts{{}, {}},
 | 
								counts:     [2]*summaryCounts{{}, {}},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		s.init(s) // Init self-collection.
 | 
							s.init(s) // Init self-collection.
 | 
				
			||||||
 | 
							s.createdTs = timestamppb.New(opts.now())
 | 
				
			||||||
		return s
 | 
							return s
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -234,7 +253,7 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
 | 
				
			||||||
		coldBuf:        make([]float64, 0, opts.BufCap),
 | 
							coldBuf:        make([]float64, 0, opts.BufCap),
 | 
				
			||||||
		streamDuration: opts.MaxAge / time.Duration(opts.AgeBuckets),
 | 
							streamDuration: opts.MaxAge / time.Duration(opts.AgeBuckets),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	s.headStreamExpTime = time.Now().Add(s.streamDuration)
 | 
						s.headStreamExpTime = opts.now().Add(s.streamDuration)
 | 
				
			||||||
	s.hotBufExpTime = s.headStreamExpTime
 | 
						s.hotBufExpTime = s.headStreamExpTime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i := uint32(0); i < opts.AgeBuckets; i++ {
 | 
						for i := uint32(0); i < opts.AgeBuckets; i++ {
 | 
				
			||||||
| 
						 | 
					@ -248,6 +267,7 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
 | 
				
			||||||
	sort.Float64s(s.sortedObjectives)
 | 
						sort.Float64s(s.sortedObjectives)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s.init(s) // Init self-collection.
 | 
						s.init(s) // Init self-collection.
 | 
				
			||||||
 | 
						s.createdTs = timestamppb.New(opts.now())
 | 
				
			||||||
	return s
 | 
						return s
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -275,6 +295,8 @@ type summary struct {
 | 
				
			||||||
	headStream                       *quantile.Stream
 | 
						headStream                       *quantile.Stream
 | 
				
			||||||
	headStreamIdx                    int
 | 
						headStreamIdx                    int
 | 
				
			||||||
	headStreamExpTime, hotBufExpTime time.Time
 | 
						headStreamExpTime, hotBufExpTime time.Time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						createdTs *timestamppb.Timestamp
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *summary) Desc() *Desc {
 | 
					func (s *summary) Desc() *Desc {
 | 
				
			||||||
| 
						 | 
					@ -296,7 +318,9 @@ func (s *summary) Observe(v float64) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *summary) Write(out *dto.Metric) error {
 | 
					func (s *summary) Write(out *dto.Metric) error {
 | 
				
			||||||
	sum := &dto.Summary{}
 | 
						sum := &dto.Summary{
 | 
				
			||||||
 | 
							CreatedTimestamp: s.createdTs,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	qs := make([]*dto.Quantile, 0, len(s.objectives))
 | 
						qs := make([]*dto.Quantile, 0, len(s.objectives))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s.bufMtx.Lock()
 | 
						s.bufMtx.Lock()
 | 
				
			||||||
| 
						 | 
					@ -429,6 +453,8 @@ type noObjectivesSummary struct {
 | 
				
			||||||
	counts [2]*summaryCounts
 | 
						counts [2]*summaryCounts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	labelPairs []*dto.LabelPair
 | 
						labelPairs []*dto.LabelPair
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						createdTs *timestamppb.Timestamp
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *noObjectivesSummary) Desc() *Desc {
 | 
					func (s *noObjectivesSummary) Desc() *Desc {
 | 
				
			||||||
| 
						 | 
					@ -479,8 +505,9 @@ func (s *noObjectivesSummary) Write(out *dto.Metric) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sum := &dto.Summary{
 | 
						sum := &dto.Summary{
 | 
				
			||||||
		SampleCount: proto.Uint64(count),
 | 
							SampleCount:      proto.Uint64(count),
 | 
				
			||||||
		SampleSum:   proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.sumBits))),
 | 
							SampleSum:        proto.Float64(math.Float64frombits(atomic.LoadUint64(&coldCounts.sumBits))),
 | 
				
			||||||
 | 
							CreatedTimestamp: s.createdTs,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	out.Summary = sum
 | 
						out.Summary = sum
 | 
				
			||||||
| 
						 | 
					@ -530,20 +557,28 @@ type SummaryVec struct {
 | 
				
			||||||
// it is handled by the Prometheus server internally, “quantile” is an illegal
 | 
					// it is handled by the Prometheus server internally, “quantile” is an illegal
 | 
				
			||||||
// label name. NewSummaryVec will panic if this label name is used.
 | 
					// label name. NewSummaryVec will panic if this label name is used.
 | 
				
			||||||
func NewSummaryVec(opts SummaryOpts, labelNames []string) *SummaryVec {
 | 
					func NewSummaryVec(opts SummaryOpts, labelNames []string) *SummaryVec {
 | 
				
			||||||
	for _, ln := range labelNames {
 | 
						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 {
 | 
							if ln == quantileLabel {
 | 
				
			||||||
			panic(errQuantileLabelNotAllowed)
 | 
								panic(errQuantileLabelNotAllowed)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	desc := NewDesc(
 | 
						desc := V2.NewDesc(
 | 
				
			||||||
		BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
 | 
							BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
 | 
				
			||||||
		opts.Help,
 | 
							opts.Help,
 | 
				
			||||||
		labelNames,
 | 
							opts.VariableLabels,
 | 
				
			||||||
		opts.ConstLabels,
 | 
							opts.ConstLabels,
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	return &SummaryVec{
 | 
						return &SummaryVec{
 | 
				
			||||||
		MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
 | 
							MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
 | 
				
			||||||
			return newSummary(desc, opts, lvs...)
 | 
								return newSummary(desc, opts.SummaryOpts, lvs...)
 | 
				
			||||||
		}),
 | 
							}),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -603,7 +638,8 @@ func (v *SummaryVec) GetMetricWith(labels Labels) (Observer, error) {
 | 
				
			||||||
// WithLabelValues works as GetMetricWithLabelValues, but panics where
 | 
					// WithLabelValues works as GetMetricWithLabelValues, but panics where
 | 
				
			||||||
// GetMetricWithLabelValues would have returned an error. Not returning an
 | 
					// GetMetricWithLabelValues would have returned an error. Not returning an
 | 
				
			||||||
// error allows shortcuts like
 | 
					// error allows shortcuts like
 | 
				
			||||||
//     myVec.WithLabelValues("404", "GET").Observe(42.21)
 | 
					//
 | 
				
			||||||
 | 
					//	myVec.WithLabelValues("404", "GET").Observe(42.21)
 | 
				
			||||||
func (v *SummaryVec) WithLabelValues(lvs ...string) Observer {
 | 
					func (v *SummaryVec) WithLabelValues(lvs ...string) Observer {
 | 
				
			||||||
	s, err := v.GetMetricWithLabelValues(lvs...)
 | 
						s, err := v.GetMetricWithLabelValues(lvs...)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -614,7 +650,8 @@ func (v *SummaryVec) WithLabelValues(lvs ...string) Observer {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// With works as GetMetricWith, but panics where GetMetricWithLabels would have
 | 
					// With works as GetMetricWith, but panics where GetMetricWithLabels would have
 | 
				
			||||||
// returned an error. Not returning an error allows shortcuts like
 | 
					// returned an error. Not returning an error allows shortcuts like
 | 
				
			||||||
//     myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21)
 | 
					//
 | 
				
			||||||
 | 
					//	myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21)
 | 
				
			||||||
func (v *SummaryVec) With(labels Labels) Observer {
 | 
					func (v *SummaryVec) With(labels Labels) Observer {
 | 
				
			||||||
	s, err := v.GetMetricWith(labels)
 | 
						s, err := v.GetMetricWith(labels)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -660,6 +697,7 @@ type constSummary struct {
 | 
				
			||||||
	sum        float64
 | 
						sum        float64
 | 
				
			||||||
	quantiles  map[float64]float64
 | 
						quantiles  map[float64]float64
 | 
				
			||||||
	labelPairs []*dto.LabelPair
 | 
						labelPairs []*dto.LabelPair
 | 
				
			||||||
 | 
						createdTs  *timestamppb.Timestamp
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *constSummary) Desc() *Desc {
 | 
					func (s *constSummary) Desc() *Desc {
 | 
				
			||||||
| 
						 | 
					@ -667,7 +705,9 @@ func (s *constSummary) Desc() *Desc {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *constSummary) Write(out *dto.Metric) error {
 | 
					func (s *constSummary) Write(out *dto.Metric) error {
 | 
				
			||||||
	sum := &dto.Summary{}
 | 
						sum := &dto.Summary{
 | 
				
			||||||
 | 
							CreatedTimestamp: s.createdTs,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	qs := make([]*dto.Quantile, 0, len(s.quantiles))
 | 
						qs := make([]*dto.Quantile, 0, len(s.quantiles))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sum.SampleCount = proto.Uint64(s.count)
 | 
						sum.SampleCount = proto.Uint64(s.count)
 | 
				
			||||||
| 
						 | 
					@ -701,7 +741,8 @@ func (s *constSummary) Write(out *dto.Metric) error {
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// quantiles maps ranks to quantile values. For example, a median latency of
 | 
					// 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:
 | 
					// 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}
 | 
					//
 | 
				
			||||||
 | 
					//	map[float64]float64{0.5: 0.23, 0.99: 0.56}
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// NewConstSummary returns an error if the length of labelValues is not
 | 
					// NewConstSummary returns an error if the length of labelValues is not
 | 
				
			||||||
// consistent with the variable labels in Desc or if Desc is invalid.
 | 
					// consistent with the variable labels in Desc or if Desc is invalid.
 | 
				
			||||||
| 
						 | 
					@ -715,7 +756,7 @@ func NewConstSummary(
 | 
				
			||||||
	if desc.err != nil {
 | 
						if desc.err != nil {
 | 
				
			||||||
		return nil, desc.err
 | 
							return nil, desc.err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err := validateLabelValues(labelValues, len(desc.variableLabels)); err != nil {
 | 
						if err := validateLabelValues(labelValues, len(desc.variableLabels.names)); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return &constSummary{
 | 
						return &constSummary{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,13 +23,24 @@ type Timer struct {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewTimer creates a new Timer. The provided Observer is used to observe a
 | 
					// NewTimer creates a new Timer. The provided Observer is used to observe a
 | 
				
			||||||
// duration in seconds. Timer is usually used to time a function call in the
 | 
					// 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:
 | 
					// following way:
 | 
				
			||||||
//    func TimeMe() {
 | 
					//
 | 
				
			||||||
//        timer := NewTimer(myHistogram)
 | 
					//	func TimeMe() {
 | 
				
			||||||
//        defer timer.ObserveDuration()
 | 
					//	    timer := NewTimer(myHistogram)
 | 
				
			||||||
//        // Do actual work.
 | 
					//	    defer timer.ObserveDuration()
 | 
				
			||||||
//    }
 | 
					//	    // Do actual work.
 | 
				
			||||||
 | 
					//	}
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// or
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//	func TimeMeWithExemplar() {
 | 
				
			||||||
 | 
					//		    timer := NewTimer(myHistogram)
 | 
				
			||||||
 | 
					//		    defer timer.ObserveDurationWithExemplar(exemplar)
 | 
				
			||||||
 | 
					//		    // Do actual work.
 | 
				
			||||||
 | 
					//		}
 | 
				
			||||||
func NewTimer(o Observer) *Timer {
 | 
					func NewTimer(o Observer) *Timer {
 | 
				
			||||||
	return &Timer{
 | 
						return &Timer{
 | 
				
			||||||
		begin:    time.Now(),
 | 
							begin:    time.Now(),
 | 
				
			||||||
| 
						 | 
					@ -52,3 +63,19 @@ func (t *Timer) ObserveDuration() time.Duration {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return d
 | 
						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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,18 +14,17 @@
 | 
				
			||||||
package prometheus
 | 
					package prometheus
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
	"unicode/utf8"
 | 
						"unicode/utf8"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
					 | 
				
			||||||
	"github.com/golang/protobuf/proto"
 | 
					 | 
				
			||||||
	"google.golang.org/protobuf/types/known/timestamppb"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus/internal"
 | 
						"github.com/prometheus/client_golang/prometheus/internal"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
						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.
 | 
					// ValueType is an enumeration of metric types that represent a simple value.
 | 
				
			||||||
| 
						 | 
					@ -93,7 +92,7 @@ func (v *valueFunc) Desc() *Desc {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (v *valueFunc) Write(out *dto.Metric) error {
 | 
					func (v *valueFunc) Write(out *dto.Metric) error {
 | 
				
			||||||
	return populateMetric(v.valType, v.function(), v.labelPairs, nil, out)
 | 
						return populateMetric(v.valType, v.function(), v.labelPairs, nil, out, nil)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewConstMetric returns a metric with one fixed value that cannot be
 | 
					// NewConstMetric returns a metric with one fixed value that cannot be
 | 
				
			||||||
| 
						 | 
					@ -107,12 +106,12 @@ func NewConstMetric(desc *Desc, valueType ValueType, value float64, labelValues
 | 
				
			||||||
	if desc.err != nil {
 | 
						if desc.err != nil {
 | 
				
			||||||
		return nil, desc.err
 | 
							return nil, desc.err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err := validateLabelValues(labelValues, len(desc.variableLabels)); err != nil {
 | 
						if err := validateLabelValues(labelValues, len(desc.variableLabels.names)); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	metric := &dto.Metric{}
 | 
						metric := &dto.Metric{}
 | 
				
			||||||
	if err := populateMetric(valueType, value, MakeLabelPairs(desc, labelValues), nil, metric); err != nil {
 | 
						if err := populateMetric(valueType, value, MakeLabelPairs(desc, labelValues), nil, metric, nil); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,6 +131,43 @@ func MustNewConstMetric(desc *Desc, valueType ValueType, value float64, labelVal
 | 
				
			||||||
	return m
 | 
						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 {
 | 
					type constMetric struct {
 | 
				
			||||||
	desc   *Desc
 | 
						desc   *Desc
 | 
				
			||||||
	metric *dto.Metric
 | 
						metric *dto.Metric
 | 
				
			||||||
| 
						 | 
					@ -155,11 +191,12 @@ func populateMetric(
 | 
				
			||||||
	labelPairs []*dto.LabelPair,
 | 
						labelPairs []*dto.LabelPair,
 | 
				
			||||||
	e *dto.Exemplar,
 | 
						e *dto.Exemplar,
 | 
				
			||||||
	m *dto.Metric,
 | 
						m *dto.Metric,
 | 
				
			||||||
 | 
						ct *timestamppb.Timestamp,
 | 
				
			||||||
) error {
 | 
					) error {
 | 
				
			||||||
	m.Label = labelPairs
 | 
						m.Label = labelPairs
 | 
				
			||||||
	switch t {
 | 
						switch t {
 | 
				
			||||||
	case CounterValue:
 | 
						case CounterValue:
 | 
				
			||||||
		m.Counter = &dto.Counter{Value: proto.Float64(v), Exemplar: e}
 | 
							m.Counter = &dto.Counter{Value: proto.Float64(v), Exemplar: e, CreatedTimestamp: ct}
 | 
				
			||||||
	case GaugeValue:
 | 
						case GaugeValue:
 | 
				
			||||||
		m.Gauge = &dto.Gauge{Value: proto.Float64(v)}
 | 
							m.Gauge = &dto.Gauge{Value: proto.Float64(v)}
 | 
				
			||||||
	case UntypedValue:
 | 
						case UntypedValue:
 | 
				
			||||||
| 
						 | 
					@ -178,19 +215,19 @@ func populateMetric(
 | 
				
			||||||
// This function is only needed for custom Metric implementations. See MetricVec
 | 
					// This function is only needed for custom Metric implementations. See MetricVec
 | 
				
			||||||
// example.
 | 
					// example.
 | 
				
			||||||
func MakeLabelPairs(desc *Desc, labelValues []string) []*dto.LabelPair {
 | 
					func MakeLabelPairs(desc *Desc, labelValues []string) []*dto.LabelPair {
 | 
				
			||||||
	totalLen := len(desc.variableLabels) + len(desc.constLabelPairs)
 | 
						totalLen := len(desc.variableLabels.names) + len(desc.constLabelPairs)
 | 
				
			||||||
	if totalLen == 0 {
 | 
						if totalLen == 0 {
 | 
				
			||||||
		// Super fast path.
 | 
							// Super fast path.
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(desc.variableLabels) == 0 {
 | 
						if len(desc.variableLabels.names) == 0 {
 | 
				
			||||||
		// Moderately fast path.
 | 
							// Moderately fast path.
 | 
				
			||||||
		return desc.constLabelPairs
 | 
							return desc.constLabelPairs
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	labelPairs := make([]*dto.LabelPair, 0, totalLen)
 | 
						labelPairs := make([]*dto.LabelPair, 0, totalLen)
 | 
				
			||||||
	for i, n := range desc.variableLabels {
 | 
						for i, l := range desc.variableLabels.names {
 | 
				
			||||||
		labelPairs = append(labelPairs, &dto.LabelPair{
 | 
							labelPairs = append(labelPairs, &dto.LabelPair{
 | 
				
			||||||
			Name:  proto.String(n),
 | 
								Name:  proto.String(l),
 | 
				
			||||||
			Value: proto.String(labelValues[i]),
 | 
								Value: proto.String(labelValues[i]),
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,6 +72,8 @@ func NewMetricVec(desc *Desc, newMetric func(lvs ...string) Metric) *MetricVec {
 | 
				
			||||||
// with a performance overhead (for creating and processing the Labels map).
 | 
					// with a performance overhead (for creating and processing the Labels map).
 | 
				
			||||||
// See also the CounterVec example.
 | 
					// See also the CounterVec example.
 | 
				
			||||||
func (m *MetricVec) DeleteLabelValues(lvs ...string) bool {
 | 
					func (m *MetricVec) DeleteLabelValues(lvs ...string) bool {
 | 
				
			||||||
 | 
						lvs = constrainLabelValues(m.desc, lvs, m.curry)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h, err := m.hashLabelValues(lvs)
 | 
						h, err := m.hashLabelValues(lvs)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
| 
						 | 
					@ -91,6 +93,9 @@ func (m *MetricVec) DeleteLabelValues(lvs ...string) bool {
 | 
				
			||||||
// This method is used for the same purpose as DeleteLabelValues(...string). See
 | 
					// This method is used for the same purpose as DeleteLabelValues(...string). See
 | 
				
			||||||
// there for pros and cons of the two methods.
 | 
					// there for pros and cons of the two methods.
 | 
				
			||||||
func (m *MetricVec) Delete(labels Labels) bool {
 | 
					func (m *MetricVec) Delete(labels Labels) bool {
 | 
				
			||||||
 | 
						labels, closer := constrainLabels(m.desc, labels)
 | 
				
			||||||
 | 
						defer closer()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h, err := m.hashLabels(labels)
 | 
						h, err := m.hashLabels(labels)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
| 
						 | 
					@ -106,6 +111,9 @@ func (m *MetricVec) Delete(labels Labels) bool {
 | 
				
			||||||
// Note that curried labels will never be matched if deleting from the curried vector.
 | 
					// 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.
 | 
					// To match curried labels with DeletePartialMatch, it must be called on the base vector.
 | 
				
			||||||
func (m *MetricVec) DeletePartialMatch(labels Labels) int {
 | 
					func (m *MetricVec) DeletePartialMatch(labels Labels) int {
 | 
				
			||||||
 | 
						labels, closer := constrainLabels(m.desc, labels)
 | 
				
			||||||
 | 
						defer closer()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return m.metricMap.deleteByLabels(labels, m.curry)
 | 
						return m.metricMap.deleteByLabels(labels, m.curry)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,11 +152,11 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) {
 | 
				
			||||||
		oldCurry = m.curry
 | 
							oldCurry = m.curry
 | 
				
			||||||
		iCurry   int
 | 
							iCurry   int
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	for i, label := range m.desc.variableLabels {
 | 
						for i, labelName := range m.desc.variableLabels.names {
 | 
				
			||||||
		val, ok := labels[label]
 | 
							val, ok := labels[labelName]
 | 
				
			||||||
		if iCurry < len(oldCurry) && oldCurry[iCurry].index == i {
 | 
							if iCurry < len(oldCurry) && oldCurry[iCurry].index == i {
 | 
				
			||||||
			if ok {
 | 
								if ok {
 | 
				
			||||||
				return nil, fmt.Errorf("label name %q is already curried", label)
 | 
									return nil, fmt.Errorf("label name %q is already curried", labelName)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			newCurry = append(newCurry, oldCurry[iCurry])
 | 
								newCurry = append(newCurry, oldCurry[iCurry])
 | 
				
			||||||
			iCurry++
 | 
								iCurry++
 | 
				
			||||||
| 
						 | 
					@ -156,7 +164,10 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) {
 | 
				
			||||||
			if !ok {
 | 
								if !ok {
 | 
				
			||||||
				continue // Label stays uncurried.
 | 
									continue // Label stays uncurried.
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			newCurry = append(newCurry, curriedLabelValue{i, val})
 | 
								newCurry = append(newCurry, curriedLabelValue{
 | 
				
			||||||
 | 
									i,
 | 
				
			||||||
 | 
									m.desc.variableLabels.constrain(labelName, val),
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if l := len(oldCurry) + len(labels) - len(newCurry); l > 0 {
 | 
						if l := len(oldCurry) + len(labels) - len(newCurry); l > 0 {
 | 
				
			||||||
| 
						 | 
					@ -199,6 +210,7 @@ func (m *MetricVec) CurryWith(labels Labels) (*MetricVec, error) {
 | 
				
			||||||
// a wrapper around MetricVec, implementing a vector for a specific Metric
 | 
					// a wrapper around MetricVec, implementing a vector for a specific Metric
 | 
				
			||||||
// implementation, for example GaugeVec.
 | 
					// implementation, for example GaugeVec.
 | 
				
			||||||
func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) {
 | 
					func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) {
 | 
				
			||||||
 | 
						lvs = constrainLabelValues(m.desc, lvs, m.curry)
 | 
				
			||||||
	h, err := m.hashLabelValues(lvs)
 | 
						h, err := m.hashLabelValues(lvs)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
| 
						 | 
					@ -224,6 +236,9 @@ func (m *MetricVec) GetMetricWithLabelValues(lvs ...string) (Metric, error) {
 | 
				
			||||||
// around MetricVec, implementing a vector for a specific Metric implementation,
 | 
					// around MetricVec, implementing a vector for a specific Metric implementation,
 | 
				
			||||||
// for example GaugeVec.
 | 
					// for example GaugeVec.
 | 
				
			||||||
func (m *MetricVec) GetMetricWith(labels Labels) (Metric, error) {
 | 
					func (m *MetricVec) GetMetricWith(labels Labels) (Metric, error) {
 | 
				
			||||||
 | 
						labels, closer := constrainLabels(m.desc, labels)
 | 
				
			||||||
 | 
						defer closer()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	h, err := m.hashLabels(labels)
 | 
						h, err := m.hashLabels(labels)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
| 
						 | 
					@ -233,7 +248,7 @@ func (m *MetricVec) GetMetricWith(labels Labels) (Metric, error) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *MetricVec) hashLabelValues(vals []string) (uint64, error) {
 | 
					func (m *MetricVec) hashLabelValues(vals []string) (uint64, error) {
 | 
				
			||||||
	if err := validateLabelValues(vals, len(m.desc.variableLabels)-len(m.curry)); err != nil {
 | 
						if err := validateLabelValues(vals, len(m.desc.variableLabels.names)-len(m.curry)); err != nil {
 | 
				
			||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -242,7 +257,7 @@ func (m *MetricVec) hashLabelValues(vals []string) (uint64, error) {
 | 
				
			||||||
		curry         = m.curry
 | 
							curry         = m.curry
 | 
				
			||||||
		iVals, iCurry int
 | 
							iVals, iCurry int
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	for i := 0; i < len(m.desc.variableLabels); i++ {
 | 
						for i := 0; i < len(m.desc.variableLabels.names); i++ {
 | 
				
			||||||
		if iCurry < len(curry) && curry[iCurry].index == i {
 | 
							if iCurry < len(curry) && curry[iCurry].index == i {
 | 
				
			||||||
			h = m.hashAdd(h, curry[iCurry].value)
 | 
								h = m.hashAdd(h, curry[iCurry].value)
 | 
				
			||||||
			iCurry++
 | 
								iCurry++
 | 
				
			||||||
| 
						 | 
					@ -256,7 +271,7 @@ func (m *MetricVec) hashLabelValues(vals []string) (uint64, error) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *MetricVec) hashLabels(labels Labels) (uint64, error) {
 | 
					func (m *MetricVec) hashLabels(labels Labels) (uint64, error) {
 | 
				
			||||||
	if err := validateValuesInLabels(labels, len(m.desc.variableLabels)-len(m.curry)); err != nil {
 | 
						if err := validateValuesInLabels(labels, len(m.desc.variableLabels.names)-len(m.curry)); err != nil {
 | 
				
			||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -265,17 +280,17 @@ func (m *MetricVec) hashLabels(labels Labels) (uint64, error) {
 | 
				
			||||||
		curry  = m.curry
 | 
							curry  = m.curry
 | 
				
			||||||
		iCurry int
 | 
							iCurry int
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	for i, label := range m.desc.variableLabels {
 | 
						for i, labelName := range m.desc.variableLabels.names {
 | 
				
			||||||
		val, ok := labels[label]
 | 
							val, ok := labels[labelName]
 | 
				
			||||||
		if iCurry < len(curry) && curry[iCurry].index == i {
 | 
							if iCurry < len(curry) && curry[iCurry].index == i {
 | 
				
			||||||
			if ok {
 | 
								if ok {
 | 
				
			||||||
				return 0, fmt.Errorf("label name %q is already curried", label)
 | 
									return 0, fmt.Errorf("label name %q is already curried", labelName)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			h = m.hashAdd(h, curry[iCurry].value)
 | 
								h = m.hashAdd(h, curry[iCurry].value)
 | 
				
			||||||
			iCurry++
 | 
								iCurry++
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if !ok {
 | 
								if !ok {
 | 
				
			||||||
				return 0, fmt.Errorf("label name %q missing in label map", label)
 | 
									return 0, fmt.Errorf("label name %q missing in label map", labelName)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			h = m.hashAdd(h, val)
 | 
								h = m.hashAdd(h, val)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -453,7 +468,7 @@ func valueMatchesVariableOrCurriedValue(targetValue string, index int, values []
 | 
				
			||||||
func matchPartialLabels(desc *Desc, values []string, labels Labels, curry []curriedLabelValue) bool {
 | 
					func matchPartialLabels(desc *Desc, values []string, labels Labels, curry []curriedLabelValue) bool {
 | 
				
			||||||
	for l, v := range labels {
 | 
						for l, v := range labels {
 | 
				
			||||||
		// Check if the target label exists in our metrics and get the index.
 | 
							// Check if the target label exists in our metrics and get the index.
 | 
				
			||||||
		varLabelIndex, validLabel := indexOf(l, desc.variableLabels)
 | 
							varLabelIndex, validLabel := indexOf(l, desc.variableLabels.names)
 | 
				
			||||||
		if validLabel {
 | 
							if validLabel {
 | 
				
			||||||
			// Check the value of that label against the target value.
 | 
								// Check the value of that label against the target value.
 | 
				
			||||||
			// We don't consider curried values in partial matches.
 | 
								// We don't consider curried values in partial matches.
 | 
				
			||||||
| 
						 | 
					@ -597,7 +612,7 @@ func matchLabels(desc *Desc, values []string, labels Labels, curry []curriedLabe
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	iCurry := 0
 | 
						iCurry := 0
 | 
				
			||||||
	for i, k := range desc.variableLabels {
 | 
						for i, k := range desc.variableLabels.names {
 | 
				
			||||||
		if iCurry < len(curry) && curry[iCurry].index == i {
 | 
							if iCurry < len(curry) && curry[iCurry].index == i {
 | 
				
			||||||
			if values[i] != curry[iCurry].value {
 | 
								if values[i] != curry[iCurry].value {
 | 
				
			||||||
				return false
 | 
									return false
 | 
				
			||||||
| 
						 | 
					@ -615,7 +630,7 @@ func matchLabels(desc *Desc, values []string, labels Labels, curry []curriedLabe
 | 
				
			||||||
func extractLabelValues(desc *Desc, labels Labels, curry []curriedLabelValue) []string {
 | 
					func extractLabelValues(desc *Desc, labels Labels, curry []curriedLabelValue) []string {
 | 
				
			||||||
	labelValues := make([]string, len(labels)+len(curry))
 | 
						labelValues := make([]string, len(labels)+len(curry))
 | 
				
			||||||
	iCurry := 0
 | 
						iCurry := 0
 | 
				
			||||||
	for i, k := range desc.variableLabels {
 | 
						for i, k := range desc.variableLabels.names {
 | 
				
			||||||
		if iCurry < len(curry) && curry[iCurry].index == i {
 | 
							if iCurry < len(curry) && curry[iCurry].index == i {
 | 
				
			||||||
			labelValues[i] = curry[iCurry].value
 | 
								labelValues[i] = curry[iCurry].value
 | 
				
			||||||
			iCurry++
 | 
								iCurry++
 | 
				
			||||||
| 
						 | 
					@ -640,3 +655,55 @@ func inlineLabelValues(lvs []string, curry []curriedLabelValue) []string {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return labelValues
 | 
						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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					// 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{}
 | 
				
			||||||
| 
						 | 
					@ -17,12 +17,10 @@ import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
						"github.com/prometheus/client_golang/prometheus/internal"
 | 
				
			||||||
	"github.com/golang/protobuf/proto"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
						dto "github.com/prometheus/client_model/go"
 | 
				
			||||||
 | 
						"google.golang.org/protobuf/proto"
 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus/internal"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WrapRegistererWith returns a Registerer wrapping the provided
 | 
					// WrapRegistererWith returns a Registerer wrapping the provided
 | 
				
			||||||
| 
						 | 
					@ -206,7 +204,7 @@ func wrapDesc(desc *Desc, prefix string, labels Labels) *Desc {
 | 
				
			||||||
		constLabels[ln] = lv
 | 
							constLabels[ln] = lv
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// NewDesc will do remaining validations.
 | 
						// NewDesc will do remaining validations.
 | 
				
			||||||
	newDesc := NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels)
 | 
						newDesc := V2.NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels)
 | 
				
			||||||
	// Propagate errors if there was any. This will override any errer
 | 
						// Propagate errors if there was any. This will override any errer
 | 
				
			||||||
	// created by NewDesc above, i.e. earlier errors get precedence.
 | 
						// created by NewDesc above, i.e. earlier errors get precedence.
 | 
				
			||||||
	if desc.err != nil {
 | 
						if desc.err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -14,6 +14,7 @@
 | 
				
			||||||
package expfmt
 | 
					package expfmt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"bufio"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"math"
 | 
						"math"
 | 
				
			||||||
| 
						 | 
					@ -21,8 +22,8 @@ import (
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
						dto "github.com/prometheus/client_model/go"
 | 
				
			||||||
 | 
						"google.golang.org/protobuf/encoding/protodelim"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/matttproud/golang_protobuf_extensions/pbutil"
 | 
					 | 
				
			||||||
	"github.com/prometheus/common/model"
 | 
						"github.com/prometheus/common/model"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,7 +45,7 @@ func ResponseFormat(h http.Header) Format {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mediatype, params, err := mime.ParseMediaType(ct)
 | 
						mediatype, params, err := mime.ParseMediaType(ct)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return FmtUnknown
 | 
							return fmtUnknown
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const textType = "text/plain"
 | 
						const textType = "text/plain"
 | 
				
			||||||
| 
						 | 
					@ -52,28 +53,28 @@ func ResponseFormat(h http.Header) Format {
 | 
				
			||||||
	switch mediatype {
 | 
						switch mediatype {
 | 
				
			||||||
	case ProtoType:
 | 
						case ProtoType:
 | 
				
			||||||
		if p, ok := params["proto"]; ok && p != ProtoProtocol {
 | 
							if p, ok := params["proto"]; ok && p != ProtoProtocol {
 | 
				
			||||||
			return FmtUnknown
 | 
								return fmtUnknown
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if e, ok := params["encoding"]; ok && e != "delimited" {
 | 
							if e, ok := params["encoding"]; ok && e != "delimited" {
 | 
				
			||||||
			return FmtUnknown
 | 
								return fmtUnknown
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return FmtProtoDelim
 | 
							return fmtProtoDelim
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case textType:
 | 
						case textType:
 | 
				
			||||||
		if v, ok := params["version"]; ok && v != TextVersion {
 | 
							if v, ok := params["version"]; ok && v != TextVersion {
 | 
				
			||||||
			return FmtUnknown
 | 
								return fmtUnknown
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return FmtText
 | 
							return fmtText
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return FmtUnknown
 | 
						return fmtUnknown
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewDecoder returns a new decoder based on the given input format.
 | 
					// 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.
 | 
					// If the input format does not imply otherwise, a text format decoder is returned.
 | 
				
			||||||
func NewDecoder(r io.Reader, format Format) Decoder {
 | 
					func NewDecoder(r io.Reader, format Format) Decoder {
 | 
				
			||||||
	switch format {
 | 
						switch format.FormatType() {
 | 
				
			||||||
	case FmtProtoDelim:
 | 
						case TypeProtoDelim:
 | 
				
			||||||
		return &protoDecoder{r: r}
 | 
							return &protoDecoder{r: r}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return &textDecoder{r: r}
 | 
						return &textDecoder{r: r}
 | 
				
			||||||
| 
						 | 
					@ -86,8 +87,10 @@ type protoDecoder struct {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Decode implements the Decoder interface.
 | 
					// Decode implements the Decoder interface.
 | 
				
			||||||
func (d *protoDecoder) Decode(v *dto.MetricFamily) error {
 | 
					func (d *protoDecoder) Decode(v *dto.MetricFamily) error {
 | 
				
			||||||
	_, err := pbutil.ReadDelimited(d.r, v)
 | 
						opts := protodelim.UnmarshalOptions{
 | 
				
			||||||
	if err != nil {
 | 
							MaxSize: -1,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if err := opts.UnmarshalFrom(bufio.NewReader(d.r), v); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if !model.IsValidMetricName(model.LabelValue(v.GetName())) {
 | 
						if !model.IsValidMetricName(model.LabelValue(v.GetName())) {
 | 
				
			||||||
| 
						 | 
					@ -115,32 +118,31 @@ func (d *protoDecoder) Decode(v *dto.MetricFamily) error {
 | 
				
			||||||
// textDecoder implements the Decoder interface for the text protocol.
 | 
					// textDecoder implements the Decoder interface for the text protocol.
 | 
				
			||||||
type textDecoder struct {
 | 
					type textDecoder struct {
 | 
				
			||||||
	r    io.Reader
 | 
						r    io.Reader
 | 
				
			||||||
	p    TextParser
 | 
						fams map[string]*dto.MetricFamily
 | 
				
			||||||
	fams []*dto.MetricFamily
 | 
						err  error
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Decode implements the Decoder interface.
 | 
					// Decode implements the Decoder interface.
 | 
				
			||||||
func (d *textDecoder) Decode(v *dto.MetricFamily) error {
 | 
					func (d *textDecoder) Decode(v *dto.MetricFamily) error {
 | 
				
			||||||
	// TODO(fabxc): Wrap this as a line reader to make streaming safer.
 | 
						if d.err == nil {
 | 
				
			||||||
	if len(d.fams) == 0 {
 | 
							// Read all metrics in one shot.
 | 
				
			||||||
		// No cached metric families, read everything and parse metrics.
 | 
							var p TextParser
 | 
				
			||||||
		fams, err := d.p.TextToMetricFamilies(d.r)
 | 
							d.fams, d.err = p.TextToMetricFamilies(d.r)
 | 
				
			||||||
		if err != nil {
 | 
							// If we don't get an error, store io.EOF for the end.
 | 
				
			||||||
			return err
 | 
							if d.err == nil {
 | 
				
			||||||
		}
 | 
								d.err = io.EOF
 | 
				
			||||||
		if len(fams) == 0 {
 | 
					 | 
				
			||||||
			return io.EOF
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		d.fams = make([]*dto.MetricFamily, 0, len(fams))
 | 
					 | 
				
			||||||
		for _, f := range fams {
 | 
					 | 
				
			||||||
			d.fams = append(d.fams, f)
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						// Pick off one MetricFamily per Decode until there's nothing left.
 | 
				
			||||||
	*v = *d.fams[0]
 | 
						for key, fam := range d.fams {
 | 
				
			||||||
	d.fams = d.fams[1:]
 | 
							v.Name = fam.Name
 | 
				
			||||||
 | 
							v.Help = fam.Help
 | 
				
			||||||
	return nil
 | 
							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
 | 
					// SampleDecoder wraps a Decoder to extract samples from the metric families
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,9 +18,11 @@ import (
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
						"google.golang.org/protobuf/encoding/protodelim"
 | 
				
			||||||
	"github.com/matttproud/golang_protobuf_extensions/pbutil"
 | 
						"google.golang.org/protobuf/encoding/prototext"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg"
 | 
						"github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg"
 | 
				
			||||||
 | 
						"github.com/prometheus/common/model"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
						dto "github.com/prometheus/client_model/go"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -60,23 +62,32 @@ func (ec encoderCloser) Close() error {
 | 
				
			||||||
// as the support is still experimental. To include the option to negotiate
 | 
					// as the support is still experimental. To include the option to negotiate
 | 
				
			||||||
// FmtOpenMetrics, use NegotiateOpenMetrics.
 | 
					// FmtOpenMetrics, use NegotiateOpenMetrics.
 | 
				
			||||||
func Negotiate(h http.Header) Format {
 | 
					func Negotiate(h http.Header) Format {
 | 
				
			||||||
 | 
						escapingScheme := Format(fmt.Sprintf("; escaping=%s", Format(model.NameEscapingScheme.String())))
 | 
				
			||||||
	for _, ac := range goautoneg.ParseAccept(h.Get(hdrAccept)) {
 | 
						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"]
 | 
							ver := ac.Params["version"]
 | 
				
			||||||
		if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
 | 
							if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
 | 
				
			||||||
			switch ac.Params["encoding"] {
 | 
								switch ac.Params["encoding"] {
 | 
				
			||||||
			case "delimited":
 | 
								case "delimited":
 | 
				
			||||||
				return FmtProtoDelim
 | 
									return fmtProtoDelim + escapingScheme
 | 
				
			||||||
			case "text":
 | 
								case "text":
 | 
				
			||||||
				return FmtProtoText
 | 
									return fmtProtoText + escapingScheme
 | 
				
			||||||
			case "compact-text":
 | 
								case "compact-text":
 | 
				
			||||||
				return FmtProtoCompact
 | 
									return fmtProtoCompact + escapingScheme
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
 | 
							if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
 | 
				
			||||||
			return FmtText
 | 
								return fmtText + escapingScheme
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return FmtText
 | 
						return fmtText + escapingScheme
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NegotiateIncludingOpenMetrics works like Negotiate but includes
 | 
					// NegotiateIncludingOpenMetrics works like Negotiate but includes
 | 
				
			||||||
| 
						 | 
					@ -84,26 +95,40 @@ func Negotiate(h http.Header) Format {
 | 
				
			||||||
// temporary and will disappear once FmtOpenMetrics is fully supported and as
 | 
					// temporary and will disappear once FmtOpenMetrics is fully supported and as
 | 
				
			||||||
// such may be negotiated by the normal Negotiate function.
 | 
					// such may be negotiated by the normal Negotiate function.
 | 
				
			||||||
func NegotiateIncludingOpenMetrics(h http.Header) Format {
 | 
					func NegotiateIncludingOpenMetrics(h http.Header) Format {
 | 
				
			||||||
 | 
						escapingScheme := Format(fmt.Sprintf("; escaping=%s", Format(model.NameEscapingScheme.String())))
 | 
				
			||||||
	for _, ac := range goautoneg.ParseAccept(h.Get(hdrAccept)) {
 | 
						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"]
 | 
							ver := ac.Params["version"]
 | 
				
			||||||
		if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
 | 
							if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
 | 
				
			||||||
			switch ac.Params["encoding"] {
 | 
								switch ac.Params["encoding"] {
 | 
				
			||||||
			case "delimited":
 | 
								case "delimited":
 | 
				
			||||||
				return FmtProtoDelim
 | 
									return fmtProtoDelim + escapingScheme
 | 
				
			||||||
			case "text":
 | 
								case "text":
 | 
				
			||||||
				return FmtProtoText
 | 
									return fmtProtoText + escapingScheme
 | 
				
			||||||
			case "compact-text":
 | 
								case "compact-text":
 | 
				
			||||||
				return FmtProtoCompact
 | 
									return fmtProtoCompact + escapingScheme
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
 | 
							if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
 | 
				
			||||||
			return FmtText
 | 
								return fmtText + escapingScheme
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion || ver == "") {
 | 
							if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") {
 | 
				
			||||||
			return FmtOpenMetrics
 | 
								switch ver {
 | 
				
			||||||
 | 
								case OpenMetricsVersion_1_0_0:
 | 
				
			||||||
 | 
									return fmtOpenMetrics_1_0_0 + escapingScheme
 | 
				
			||||||
 | 
								default:
 | 
				
			||||||
 | 
									return fmtOpenMetrics_0_0_1 + escapingScheme
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return FmtText
 | 
						return fmtText + escapingScheme
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewEncoder returns a new encoder based on content type negotiation. All
 | 
					// NewEncoder returns a new encoder based on content type negotiation. All
 | 
				
			||||||
| 
						 | 
					@ -112,44 +137,48 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
 | 
				
			||||||
// for FmtOpenMetrics, but a future (breaking) release will add the Close method
 | 
					// for FmtOpenMetrics, but a future (breaking) release will add the Close method
 | 
				
			||||||
// to the Encoder interface directly. The current version of the Encoder
 | 
					// to the Encoder interface directly. The current version of the Encoder
 | 
				
			||||||
// interface is kept for backwards compatibility.
 | 
					// interface is kept for backwards compatibility.
 | 
				
			||||||
 | 
					// In cases where the Format does not allow for UTF-8 names, the global
 | 
				
			||||||
 | 
					// NameEscapingScheme will be applied.
 | 
				
			||||||
func NewEncoder(w io.Writer, format Format) Encoder {
 | 
					func NewEncoder(w io.Writer, format Format) Encoder {
 | 
				
			||||||
	switch format {
 | 
						escapingScheme := format.ToEscapingScheme()
 | 
				
			||||||
	case FmtProtoDelim:
 | 
					
 | 
				
			||||||
 | 
						switch format.FormatType() {
 | 
				
			||||||
 | 
						case TypeProtoDelim:
 | 
				
			||||||
		return encoderCloser{
 | 
							return encoderCloser{
 | 
				
			||||||
			encode: func(v *dto.MetricFamily) error {
 | 
								encode: func(v *dto.MetricFamily) error {
 | 
				
			||||||
				_, err := pbutil.WriteDelimited(w, v)
 | 
									_, err := protodelim.MarshalTo(w, v)
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			close: func() error { return nil },
 | 
								close: func() error { return nil },
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case FmtProtoCompact:
 | 
						case TypeProtoCompact:
 | 
				
			||||||
		return encoderCloser{
 | 
							return encoderCloser{
 | 
				
			||||||
			encode: func(v *dto.MetricFamily) error {
 | 
								encode: func(v *dto.MetricFamily) error {
 | 
				
			||||||
				_, err := fmt.Fprintln(w, v.String())
 | 
									_, err := fmt.Fprintln(w, model.EscapeMetricFamily(v, escapingScheme).String())
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			close: func() error { return nil },
 | 
								close: func() error { return nil },
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case FmtProtoText:
 | 
						case TypeProtoText:
 | 
				
			||||||
		return encoderCloser{
 | 
							return encoderCloser{
 | 
				
			||||||
			encode: func(v *dto.MetricFamily) error {
 | 
								encode: func(v *dto.MetricFamily) error {
 | 
				
			||||||
				_, err := fmt.Fprintln(w, proto.MarshalTextString(v))
 | 
									_, err := fmt.Fprintln(w, prototext.Format(model.EscapeMetricFamily(v, escapingScheme)))
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			close: func() error { return nil },
 | 
								close: func() error { return nil },
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case FmtText:
 | 
						case TypeTextPlain:
 | 
				
			||||||
		return encoderCloser{
 | 
							return encoderCloser{
 | 
				
			||||||
			encode: func(v *dto.MetricFamily) error {
 | 
								encode: func(v *dto.MetricFamily) error {
 | 
				
			||||||
				_, err := MetricFamilyToText(w, v)
 | 
									_, err := MetricFamilyToText(w, model.EscapeMetricFamily(v, escapingScheme))
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			close: func() error { return nil },
 | 
								close: func() error { return nil },
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case FmtOpenMetrics:
 | 
						case TypeOpenMetrics:
 | 
				
			||||||
		return encoderCloser{
 | 
							return encoderCloser{
 | 
				
			||||||
			encode: func(v *dto.MetricFamily) error {
 | 
								encode: func(v *dto.MetricFamily) error {
 | 
				
			||||||
				_, err := MetricFamilyToOpenMetrics(w, v)
 | 
									_, err := MetricFamilyToOpenMetrics(w, model.EscapeMetricFamily(v, escapingScheme))
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			close: func() error {
 | 
								close: func() error {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,28 +14,154 @@
 | 
				
			||||||
// Package expfmt contains tools for reading and writing Prometheus metrics.
 | 
					// Package expfmt contains tools for reading and writing Prometheus metrics.
 | 
				
			||||||
package expfmt
 | 
					package expfmt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/prometheus/common/model"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Format specifies the HTTP content type of the different wire protocols.
 | 
					// Format specifies the HTTP content type of the different wire protocols.
 | 
				
			||||||
type Format string
 | 
					type Format string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Constants to assemble the Content-Type values for the different wire protocols.
 | 
					// 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 (
 | 
					const (
 | 
				
			||||||
	TextVersion        = "0.0.4"
 | 
						TextVersion              = "0.0.4"
 | 
				
			||||||
	ProtoType          = `application/vnd.google.protobuf`
 | 
						ProtoType                = `application/vnd.google.protobuf`
 | 
				
			||||||
	ProtoProtocol      = `io.prometheus.client.MetricFamily`
 | 
						ProtoProtocol            = `io.prometheus.client.MetricFamily`
 | 
				
			||||||
	ProtoFmt           = ProtoType + "; proto=" + ProtoProtocol + ";"
 | 
						protoFmt                 = ProtoType + "; proto=" + ProtoProtocol + ";"
 | 
				
			||||||
	OpenMetricsType    = `application/openmetrics-text`
 | 
						OpenMetricsType          = `application/openmetrics-text`
 | 
				
			||||||
	OpenMetricsVersion = "0.0.1"
 | 
						OpenMetricsVersion_0_0_1 = "0.0.1"
 | 
				
			||||||
 | 
						OpenMetricsVersion_1_0_0 = "1.0.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// The Content-Type values for the different wire protocols.
 | 
						// The Content-Type values for the different wire protocols. Note that these
 | 
				
			||||||
	FmtUnknown      Format = `<unknown>`
 | 
						// values are now unexported. If code was relying on comparisons to these
 | 
				
			||||||
	FmtText         Format = `text/plain; version=` + TextVersion + `; charset=utf-8`
 | 
						// constants, instead use FormatType().
 | 
				
			||||||
	FmtProtoDelim   Format = ProtoFmt + ` encoding=delimited`
 | 
						fmtUnknown           Format = `<unknown>`
 | 
				
			||||||
	FmtProtoText    Format = ProtoFmt + ` encoding=text`
 | 
						fmtText              Format = `text/plain; version=` + TextVersion + `; charset=utf-8`
 | 
				
			||||||
	FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text`
 | 
						fmtProtoDelim        Format = protoFmt + ` encoding=delimited`
 | 
				
			||||||
	FmtOpenMetrics  Format = OpenMetricsType + `; version=` + OpenMetricsVersion + `; charset=utf-8`
 | 
						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 (
 | 
					const (
 | 
				
			||||||
	hdrContentType = "Content-Type"
 | 
						hdrContentType = "Content-Type"
 | 
				
			||||||
	hdrAccept      = "Accept"
 | 
						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 = 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.
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// FormatType deduces an overall FormatType for the given format.
 | 
				
			||||||
 | 
					func (f Format) FormatType() FormatType {
 | 
				
			||||||
 | 
						toks := strings.Split(string(f), ";")
 | 
				
			||||||
 | 
						if len(toks) < 2 {
 | 
				
			||||||
 | 
							return TypeUnknown
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,8 +21,8 @@ import "bytes"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Fuzz text metric parser with with github.com/dvyukov/go-fuzz:
 | 
					// Fuzz text metric parser with with github.com/dvyukov/go-fuzz:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//     go-fuzz-build github.com/prometheus/common/expfmt
 | 
					//	go-fuzz-build github.com/prometheus/common/expfmt
 | 
				
			||||||
//     go-fuzz -bin expfmt-fuzz.zip -workdir fuzz
 | 
					//	go-fuzz -bin expfmt-fuzz.zip -workdir fuzz
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Further input samples should go in the folder fuzz/corpus.
 | 
					// Further input samples should go in the folder fuzz/corpus.
 | 
				
			||||||
func Fuzz(in []byte) int {
 | 
					func Fuzz(in []byte) int {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,18 @@ import (
 | 
				
			||||||
// sanity checks. If the input contains duplicate metrics or invalid metric or
 | 
					// sanity checks. If the input contains duplicate metrics or invalid metric or
 | 
				
			||||||
// label names, the conversion will result in invalid text format output.
 | 
					// 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'.
 | 
					// This function fulfills the type 'expfmt.encoder'.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Note that OpenMetrics requires a final `# EOF` line. Since this function acts
 | 
					// Note that OpenMetrics requires a final `# EOF` line. Since this function acts
 | 
				
			||||||
| 
						 | 
					@ -46,20 +58,20 @@ import (
 | 
				
			||||||
// missing features and peculiarities to avoid complications when switching from
 | 
					// missing features and peculiarities to avoid complications when switching from
 | 
				
			||||||
// Prometheus to OpenMetrics or vice versa:
 | 
					// Prometheus to OpenMetrics or vice versa:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// - Counters are expected to have the `_total` suffix in their metric name. In
 | 
					//   - Counters are expected to have the `_total` suffix in their metric name. In
 | 
				
			||||||
//   the output, the suffix will be truncated from the `# TYPE` and `# HELP`
 | 
					//     the output, the suffix will be truncated from the `# TYPE` and `# HELP`
 | 
				
			||||||
//   line. A counter with a missing `_total` suffix is not an error. However,
 | 
					//     line. 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
 | 
					//     its type will be set to `unknown` in that case to avoid invalid OpenMetrics
 | 
				
			||||||
//   output.
 | 
					//     output.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// - No support for the following (optional) features: `# UNIT` line, `_created`
 | 
					//   - No support for the following (optional) features: `# UNIT` line, `_created`
 | 
				
			||||||
//   line, info type, stateset type, gaugehistogram type.
 | 
					//     line, info type, stateset type, gaugehistogram type.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// - The size of exemplar labels is not checked (i.e. it's possible to create
 | 
					//   - 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).
 | 
					//     exemplars that are larger than allowed by the OpenMetrics specification).
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// - The value of Counters is not checked. (OpenMetrics doesn't allow counters
 | 
					//   - The value of Counters is not checked. (OpenMetrics doesn't allow counters
 | 
				
			||||||
//   with a `NaN` value.)
 | 
					//     with a `NaN` value.)
 | 
				
			||||||
func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily) (written int, err error) {
 | 
					func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily) (written int, err error) {
 | 
				
			||||||
	name := in.GetName()
 | 
						name := in.GetName()
 | 
				
			||||||
	if name == "" {
 | 
						if name == "" {
 | 
				
			||||||
| 
						 | 
					@ -98,7 +110,7 @@ func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily) (written int
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		n, err = w.WriteString(shortName)
 | 
							n, err = writeName(w, shortName)
 | 
				
			||||||
		written += n
 | 
							written += n
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
| 
						 | 
					@ -124,7 +136,7 @@ func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily) (written int
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	n, err = w.WriteString(shortName)
 | 
						n, err = writeName(w, shortName)
 | 
				
			||||||
	written += n
 | 
						written += n
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
| 
						 | 
					@ -303,21 +315,9 @@ func writeOpenMetricsSample(
 | 
				
			||||||
	floatValue float64, intValue uint64, useIntValue bool,
 | 
						floatValue float64, intValue uint64, useIntValue bool,
 | 
				
			||||||
	exemplar *dto.Exemplar,
 | 
						exemplar *dto.Exemplar,
 | 
				
			||||||
) (int, error) {
 | 
					) (int, error) {
 | 
				
			||||||
	var written int
 | 
						written := 0
 | 
				
			||||||
	n, err := w.WriteString(name)
 | 
						n, err := writeOpenMetricsNameAndLabelPairs(
 | 
				
			||||||
	written += n
 | 
							w, name+suffix, metric.Label, additionalLabelName, additionalLabelValue,
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return written, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if suffix != "" {
 | 
					 | 
				
			||||||
		n, err = w.WriteString(suffix)
 | 
					 | 
				
			||||||
		written += n
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			return written, err
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	n, err = writeOpenMetricsLabelPairs(
 | 
					 | 
				
			||||||
		w, metric.Label, additionalLabelName, additionalLabelValue,
 | 
					 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	written += n
 | 
						written += n
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -365,27 +365,58 @@ func writeOpenMetricsSample(
 | 
				
			||||||
	return written, nil
 | 
						return written, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// writeOpenMetricsLabelPairs works like writeOpenMetrics but formats the float
 | 
					// writeOpenMetricsNameAndLabelPairs works like writeOpenMetricsSample but
 | 
				
			||||||
// in OpenMetrics style.
 | 
					// formats the float in OpenMetrics style.
 | 
				
			||||||
func writeOpenMetricsLabelPairs(
 | 
					func writeOpenMetricsNameAndLabelPairs(
 | 
				
			||||||
	w enhancedWriter,
 | 
						w enhancedWriter,
 | 
				
			||||||
 | 
						name string,
 | 
				
			||||||
	in []*dto.LabelPair,
 | 
						in []*dto.LabelPair,
 | 
				
			||||||
	additionalLabelName string, additionalLabelValue float64,
 | 
						additionalLabelName string, additionalLabelValue float64,
 | 
				
			||||||
) (int, error) {
 | 
					) (int, error) {
 | 
				
			||||||
	if len(in) == 0 && additionalLabelName == "" {
 | 
					 | 
				
			||||||
		return 0, nil
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	var (
 | 
						var (
 | 
				
			||||||
		written   int
 | 
							written            int
 | 
				
			||||||
		separator byte = '{'
 | 
							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 {
 | 
						for _, lp := range in {
 | 
				
			||||||
		err := w.WriteByte(separator)
 | 
							err := w.WriteByte(separator)
 | 
				
			||||||
		written++
 | 
							written++
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return written, err
 | 
								return written, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		n, err := w.WriteString(lp.GetName())
 | 
							n, err := writeName(w, lp.GetName())
 | 
				
			||||||
		written += n
 | 
							written += n
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return written, err
 | 
								return written, err
 | 
				
			||||||
| 
						 | 
					@ -451,7 +482,7 @@ func writeExemplar(w enhancedWriter, e *dto.Exemplar) (int, error) {
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return written, err
 | 
							return written, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	n, err = writeOpenMetricsLabelPairs(w, e.Label, "", 0)
 | 
						n, err = writeOpenMetricsNameAndLabelPairs(w, "", e.Label, "", 0)
 | 
				
			||||||
	written += n
 | 
						written += n
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return written, err
 | 
							return written, err
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,6 @@ import (
 | 
				
			||||||
	"bufio"
 | 
						"bufio"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"io/ioutil"
 | 
					 | 
				
			||||||
	"math"
 | 
						"math"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
| 
						 | 
					@ -44,7 +43,7 @@ const (
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	bufPool = sync.Pool{
 | 
						bufPool = sync.Pool{
 | 
				
			||||||
		New: func() interface{} {
 | 
							New: func() interface{} {
 | 
				
			||||||
			return bufio.NewWriter(ioutil.Discard)
 | 
								return bufio.NewWriter(io.Discard)
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	numBufPool = sync.Pool{
 | 
						numBufPool = sync.Pool{
 | 
				
			||||||
| 
						 | 
					@ -63,6 +62,18 @@ var (
 | 
				
			||||||
// contains duplicate metrics or invalid metric or label names, the conversion
 | 
					// contains duplicate metrics or invalid metric or label names, the conversion
 | 
				
			||||||
// will result in invalid text format output.
 | 
					// 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'.
 | 
					// This method fulfills the type 'prometheus.encoder'.
 | 
				
			||||||
func MetricFamilyToText(out io.Writer, in *dto.MetricFamily) (written int, err error) {
 | 
					func MetricFamilyToText(out io.Writer, in *dto.MetricFamily) (written int, err error) {
 | 
				
			||||||
	// Fail-fast checks.
 | 
						// Fail-fast checks.
 | 
				
			||||||
| 
						 | 
					@ -99,7 +110,7 @@ func MetricFamilyToText(out io.Writer, in *dto.MetricFamily) (written int, err e
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		n, err = w.WriteString(name)
 | 
							n, err = writeName(w, name)
 | 
				
			||||||
		written += n
 | 
							written += n
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
| 
						 | 
					@ -125,7 +136,7 @@ func MetricFamilyToText(out io.Writer, in *dto.MetricFamily) (written int, err e
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	n, err = w.WriteString(name)
 | 
						n, err = writeName(w, name)
 | 
				
			||||||
	written += n
 | 
						written += n
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
| 
						 | 
					@ -281,21 +292,9 @@ func writeSample(
 | 
				
			||||||
	additionalLabelName string, additionalLabelValue float64,
 | 
						additionalLabelName string, additionalLabelValue float64,
 | 
				
			||||||
	value float64,
 | 
						value float64,
 | 
				
			||||||
) (int, error) {
 | 
					) (int, error) {
 | 
				
			||||||
	var written int
 | 
						written := 0
 | 
				
			||||||
	n, err := w.WriteString(name)
 | 
						n, err := writeNameAndLabelPairs(
 | 
				
			||||||
	written += n
 | 
							w, name+suffix, metric.Label, additionalLabelName, additionalLabelValue,
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return written, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if suffix != "" {
 | 
					 | 
				
			||||||
		n, err = w.WriteString(suffix)
 | 
					 | 
				
			||||||
		written += n
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			return written, err
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	n, err = writeLabelPairs(
 | 
					 | 
				
			||||||
		w, metric.Label, additionalLabelName, additionalLabelValue,
 | 
					 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	written += n
 | 
						written += n
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -331,32 +330,64 @@ func writeSample(
 | 
				
			||||||
	return written, nil
 | 
						return written, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// writeLabelPairs converts a slice of LabelPair proto messages plus the
 | 
					// writeNameAndLabelPairs converts a slice of LabelPair proto messages plus the
 | 
				
			||||||
// explicitly given additional label pair into text formatted as required by the
 | 
					// explicitly given metric name and additional label pair into text formatted as
 | 
				
			||||||
// text format and writes it to 'w'. An empty slice in combination with an empty
 | 
					// required by the text format and writes it to 'w'. An empty slice in
 | 
				
			||||||
// string 'additionalLabelName' results in nothing being written. Otherwise, the
 | 
					// combination with an empty string 'additionalLabelName' results in nothing
 | 
				
			||||||
// label pairs are written, escaped as required by the text format, and enclosed
 | 
					// being written. Otherwise, the label pairs are written, escaped as required by
 | 
				
			||||||
// in '{...}'. The function returns the number of bytes written and any error
 | 
					// the text format, and enclosed in '{...}'. The function returns the number of
 | 
				
			||||||
// encountered.
 | 
					// bytes written and any error encountered. If the metric name is not
 | 
				
			||||||
func writeLabelPairs(
 | 
					// legacy-valid, it will be put inside the brackets as well. Legacy-invalid
 | 
				
			||||||
 | 
					// label names will also be quoted.
 | 
				
			||||||
 | 
					func writeNameAndLabelPairs(
 | 
				
			||||||
	w enhancedWriter,
 | 
						w enhancedWriter,
 | 
				
			||||||
 | 
						name string,
 | 
				
			||||||
	in []*dto.LabelPair,
 | 
						in []*dto.LabelPair,
 | 
				
			||||||
	additionalLabelName string, additionalLabelValue float64,
 | 
						additionalLabelName string, additionalLabelValue float64,
 | 
				
			||||||
) (int, error) {
 | 
					) (int, error) {
 | 
				
			||||||
	if len(in) == 0 && additionalLabelName == "" {
 | 
					 | 
				
			||||||
		return 0, nil
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	var (
 | 
						var (
 | 
				
			||||||
		written   int
 | 
							written            int
 | 
				
			||||||
		separator byte = '{'
 | 
							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 {
 | 
						for _, lp := range in {
 | 
				
			||||||
		err := w.WriteByte(separator)
 | 
							err := w.WriteByte(separator)
 | 
				
			||||||
		written++
 | 
							written++
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return written, err
 | 
								return written, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		n, err := w.WriteString(lp.GetName())
 | 
							n, err := writeName(w, lp.GetName())
 | 
				
			||||||
		written += n
 | 
							written += n
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return written, err
 | 
								return written, err
 | 
				
			||||||
| 
						 | 
					@ -463,3 +494,27 @@ func writeInt(w enhancedWriter, i int64) (int, error) {
 | 
				
			||||||
	numBufPool.Put(bp)
 | 
						numBufPool.Put(bp)
 | 
				
			||||||
	return written, err
 | 
						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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,7 @@ package expfmt
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bufio"
 | 
						"bufio"
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"math"
 | 
						"math"
 | 
				
			||||||
| 
						 | 
					@ -24,7 +25,8 @@ import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dto "github.com/prometheus/client_model/go"
 | 
						dto "github.com/prometheus/client_model/go"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
 | 
						"google.golang.org/protobuf/proto"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/prometheus/common/model"
 | 
						"github.com/prometheus/common/model"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,7 +114,7 @@ func (p *TextParser) TextToMetricFamilies(in io.Reader) (map[string]*dto.MetricF
 | 
				
			||||||
	// stream. Turn this error into something nicer and more
 | 
						// stream. Turn this error into something nicer and more
 | 
				
			||||||
	// meaningful. (io.EOF is often used as a signal for the legitimate end
 | 
						// meaningful. (io.EOF is often used as a signal for the legitimate end
 | 
				
			||||||
	// of an input stream.)
 | 
						// of an input stream.)
 | 
				
			||||||
	if p.err == io.EOF {
 | 
						if p.err != nil && errors.Is(p.err, io.EOF) {
 | 
				
			||||||
		p.parseError("unexpected end of input stream")
 | 
							p.parseError("unexpected end of input stream")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return p.metricFamiliesByName, p.err
 | 
						return p.metricFamiliesByName, p.err
 | 
				
			||||||
| 
						 | 
					@ -142,9 +144,13 @@ func (p *TextParser) reset(in io.Reader) {
 | 
				
			||||||
func (p *TextParser) startOfLine() stateFn {
 | 
					func (p *TextParser) startOfLine() stateFn {
 | 
				
			||||||
	p.lineCount++
 | 
						p.lineCount++
 | 
				
			||||||
	if p.skipBlankTab(); p.err != nil {
 | 
						if p.skipBlankTab(); p.err != nil {
 | 
				
			||||||
		// End of input reached. This is the only case where
 | 
							// This is the only place that we expect to see io.EOF,
 | 
				
			||||||
		// that is not an error but a signal that we are done.
 | 
							// which is not an error but the signal that we are done.
 | 
				
			||||||
		p.err = nil
 | 
							// 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
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	switch p.currentByte {
 | 
						switch p.currentByte {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										22
									
								
								vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go
								
								
									generated
								
								
									vendored
								
								
							
							
						
						
									
										22
									
								
								vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go
								
								
									generated
								
								
									vendored
								
								
							| 
						 | 
					@ -11,18 +11,18 @@ Redistribution and use in source and binary forms, with or without
 | 
				
			||||||
modification, are permitted provided that the following conditions are
 | 
					modification, are permitted provided that the following conditions are
 | 
				
			||||||
met:
 | 
					met:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Redistributions of source code must retain the above copyright
 | 
						Redistributions of source code must retain the above copyright
 | 
				
			||||||
    notice, this list of conditions and the following disclaimer.
 | 
						notice, this list of conditions and the following disclaimer.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Redistributions in binary form must reproduce the above copyright
 | 
						Redistributions in binary form must reproduce the above copyright
 | 
				
			||||||
    notice, this list of conditions and the following disclaimer in
 | 
						notice, this list of conditions and the following disclaimer in
 | 
				
			||||||
    the documentation and/or other materials provided with the
 | 
						the documentation and/or other materials provided with the
 | 
				
			||||||
    distribution.
 | 
						distribution.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Neither the name of the Open Knowledge Foundation Ltd. nor the
 | 
						Neither the name of the Open Knowledge Foundation Ltd. nor the
 | 
				
			||||||
    names of its contributors may be used to endorse or promote
 | 
						names of its contributors may be used to endorse or promote
 | 
				
			||||||
    products derived from this software without specific prior written
 | 
						products derived from this software without specific prior written
 | 
				
			||||||
    permission.
 | 
						permission.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
					THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
				
			||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
					"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
				
			||||||
| 
						 | 
					@ -35,8 +35,6 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 | 
				
			||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 | 
					THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 | 
				
			||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
					(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
				
			||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
					OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
package goautoneg
 | 
					package goautoneg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,13 +90,13 @@ func (a *Alert) Validate() error {
 | 
				
			||||||
		return fmt.Errorf("start time must be before end time")
 | 
							return fmt.Errorf("start time must be before end time")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err := a.Labels.Validate(); err != nil {
 | 
						if err := a.Labels.Validate(); err != nil {
 | 
				
			||||||
		return fmt.Errorf("invalid label set: %s", err)
 | 
							return fmt.Errorf("invalid label set: %w", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(a.Labels) == 0 {
 | 
						if len(a.Labels) == 0 {
 | 
				
			||||||
		return fmt.Errorf("at least one label pair required")
 | 
							return fmt.Errorf("at least one label pair required")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err := a.Annotations.Validate(); err != nil {
 | 
						if err := a.Annotations.Validate(); err != nil {
 | 
				
			||||||
		return fmt.Errorf("invalid annotations: %s", err)
 | 
							return fmt.Errorf("invalid annotations: %w", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,17 +97,25 @@ var LabelNameRE = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$")
 | 
				
			||||||
// therewith.
 | 
					// therewith.
 | 
				
			||||||
type LabelName string
 | 
					type LabelName string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IsValid is true iff the label name matches the pattern of LabelNameRE. This
 | 
					// IsValid returns true iff name matches the pattern of LabelNameRE for legacy
 | 
				
			||||||
// method, however, does not use LabelNameRE for the check but a much faster
 | 
					// names, and iff it's valid UTF-8 if NameValidationScheme is set to
 | 
				
			||||||
// hardcoded implementation.
 | 
					// UTF8Validation. For the legacy matching, it does not use LabelNameRE for the
 | 
				
			||||||
 | 
					// check but a much faster hardcoded implementation.
 | 
				
			||||||
func (ln LabelName) IsValid() bool {
 | 
					func (ln LabelName) IsValid() bool {
 | 
				
			||||||
	if len(ln) == 0 {
 | 
						if len(ln) == 0 {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, b := range ln {
 | 
						switch NameValidationScheme {
 | 
				
			||||||
		if !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || (b >= '0' && b <= '9' && i > 0)) {
 | 
						case LegacyValidation:
 | 
				
			||||||
			return false
 | 
							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
 | 
						return true
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -164,7 +172,7 @@ func (l LabelNames) String() string {
 | 
				
			||||||
// A LabelValue is an associated value for a LabelName.
 | 
					// A LabelValue is an associated value for a LabelName.
 | 
				
			||||||
type LabelValue string
 | 
					type LabelValue string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IsValid returns true iff the string is a valid UTF8.
 | 
					// IsValid returns true iff the string is a valid UTF-8.
 | 
				
			||||||
func (lv LabelValue) IsValid() bool {
 | 
					func (lv LabelValue) IsValid() bool {
 | 
				
			||||||
	return utf8.ValidString(string(lv))
 | 
						return utf8.ValidString(string(lv))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					// 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")
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -18,15 +18,84 @@ import (
 | 
				
			||||||
	"regexp"
 | 
						"regexp"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
						"unicode/utf8"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dto "github.com/prometheus/client_model/go"
 | 
				
			||||||
 | 
						"google.golang.org/protobuf/proto"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	// MetricNameRE is a regular expression matching valid metric
 | 
						// NameValidationScheme determines the method of name validation to be used by
 | 
				
			||||||
	// names. Note that the IsValidMetricName function performs the same
 | 
						// all calls to IsValidMetricName() and LabelName IsValid(). Setting UTF-8 mode
 | 
				
			||||||
	// check but faster than a match with this regular expression.
 | 
						// in isolation from other components that don't support UTF-8 may result in
 | 
				
			||||||
	MetricNameRE = regexp.MustCompile(`^[a-zA-Z_:][a-zA-Z0-9_:]*$`)
 | 
						// 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 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.
 | 
					// a singleton and refers to one and only one stream of samples.
 | 
				
			||||||
type Metric LabelSet
 | 
					type Metric LabelSet
 | 
				
			||||||
| 
						 | 
					@ -86,17 +155,302 @@ func (m Metric) FastFingerprint() Fingerprint {
 | 
				
			||||||
	return LabelSet(m).FastFingerprint()
 | 
						return LabelSet(m).FastFingerprint()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IsValidMetricName returns true iff name matches the pattern of MetricNameRE.
 | 
					// 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
 | 
					// This function, however, does not use MetricNameRE for the check but a much
 | 
				
			||||||
// faster hardcoded implementation.
 | 
					// faster hardcoded implementation.
 | 
				
			||||||
func IsValidMetricName(n LabelValue) bool {
 | 
					func IsValidLegacyMetricName(n LabelValue) bool {
 | 
				
			||||||
	if len(n) == 0 {
 | 
						if len(n) == 0 {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, b := range n {
 | 
						for i, b := range n {
 | 
				
			||||||
		if !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || b == ':' || (b >= '0' && b <= '9' && i > 0)) {
 | 
							if !isValidLegacyRune(b, i) {
 | 
				
			||||||
			return false
 | 
								return false
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return true
 | 
						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,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 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)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,10 +22,8 @@ import (
 | 
				
			||||||
// when calculating their combined hash value (aka signature aka fingerprint).
 | 
					// when calculating their combined hash value (aka signature aka fingerprint).
 | 
				
			||||||
const SeparatorByte byte = 255
 | 
					const SeparatorByte byte = 255
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					// cache the signature of an empty label set.
 | 
				
			||||||
	// cache the signature of an empty label set.
 | 
					var emptyLabelSignature = hashNew()
 | 
				
			||||||
	emptyLabelSignature = hashNew()
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// LabelsToSignature returns a quasi-unique signature (i.e., fingerprint) for a
 | 
					// LabelsToSignature returns a quasi-unique signature (i.e., fingerprint) for a
 | 
				
			||||||
// given label set. (Collisions are possible but unlikely if the number of label
 | 
					// given label set. (Collisions are possible but unlikely if the number of label
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,7 +81,7 @@ func (s *Silence) Validate() error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, m := range s.Matchers {
 | 
						for _, m := range s.Matchers {
 | 
				
			||||||
		if err := m.Validate(); err != nil {
 | 
							if err := m.Validate(); err != nil {
 | 
				
			||||||
			return fmt.Errorf("invalid matcher: %s", err)
 | 
								return fmt.Errorf("invalid matcher: %w", err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if s.StartsAt.IsZero() {
 | 
						if s.StartsAt.IsZero() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,6 @@ import (
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"math"
 | 
						"math"
 | 
				
			||||||
	"regexp"
 | 
					 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
| 
						 | 
					@ -183,54 +182,78 @@ func (d *Duration) Type() string {
 | 
				
			||||||
	return "duration"
 | 
						return "duration"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var durationRE = regexp.MustCompile("^(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?$")
 | 
					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
 | 
					// 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.
 | 
					// always has 365d, a week always has 7d, and a day always has 24h.
 | 
				
			||||||
func ParseDuration(durationStr string) (Duration, error) {
 | 
					func ParseDuration(s string) (Duration, error) {
 | 
				
			||||||
	switch durationStr {
 | 
						switch s {
 | 
				
			||||||
	case "0":
 | 
						case "0":
 | 
				
			||||||
		// Allow 0 without a unit.
 | 
							// Allow 0 without a unit.
 | 
				
			||||||
		return 0, nil
 | 
							return 0, nil
 | 
				
			||||||
	case "":
 | 
						case "":
 | 
				
			||||||
		return 0, errors.New("empty duration string")
 | 
							return 0, errors.New("empty duration string")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	matches := durationRE.FindStringSubmatch(durationStr)
 | 
					 | 
				
			||||||
	if matches == nil {
 | 
					 | 
				
			||||||
		return 0, fmt.Errorf("not a valid duration string: %q", durationStr)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	var dur time.Duration
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Parse the match at pos `pos` in the regex and use `mult` to turn that
 | 
						orig := s
 | 
				
			||||||
	// into ms, then add that value to the total parsed duration.
 | 
						var dur uint64
 | 
				
			||||||
	var overflowErr error
 | 
						lastUnitPos := 0
 | 
				
			||||||
	m := func(pos int, mult time.Duration) {
 | 
					
 | 
				
			||||||
		if matches[pos] == "" {
 | 
						for s != "" {
 | 
				
			||||||
			return
 | 
							if !isdigit(s[0]) {
 | 
				
			||||||
 | 
								return 0, fmt.Errorf("not a valid duration string: %q", orig)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		n, _ := strconv.Atoi(matches[pos])
 | 
							// 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).
 | 
							// Check if the provided duration overflows time.Duration (> ~ 290years).
 | 
				
			||||||
		if n > int((1<<63-1)/mult/time.Millisecond) {
 | 
							if v > 1<<63/unit.mult {
 | 
				
			||||||
			overflowErr = errors.New("duration out of range")
 | 
								return 0, errors.New("duration out of range")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		d := time.Duration(n) * time.Millisecond
 | 
							dur += v * unit.mult
 | 
				
			||||||
		dur += d * mult
 | 
							if dur > 1<<63-1 {
 | 
				
			||||||
 | 
								return 0, errors.New("duration out of range")
 | 
				
			||||||
		if dur < 0 {
 | 
					 | 
				
			||||||
			overflowErr = errors.New("duration out of range")
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return Duration(dur), nil
 | 
				
			||||||
	m(2, 1000*60*60*24*365) // y
 | 
					 | 
				
			||||||
	m(4, 1000*60*60*24*7)   // w
 | 
					 | 
				
			||||||
	m(6, 1000*60*60*24)     // d
 | 
					 | 
				
			||||||
	m(8, 1000*60*60)        // h
 | 
					 | 
				
			||||||
	m(10, 1000*60)          // m
 | 
					 | 
				
			||||||
	m(12, 1000)             // s
 | 
					 | 
				
			||||||
	m(14, 1)                // ms
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return Duration(dur), overflowErr
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (d Duration) String() string {
 | 
					func (d Duration) String() string {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,104 +16,26 @@ package model
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"math"
 | 
					 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					// ZeroSample is the pseudo zero-value of Sample used to signal a
 | 
				
			||||||
	// ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a
 | 
					// non-existing sample. It is a Sample with timestamp Earliest, value 0.0,
 | 
				
			||||||
	// non-existing sample pair. It is a SamplePair with timestamp Earliest and
 | 
					// and metric nil. Note that the natural zero value of Sample has a timestamp
 | 
				
			||||||
	// value 0.0. Note that the natural zero value of SamplePair has a timestamp
 | 
					// of 0, which is possible to appear in a real Sample and thus not suitable
 | 
				
			||||||
	// of 0, which is possible to appear in a real SamplePair and thus not
 | 
					// to signal a non-existing Sample.
 | 
				
			||||||
	// suitable to signal a non-existing SamplePair.
 | 
					var ZeroSample = Sample{Timestamp: Earliest}
 | 
				
			||||||
	ZeroSamplePair = SamplePair{Timestamp: Earliest}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// ZeroSample is the pseudo zero-value of Sample used to signal a
 | 
					// Sample is a sample pair associated with a metric. A single sample must either
 | 
				
			||||||
	// non-existing sample. It is a Sample with timestamp Earliest, value 0.0,
 | 
					// define Value or Histogram but not both. Histogram == nil implies the Value
 | 
				
			||||||
	// and metric nil. Note that the natural zero value of Sample has a timestamp
 | 
					// field is used, otherwise it should be ignored.
 | 
				
			||||||
	// of 0, which is possible to appear in a real Sample and thus not suitable
 | 
					 | 
				
			||||||
	// to signal a non-existing Sample.
 | 
					 | 
				
			||||||
	ZeroSample = Sample{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
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// MarshalJSON implements json.Marshaler.
 | 
					 | 
				
			||||||
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)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Sample is a sample pair associated with a metric.
 | 
					 | 
				
			||||||
type Sample struct {
 | 
					type Sample struct {
 | 
				
			||||||
	Metric    Metric      `json:"metric"`
 | 
						Metric    Metric           `json:"metric"`
 | 
				
			||||||
	Value     SampleValue `json:"value"`
 | 
						Value     SampleValue      `json:"value"`
 | 
				
			||||||
	Timestamp Time        `json:"timestamp"`
 | 
						Timestamp Time             `json:"timestamp"`
 | 
				
			||||||
 | 
						Histogram *SampleHistogram `json:"histogram"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Equal compares first the metrics, then the timestamp, then the value. The
 | 
					// Equal compares first the metrics, then the timestamp, then the value. The
 | 
				
			||||||
| 
						 | 
					@ -129,11 +51,19 @@ func (s *Sample) Equal(o *Sample) bool {
 | 
				
			||||||
	if !s.Timestamp.Equal(o.Timestamp) {
 | 
						if !s.Timestamp.Equal(o.Timestamp) {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if s.Histogram != nil {
 | 
				
			||||||
 | 
							return s.Histogram.Equal(o.Histogram)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return s.Value.Equal(o.Value)
 | 
						return s.Value.Equal(o.Value)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s Sample) String() string {
 | 
					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{
 | 
						return fmt.Sprintf("%s => %s", s.Metric, SamplePair{
 | 
				
			||||||
		Timestamp: s.Timestamp,
 | 
							Timestamp: s.Timestamp,
 | 
				
			||||||
		Value:     s.Value,
 | 
							Value:     s.Value,
 | 
				
			||||||
| 
						 | 
					@ -142,6 +72,19 @@ func (s Sample) String() string {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// MarshalJSON implements json.Marshaler.
 | 
					// MarshalJSON implements json.Marshaler.
 | 
				
			||||||
func (s Sample) MarshalJSON() ([]byte, error) {
 | 
					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 {
 | 
						v := struct {
 | 
				
			||||||
		Metric Metric     `json:"metric"`
 | 
							Metric Metric     `json:"metric"`
 | 
				
			||||||
		Value  SamplePair `json:"value"`
 | 
							Value  SamplePair `json:"value"`
 | 
				
			||||||
| 
						 | 
					@ -152,21 +95,25 @@ func (s Sample) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
			Value:     s.Value,
 | 
								Value:     s.Value,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	return json.Marshal(&v)
 | 
						return json.Marshal(&v)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UnmarshalJSON implements json.Unmarshaler.
 | 
					// UnmarshalJSON implements json.Unmarshaler.
 | 
				
			||||||
func (s *Sample) UnmarshalJSON(b []byte) error {
 | 
					func (s *Sample) UnmarshalJSON(b []byte) error {
 | 
				
			||||||
	v := struct {
 | 
						v := struct {
 | 
				
			||||||
		Metric Metric     `json:"metric"`
 | 
							Metric    Metric              `json:"metric"`
 | 
				
			||||||
		Value  SamplePair `json:"value"`
 | 
							Value     SamplePair          `json:"value"`
 | 
				
			||||||
 | 
							Histogram SampleHistogramPair `json:"histogram"`
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		Metric: s.Metric,
 | 
							Metric: s.Metric,
 | 
				
			||||||
		Value: SamplePair{
 | 
							Value: SamplePair{
 | 
				
			||||||
			Timestamp: s.Timestamp,
 | 
								Timestamp: s.Timestamp,
 | 
				
			||||||
			Value:     s.Value,
 | 
								Value:     s.Value,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							Histogram: SampleHistogramPair{
 | 
				
			||||||
 | 
								Timestamp: s.Timestamp,
 | 
				
			||||||
 | 
								Histogram: s.Histogram,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := json.Unmarshal(b, &v); err != nil {
 | 
						if err := json.Unmarshal(b, &v); err != nil {
 | 
				
			||||||
| 
						 | 
					@ -174,8 +121,13 @@ func (s *Sample) UnmarshalJSON(b []byte) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s.Metric = v.Metric
 | 
						s.Metric = v.Metric
 | 
				
			||||||
	s.Timestamp = v.Value.Timestamp
 | 
						if v.Histogram.Histogram != nil {
 | 
				
			||||||
	s.Value = v.Value.Value
 | 
							s.Timestamp = v.Histogram.Timestamp
 | 
				
			||||||
 | 
							s.Histogram = v.Histogram.Histogram
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							s.Timestamp = v.Value.Timestamp
 | 
				
			||||||
 | 
							s.Value = v.Value.Value
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -221,80 +173,76 @@ func (s Samples) Equal(o Samples) bool {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SampleStream is a stream of Values belonging to an attached COWMetric.
 | 
					// SampleStream is a stream of Values belonging to an attached COWMetric.
 | 
				
			||||||
type SampleStream struct {
 | 
					type SampleStream struct {
 | 
				
			||||||
	Metric Metric       `json:"metric"`
 | 
						Metric     Metric                `json:"metric"`
 | 
				
			||||||
	Values []SamplePair `json:"values"`
 | 
						Values     []SamplePair          `json:"values"`
 | 
				
			||||||
 | 
						Histograms []SampleHistogramPair `json:"histograms"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ss SampleStream) String() string {
 | 
					func (ss SampleStream) String() string {
 | 
				
			||||||
	vals := make([]string, len(ss.Values))
 | 
						valuesLength := len(ss.Values)
 | 
				
			||||||
 | 
						vals := make([]string, valuesLength+len(ss.Histograms))
 | 
				
			||||||
	for i, v := range ss.Values {
 | 
						for i, v := range ss.Values {
 | 
				
			||||||
		vals[i] = v.String()
 | 
							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"))
 | 
						return fmt.Sprintf("%s =>\n%s", ss.Metric, strings.Join(vals, "\n"))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Value is a generic interface for values resulting from a query evaluation.
 | 
					func (ss SampleStream) MarshalJSON() ([]byte, error) {
 | 
				
			||||||
type Value interface {
 | 
						if len(ss.Histograms) > 0 && len(ss.Values) > 0 {
 | 
				
			||||||
	Type() ValueType
 | 
							v := struct {
 | 
				
			||||||
	String() string
 | 
								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 (Matrix) Type() ValueType  { return ValMatrix }
 | 
					func (ss *SampleStream) UnmarshalJSON(b []byte) error {
 | 
				
			||||||
func (Vector) Type() ValueType  { return ValVector }
 | 
						v := struct {
 | 
				
			||||||
func (*Scalar) Type() ValueType { return ValScalar }
 | 
							Metric     Metric                `json:"metric"`
 | 
				
			||||||
func (*String) Type() ValueType { return ValString }
 | 
							Values     []SamplePair          `json:"values"`
 | 
				
			||||||
 | 
							Histograms []SampleHistogramPair `json:"histograms"`
 | 
				
			||||||
 | 
						}{
 | 
				
			||||||
 | 
							Metric:     ss.Metric,
 | 
				
			||||||
 | 
							Values:     ss.Values,
 | 
				
			||||||
 | 
							Histograms: ss.Histograms,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ValueType int
 | 
						if err := json.Unmarshal(b, &v); err != nil {
 | 
				
			||||||
 | 
					 | 
				
			||||||
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
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	switch s {
 | 
					 | 
				
			||||||
	case "<ValNone>":
 | 
					 | 
				
			||||||
		*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 {
 | 
						ss.Metric = v.Metric
 | 
				
			||||||
	switch e {
 | 
						ss.Values = v.Values
 | 
				
			||||||
	case ValNone:
 | 
						ss.Histograms = v.Histograms
 | 
				
			||||||
		return "<ValNone>"
 | 
					
 | 
				
			||||||
	case ValScalar:
 | 
						return nil
 | 
				
			||||||
		return "scalar"
 | 
					 | 
				
			||||||
	case ValVector:
 | 
					 | 
				
			||||||
		return "vector"
 | 
					 | 
				
			||||||
	case ValMatrix:
 | 
					 | 
				
			||||||
		return "matrix"
 | 
					 | 
				
			||||||
	case ValString:
 | 
					 | 
				
			||||||
		return "string"
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	panic("ValueType.String: unhandled value type")
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Scalar is a scalar value evaluated at the set timestamp.
 | 
					// Scalar is a scalar value evaluated at the set timestamp.
 | 
				
			||||||
| 
						 | 
					@ -324,7 +272,7 @@ func (s *Scalar) UnmarshalJSON(b []byte) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	value, err := strconv.ParseFloat(f, 64)
 | 
						value, err := strconv.ParseFloat(f, 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return fmt.Errorf("error parsing sample value: %s", err)
 | 
							return fmt.Errorf("error parsing sample value: %w", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	s.Value = SampleValue(value)
 | 
						s.Value = SampleValue(value)
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,98 @@
 | 
				
			||||||
 | 
					// 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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,178 @@
 | 
				
			||||||
 | 
					// 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))
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,83 @@
 | 
				
			||||||
 | 
					// 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 "<ValNone>":
 | 
				
			||||||
 | 
							*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 "<ValNone>"
 | 
				
			||||||
 | 
						case ValScalar:
 | 
				
			||||||
 | 
							return "scalar"
 | 
				
			||||||
 | 
						case ValVector:
 | 
				
			||||||
 | 
							return "vector"
 | 
				
			||||||
 | 
						case ValMatrix:
 | 
				
			||||||
 | 
							return "matrix"
 | 
				
			||||||
 | 
						case ValString:
 | 
				
			||||||
 | 
							return "string"
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						panic("ValueType.String: unhandled value type")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
linters:
 | 
					linters:
 | 
				
			||||||
  enable:
 | 
					  enable:
 | 
				
			||||||
  - godot
 | 
					  - godot
 | 
				
			||||||
 | 
					  - misspell
 | 
				
			||||||
  - revive
 | 
					  - revive
 | 
				
			||||||
 | 
					
 | 
				
			||||||
linter-settings:
 | 
					linter-settings:
 | 
				
			||||||
| 
						 | 
					@ -10,3 +11,5 @@ linter-settings:
 | 
				
			||||||
    exclude:
 | 
					    exclude:
 | 
				
			||||||
    # Ignore "See: URL"
 | 
					    # Ignore "See: URL"
 | 
				
			||||||
    - 'See:'
 | 
					    - 'See:'
 | 
				
			||||||
 | 
					  misspell:
 | 
				
			||||||
 | 
					    locale: US
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,25 +49,28 @@ endif
 | 
				
			||||||
GOTEST := $(GO) test
 | 
					GOTEST := $(GO) test
 | 
				
			||||||
GOTEST_DIR :=
 | 
					GOTEST_DIR :=
 | 
				
			||||||
ifneq ($(CIRCLE_JOB),)
 | 
					ifneq ($(CIRCLE_JOB),)
 | 
				
			||||||
ifneq ($(shell which gotestsum),)
 | 
					ifneq ($(shell command -v gotestsum > /dev/null),)
 | 
				
			||||||
	GOTEST_DIR := test-results
 | 
						GOTEST_DIR := test-results
 | 
				
			||||||
	GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml --
 | 
						GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml --
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PROMU_VERSION ?= 0.13.0
 | 
					PROMU_VERSION ?= 0.15.0
 | 
				
			||||||
PROMU_URL     := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
 | 
					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 :=
 | 
				
			||||||
GOLANGCI_LINT_OPTS ?=
 | 
					GOLANGCI_LINT_OPTS ?=
 | 
				
			||||||
GOLANGCI_LINT_VERSION ?= v1.45.2
 | 
					GOLANGCI_LINT_VERSION ?= v1.54.2
 | 
				
			||||||
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
 | 
					# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
 | 
				
			||||||
# windows isn't included here because of the path separator being different.
 | 
					# windows isn't included here because of the path separator being different.
 | 
				
			||||||
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
 | 
					ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
 | 
				
			||||||
	ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
 | 
						ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
 | 
				
			||||||
		# If we're in CI and there is an Actions file, that means the linter
 | 
							# 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.
 | 
							# is being run in Actions, so we don't need to run it here.
 | 
				
			||||||
		ifeq (,$(CIRCLE_JOB))
 | 
							ifneq (,$(SKIP_GOLANGCI_LINT))
 | 
				
			||||||
 | 
								GOLANGCI_LINT :=
 | 
				
			||||||
 | 
							else ifeq (,$(CIRCLE_JOB))
 | 
				
			||||||
			GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
 | 
								GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
 | 
				
			||||||
		else ifeq (,$(wildcard .github/workflows/golangci-lint.yml))
 | 
							else ifeq (,$(wildcard .github/workflows/golangci-lint.yml))
 | 
				
			||||||
			GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
 | 
								GOLANGCI_LINT := $(FIRST_GOPATH)/bin/golangci-lint
 | 
				
			||||||
| 
						 | 
					@ -88,6 +91,8 @@ BUILD_DOCKER_ARCHS = $(addprefix common-docker-,$(DOCKER_ARCHS))
 | 
				
			||||||
PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS))
 | 
					PUBLISH_DOCKER_ARCHS = $(addprefix common-docker-publish-,$(DOCKER_ARCHS))
 | 
				
			||||||
TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS))
 | 
					TAG_DOCKER_ARCHS = $(addprefix common-docker-tag-latest-,$(DOCKER_ARCHS))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SANITIZED_DOCKER_IMAGE_TAG := $(subst +,-,$(DOCKER_IMAGE_TAG))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ifeq ($(GOHOSTARCH),amd64)
 | 
					ifeq ($(GOHOSTARCH),amd64)
 | 
				
			||||||
        ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows))
 | 
					        ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin windows))
 | 
				
			||||||
                # Only supported on amd64
 | 
					                # Only supported on amd64
 | 
				
			||||||
| 
						 | 
					@ -173,7 +178,7 @@ endif
 | 
				
			||||||
.PHONY: common-yamllint
 | 
					.PHONY: common-yamllint
 | 
				
			||||||
common-yamllint:
 | 
					common-yamllint:
 | 
				
			||||||
	@echo ">> running yamllint on all YAML files in the repository"
 | 
						@echo ">> running yamllint on all YAML files in the repository"
 | 
				
			||||||
ifeq (, $(shell which yamllint))
 | 
					ifeq (, $(shell command -v yamllint > /dev/null))
 | 
				
			||||||
	@echo "yamllint not installed so skipping"
 | 
						@echo "yamllint not installed so skipping"
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
	yamllint .
 | 
						yamllint .
 | 
				
			||||||
| 
						 | 
					@ -202,7 +207,7 @@ common-tarball: promu
 | 
				
			||||||
.PHONY: common-docker $(BUILD_DOCKER_ARCHS)
 | 
					.PHONY: common-docker $(BUILD_DOCKER_ARCHS)
 | 
				
			||||||
common-docker: $(BUILD_DOCKER_ARCHS)
 | 
					common-docker: $(BUILD_DOCKER_ARCHS)
 | 
				
			||||||
$(BUILD_DOCKER_ARCHS): common-docker-%:
 | 
					$(BUILD_DOCKER_ARCHS): common-docker-%:
 | 
				
			||||||
	docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" \
 | 
						docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)" \
 | 
				
			||||||
		-f $(DOCKERFILE_PATH) \
 | 
							-f $(DOCKERFILE_PATH) \
 | 
				
			||||||
		--build-arg ARCH="$*" \
 | 
							--build-arg ARCH="$*" \
 | 
				
			||||||
		--build-arg OS="linux" \
 | 
							--build-arg OS="linux" \
 | 
				
			||||||
| 
						 | 
					@ -211,19 +216,19 @@ $(BUILD_DOCKER_ARCHS): common-docker-%:
 | 
				
			||||||
.PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS)
 | 
					.PHONY: common-docker-publish $(PUBLISH_DOCKER_ARCHS)
 | 
				
			||||||
common-docker-publish: $(PUBLISH_DOCKER_ARCHS)
 | 
					common-docker-publish: $(PUBLISH_DOCKER_ARCHS)
 | 
				
			||||||
$(PUBLISH_DOCKER_ARCHS): common-docker-publish-%:
 | 
					$(PUBLISH_DOCKER_ARCHS): common-docker-publish-%:
 | 
				
			||||||
	docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)"
 | 
						docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(SANITIZED_DOCKER_IMAGE_TAG)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DOCKER_MAJOR_VERSION_TAG = $(firstword $(subst ., ,$(shell cat VERSION)))
 | 
					DOCKER_MAJOR_VERSION_TAG = $(firstword $(subst ., ,$(shell cat VERSION)))
 | 
				
			||||||
.PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS)
 | 
					.PHONY: common-docker-tag-latest $(TAG_DOCKER_ARCHS)
 | 
				
			||||||
common-docker-tag-latest: $(TAG_DOCKER_ARCHS)
 | 
					common-docker-tag-latest: $(TAG_DOCKER_ARCHS)
 | 
				
			||||||
$(TAG_DOCKER_ARCHS): common-docker-tag-latest-%:
 | 
					$(TAG_DOCKER_ARCHS): common-docker-tag-latest-%:
 | 
				
			||||||
	docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(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-$*:latest"
 | 
				
			||||||
	docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$*:v$(DOCKER_MAJOR_VERSION_TAG)"
 | 
						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
 | 
					.PHONY: common-docker-manifest
 | 
				
			||||||
common-docker-manifest:
 | 
					common-docker-manifest:
 | 
				
			||||||
	DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" $(foreach ARCH,$(DOCKER_ARCHS),$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)-linux-$(ARCH):$(DOCKER_IMAGE_TAG))
 | 
						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):$(DOCKER_IMAGE_TAG)"
 | 
						DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(SANITIZED_DOCKER_IMAGE_TAG)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.PHONY: promu
 | 
					.PHONY: promu
 | 
				
			||||||
promu: $(PROMU)
 | 
					promu: $(PROMU)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,11 +51,11 @@ ensure the `fixtures` directory is up to date by removing the existing directory
 | 
				
			||||||
extracting the ttar file using `make fixtures/.unpacked` or just `make test`.
 | 
					extracting the ttar file using `make fixtures/.unpacked` or just `make test`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
rm -rf fixtures
 | 
					rm -rf testdata/fixtures
 | 
				
			||||||
make test
 | 
					make test
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Next, make the required changes to the extracted files in the `fixtures` directory.  When
 | 
					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
 | 
					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
 | 
					based on the updated `fixtures` directory.  And finally, verify the changes using
 | 
				
			||||||
`git diff fixtures.ttar`.
 | 
					`git diff testdata/fixtures.ttar`.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,7 @@ type ARPEntry struct {
 | 
				
			||||||
func (fs FS) GatherARPEntries() ([]ARPEntry, error) {
 | 
					func (fs FS) GatherARPEntries() ([]ARPEntry, error) {
 | 
				
			||||||
	data, err := os.ReadFile(fs.proc.Path("net/arp"))
 | 
						data, err := os.ReadFile(fs.proc.Path("net/arp"))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("error reading arp %q: %w", fs.proc.Path("net/arp"), err)
 | 
							return nil, fmt.Errorf("%s: error reading arp %s: %w", ErrFileRead, fs.proc.Path("net/arp"), err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return parseARPEntries(data)
 | 
						return parseARPEntries(data)
 | 
				
			||||||
| 
						 | 
					@ -78,11 +78,11 @@ func parseARPEntries(data []byte) ([]ARPEntry, error) {
 | 
				
			||||||
		} else if width == expectedDataWidth {
 | 
							} else if width == expectedDataWidth {
 | 
				
			||||||
			entry, err := parseARPEntry(columns)
 | 
								entry, err := parseARPEntry(columns)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				return []ARPEntry{}, fmt.Errorf("failed to parse ARP entry: %w", err)
 | 
									return []ARPEntry{}, fmt.Errorf("%s: Failed to parse ARP entry: %v: %w", ErrFileParse, entry, err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			entries = append(entries, entry)
 | 
								entries = append(entries, entry)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return []ARPEntry{}, fmt.Errorf("%d columns were detected, but %d were expected", width, expectedDataWidth)
 | 
								return []ARPEntry{}, fmt.Errorf("%s: %d columns found, but expected %d: %w", ErrFileParse, width, expectedDataWidth, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
 | 
				
			||||||
		parts := strings.Fields(line)
 | 
							parts := strings.Fields(line)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(parts) < 4 {
 | 
							if len(parts) < 4 {
 | 
				
			||||||
			return nil, fmt.Errorf("invalid number of fields when parsing buddyinfo")
 | 
								return nil, fmt.Errorf("%w: Invalid number of fields, found: %v", ErrFileParse, parts)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		node := strings.TrimRight(parts[1], ",")
 | 
							node := strings.TrimRight(parts[1], ",")
 | 
				
			||||||
| 
						 | 
					@ -66,7 +66,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
 | 
				
			||||||
			bucketCount = arraySize
 | 
								bucketCount = arraySize
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if bucketCount != arraySize {
 | 
								if bucketCount != arraySize {
 | 
				
			||||||
				return nil, fmt.Errorf("mismatch in number of buddyinfo buckets, previous count %d, new count %d", bucketCount, arraySize)
 | 
									return nil, fmt.Errorf("%w: mismatch in number of buddyinfo buckets, previous count %d, new count %d", ErrFileParse, bucketCount, arraySize)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,7 +74,7 @@ func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error) {
 | 
				
			||||||
		for i := 0; i < arraySize; i++ {
 | 
							for i := 0; i < arraySize; i++ {
 | 
				
			||||||
			sizes[i], err = strconv.ParseFloat(parts[i+4], 64)
 | 
								sizes[i], err = strconv.ParseFloat(parts[i+4], 64)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				return nil, fmt.Errorf("invalid value in buddyinfo: %w", err)
 | 
									return nil, fmt.Errorf("%s: Invalid valid in buddyinfo: %f: %w", ErrFileParse, sizes[i], err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,7 +79,7 @@ func parseCPUInfoX86(info []byte) ([]CPUInfo, error) {
 | 
				
			||||||
	// find the first "processor" line
 | 
						// find the first "processor" line
 | 
				
			||||||
	firstLine := firstNonEmptyLine(scanner)
 | 
						firstLine := firstNonEmptyLine(scanner)
 | 
				
			||||||
	if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
 | 
						if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine)
 | 
							return nil, fmt.Errorf("%w: Cannot parse  line: %q", ErrFileParse, firstLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	field := strings.SplitN(firstLine, ": ", 2)
 | 
						field := strings.SplitN(firstLine, ": ", 2)
 | 
				
			||||||
	v, err := strconv.ParseUint(field[1], 0, 32)
 | 
						v, err := strconv.ParseUint(field[1], 0, 32)
 | 
				
			||||||
| 
						 | 
					@ -192,9 +192,10 @@ func parseCPUInfoARM(info []byte) ([]CPUInfo, error) {
 | 
				
			||||||
	scanner := bufio.NewScanner(bytes.NewReader(info))
 | 
						scanner := bufio.NewScanner(bytes.NewReader(info))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	firstLine := firstNonEmptyLine(scanner)
 | 
						firstLine := firstNonEmptyLine(scanner)
 | 
				
			||||||
	match, _ := regexp.MatchString("^[Pp]rocessor", firstLine)
 | 
						match, err := regexp.MatchString("^[Pp]rocessor", firstLine)
 | 
				
			||||||
	if !match || !strings.Contains(firstLine, ":") {
 | 
						if !match || !strings.Contains(firstLine, ":") {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine)
 | 
							return nil, fmt.Errorf("%s: Cannot parse line: %q: %w", ErrFileParse, firstLine, err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	field := strings.SplitN(firstLine, ": ", 2)
 | 
						field := strings.SplitN(firstLine, ": ", 2)
 | 
				
			||||||
	cpuinfo := []CPUInfo{}
 | 
						cpuinfo := []CPUInfo{}
 | 
				
			||||||
| 
						 | 
					@ -258,7 +259,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	firstLine := firstNonEmptyLine(scanner)
 | 
						firstLine := firstNonEmptyLine(scanner)
 | 
				
			||||||
	if !strings.HasPrefix(firstLine, "vendor_id") || !strings.Contains(firstLine, ":") {
 | 
						if !strings.HasPrefix(firstLine, "vendor_id") || !strings.Contains(firstLine, ":") {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine)
 | 
							return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, firstLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	field := strings.SplitN(firstLine, ": ", 2)
 | 
						field := strings.SplitN(firstLine, ": ", 2)
 | 
				
			||||||
	cpuinfo := []CPUInfo{}
 | 
						cpuinfo := []CPUInfo{}
 | 
				
			||||||
| 
						 | 
					@ -283,7 +284,7 @@ func parseCPUInfoS390X(info []byte) ([]CPUInfo, error) {
 | 
				
			||||||
		if strings.HasPrefix(line, "processor") {
 | 
							if strings.HasPrefix(line, "processor") {
 | 
				
			||||||
			match := cpuinfoS390XProcessorRegexp.FindStringSubmatch(line)
 | 
								match := cpuinfoS390XProcessorRegexp.FindStringSubmatch(line)
 | 
				
			||||||
			if len(match) < 2 {
 | 
								if len(match) < 2 {
 | 
				
			||||||
				return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine)
 | 
									return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			cpu := commonCPUInfo
 | 
								cpu := commonCPUInfo
 | 
				
			||||||
			v, err := strconv.ParseUint(match[1], 0, 32)
 | 
								v, err := strconv.ParseUint(match[1], 0, 32)
 | 
				
			||||||
| 
						 | 
					@ -343,7 +344,7 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) {
 | 
				
			||||||
	// find the first "processor" line
 | 
						// find the first "processor" line
 | 
				
			||||||
	firstLine := firstNonEmptyLine(scanner)
 | 
						firstLine := firstNonEmptyLine(scanner)
 | 
				
			||||||
	if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") {
 | 
						if !strings.HasPrefix(firstLine, "system type") || !strings.Contains(firstLine, ":") {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine)
 | 
							return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	field := strings.SplitN(firstLine, ": ", 2)
 | 
						field := strings.SplitN(firstLine, ": ", 2)
 | 
				
			||||||
	cpuinfo := []CPUInfo{}
 | 
						cpuinfo := []CPUInfo{}
 | 
				
			||||||
| 
						 | 
					@ -380,12 +381,48 @@ func parseCPUInfoMips(info []byte) ([]CPUInfo, error) {
 | 
				
			||||||
	return cpuinfo, nil
 | 
						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, errors.New("invalid cpuinfo file: " + 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) {
 | 
					func parseCPUInfoPPC(info []byte) ([]CPUInfo, error) {
 | 
				
			||||||
	scanner := bufio.NewScanner(bytes.NewReader(info))
 | 
						scanner := bufio.NewScanner(bytes.NewReader(info))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	firstLine := firstNonEmptyLine(scanner)
 | 
						firstLine := firstNonEmptyLine(scanner)
 | 
				
			||||||
	if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
 | 
						if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine)
 | 
							return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	field := strings.SplitN(firstLine, ": ", 2)
 | 
						field := strings.SplitN(firstLine, ": ", 2)
 | 
				
			||||||
	v, err := strconv.ParseUint(field[1], 0, 32)
 | 
						v, err := strconv.ParseUint(field[1], 0, 32)
 | 
				
			||||||
| 
						 | 
					@ -430,7 +467,7 @@ func parseCPUInfoRISCV(info []byte) ([]CPUInfo, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	firstLine := firstNonEmptyLine(scanner)
 | 
						firstLine := firstNonEmptyLine(scanner)
 | 
				
			||||||
	if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
 | 
						if !strings.HasPrefix(firstLine, "processor") || !strings.Contains(firstLine, ":") {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid cpuinfo file: %q", firstLine)
 | 
							return nil, fmt.Errorf("%w: %q", ErrFileParse, firstLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	field := strings.SplitN(firstLine, ": ", 2)
 | 
						field := strings.SplitN(firstLine, ": ", 2)
 | 
				
			||||||
	v, err := strconv.ParseUint(field[1], 0, 32)
 | 
						v, err := strconv.ParseUint(field[1], 0, 32)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					// 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
 | 
				
			||||||
| 
						 | 
					@ -11,8 +11,8 @@
 | 
				
			||||||
// See the License for the specific language governing permissions and
 | 
					// See the License for the specific language governing permissions and
 | 
				
			||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//go:build linux && !386 && !amd64 && !arm && !arm64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x
 | 
					//go:build linux && !386 && !amd64 && !arm && !arm64 && !loong64 && !mips && !mips64 && !mips64le && !mipsle && !ppc64 && !ppc64le && !riscv64 && !s390x
 | 
				
			||||||
// +build linux,!386,!amd64,!arm,!arm64,!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
 | 
					package procfs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,12 +55,13 @@ func (fs FS) Crypto() ([]Crypto, error) {
 | 
				
			||||||
	path := fs.proc.Path("crypto")
 | 
						path := fs.proc.Path("crypto")
 | 
				
			||||||
	b, err := util.ReadFileNoStat(path)
 | 
						b, err := util.ReadFileNoStat(path)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("error reading crypto %q: %w", path, err)
 | 
							return nil, fmt.Errorf("%s: Cannot read file %v: %w", ErrFileRead, b, err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	crypto, err := parseCrypto(bytes.NewReader(b))
 | 
						crypto, err := parseCrypto(bytes.NewReader(b))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("error parsing crypto %q: %w", path, err)
 | 
							return nil, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, crypto, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return crypto, nil
 | 
						return crypto, nil
 | 
				
			||||||
| 
						 | 
					@ -83,7 +84,7 @@ func parseCrypto(r io.Reader) ([]Crypto, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		kv := strings.Split(text, ":")
 | 
							kv := strings.Split(text, ":")
 | 
				
			||||||
		if len(kv) != 2 {
 | 
							if len(kv) != 2 {
 | 
				
			||||||
			return nil, fmt.Errorf("malformed crypto line: %q", text)
 | 
								return nil, fmt.Errorf("%w: Cannot parae line: %q", ErrFileParse, text)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		k := strings.TrimSpace(kv[0])
 | 
							k := strings.TrimSpace(kv[0])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,30 +16,29 @@
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// Example:
 | 
					// Example:
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    package main
 | 
					//	package main
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    import (
 | 
					//	import (
 | 
				
			||||||
//    	"fmt"
 | 
					//		"fmt"
 | 
				
			||||||
//    	"log"
 | 
					//		"log"
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    	"github.com/prometheus/procfs"
 | 
					//		"github.com/prometheus/procfs"
 | 
				
			||||||
//    )
 | 
					//	)
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    func main() {
 | 
					//	func main() {
 | 
				
			||||||
//    	p, err := procfs.Self()
 | 
					//		p, err := procfs.Self()
 | 
				
			||||||
//    	if err != nil {
 | 
					//		if err != nil {
 | 
				
			||||||
//    		log.Fatalf("could not get process: %s", err)
 | 
					//			log.Fatalf("could not get process: %s", err)
 | 
				
			||||||
//    	}
 | 
					//		}
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//    	stat, err := p.Stat()
 | 
					//		stat, err := p.Stat()
 | 
				
			||||||
//    	if err != nil {
 | 
					//		if err != nil {
 | 
				
			||||||
//    		log.Fatalf("could not get process stat: %s", err)
 | 
					//			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())
 | 
					 | 
				
			||||||
//    }
 | 
					 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					//		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
 | 
					package procfs
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,8 @@ import (
 | 
				
			||||||
// FS represents the pseudo-filesystem sys, which provides an interface to
 | 
					// FS represents the pseudo-filesystem sys, which provides an interface to
 | 
				
			||||||
// kernel data structures.
 | 
					// kernel data structures.
 | 
				
			||||||
type FS struct {
 | 
					type FS struct {
 | 
				
			||||||
	proc fs.FS
 | 
						proc   fs.FS
 | 
				
			||||||
 | 
						isReal bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DefaultMountPoint is the common mount point of the proc filesystem.
 | 
					// DefaultMountPoint is the common mount point of the proc filesystem.
 | 
				
			||||||
| 
						 | 
					@ -39,5 +40,11 @@ func NewFS(mountPoint string) (FS, error) {
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return FS{}, err
 | 
							return FS{}, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return FS{fs}, nil
 | 
					
 | 
				
			||||||
 | 
						isReal, err := isRealProc(mountPoint)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return FS{}, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return FS{fs, isReal}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					// 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					// 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -236,7 +236,7 @@ func (fs FS) Fscacheinfo() (Fscacheinfo, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	m, err := parseFscacheinfo(bytes.NewReader(b))
 | 
						m, err := parseFscacheinfo(bytes.NewReader(b))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return Fscacheinfo{}, fmt.Errorf("failed to parse Fscacheinfo: %w", err)
 | 
							return Fscacheinfo{}, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, m, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return *m, nil
 | 
						return *m, nil
 | 
				
			||||||
| 
						 | 
					@ -245,7 +245,7 @@ func (fs FS) Fscacheinfo() (Fscacheinfo, error) {
 | 
				
			||||||
func setFSCacheFields(fields []string, setFields ...*uint64) error {
 | 
					func setFSCacheFields(fields []string, setFields ...*uint64) error {
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	if len(fields) < len(setFields) {
 | 
						if len(fields) < len(setFields) {
 | 
				
			||||||
		return fmt.Errorf("Insufficient number of fields, expected %v, got %v", len(setFields), len(fields))
 | 
							return fmt.Errorf("%s: Expected %d, but got %d: %w", ErrFileParse, len(setFields), len(fields), err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i := range setFields {
 | 
						for i := range setFields {
 | 
				
			||||||
| 
						 | 
					@ -263,7 +263,7 @@ func parseFscacheinfo(r io.Reader) (*Fscacheinfo, error) {
 | 
				
			||||||
	for s.Scan() {
 | 
						for s.Scan() {
 | 
				
			||||||
		fields := strings.Fields(s.Text())
 | 
							fields := strings.Fields(s.Text())
 | 
				
			||||||
		if len(fields) < 2 {
 | 
							if len(fields) < 2 {
 | 
				
			||||||
			return nil, fmt.Errorf("malformed Fscacheinfo line: %q", s.Text())
 | 
								return nil, fmt.Errorf("%w: malformed Fscacheinfo line: %q", ErrFileParse, s.Text())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch fields[0] {
 | 
							switch fields[0] {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,6 +64,21 @@ func ParsePInt64s(ss []string) ([]*int64, error) {
 | 
				
			||||||
	return us, nil
 | 
						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.
 | 
					// ReadUintFromFile reads a file and attempts to parse a uint64 from it.
 | 
				
			||||||
func ReadUintFromFile(path string) (uint64, error) {
 | 
					func ReadUintFromFile(path string) (uint64, error) {
 | 
				
			||||||
	data, err := os.ReadFile(path)
 | 
						data, err := os.ReadFile(path)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -221,15 +221,16 @@ func parseIPPort(s string) (net.IP, uint16, error) {
 | 
				
			||||||
	case 46:
 | 
						case 46:
 | 
				
			||||||
		ip = net.ParseIP(s[1:40])
 | 
							ip = net.ParseIP(s[1:40])
 | 
				
			||||||
		if ip == nil {
 | 
							if ip == nil {
 | 
				
			||||||
			return nil, 0, fmt.Errorf("invalid IPv6 address: %s", s[1:40])
 | 
								return nil, 0, fmt.Errorf("%s: Invalid IPv6 addr %s: %w", ErrFileParse, s[1:40], err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return nil, 0, fmt.Errorf("unexpected IP:Port: %s", s)
 | 
							return nil, 0, fmt.Errorf("%s: Unexpected IP:Port %s: %w", ErrFileParse, s, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	portString := s[len(s)-4:]
 | 
						portString := s[len(s)-4:]
 | 
				
			||||||
	if len(portString) != 4 {
 | 
						if len(portString) != 4 {
 | 
				
			||||||
		return nil, 0, fmt.Errorf("unexpected port string format: %s", portString)
 | 
							return nil, 0,
 | 
				
			||||||
 | 
								fmt.Errorf("%s: Unexpected port string format %s: %w", ErrFileParse, portString, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	port, err := strconv.ParseUint(portString, 16, 16)
 | 
						port, err := strconv.ParseUint(portString, 16, 16)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,14 +44,14 @@ func parseLoad(loadavgBytes []byte) (*LoadAvg, error) {
 | 
				
			||||||
	loads := make([]float64, 3)
 | 
						loads := make([]float64, 3)
 | 
				
			||||||
	parts := strings.Fields(string(loadavgBytes))
 | 
						parts := strings.Fields(string(loadavgBytes))
 | 
				
			||||||
	if len(parts) < 3 {
 | 
						if len(parts) < 3 {
 | 
				
			||||||
		return nil, fmt.Errorf("malformed loadavg line: too few fields in loadavg string: %q", string(loadavgBytes))
 | 
							return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, string(loadavgBytes))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	for i, load := range parts[0:3] {
 | 
						for i, load := range parts[0:3] {
 | 
				
			||||||
		loads[i], err = strconv.ParseFloat(load, 64)
 | 
							loads[i], err = strconv.ParseFloat(load, 64)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("could not parse load %q: %w", load, err)
 | 
								return nil, fmt.Errorf("%s: Cannot parse load: %f: %w", ErrFileParse, loads[i], err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return &LoadAvg{
 | 
						return &LoadAvg{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,7 +70,7 @@ func (fs FS) MDStat() ([]MDStat, error) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	mdstat, err := parseMDStat(data)
 | 
						mdstat, err := parseMDStat(data)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("error parsing mdstat %q: %w", fs.proc.Path("mdstat"), err)
 | 
							return nil, fmt.Errorf("%s: Cannot parse %v: %w", ErrFileParse, fs.proc.Path("mdstat"), err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return mdstat, nil
 | 
						return mdstat, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -90,13 +90,13 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		deviceFields := strings.Fields(line)
 | 
							deviceFields := strings.Fields(line)
 | 
				
			||||||
		if len(deviceFields) < 3 {
 | 
							if len(deviceFields) < 3 {
 | 
				
			||||||
			return nil, fmt.Errorf("not enough fields in mdline (expected at least 3): %s", line)
 | 
								return nil, fmt.Errorf("%s: Expected 3+ lines, got %q", ErrFileParse, line)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		mdName := deviceFields[0] // mdx
 | 
							mdName := deviceFields[0] // mdx
 | 
				
			||||||
		state := deviceFields[2]  // active or inactive
 | 
							state := deviceFields[2]  // active or inactive
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(lines) <= i+3 {
 | 
							if len(lines) <= i+3 {
 | 
				
			||||||
			return nil, fmt.Errorf("error parsing %q: too few lines for md device", mdName)
 | 
								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).
 | 
							// Failed disks have the suffix (F) & Spare disks have the suffix (S).
 | 
				
			||||||
| 
						 | 
					@ -105,7 +105,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
 | 
				
			||||||
		active, total, down, size, err := evalStatusLine(lines[i], lines[i+1])
 | 
							active, total, down, size, err := evalStatusLine(lines[i], lines[i+1])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("error parsing md device lines: %w", err)
 | 
								return nil, fmt.Errorf("%s: Cannot parse md device lines: %v: %w", ErrFileParse, active, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		syncLineIdx := i + 2
 | 
							syncLineIdx := i + 2
 | 
				
			||||||
| 
						 | 
					@ -140,7 +140,7 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				syncedBlocks, pct, finish, speed, err = evalRecoveryLine(lines[syncLineIdx])
 | 
									syncedBlocks, pct, finish, speed, err = evalRecoveryLine(lines[syncLineIdx])
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return nil, fmt.Errorf("error parsing sync line in md device %q: %w", mdName, err)
 | 
										return nil, fmt.Errorf("%s: Cannot parse sync line in md device: %q: %w", ErrFileParse, mdName, err)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -168,13 +168,13 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
 | 
				
			||||||
func evalStatusLine(deviceLine, statusLine string) (active, total, down, size int64, err error) {
 | 
					func evalStatusLine(deviceLine, statusLine string) (active, total, down, size int64, err error) {
 | 
				
			||||||
	statusFields := strings.Fields(statusLine)
 | 
						statusFields := strings.Fields(statusLine)
 | 
				
			||||||
	if len(statusFields) < 1 {
 | 
						if len(statusFields) < 1 {
 | 
				
			||||||
		return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q", statusLine)
 | 
							return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sizeStr := statusFields[0]
 | 
						sizeStr := statusFields[0]
 | 
				
			||||||
	size, err = strconv.ParseInt(sizeStr, 10, 64)
 | 
						size, err = strconv.ParseInt(sizeStr, 10, 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err)
 | 
							return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if strings.Contains(deviceLine, "raid0") || strings.Contains(deviceLine, "linear") {
 | 
						if strings.Contains(deviceLine, "raid0") || strings.Contains(deviceLine, "linear") {
 | 
				
			||||||
| 
						 | 
					@ -189,17 +189,17 @@ func evalStatusLine(deviceLine, statusLine string) (active, total, down, size in
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	matches := statusLineRE.FindStringSubmatch(statusLine)
 | 
						matches := statusLineRE.FindStringSubmatch(statusLine)
 | 
				
			||||||
	if len(matches) != 5 {
 | 
						if len(matches) != 5 {
 | 
				
			||||||
		return 0, 0, 0, 0, fmt.Errorf("couldn't find all the substring matches: %s", statusLine)
 | 
							return 0, 0, 0, 0, fmt.Errorf("%s: Could not fild all substring matches %s: %w", ErrFileParse, statusLine, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	total, err = strconv.ParseInt(matches[2], 10, 64)
 | 
						total, err = strconv.ParseInt(matches[2], 10, 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err)
 | 
							return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected statusline %q: %w", ErrFileParse, statusLine, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	active, err = strconv.ParseInt(matches[3], 10, 64)
 | 
						active, err = strconv.ParseInt(matches[3], 10, 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, 0, 0, 0, fmt.Errorf("unexpected statusLine %q: %w", statusLine, err)
 | 
							return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected active %d: %w", ErrFileParse, active, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	down = int64(strings.Count(matches[4], "_"))
 | 
						down = int64(strings.Count(matches[4], "_"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -209,42 +209,42 @@ func evalStatusLine(deviceLine, statusLine string) (active, total, down, size in
 | 
				
			||||||
func evalRecoveryLine(recoveryLine string) (syncedBlocks int64, pct float64, finish float64, speed float64, err error) {
 | 
					func evalRecoveryLine(recoveryLine string) (syncedBlocks int64, pct float64, finish float64, speed float64, err error) {
 | 
				
			||||||
	matches := recoveryLineBlocksRE.FindStringSubmatch(recoveryLine)
 | 
						matches := recoveryLineBlocksRE.FindStringSubmatch(recoveryLine)
 | 
				
			||||||
	if len(matches) != 2 {
 | 
						if len(matches) != 2 {
 | 
				
			||||||
		return 0, 0, 0, 0, fmt.Errorf("unexpected recoveryLine: %s", recoveryLine)
 | 
							return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected recoveryLine %s: %w", ErrFileParse, recoveryLine, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	syncedBlocks, err = strconv.ParseInt(matches[1], 10, 64)
 | 
						syncedBlocks, err = strconv.ParseInt(matches[1], 10, 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, 0, 0, 0, fmt.Errorf("error parsing int from recoveryLine %q: %w", recoveryLine, err)
 | 
							return 0, 0, 0, 0, fmt.Errorf("%s: Unexpected parsing of recoveryLine %q: %w", ErrFileParse, recoveryLine, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Get percentage complete
 | 
						// Get percentage complete
 | 
				
			||||||
	matches = recoveryLinePctRE.FindStringSubmatch(recoveryLine)
 | 
						matches = recoveryLinePctRE.FindStringSubmatch(recoveryLine)
 | 
				
			||||||
	if len(matches) != 2 {
 | 
						if len(matches) != 2 {
 | 
				
			||||||
		return syncedBlocks, 0, 0, 0, fmt.Errorf("unexpected recoveryLine matching percentage: %s", recoveryLine)
 | 
							return syncedBlocks, 0, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching percentage %s", ErrFileParse, recoveryLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pct, err = strconv.ParseFloat(strings.TrimSpace(matches[1]), 64)
 | 
						pct, err = strconv.ParseFloat(strings.TrimSpace(matches[1]), 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return syncedBlocks, 0, 0, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err)
 | 
							return syncedBlocks, 0, 0, 0, fmt.Errorf("%w: Error parsing float from recoveryLine %q", ErrFileParse, recoveryLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Get time expected left to complete
 | 
						// Get time expected left to complete
 | 
				
			||||||
	matches = recoveryLineFinishRE.FindStringSubmatch(recoveryLine)
 | 
						matches = recoveryLineFinishRE.FindStringSubmatch(recoveryLine)
 | 
				
			||||||
	if len(matches) != 2 {
 | 
						if len(matches) != 2 {
 | 
				
			||||||
		return syncedBlocks, pct, 0, 0, fmt.Errorf("unexpected recoveryLine matching est. finish time: %s", recoveryLine)
 | 
							return syncedBlocks, pct, 0, 0, fmt.Errorf("%w: Unexpected recoveryLine matching est. finish time: %s", ErrFileParse, recoveryLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	finish, err = strconv.ParseFloat(matches[1], 64)
 | 
						finish, err = strconv.ParseFloat(matches[1], 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return syncedBlocks, pct, 0, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err)
 | 
							return syncedBlocks, pct, 0, 0, fmt.Errorf("%w: Unable to parse float from recoveryLine: %q", ErrFileParse, recoveryLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Get recovery speed
 | 
						// Get recovery speed
 | 
				
			||||||
	matches = recoveryLineSpeedRE.FindStringSubmatch(recoveryLine)
 | 
						matches = recoveryLineSpeedRE.FindStringSubmatch(recoveryLine)
 | 
				
			||||||
	if len(matches) != 2 {
 | 
						if len(matches) != 2 {
 | 
				
			||||||
		return syncedBlocks, pct, finish, 0, fmt.Errorf("unexpected recoveryLine matching speed: %s", recoveryLine)
 | 
							return syncedBlocks, pct, finish, 0, fmt.Errorf("%w: Unexpected recoveryLine value: %s", ErrFileParse, recoveryLine)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	speed, err = strconv.ParseFloat(matches[1], 64)
 | 
						speed, err = strconv.ParseFloat(matches[1], 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return syncedBlocks, pct, finish, 0, fmt.Errorf("error parsing float from recoveryLine %q: %w", recoveryLine, err)
 | 
							return syncedBlocks, pct, finish, 0, fmt.Errorf("%s: Error parsing float from recoveryLine: %q: %w", ErrFileParse, recoveryLine, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return syncedBlocks, pct, finish, speed, nil
 | 
						return syncedBlocks, pct, finish, speed, nil
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -152,7 +152,7 @@ func (fs FS) Meminfo() (Meminfo, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	m, err := parseMemInfo(bytes.NewReader(b))
 | 
						m, err := parseMemInfo(bytes.NewReader(b))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return Meminfo{}, fmt.Errorf("failed to parse meminfo: %w", err)
 | 
							return Meminfo{}, fmt.Errorf("%s: %w", ErrFileParse, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return *m, nil
 | 
						return *m, nil
 | 
				
			||||||
| 
						 | 
					@ -165,7 +165,7 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) {
 | 
				
			||||||
		// Each line has at least a name and value; we ignore the unit.
 | 
							// Each line has at least a name and value; we ignore the unit.
 | 
				
			||||||
		fields := strings.Fields(s.Text())
 | 
							fields := strings.Fields(s.Text())
 | 
				
			||||||
		if len(fields) < 2 {
 | 
							if len(fields) < 2 {
 | 
				
			||||||
			return nil, fmt.Errorf("malformed meminfo line: %q", s.Text())
 | 
								return nil, fmt.Errorf("%w: Malformed line %q", ErrFileParse, s.Text())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		v, err := strconv.ParseUint(fields[1], 0, 64)
 | 
							v, err := strconv.ParseUint(fields[1], 0, 64)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,11 +78,11 @@ func parseMountInfoString(mountString string) (*MountInfo, error) {
 | 
				
			||||||
	mountInfo := strings.Split(mountString, " ")
 | 
						mountInfo := strings.Split(mountString, " ")
 | 
				
			||||||
	mountInfoLength := len(mountInfo)
 | 
						mountInfoLength := len(mountInfo)
 | 
				
			||||||
	if mountInfoLength < 10 {
 | 
						if mountInfoLength < 10 {
 | 
				
			||||||
		return nil, fmt.Errorf("couldn't find enough fields in mount string: %s", mountString)
 | 
							return nil, fmt.Errorf("%w: Too few fields in mount string: %s", ErrFileParse, mountString)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if mountInfo[mountInfoLength-4] != "-" {
 | 
						if mountInfo[mountInfoLength-4] != "-" {
 | 
				
			||||||
		return nil, fmt.Errorf("couldn't find separator in expected field: %s", mountInfo[mountInfoLength-4])
 | 
							return nil, fmt.Errorf("%w: couldn't find separator in expected field: %s", ErrFileParse, mountInfo[mountInfoLength-4])
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mount := &MountInfo{
 | 
						mount := &MountInfo{
 | 
				
			||||||
| 
						 | 
					@ -98,18 +98,18 @@ func parseMountInfoString(mountString string) (*MountInfo, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mount.MountID, err = strconv.Atoi(mountInfo[0])
 | 
						mount.MountID, err = strconv.Atoi(mountInfo[0])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse mount ID")
 | 
							return nil, fmt.Errorf("%w: mount ID: %q", ErrFileParse, mount.MountID)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	mount.ParentID, err = strconv.Atoi(mountInfo[1])
 | 
						mount.ParentID, err = strconv.Atoi(mountInfo[1])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse parent ID")
 | 
							return nil, fmt.Errorf("%w: parent ID: %q", ErrFileParse, mount.ParentID)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Has optional fields, which is a space separated list of values.
 | 
						// Has optional fields, which is a space separated list of values.
 | 
				
			||||||
	// Example: shared:2 master:7
 | 
						// Example: shared:2 master:7
 | 
				
			||||||
	if mountInfo[6] != "" {
 | 
						if mountInfo[6] != "" {
 | 
				
			||||||
		mount.OptionalFields, err = mountOptionsParseOptionalFields(mountInfo[6 : mountInfoLength-4])
 | 
							mount.OptionalFields, err = mountOptionsParseOptionalFields(mountInfo[6 : mountInfoLength-4])
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, fmt.Errorf("%s: %w", ErrFileParse, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return mount, nil
 | 
						return mount, nil
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,6 +44,14 @@ const (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fieldTransport11TCPLen = 13
 | 
						fieldTransport11TCPLen = 13
 | 
				
			||||||
	fieldTransport11UDPLen = 10
 | 
						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.
 | 
					// A Mount is a device mount parsed from /proc/[pid]/mountstats.
 | 
				
			||||||
| 
						 | 
					@ -186,6 +194,8 @@ type NFSOperationStats struct {
 | 
				
			||||||
	CumulativeTotalResponseMilliseconds uint64
 | 
						CumulativeTotalResponseMilliseconds uint64
 | 
				
			||||||
	// Duration from when a request was enqueued to when it was completely handled.
 | 
						// Duration from when a request was enqueued to when it was completely handled.
 | 
				
			||||||
	CumulativeTotalRequestMilliseconds uint64
 | 
						CumulativeTotalRequestMilliseconds uint64
 | 
				
			||||||
 | 
						// The average time from the point the client sends RPC requests until it receives the response.
 | 
				
			||||||
 | 
						AverageRTTMilliseconds float64
 | 
				
			||||||
	// The count of operations that complete with tk_status < 0.  These statuses usually indicate error conditions.
 | 
						// The count of operations that complete with tk_status < 0.  These statuses usually indicate error conditions.
 | 
				
			||||||
	Errors uint64
 | 
						Errors uint64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -231,6 +241,33 @@ type NFSTransportStats struct {
 | 
				
			||||||
	// A running counter, incremented on each request as the current size of the
 | 
						// A running counter, incremented on each request as the current size of the
 | 
				
			||||||
	// pending queue.
 | 
						// pending queue.
 | 
				
			||||||
	CumulativePendingQueue uint64
 | 
						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
 | 
					// parseMountStats parses a /proc/[pid]/mountstats file and returns a slice
 | 
				
			||||||
| 
						 | 
					@ -264,7 +301,7 @@ func parseMountStats(r io.Reader) ([]*Mount, error) {
 | 
				
			||||||
		if len(ss) > deviceEntryLen {
 | 
							if len(ss) > deviceEntryLen {
 | 
				
			||||||
			// Only NFSv3 and v4 are supported for parsing statistics
 | 
								// Only NFSv3 and v4 are supported for parsing statistics
 | 
				
			||||||
			if m.Type != nfs3Type && m.Type != nfs4Type {
 | 
								if m.Type != nfs3Type && m.Type != nfs4Type {
 | 
				
			||||||
				return nil, fmt.Errorf("cannot parse MountStats for fstype %q", m.Type)
 | 
									return nil, fmt.Errorf("%w: Cannot parse MountStats for %q", ErrFileParse, m.Type)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			statVersion := strings.TrimPrefix(ss[8], statVersionPrefix)
 | 
								statVersion := strings.TrimPrefix(ss[8], statVersionPrefix)
 | 
				
			||||||
| 
						 | 
					@ -284,10 +321,11 @@ func parseMountStats(r io.Reader) ([]*Mount, error) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// parseMount parses an entry in /proc/[pid]/mountstats in the format:
 | 
					// parseMount parses an entry in /proc/[pid]/mountstats in the format:
 | 
				
			||||||
//   device [device] mounted on [mount] with fstype [type]
 | 
					//
 | 
				
			||||||
 | 
					//	device [device] mounted on [mount] with fstype [type]
 | 
				
			||||||
func parseMount(ss []string) (*Mount, error) {
 | 
					func parseMount(ss []string) (*Mount, error) {
 | 
				
			||||||
	if len(ss) < deviceEntryLen {
 | 
						if len(ss) < deviceEntryLen {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid device entry: %v", ss)
 | 
							return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Check for specific words appearing at specific indices to ensure
 | 
						// Check for specific words appearing at specific indices to ensure
 | 
				
			||||||
| 
						 | 
					@ -305,7 +343,7 @@ func parseMount(ss []string) (*Mount, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, f := range format {
 | 
						for _, f := range format {
 | 
				
			||||||
		if ss[f.i] != f.s {
 | 
							if ss[f.i] != f.s {
 | 
				
			||||||
			return nil, fmt.Errorf("invalid device entry: %v", ss)
 | 
								return nil, fmt.Errorf("%w: Invalid device %q", ErrFileParse, ss)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -342,7 +380,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
 | 
				
			||||||
		switch ss[0] {
 | 
							switch ss[0] {
 | 
				
			||||||
		case fieldOpts:
 | 
							case fieldOpts:
 | 
				
			||||||
			if len(ss) < 2 {
 | 
								if len(ss) < 2 {
 | 
				
			||||||
				return nil, fmt.Errorf("not enough information for NFS stats: %v", ss)
 | 
									return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if stats.Opts == nil {
 | 
								if stats.Opts == nil {
 | 
				
			||||||
				stats.Opts = map[string]string{}
 | 
									stats.Opts = map[string]string{}
 | 
				
			||||||
| 
						 | 
					@ -357,7 +395,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		case fieldAge:
 | 
							case fieldAge:
 | 
				
			||||||
			if len(ss) < 2 {
 | 
								if len(ss) < 2 {
 | 
				
			||||||
				return nil, fmt.Errorf("not enough information for NFS stats: %v", ss)
 | 
									return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			// Age integer is in seconds
 | 
								// Age integer is in seconds
 | 
				
			||||||
			d, err := time.ParseDuration(ss[1] + "s")
 | 
								d, err := time.ParseDuration(ss[1] + "s")
 | 
				
			||||||
| 
						 | 
					@ -368,7 +406,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
 | 
				
			||||||
			stats.Age = d
 | 
								stats.Age = d
 | 
				
			||||||
		case fieldBytes:
 | 
							case fieldBytes:
 | 
				
			||||||
			if len(ss) < 2 {
 | 
								if len(ss) < 2 {
 | 
				
			||||||
				return nil, fmt.Errorf("not enough information for NFS stats: %v", ss)
 | 
									return nil, fmt.Errorf("%w: Incomplete information for NFS stats: %v", ErrFileParse, ss)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			bstats, err := parseNFSBytesStats(ss[1:])
 | 
								bstats, err := parseNFSBytesStats(ss[1:])
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -378,7 +416,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
 | 
				
			||||||
			stats.Bytes = *bstats
 | 
								stats.Bytes = *bstats
 | 
				
			||||||
		case fieldEvents:
 | 
							case fieldEvents:
 | 
				
			||||||
			if len(ss) < 2 {
 | 
								if len(ss) < 2 {
 | 
				
			||||||
				return nil, fmt.Errorf("not enough information for NFS stats: %v", ss)
 | 
									return nil, fmt.Errorf("%w: Incomplete information for NFS events: %v", ErrFileParse, ss)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			estats, err := parseNFSEventsStats(ss[1:])
 | 
								estats, err := parseNFSEventsStats(ss[1:])
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -388,7 +426,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
 | 
				
			||||||
			stats.Events = *estats
 | 
								stats.Events = *estats
 | 
				
			||||||
		case fieldTransport:
 | 
							case fieldTransport:
 | 
				
			||||||
			if len(ss) < 3 {
 | 
								if len(ss) < 3 {
 | 
				
			||||||
				return nil, fmt.Errorf("not enough information for NFS transport stats: %v", ss)
 | 
									return nil, fmt.Errorf("%w: Incomplete information for NFS transport stats: %v", ErrFileParse, ss)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			tstats, err := parseNFSTransportStats(ss[1:], statVersion)
 | 
								tstats, err := parseNFSTransportStats(ss[1:], statVersion)
 | 
				
			||||||
| 
						 | 
					@ -427,7 +465,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
 | 
				
			||||||
// integer fields.
 | 
					// integer fields.
 | 
				
			||||||
func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) {
 | 
					func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) {
 | 
				
			||||||
	if len(ss) != fieldBytesLen {
 | 
						if len(ss) != fieldBytesLen {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid NFS bytes stats: %v", ss)
 | 
							return nil, fmt.Errorf("%w: Invalid NFS bytes stats: %v", ErrFileParse, ss)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ns := make([]uint64, 0, fieldBytesLen)
 | 
						ns := make([]uint64, 0, fieldBytesLen)
 | 
				
			||||||
| 
						 | 
					@ -456,7 +494,7 @@ func parseNFSBytesStats(ss []string) (*NFSBytesStats, error) {
 | 
				
			||||||
// integer fields.
 | 
					// integer fields.
 | 
				
			||||||
func parseNFSEventsStats(ss []string) (*NFSEventsStats, error) {
 | 
					func parseNFSEventsStats(ss []string) (*NFSEventsStats, error) {
 | 
				
			||||||
	if len(ss) != fieldEventsLen {
 | 
						if len(ss) != fieldEventsLen {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid NFS events stats: %v", ss)
 | 
							return nil, fmt.Errorf("%w: invalid NFS events stats: %v", ErrFileParse, ss)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ns := make([]uint64, 0, fieldEventsLen)
 | 
						ns := make([]uint64, 0, fieldEventsLen)
 | 
				
			||||||
| 
						 | 
					@ -520,7 +558,7 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(ss) < minFields {
 | 
							if len(ss) < minFields {
 | 
				
			||||||
			return nil, fmt.Errorf("invalid NFS per-operations stats: %v", ss)
 | 
								return nil, fmt.Errorf("%w: invalid NFS per-operations stats: %v", ErrFileParse, ss)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Skip string operation name for integers
 | 
							// Skip string operation name for integers
 | 
				
			||||||
| 
						 | 
					@ -533,7 +571,6 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ns = append(ns, n)
 | 
								ns = append(ns, n)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		opStats := NFSOperationStats{
 | 
							opStats := NFSOperationStats{
 | 
				
			||||||
			Operation:                           strings.TrimSuffix(ss[0], ":"),
 | 
								Operation:                           strings.TrimSuffix(ss[0], ":"),
 | 
				
			||||||
			Requests:                            ns[0],
 | 
								Requests:                            ns[0],
 | 
				
			||||||
| 
						 | 
					@ -545,6 +582,9 @@ func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error) {
 | 
				
			||||||
			CumulativeTotalResponseMilliseconds: ns[6],
 | 
								CumulativeTotalResponseMilliseconds: ns[6],
 | 
				
			||||||
			CumulativeTotalRequestMilliseconds:  ns[7],
 | 
								CumulativeTotalRequestMilliseconds:  ns[7],
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if ns[0] != 0 {
 | 
				
			||||||
 | 
								opStats.AverageRTTMilliseconds = float64(ns[6]) / float64(ns[0])
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(ns) > 8 {
 | 
							if len(ns) > 8 {
 | 
				
			||||||
			opStats.Errors = ns[8]
 | 
								opStats.Errors = ns[8]
 | 
				
			||||||
| 
						 | 
					@ -571,10 +611,10 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats
 | 
				
			||||||
		} else if protocol == "udp" {
 | 
							} else if protocol == "udp" {
 | 
				
			||||||
			expectedLength = fieldTransport10UDPLen
 | 
								expectedLength = fieldTransport10UDPLen
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.0 statement: %v", protocol, ss)
 | 
								return nil, fmt.Errorf("%w: Invalid NFS protocol \"%s\" in stats 1.0 statement: %v", ErrFileParse, protocol, ss)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if len(ss) != expectedLength {
 | 
							if len(ss) != expectedLength {
 | 
				
			||||||
			return nil, fmt.Errorf("invalid NFS transport stats 1.0 statement: %v", ss)
 | 
								return nil, fmt.Errorf("%w: Invalid NFS transport stats 1.0 statement: %v", ErrFileParse, ss)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case statVersion11:
 | 
						case statVersion11:
 | 
				
			||||||
		var expectedLength int
 | 
							var expectedLength int
 | 
				
			||||||
| 
						 | 
					@ -582,14 +622,17 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats
 | 
				
			||||||
			expectedLength = fieldTransport11TCPLen
 | 
								expectedLength = fieldTransport11TCPLen
 | 
				
			||||||
		} else if protocol == "udp" {
 | 
							} else if protocol == "udp" {
 | 
				
			||||||
			expectedLength = fieldTransport11UDPLen
 | 
								expectedLength = fieldTransport11UDPLen
 | 
				
			||||||
 | 
							} else if protocol == "rdma" {
 | 
				
			||||||
 | 
								expectedLength = fieldTransport11RDMAMinLen
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return nil, fmt.Errorf("invalid NFS protocol \"%s\" in stats 1.1 statement: %v", protocol, ss)
 | 
								return nil, fmt.Errorf("%w: invalid NFS protocol \"%s\" in stats 1.1 statement: %v", ErrFileParse, protocol, ss)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if len(ss) != expectedLength {
 | 
							if (len(ss) != expectedLength && (protocol == "tcp" || protocol == "udp")) ||
 | 
				
			||||||
			return nil, fmt.Errorf("invalid NFS transport stats 1.1 statement: %v", ss)
 | 
								(protocol == "rdma" && len(ss) < expectedLength) {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("%w: invalid NFS transport stats 1.1 statement: %v, protocol: %v", ErrFileParse, ss, protocol)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return nil, fmt.Errorf("unrecognized NFS transport stats version: %q", statVersion)
 | 
							return nil, fmt.Errorf("%s: 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
 | 
						// Allocate enough for v1.1 stats since zero value for v1.1 stats will be okay
 | 
				
			||||||
| 
						 | 
					@ -599,7 +642,9 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats
 | 
				
			||||||
	// Note: slice length must be set to length of v1.1 stats to avoid a panic when
 | 
						// Note: slice length must be set to length of v1.1 stats to avoid a panic when
 | 
				
			||||||
	// only v1.0 stats are present.
 | 
						// only v1.0 stats are present.
 | 
				
			||||||
	// See: https://github.com/prometheus/node_exporter/issues/571.
 | 
						// See: https://github.com/prometheus/node_exporter/issues/571.
 | 
				
			||||||
	ns := make([]uint64, fieldTransport11TCPLen)
 | 
						//
 | 
				
			||||||
 | 
						// Note: NFS Over RDMA slice length is fieldTransport11RDMAMaxLen
 | 
				
			||||||
 | 
						ns := make([]uint64, fieldTransport11RDMAMaxLen+3)
 | 
				
			||||||
	for i, s := range ss {
 | 
						for i, s := range ss {
 | 
				
			||||||
		n, err := strconv.ParseUint(s, 10, 64)
 | 
							n, err := strconv.ParseUint(s, 10, 64)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -617,9 +662,14 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats
 | 
				
			||||||
	// we set them to 0 here.
 | 
						// we set them to 0 here.
 | 
				
			||||||
	if protocol == "udp" {
 | 
						if protocol == "udp" {
 | 
				
			||||||
		ns = append(ns[:2], append(make([]uint64, 3), ns[2:]...)...)
 | 
							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{
 | 
						return &NFSTransportStats{
 | 
				
			||||||
 | 
							// NFS xprt over tcp or udp
 | 
				
			||||||
		Protocol:                 protocol,
 | 
							Protocol:                 protocol,
 | 
				
			||||||
		Port:                     ns[0],
 | 
							Port:                     ns[0],
 | 
				
			||||||
		Bind:                     ns[1],
 | 
							Bind:                     ns[1],
 | 
				
			||||||
| 
						 | 
					@ -631,8 +681,32 @@ func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats
 | 
				
			||||||
		BadTransactionIDs:        ns[7],
 | 
							BadTransactionIDs:        ns[7],
 | 
				
			||||||
		CumulativeActiveRequests: ns[8],
 | 
							CumulativeActiveRequests: ns[8],
 | 
				
			||||||
		CumulativeBacklog:        ns[9],
 | 
							CumulativeBacklog:        ns[9],
 | 
				
			||||||
		MaximumRPCSlotsUsed:      ns[10],
 | 
					
 | 
				
			||||||
		CumulativeSendingQueue:   ns[11],
 | 
							// NFS xprt over tcp or udp
 | 
				
			||||||
		CumulativePendingQueue:   ns[12],
 | 
							// 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
 | 
						}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,6 @@ import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"strconv"
 | 
					 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/prometheus/procfs/internal/util"
 | 
						"github.com/prometheus/procfs/internal/util"
 | 
				
			||||||
| 
						 | 
					@ -28,9 +27,13 @@ import (
 | 
				
			||||||
// and contains netfilter conntrack statistics at one CPU core.
 | 
					// and contains netfilter conntrack statistics at one CPU core.
 | 
				
			||||||
type ConntrackStatEntry struct {
 | 
					type ConntrackStatEntry struct {
 | 
				
			||||||
	Entries       uint64
 | 
						Entries       uint64
 | 
				
			||||||
 | 
						Searched      uint64
 | 
				
			||||||
	Found         uint64
 | 
						Found         uint64
 | 
				
			||||||
 | 
						New           uint64
 | 
				
			||||||
	Invalid       uint64
 | 
						Invalid       uint64
 | 
				
			||||||
	Ignore        uint64
 | 
						Ignore        uint64
 | 
				
			||||||
 | 
						Delete        uint64
 | 
				
			||||||
 | 
						DeleteList    uint64
 | 
				
			||||||
	Insert        uint64
 | 
						Insert        uint64
 | 
				
			||||||
	InsertFailed  uint64
 | 
						InsertFailed  uint64
 | 
				
			||||||
	Drop          uint64
 | 
						Drop          uint64
 | 
				
			||||||
| 
						 | 
					@ -55,7 +58,7 @@ func readConntrackStat(path string) ([]ConntrackStatEntry, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	stat, err := parseConntrackStat(bytes.NewReader(b))
 | 
						stat, err := parseConntrackStat(bytes.NewReader(b))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to read conntrack stats from %q: %w", path, err)
 | 
							return nil, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, path, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return stat, nil
 | 
						return stat, nil
 | 
				
			||||||
| 
						 | 
					@ -81,73 +84,35 @@ func parseConntrackStat(r io.Reader) ([]ConntrackStatEntry, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Parses a ConntrackStatEntry from given array of fields.
 | 
					// Parses a ConntrackStatEntry from given array of fields.
 | 
				
			||||||
func parseConntrackStatEntry(fields []string) (*ConntrackStatEntry, error) {
 | 
					func parseConntrackStatEntry(fields []string) (*ConntrackStatEntry, error) {
 | 
				
			||||||
	if len(fields) != 17 {
 | 
						entries, err := util.ParseHexUint64s(fields)
 | 
				
			||||||
		return nil, fmt.Errorf("invalid conntrackstat entry, missing fields")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	entry := &ConntrackStatEntry{}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	entries, err := parseConntrackStatField(fields[0])
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, fmt.Errorf("%s: Cannot parse entry: %d: %w", ErrFileParse, entries, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	entry.Entries = entries
 | 
						numEntries := len(entries)
 | 
				
			||||||
 | 
						if numEntries < 16 || numEntries > 17 {
 | 
				
			||||||
	found, err := parseConntrackStatField(fields[2])
 | 
							return nil,
 | 
				
			||||||
	if err != nil {
 | 
								fmt.Errorf("%w: invalid conntrackstat entry, invalid number of fields: %d", ErrFileParse, numEntries)
 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	entry.Found = found
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	invalid, err := parseConntrackStatField(fields[4])
 | 
						stats := &ConntrackStatEntry{
 | 
				
			||||||
	if err != nil {
 | 
							Entries:      *entries[0],
 | 
				
			||||||
		return nil, err
 | 
							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],
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	entry.Invalid = invalid
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ignore, err := parseConntrackStatField(fields[5])
 | 
						// Ignore missing search_restart on Linux < 2.6.35.
 | 
				
			||||||
	if err != nil {
 | 
						if numEntries == 17 {
 | 
				
			||||||
		return nil, err
 | 
							stats.SearchRestart = *entries[16]
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	entry.Ignore = ignore
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	insert, err := parseConntrackStatField(fields[8])
 | 
						return stats, nil
 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	entry.Insert = insert
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	insertFailed, err := parseConntrackStatField(fields[9])
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	entry.InsertFailed = insertFailed
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	drop, err := parseConntrackStatField(fields[10])
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	entry.Drop = drop
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	earlyDrop, err := parseConntrackStatField(fields[11])
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	entry.EarlyDrop = earlyDrop
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	searchRestart, err := parseConntrackStatField(fields[16])
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return nil, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	entry.SearchRestart = searchRestart
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return entry, nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Parses a uint64 from given hex in string.
 | 
					 | 
				
			||||||
func parseConntrackStatField(field string) (uint64, error) {
 | 
					 | 
				
			||||||
	val, err := strconv.ParseUint(field, 16, 64)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return 0, fmt.Errorf("couldn't parse %q field: %w", field, err)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return val, err
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -130,7 +130,7 @@ func parseIP(hexIP string) (net.IP, error) {
 | 
				
			||||||
	var byteIP []byte
 | 
						var byteIP []byte
 | 
				
			||||||
	byteIP, err := hex.DecodeString(hexIP)
 | 
						byteIP, err := hex.DecodeString(hexIP)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse address field in socket line %q", hexIP)
 | 
							return nil, fmt.Errorf("%s: Cannot parse socket field in %q: %w", ErrFileParse, hexIP, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	switch len(byteIP) {
 | 
						switch len(byteIP) {
 | 
				
			||||||
	case 4:
 | 
						case 4:
 | 
				
			||||||
| 
						 | 
					@ -144,7 +144,7 @@ func parseIP(hexIP string) (net.IP, error) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return i, nil
 | 
							return i, nil
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return nil, fmt.Errorf("Unable to parse IP %s", hexIP)
 | 
							return nil, fmt.Errorf("%s: Unable to parse IP %s: %w", ErrFileParse, hexIP, nil)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -153,7 +153,8 @@ func parseNetIPSocketLine(fields []string) (*netIPSocketLine, error) {
 | 
				
			||||||
	line := &netIPSocketLine{}
 | 
						line := &netIPSocketLine{}
 | 
				
			||||||
	if len(fields) < 10 {
 | 
						if len(fields) < 10 {
 | 
				
			||||||
		return nil, fmt.Errorf(
 | 
							return nil, fmt.Errorf(
 | 
				
			||||||
			"cannot parse net socket line as it has less then 10 columns %q",
 | 
								"%w: Less than 10 columns found %q",
 | 
				
			||||||
 | 
								ErrFileParse,
 | 
				
			||||||
			strings.Join(fields, " "),
 | 
								strings.Join(fields, " "),
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -162,64 +163,65 @@ func parseNetIPSocketLine(fields []string) (*netIPSocketLine, error) {
 | 
				
			||||||
	// sl
 | 
						// sl
 | 
				
			||||||
	s := strings.Split(fields[0], ":")
 | 
						s := strings.Split(fields[0], ":")
 | 
				
			||||||
	if len(s) != 2 {
 | 
						if len(s) != 2 {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse sl field in socket line %q", fields[0])
 | 
							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 {
 | 
						if line.Sl, err = strconv.ParseUint(s[0], 0, 64); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse sl value in socket line: %w", err)
 | 
							return nil, fmt.Errorf("%s: Unable to parse sl field in %q: %w", ErrFileParse, line.Sl, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// local_address
 | 
						// local_address
 | 
				
			||||||
	l := strings.Split(fields[1], ":")
 | 
						l := strings.Split(fields[1], ":")
 | 
				
			||||||
	if len(l) != 2 {
 | 
						if len(l) != 2 {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse local_address field in socket line %q", fields[1])
 | 
							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 {
 | 
						if line.LocalAddr, err = parseIP(l[0]); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if line.LocalPort, err = strconv.ParseUint(l[1], 16, 64); err != nil {
 | 
						if line.LocalPort, err = strconv.ParseUint(l[1], 16, 64); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse local_address port value in socket line: %w", err)
 | 
							return nil, fmt.Errorf("%s: Unable to parse local_address port value line %q: %w", ErrFileParse, line.LocalPort, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// remote_address
 | 
						// remote_address
 | 
				
			||||||
	r := strings.Split(fields[2], ":")
 | 
						r := strings.Split(fields[2], ":")
 | 
				
			||||||
	if len(r) != 2 {
 | 
						if len(r) != 2 {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse rem_address field in socket line %q", fields[1])
 | 
							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 {
 | 
						if line.RemAddr, err = parseIP(r[0]); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if line.RemPort, err = strconv.ParseUint(r[1], 16, 64); err != nil {
 | 
						if line.RemPort, err = strconv.ParseUint(r[1], 16, 64); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse rem_address port value in socket line: %w", err)
 | 
							return nil, fmt.Errorf("%s: Cannot parse rem_address port value in %q: %w", ErrFileParse, line.RemPort, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// st
 | 
						// st
 | 
				
			||||||
	if line.St, err = strconv.ParseUint(fields[3], 16, 64); err != nil {
 | 
						if line.St, err = strconv.ParseUint(fields[3], 16, 64); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse st value in socket line: %w", err)
 | 
							return nil, fmt.Errorf("%s: Cannot parse st value in %q: %w", ErrFileParse, line.St, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// tx_queue and rx_queue
 | 
						// tx_queue and rx_queue
 | 
				
			||||||
	q := strings.Split(fields[4], ":")
 | 
						q := strings.Split(fields[4], ":")
 | 
				
			||||||
	if len(q) != 2 {
 | 
						if len(q) != 2 {
 | 
				
			||||||
		return nil, fmt.Errorf(
 | 
							return nil, fmt.Errorf(
 | 
				
			||||||
			"cannot parse tx/rx queues in socket line as it has a missing colon %q",
 | 
								"%w: Missing colon for tx/rx queues in socket line %q",
 | 
				
			||||||
 | 
								ErrFileParse,
 | 
				
			||||||
			fields[4],
 | 
								fields[4],
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if line.TxQueue, err = strconv.ParseUint(q[0], 16, 64); err != nil {
 | 
						if line.TxQueue, err = strconv.ParseUint(q[0], 16, 64); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse tx_queue value in socket line: %w", err)
 | 
							return nil, fmt.Errorf("%s: Cannot parse tx_queue value in %q: %w", ErrFileParse, line.TxQueue, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if line.RxQueue, err = strconv.ParseUint(q[1], 16, 64); err != nil {
 | 
						if line.RxQueue, err = strconv.ParseUint(q[1], 16, 64); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse rx_queue value in socket line: %w", err)
 | 
							return nil, fmt.Errorf("%s: Cannot parse trx_queue value in %q: %w", ErrFileParse, line.RxQueue, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// uid
 | 
						// uid
 | 
				
			||||||
	if line.UID, err = strconv.ParseUint(fields[7], 0, 64); err != nil {
 | 
						if line.UID, err = strconv.ParseUint(fields[7], 0, 64); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse uid value in socket line: %w", err)
 | 
							return nil, fmt.Errorf("%s: Cannot parse UID value in %q: %w", ErrFileParse, line.UID, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// inode
 | 
						// inode
 | 
				
			||||||
	if line.Inode, err = strconv.ParseUint(fields[9], 0, 64); err != nil {
 | 
						if line.Inode, err = strconv.ParseUint(fields[9], 0, 64); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("cannot parse inode value in socket line: %w", err)
 | 
							return nil, fmt.Errorf("%s: Cannot parse inode value in %q: %w", ErrFileParse, line.Inode, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return line, nil
 | 
						return line, nil
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -131,7 +131,7 @@ func (ps NetProtocolStats) parseLine(rawLine string) (*NetProtocolStatLine, erro
 | 
				
			||||||
	} else if fields[6] == disabled {
 | 
						} else if fields[6] == disabled {
 | 
				
			||||||
		line.Slab = false
 | 
							line.Slab = false
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		return nil, fmt.Errorf("unable to parse capability for protocol: %s", line.Name)
 | 
							return nil, fmt.Errorf("%w: capability for protocol: %s", ErrFileParse, line.Name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	line.ModuleName = fields[7]
 | 
						line.ModuleName = fields[7]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -173,7 +173,7 @@ func (pc *NetProtocolCapabilities) parseCapabilities(capabilities []string) erro
 | 
				
			||||||
		} else if capabilities[i] == "n" {
 | 
							} else if capabilities[i] == "n" {
 | 
				
			||||||
			*capabilityFields[i] = false
 | 
								*capabilityFields[i] = false
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return fmt.Errorf("unable to parse capability block for protocol: position %d", i)
 | 
								return fmt.Errorf("%w: capability block for protocol: position %d", ErrFileParse, i)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,143 @@
 | 
				
			||||||
 | 
					// 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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,6 @@ package procfs
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bufio"
 | 
						"bufio"
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"errors"
 | 
					 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
| 
						 | 
					@ -70,7 +69,7 @@ func readSockstat(name string) (*NetSockstat, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	stat, err := parseSockstat(bytes.NewReader(b))
 | 
						stat, err := parseSockstat(bytes.NewReader(b))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to read sockstats from %q: %w", name, err)
 | 
							return nil, fmt.Errorf("%s: sockstats from %q: %w", ErrFileRead, name, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return stat, nil
 | 
						return stat, nil
 | 
				
			||||||
| 
						 | 
					@ -84,13 +83,13 @@ func parseSockstat(r io.Reader) (*NetSockstat, error) {
 | 
				
			||||||
		// Expect a minimum of a protocol and one key/value pair.
 | 
							// Expect a minimum of a protocol and one key/value pair.
 | 
				
			||||||
		fields := strings.Split(s.Text(), " ")
 | 
							fields := strings.Split(s.Text(), " ")
 | 
				
			||||||
		if len(fields) < 3 {
 | 
							if len(fields) < 3 {
 | 
				
			||||||
			return nil, fmt.Errorf("malformed sockstat line: %q", s.Text())
 | 
								return nil, fmt.Errorf("%w: Malformed sockstat line: %q", ErrFileParse, s.Text())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// The remaining fields are key/value pairs.
 | 
							// The remaining fields are key/value pairs.
 | 
				
			||||||
		kvs, err := parseSockstatKVs(fields[1:])
 | 
							kvs, err := parseSockstatKVs(fields[1:])
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("error parsing sockstat key/value pairs from %q: %w", s.Text(), err)
 | 
								return nil, fmt.Errorf("%s: sockstat key/value pairs from %q: %w", ErrFileParse, s.Text(), err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// The first field is the protocol. We must trim its colon suffix.
 | 
							// The first field is the protocol. We must trim its colon suffix.
 | 
				
			||||||
| 
						 | 
					@ -119,7 +118,7 @@ func parseSockstat(r io.Reader) (*NetSockstat, error) {
 | 
				
			||||||
// parseSockstatKVs parses a string slice into a map of key/value pairs.
 | 
					// parseSockstatKVs parses a string slice into a map of key/value pairs.
 | 
				
			||||||
func parseSockstatKVs(kvs []string) (map[string]int, error) {
 | 
					func parseSockstatKVs(kvs []string) (map[string]int, error) {
 | 
				
			||||||
	if len(kvs)%2 != 0 {
 | 
						if len(kvs)%2 != 0 {
 | 
				
			||||||
		return nil, errors.New("odd number of fields in key/value pairs")
 | 
							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.
 | 
						// Iterate two values at a time to gather key/value pairs.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,8 +27,9 @@ import (
 | 
				
			||||||
// For the proc file format details,
 | 
					// For the proc file format details,
 | 
				
			||||||
// See:
 | 
					// See:
 | 
				
			||||||
// * Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2343
 | 
					// * Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2343
 | 
				
			||||||
// * Linux 4.17 https://elixir.bootlin.com/linux/v4.17/source/net/core/net-procfs.c#L162
 | 
					// * Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086
 | 
				
			||||||
// and https://elixir.bootlin.com/linux/v4.17/source/include/linux/netdevice.h#L2810.
 | 
					// * 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.
 | 
					// SoftnetStat contains a single row of data from /proc/net/softnet_stat.
 | 
				
			||||||
type SoftnetStat struct {
 | 
					type SoftnetStat struct {
 | 
				
			||||||
| 
						 | 
					@ -38,6 +39,18 @@ type SoftnetStat struct {
 | 
				
			||||||
	Dropped uint32
 | 
						Dropped uint32
 | 
				
			||||||
	// Number of times processing packets ran out of quota.
 | 
						// Number of times processing packets ran out of quota.
 | 
				
			||||||
	TimeSqueezed uint32
 | 
						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"
 | 
					var softNetProcFile = "net/softnet_stat"
 | 
				
			||||||
| 
						 | 
					@ -51,7 +64,7 @@ func (fs FS) NetSoftnetStat() ([]SoftnetStat, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	entries, err := parseSoftnet(bytes.NewReader(b))
 | 
						entries, err := parseSoftnet(bytes.NewReader(b))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse /proc/net/softnet_stat: %w", err)
 | 
							return nil, fmt.Errorf("%s: /proc/net/softnet_stat: %w", ErrFileParse, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return entries, nil
 | 
						return entries, nil
 | 
				
			||||||
| 
						 | 
					@ -63,25 +76,65 @@ func parseSoftnet(r io.Reader) ([]SoftnetStat, error) {
 | 
				
			||||||
	s := bufio.NewScanner(r)
 | 
						s := bufio.NewScanner(r)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var stats []SoftnetStat
 | 
						var stats []SoftnetStat
 | 
				
			||||||
 | 
						cpuIndex := 0
 | 
				
			||||||
	for s.Scan() {
 | 
						for s.Scan() {
 | 
				
			||||||
		columns := strings.Fields(s.Text())
 | 
							columns := strings.Fields(s.Text())
 | 
				
			||||||
		width := len(columns)
 | 
							width := len(columns)
 | 
				
			||||||
 | 
							softnetStat := SoftnetStat{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if width < minColumns {
 | 
							if width < minColumns {
 | 
				
			||||||
			return nil, fmt.Errorf("%d columns were detected, but at least %d were expected", width, minColumns)
 | 
								return nil, fmt.Errorf("%w: detected %d columns, but expected at least %d", ErrFileParse, width, minColumns)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// We only parse the first three columns at the moment.
 | 
							// Linux 2.6.23 https://elixir.bootlin.com/linux/v2.6.23/source/net/core/dev.c#L2347
 | 
				
			||||||
		us, err := parseHexUint32s(columns[0:3])
 | 
							if width >= minColumns {
 | 
				
			||||||
		if err != nil {
 | 
								us, err := parseHexUint32s(columns[0:9])
 | 
				
			||||||
			return nil, err
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return nil, err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								softnetStat.Processed = us[0]
 | 
				
			||||||
 | 
								softnetStat.Dropped = us[1]
 | 
				
			||||||
 | 
								softnetStat.TimeSqueezed = us[2]
 | 
				
			||||||
 | 
								softnetStat.CPUCollision = us[8]
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		stats = append(stats, SoftnetStat{
 | 
							// Linux 2.6.39 https://elixir.bootlin.com/linux/v2.6.39/source/net/core/dev.c#L4086
 | 
				
			||||||
			Processed:    us[0],
 | 
							if width >= 10 {
 | 
				
			||||||
			Dropped:      us[1],
 | 
								us, err := parseHexUint32s(columns[9:10])
 | 
				
			||||||
			TimeSqueezed: us[2],
 | 
								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
 | 
						return stats, nil
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -108,14 +108,14 @@ func parseNetUNIX(r io.Reader) (*NetUNIX, error) {
 | 
				
			||||||
		line := s.Text()
 | 
							line := s.Text()
 | 
				
			||||||
		item, err := nu.parseLine(line, hasInode, minFields)
 | 
							item, err := nu.parseLine(line, hasInode, minFields)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("failed to parse /proc/net/unix data %q: %w", line, err)
 | 
								return nil, fmt.Errorf("%s: /proc/net/unix encountered data %q: %w", ErrFileParse, line, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		nu.Rows = append(nu.Rows, item)
 | 
							nu.Rows = append(nu.Rows, item)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := s.Err(); err != nil {
 | 
						if err := s.Err(); err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to scan /proc/net/unix data: %w", err)
 | 
							return nil, fmt.Errorf("%s: /proc/net/unix encountered data: %w", ErrFileParse, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &nu, nil
 | 
						return &nu, nil
 | 
				
			||||||
| 
						 | 
					@ -126,7 +126,7 @@ func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	l := len(fields)
 | 
						l := len(fields)
 | 
				
			||||||
	if l < min {
 | 
						if l < min {
 | 
				
			||||||
		return nil, fmt.Errorf("expected at least %d fields but got %d", min, l)
 | 
							return nil, fmt.Errorf("%w: expected at least %d fields but got %d", ErrFileParse, min, l)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Field offsets are as follows:
 | 
						// Field offsets are as follows:
 | 
				
			||||||
| 
						 | 
					@ -136,29 +136,29 @@ func (u *NetUNIX) parseLine(line string, hasInode bool, min int) (*NetUNIXLine,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	users, err := u.parseUsers(fields[1])
 | 
						users, err := u.parseUsers(fields[1])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse ref count %q: %w", fields[1], err)
 | 
							return nil, fmt.Errorf("%s: ref count %q: %w", ErrFileParse, fields[1], err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flags, err := u.parseFlags(fields[3])
 | 
						flags, err := u.parseFlags(fields[3])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse flags %q: %w", fields[3], err)
 | 
							return nil, fmt.Errorf("%s: Unable to parse flags %q: %w", ErrFileParse, fields[3], err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	typ, err := u.parseType(fields[4])
 | 
						typ, err := u.parseType(fields[4])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse type %q: %w", fields[4], err)
 | 
							return nil, fmt.Errorf("%s: Failed to parse type %q: %w", ErrFileParse, fields[4], err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	state, err := u.parseState(fields[5])
 | 
						state, err := u.parseState(fields[5])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse state %q: %w", fields[5], err)
 | 
							return nil, fmt.Errorf("%s: Failed to parse state %q: %w", ErrFileParse, fields[5], err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var inode uint64
 | 
						var inode uint64
 | 
				
			||||||
	if hasInode {
 | 
						if hasInode {
 | 
				
			||||||
		inode, err = u.parseInode(fields[6])
 | 
							inode, err = u.parseInode(fields[6])
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("failed to parse inode %q: %w", fields[6], err)
 | 
								return nil, fmt.Errorf("%s failed to parse inode %q: %w", ErrFileParse, fields[6], err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,182 @@
 | 
				
			||||||
 | 
					// 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("%s: 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("%s: 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("%s: Quality:level as integer %q: %w", ErrFileParse, qlevel, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							qnoise, err := strconv.Atoi(strings.TrimSuffix(stats[3], "."))
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("%s: Quality:noise as integer %q: %w", ErrFileParse, qnoise, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							dnwid, err := strconv.Atoi(stats[4])
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("%s: Discarded:nwid as integer %q: %w", ErrFileParse, dnwid, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							dcrypt, err := strconv.Atoi(stats[5])
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("%s: Discarded:crypt as integer %q: %w", ErrFileParse, dcrypt, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							dfrag, err := strconv.Atoi(stats[6])
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("%s: Discarded:frag as integer %q: %w", ErrFileParse, dfrag, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							dretry, err := strconv.Atoi(stats[7])
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("%s: Discarded:retry as integer %q: %w", ErrFileParse, dretry, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							dmisc, err := strconv.Atoi(stats[8])
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("%s: Discarded:misc as integer %q: %w", ErrFileParse, dmisc, err)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							mbeacon, err := strconv.Atoi(stats[9])
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, fmt.Errorf("%s: 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("%s: Failed to scan /proc/net/wireless: %w", ErrFileRead, err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return interfaces, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -115,7 +115,7 @@ func (fs FS) NewXfrmStat() (XfrmStat, error) {
 | 
				
			||||||
		fields := strings.Fields(s.Text())
 | 
							fields := strings.Fields(s.Text())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(fields) != 2 {
 | 
							if len(fields) != 2 {
 | 
				
			||||||
			return XfrmStat{}, fmt.Errorf("couldn't parse %q line %q", file.Name(), s.Text())
 | 
								return XfrmStat{}, fmt.Errorf("%w: %q line %q", ErrFileParse, file.Name(), s.Text())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		name := fields[0]
 | 
							name := fields[0]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,32 +37,46 @@ func (fs FS) NetStat() ([]NetStat, error) {
 | 
				
			||||||
	var netStatsTotal []NetStat
 | 
						var netStatsTotal []NetStat
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, filePath := range statFiles {
 | 
						for _, filePath := range statFiles {
 | 
				
			||||||
		file, err := os.Open(filePath)
 | 
							procNetstat, err := parseNetstat(filePath)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							procNetstat.Filename = filepath.Base(filePath)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		netStatFile := NetStat{
 | 
							netStatsTotal = append(netStatsTotal, procNetstat)
 | 
				
			||||||
			Filename: filepath.Base(filePath),
 | 
					 | 
				
			||||||
			Stats:    make(map[string][]uint64),
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		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 nil, err
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				netStatFile.Stats[headers[num]] = append(netStatFile.Stats[headers[num]], value)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		netStatsTotal = append(netStatsTotal, netStatFile)
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return netStatsTotal, nil
 | 
						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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,13 +15,13 @@ package procfs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/prometheus/procfs/internal/fs"
 | 
					 | 
				
			||||||
	"github.com/prometheus/procfs/internal/util"
 | 
						"github.com/prometheus/procfs/internal/util"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,12 +30,18 @@ type Proc struct {
 | 
				
			||||||
	// The process ID.
 | 
						// The process ID.
 | 
				
			||||||
	PID int
 | 
						PID int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fs fs.FS
 | 
						fs FS
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Procs represents a list of Proc structs.
 | 
					// Procs represents a list of Proc structs.
 | 
				
			||||||
type Procs []Proc
 | 
					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) Len() int           { return len(p) }
 | 
				
			||||||
func (p Procs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }
 | 
					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 }
 | 
					func (p Procs) Less(i, j int) bool { return p[i].PID < p[j].PID }
 | 
				
			||||||
| 
						 | 
					@ -43,7 +49,7 @@ 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.
 | 
					// Self returns a process for the current process read via /proc/self.
 | 
				
			||||||
func Self() (Proc, error) {
 | 
					func Self() (Proc, error) {
 | 
				
			||||||
	fs, err := NewFS(DefaultMountPoint)
 | 
						fs, err := NewFS(DefaultMountPoint)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil || errors.Unwrap(err) == ErrMountPoint {
 | 
				
			||||||
		return Proc{}, err
 | 
							return Proc{}, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return fs.Self()
 | 
						return fs.Self()
 | 
				
			||||||
| 
						 | 
					@ -92,7 +98,7 @@ func (fs FS) Proc(pid int) (Proc, error) {
 | 
				
			||||||
	if _, err := os.Stat(fs.proc.Path(strconv.Itoa(pid))); err != nil {
 | 
						if _, err := os.Stat(fs.proc.Path(strconv.Itoa(pid))); err != nil {
 | 
				
			||||||
		return Proc{}, err
 | 
							return Proc{}, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return Proc{PID: pid, fs: fs.proc}, nil
 | 
						return Proc{PID: pid, fs: fs}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// AllProcs returns a list of all currently available processes.
 | 
					// AllProcs returns a list of all currently available processes.
 | 
				
			||||||
| 
						 | 
					@ -105,7 +111,7 @@ func (fs FS) AllProcs() (Procs, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	names, err := d.Readdirnames(-1)
 | 
						names, err := d.Readdirnames(-1)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return Procs{}, fmt.Errorf("could not read %q: %w", d.Name(), err)
 | 
							return Procs{}, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, names, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p := Procs{}
 | 
						p := Procs{}
 | 
				
			||||||
| 
						 | 
					@ -114,7 +120,7 @@ func (fs FS) AllProcs() (Procs, error) {
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		p = append(p, Proc{PID: int(pid), fs: fs.proc})
 | 
							p = append(p, Proc{PID: int(pid), fs: fs})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return p, nil
 | 
						return p, nil
 | 
				
			||||||
| 
						 | 
					@ -206,7 +212,7 @@ func (p Proc) FileDescriptors() ([]uintptr, error) {
 | 
				
			||||||
	for i, n := range names {
 | 
						for i, n := range names {
 | 
				
			||||||
		fd, err := strconv.ParseInt(n, 10, 32)
 | 
							fd, err := strconv.ParseInt(n, 10, 32)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("could not parse fd %q: %w", n, err)
 | 
								return nil, fmt.Errorf("%s: Cannot parse line: %v: %w", ErrFileParse, i, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		fds[i] = uintptr(fd)
 | 
							fds[i] = uintptr(fd)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -237,6 +243,19 @@ func (p Proc) FileDescriptorTargets() ([]string, error) {
 | 
				
			||||||
// FileDescriptorsLen returns the number of currently open file descriptors of
 | 
					// FileDescriptorsLen returns the number of currently open file descriptors of
 | 
				
			||||||
// a process.
 | 
					// a process.
 | 
				
			||||||
func (p Proc) FileDescriptorsLen() (int, error) {
 | 
					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()
 | 
						fds, err := p.fileDescriptors()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
| 
						 | 
					@ -278,14 +297,14 @@ func (p Proc) fileDescriptors() ([]string, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	names, err := d.Readdirnames(-1)
 | 
						names, err := d.Readdirnames(-1)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("could not read %q: %w", d.Name(), err)
 | 
							return nil, fmt.Errorf("%s: Cannot read file: %v: %w", ErrFileRead, names, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return names, nil
 | 
						return names, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p Proc) path(pa ...string) string {
 | 
					func (p Proc) path(pa ...string) string {
 | 
				
			||||||
	return p.fs.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...)
 | 
						return p.fs.proc.Path(append([]string{strconv.Itoa(p.PID)}, pa...)...)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// FileDescriptorsInfo retrieves information about all file descriptors of
 | 
					// FileDescriptorsInfo retrieves information about all file descriptors of
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ import (
 | 
				
			||||||
	"github.com/prometheus/procfs/internal/util"
 | 
						"github.com/prometheus/procfs/internal/util"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Cgroup models one line from /proc/[pid]/cgroup. Each Cgroup struct describes the the placement of a PID inside a
 | 
					// 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
 | 
					// 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
 | 
					// 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
 | 
					// contain all running processes, so the question answerable with a Cgroup struct is 'where is this process in
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fields := strings.SplitN(cgroupStr, ":", 3)
 | 
						fields := strings.SplitN(cgroupStr, ":", 3)
 | 
				
			||||||
	if len(fields) < 3 {
 | 
						if len(fields) < 3 {
 | 
				
			||||||
		return nil, fmt.Errorf("at least 3 fields required, found %d fields in cgroup string: %s", len(fields), cgroupStr)
 | 
							return nil, fmt.Errorf("%w: 3+ fields required, found %d fields in cgroup string: %s", ErrFileParse, len(fields), cgroupStr)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cgroup := &Cgroup{
 | 
						cgroup := &Cgroup{
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@ func parseCgroupString(cgroupStr string) (*Cgroup, error) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	cgroup.HierarchyID, err = strconv.Atoi(fields[0])
 | 
						cgroup.HierarchyID, err = strconv.Atoi(fields[0])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse hierarchy ID")
 | 
							return nil, fmt.Errorf("%w: hierarchy ID: %q", ErrFileParse, cgroup.HierarchyID)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if fields[1] != "" {
 | 
						if fields[1] != "" {
 | 
				
			||||||
		ssNames := strings.Split(fields[1], ",")
 | 
							ssNames := strings.Split(fields[1], ",")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,7 @@ func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) {
 | 
				
			||||||
	fields := strings.Fields(CgroupSummaryStr)
 | 
						fields := strings.Fields(CgroupSummaryStr)
 | 
				
			||||||
	// require at least 4 fields
 | 
						// require at least 4 fields
 | 
				
			||||||
	if len(fields) < 4 {
 | 
						if len(fields) < 4 {
 | 
				
			||||||
		return nil, fmt.Errorf("at least 4 fields required, found %d fields in cgroup info string: %s", len(fields), CgroupSummaryStr)
 | 
							return nil, fmt.Errorf("%w: 4+ fields required, found %d fields in cgroup info string: %s", ErrFileParse, len(fields), CgroupSummaryStr)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	CgroupSummary := &CgroupSummary{
 | 
						CgroupSummary := &CgroupSummary{
 | 
				
			||||||
| 
						 | 
					@ -54,15 +54,15 @@ func parseCgroupSummaryString(CgroupSummaryStr string) (*CgroupSummary, error) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	CgroupSummary.Hierarchy, err = strconv.Atoi(fields[1])
 | 
						CgroupSummary.Hierarchy, err = strconv.Atoi(fields[1])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse hierarchy ID")
 | 
							return nil, fmt.Errorf("%w: Unable to parse hierarchy ID from %q", ErrFileParse, fields[1])
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	CgroupSummary.Cgroups, err = strconv.Atoi(fields[2])
 | 
						CgroupSummary.Cgroups, err = strconv.Atoi(fields[2])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse Cgroup Num")
 | 
							return nil, fmt.Errorf("%w: Unable to parse Cgroup Num from %q", ErrFileParse, fields[2])
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	CgroupSummary.Enabled, err = strconv.Atoi(fields[3])
 | 
						CgroupSummary.Enabled, err = strconv.Atoi(fields[3])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to parse Enabled")
 | 
							return nil, fmt.Errorf("%w: Unable to parse Enabled from %q", ErrFileParse, fields[3])
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return CgroupSummary, nil
 | 
						return CgroupSummary, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,6 +26,7 @@ var (
 | 
				
			||||||
	rPos          = regexp.MustCompile(`^pos:\s+(\d+)$`)
 | 
						rPos          = regexp.MustCompile(`^pos:\s+(\d+)$`)
 | 
				
			||||||
	rFlags        = regexp.MustCompile(`^flags:\s+(\d+)$`)
 | 
						rFlags        = regexp.MustCompile(`^flags:\s+(\d+)$`)
 | 
				
			||||||
	rMntID        = regexp.MustCompile(`^mnt_id:\s+(\d+)$`)
 | 
						rMntID        = regexp.MustCompile(`^mnt_id:\s+(\d+)$`)
 | 
				
			||||||
 | 
						rIno          = regexp.MustCompile(`^ino:\s+(\d+)$`)
 | 
				
			||||||
	rInotify      = regexp.MustCompile(`^inotify`)
 | 
						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]+))?`)
 | 
						rInotifyParts = regexp.MustCompile(`^inotify\s+wd:([0-9a-f]+)\s+ino:([0-9a-f]+)\s+sdev:([0-9a-f]+)(?:\s+mask:([0-9a-f]+))?`)
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -40,6 +41,8 @@ type ProcFDInfo struct {
 | 
				
			||||||
	Flags string
 | 
						Flags string
 | 
				
			||||||
	// Mount point ID
 | 
						// Mount point ID
 | 
				
			||||||
	MntID string
 | 
						MntID string
 | 
				
			||||||
 | 
						// Inode number
 | 
				
			||||||
 | 
						Ino string
 | 
				
			||||||
	// List of inotify lines (structured) in the fdinfo file (kernel 3.8+ only)
 | 
						// List of inotify lines (structured) in the fdinfo file (kernel 3.8+ only)
 | 
				
			||||||
	InotifyInfos []InotifyInfo
 | 
						InotifyInfos []InotifyInfo
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -51,7 +54,7 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var text, pos, flags, mntid string
 | 
						var text, pos, flags, mntid, ino string
 | 
				
			||||||
	var inotify []InotifyInfo
 | 
						var inotify []InotifyInfo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	scanner := bufio.NewScanner(bytes.NewReader(data))
 | 
						scanner := bufio.NewScanner(bytes.NewReader(data))
 | 
				
			||||||
| 
						 | 
					@ -63,6 +66,8 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) {
 | 
				
			||||||
			flags = rFlags.FindStringSubmatch(text)[1]
 | 
								flags = rFlags.FindStringSubmatch(text)[1]
 | 
				
			||||||
		} else if rMntID.MatchString(text) {
 | 
							} else if rMntID.MatchString(text) {
 | 
				
			||||||
			mntid = rMntID.FindStringSubmatch(text)[1]
 | 
								mntid = rMntID.FindStringSubmatch(text)[1]
 | 
				
			||||||
 | 
							} else if rIno.MatchString(text) {
 | 
				
			||||||
 | 
								ino = rIno.FindStringSubmatch(text)[1]
 | 
				
			||||||
		} else if rInotify.MatchString(text) {
 | 
							} else if rInotify.MatchString(text) {
 | 
				
			||||||
			newInotify, err := parseInotifyInfo(text)
 | 
								newInotify, err := parseInotifyInfo(text)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
| 
						 | 
					@ -77,6 +82,7 @@ func (p Proc) FDInfo(fd string) (*ProcFDInfo, error) {
 | 
				
			||||||
		Pos:          pos,
 | 
							Pos:          pos,
 | 
				
			||||||
		Flags:        flags,
 | 
							Flags:        flags,
 | 
				
			||||||
		MntID:        mntid,
 | 
							MntID:        mntid,
 | 
				
			||||||
 | 
							Ino:          ino,
 | 
				
			||||||
		InotifyInfos: inotify,
 | 
							InotifyInfos: inotify,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -111,7 +117,7 @@ func parseInotifyInfo(line string) (*InotifyInfo, error) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return i, nil
 | 
							return i, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil, fmt.Errorf("invalid inode entry: %q", line)
 | 
						return nil, fmt.Errorf("%w: invalid inode entry: %q", ErrFileParse, line)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ProcFDInfos represents a list of ProcFDInfo structs.
 | 
					// ProcFDInfos represents a list of ProcFDInfo structs.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,98 @@
 | 
				
			||||||
 | 
					// 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()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -103,7 +103,7 @@ func (p Proc) Limits() (ProcLimits, error) {
 | 
				
			||||||
		//fields := limitsMatch.Split(s.Text(), limitsFields)
 | 
							//fields := limitsMatch.Split(s.Text(), limitsFields)
 | 
				
			||||||
		fields := limitsMatch.FindStringSubmatch(s.Text())
 | 
							fields := limitsMatch.FindStringSubmatch(s.Text())
 | 
				
			||||||
		if len(fields) != limitsFields {
 | 
							if len(fields) != limitsFields {
 | 
				
			||||||
			return ProcLimits{}, fmt.Errorf("couldn't parse %q line %q", f.Name(), s.Text())
 | 
								return ProcLimits{}, fmt.Errorf("%w: couldn't parse %q line %q", ErrFileParse, f.Name(), s.Text())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch fields[1] {
 | 
							switch fields[1] {
 | 
				
			||||||
| 
						 | 
					@ -154,7 +154,7 @@ func parseUint(s string) (uint64, error) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	i, err := strconv.ParseUint(s, 10, 64)
 | 
						i, err := strconv.ParseUint(s, 10, 64)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, fmt.Errorf("couldn't parse value %q: %w", s, err)
 | 
							return 0, fmt.Errorf("%s: couldn't parse value %q: %w", ErrFileParse, s, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return i, nil
 | 
						return i, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,17 +63,17 @@ type ProcMap struct {
 | 
				
			||||||
// parseDevice parses the device token of a line and converts it to a dev_t
 | 
					// parseDevice parses the device token of a line and converts it to a dev_t
 | 
				
			||||||
// (mkdev) like structure.
 | 
					// (mkdev) like structure.
 | 
				
			||||||
func parseDevice(s string) (uint64, error) {
 | 
					func parseDevice(s string) (uint64, error) {
 | 
				
			||||||
	toks := strings.Split(s, ":")
 | 
						i := strings.Index(s, ":")
 | 
				
			||||||
	if len(toks) < 2 {
 | 
						if i == -1 {
 | 
				
			||||||
		return 0, fmt.Errorf("unexpected number of fields")
 | 
							return 0, fmt.Errorf("%w: expected separator `:` in %s", ErrFileParse, s)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	major, err := strconv.ParseUint(toks[0], 16, 0)
 | 
						major, err := strconv.ParseUint(s[0:i], 16, 0)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	minor, err := strconv.ParseUint(toks[1], 16, 0)
 | 
						minor, err := strconv.ParseUint(s[i+1:], 16, 0)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -93,17 +93,17 @@ func parseAddress(s string) (uintptr, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// parseAddresses parses the start-end address.
 | 
					// parseAddresses parses the start-end address.
 | 
				
			||||||
func parseAddresses(s string) (uintptr, uintptr, error) {
 | 
					func parseAddresses(s string) (uintptr, uintptr, error) {
 | 
				
			||||||
	toks := strings.Split(s, "-")
 | 
						idx := strings.Index(s, "-")
 | 
				
			||||||
	if len(toks) < 2 {
 | 
						if idx == -1 {
 | 
				
			||||||
		return 0, 0, fmt.Errorf("invalid address")
 | 
							return 0, 0, fmt.Errorf("%w: expected separator `-` in %s", ErrFileParse, s)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	saddr, err := parseAddress(toks[0])
 | 
						saddr, err := parseAddress(s[0:idx])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, 0, err
 | 
							return 0, 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	eaddr, err := parseAddress(toks[1])
 | 
						eaddr, err := parseAddress(s[idx+1:])
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, 0, err
 | 
							return 0, 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -114,7 +114,7 @@ func parseAddresses(s string) (uintptr, uintptr, error) {
 | 
				
			||||||
// parsePermissions parses a token and returns any that are set.
 | 
					// parsePermissions parses a token and returns any that are set.
 | 
				
			||||||
func parsePermissions(s string) (*ProcMapPermissions, error) {
 | 
					func parsePermissions(s string) (*ProcMapPermissions, error) {
 | 
				
			||||||
	if len(s) < 4 {
 | 
						if len(s) < 4 {
 | 
				
			||||||
		return nil, fmt.Errorf("invalid permissions token")
 | 
							return nil, fmt.Errorf("%w: invalid permissions token", ErrFileParse)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	perms := ProcMapPermissions{}
 | 
						perms := ProcMapPermissions{}
 | 
				
			||||||
| 
						 | 
					@ -141,7 +141,7 @@ func parsePermissions(s string) (*ProcMapPermissions, error) {
 | 
				
			||||||
func parseProcMap(text string) (*ProcMap, error) {
 | 
					func parseProcMap(text string) (*ProcMap, error) {
 | 
				
			||||||
	fields := strings.Fields(text)
 | 
						fields := strings.Fields(text)
 | 
				
			||||||
	if len(fields) < 5 {
 | 
						if len(fields) < 5 {
 | 
				
			||||||
		return nil, fmt.Errorf("truncated procmap entry")
 | 
							return nil, fmt.Errorf("%w: truncated procmap entry", ErrFileParse)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	saddr, eaddr, err := parseAddresses(fields[0])
 | 
						saddr, eaddr, err := parseAddresses(fields[0])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,139 +33,140 @@ type ProcNetstat struct {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type TcpExt struct { // nolint:revive
 | 
					type TcpExt struct { // nolint:revive
 | 
				
			||||||
	SyncookiesSent            float64
 | 
						SyncookiesSent            *float64
 | 
				
			||||||
	SyncookiesRecv            float64
 | 
						SyncookiesRecv            *float64
 | 
				
			||||||
	SyncookiesFailed          float64
 | 
						SyncookiesFailed          *float64
 | 
				
			||||||
	EmbryonicRsts             float64
 | 
						EmbryonicRsts             *float64
 | 
				
			||||||
	PruneCalled               float64
 | 
						PruneCalled               *float64
 | 
				
			||||||
	RcvPruned                 float64
 | 
						RcvPruned                 *float64
 | 
				
			||||||
	OfoPruned                 float64
 | 
						OfoPruned                 *float64
 | 
				
			||||||
	OutOfWindowIcmps          float64
 | 
						OutOfWindowIcmps          *float64
 | 
				
			||||||
	LockDroppedIcmps          float64
 | 
						LockDroppedIcmps          *float64
 | 
				
			||||||
	ArpFilter                 float64
 | 
						ArpFilter                 *float64
 | 
				
			||||||
	TW                        float64
 | 
						TW                        *float64
 | 
				
			||||||
	TWRecycled                float64
 | 
						TWRecycled                *float64
 | 
				
			||||||
	TWKilled                  float64
 | 
						TWKilled                  *float64
 | 
				
			||||||
	PAWSActive                float64
 | 
						PAWSActive                *float64
 | 
				
			||||||
	PAWSEstab                 float64
 | 
						PAWSEstab                 *float64
 | 
				
			||||||
	DelayedACKs               float64
 | 
						DelayedACKs               *float64
 | 
				
			||||||
	DelayedACKLocked          float64
 | 
						DelayedACKLocked          *float64
 | 
				
			||||||
	DelayedACKLost            float64
 | 
						DelayedACKLost            *float64
 | 
				
			||||||
	ListenOverflows           float64
 | 
						ListenOverflows           *float64
 | 
				
			||||||
	ListenDrops               float64
 | 
						ListenDrops               *float64
 | 
				
			||||||
	TCPHPHits                 float64
 | 
						TCPHPHits                 *float64
 | 
				
			||||||
	TCPPureAcks               float64
 | 
						TCPPureAcks               *float64
 | 
				
			||||||
	TCPHPAcks                 float64
 | 
						TCPHPAcks                 *float64
 | 
				
			||||||
	TCPRenoRecovery           float64
 | 
						TCPRenoRecovery           *float64
 | 
				
			||||||
	TCPSackRecovery           float64
 | 
						TCPSackRecovery           *float64
 | 
				
			||||||
	TCPSACKReneging           float64
 | 
						TCPSACKReneging           *float64
 | 
				
			||||||
	TCPSACKReorder            float64
 | 
						TCPSACKReorder            *float64
 | 
				
			||||||
	TCPRenoReorder            float64
 | 
						TCPRenoReorder            *float64
 | 
				
			||||||
	TCPTSReorder              float64
 | 
						TCPTSReorder              *float64
 | 
				
			||||||
	TCPFullUndo               float64
 | 
						TCPFullUndo               *float64
 | 
				
			||||||
	TCPPartialUndo            float64
 | 
						TCPPartialUndo            *float64
 | 
				
			||||||
	TCPDSACKUndo              float64
 | 
						TCPDSACKUndo              *float64
 | 
				
			||||||
	TCPLossUndo               float64
 | 
						TCPLossUndo               *float64
 | 
				
			||||||
	TCPLostRetransmit         float64
 | 
						TCPLostRetransmit         *float64
 | 
				
			||||||
	TCPRenoFailures           float64
 | 
						TCPRenoFailures           *float64
 | 
				
			||||||
	TCPSackFailures           float64
 | 
						TCPSackFailures           *float64
 | 
				
			||||||
	TCPLossFailures           float64
 | 
						TCPLossFailures           *float64
 | 
				
			||||||
	TCPFastRetrans            float64
 | 
						TCPFastRetrans            *float64
 | 
				
			||||||
	TCPSlowStartRetrans       float64
 | 
						TCPSlowStartRetrans       *float64
 | 
				
			||||||
	TCPTimeouts               float64
 | 
						TCPTimeouts               *float64
 | 
				
			||||||
	TCPLossProbes             float64
 | 
						TCPLossProbes             *float64
 | 
				
			||||||
	TCPLossProbeRecovery      float64
 | 
						TCPLossProbeRecovery      *float64
 | 
				
			||||||
	TCPRenoRecoveryFail       float64
 | 
						TCPRenoRecoveryFail       *float64
 | 
				
			||||||
	TCPSackRecoveryFail       float64
 | 
						TCPSackRecoveryFail       *float64
 | 
				
			||||||
	TCPRcvCollapsed           float64
 | 
						TCPRcvCollapsed           *float64
 | 
				
			||||||
	TCPDSACKOldSent           float64
 | 
						TCPDSACKOldSent           *float64
 | 
				
			||||||
	TCPDSACKOfoSent           float64
 | 
						TCPDSACKOfoSent           *float64
 | 
				
			||||||
	TCPDSACKRecv              float64
 | 
						TCPDSACKRecv              *float64
 | 
				
			||||||
	TCPDSACKOfoRecv           float64
 | 
						TCPDSACKOfoRecv           *float64
 | 
				
			||||||
	TCPAbortOnData            float64
 | 
						TCPAbortOnData            *float64
 | 
				
			||||||
	TCPAbortOnClose           float64
 | 
						TCPAbortOnClose           *float64
 | 
				
			||||||
	TCPAbortOnMemory          float64
 | 
						TCPAbortOnMemory          *float64
 | 
				
			||||||
	TCPAbortOnTimeout         float64
 | 
						TCPAbortOnTimeout         *float64
 | 
				
			||||||
	TCPAbortOnLinger          float64
 | 
						TCPAbortOnLinger          *float64
 | 
				
			||||||
	TCPAbortFailed            float64
 | 
						TCPAbortFailed            *float64
 | 
				
			||||||
	TCPMemoryPressures        float64
 | 
						TCPMemoryPressures        *float64
 | 
				
			||||||
	TCPMemoryPressuresChrono  float64
 | 
						TCPMemoryPressuresChrono  *float64
 | 
				
			||||||
	TCPSACKDiscard            float64
 | 
						TCPSACKDiscard            *float64
 | 
				
			||||||
	TCPDSACKIgnoredOld        float64
 | 
						TCPDSACKIgnoredOld        *float64
 | 
				
			||||||
	TCPDSACKIgnoredNoUndo     float64
 | 
						TCPDSACKIgnoredNoUndo     *float64
 | 
				
			||||||
	TCPSpuriousRTOs           float64
 | 
						TCPSpuriousRTOs           *float64
 | 
				
			||||||
	TCPMD5NotFound            float64
 | 
						TCPMD5NotFound            *float64
 | 
				
			||||||
	TCPMD5Unexpected          float64
 | 
						TCPMD5Unexpected          *float64
 | 
				
			||||||
	TCPMD5Failure             float64
 | 
						TCPMD5Failure             *float64
 | 
				
			||||||
	TCPSackShifted            float64
 | 
						TCPSackShifted            *float64
 | 
				
			||||||
	TCPSackMerged             float64
 | 
						TCPSackMerged             *float64
 | 
				
			||||||
	TCPSackShiftFallback      float64
 | 
						TCPSackShiftFallback      *float64
 | 
				
			||||||
	TCPBacklogDrop            float64
 | 
						TCPBacklogDrop            *float64
 | 
				
			||||||
	PFMemallocDrop            float64
 | 
						PFMemallocDrop            *float64
 | 
				
			||||||
	TCPMinTTLDrop             float64
 | 
						TCPMinTTLDrop             *float64
 | 
				
			||||||
	TCPDeferAcceptDrop        float64
 | 
						TCPDeferAcceptDrop        *float64
 | 
				
			||||||
	IPReversePathFilter       float64
 | 
						IPReversePathFilter       *float64
 | 
				
			||||||
	TCPTimeWaitOverflow       float64
 | 
						TCPTimeWaitOverflow       *float64
 | 
				
			||||||
	TCPReqQFullDoCookies      float64
 | 
						TCPReqQFullDoCookies      *float64
 | 
				
			||||||
	TCPReqQFullDrop           float64
 | 
						TCPReqQFullDrop           *float64
 | 
				
			||||||
	TCPRetransFail            float64
 | 
						TCPRetransFail            *float64
 | 
				
			||||||
	TCPRcvCoalesce            float64
 | 
						TCPRcvCoalesce            *float64
 | 
				
			||||||
	TCPOFOQueue               float64
 | 
						TCPRcvQDrop               *float64
 | 
				
			||||||
	TCPOFODrop                float64
 | 
						TCPOFOQueue               *float64
 | 
				
			||||||
	TCPOFOMerge               float64
 | 
						TCPOFODrop                *float64
 | 
				
			||||||
	TCPChallengeACK           float64
 | 
						TCPOFOMerge               *float64
 | 
				
			||||||
	TCPSYNChallenge           float64
 | 
						TCPChallengeACK           *float64
 | 
				
			||||||
	TCPFastOpenActive         float64
 | 
						TCPSYNChallenge           *float64
 | 
				
			||||||
	TCPFastOpenActiveFail     float64
 | 
						TCPFastOpenActive         *float64
 | 
				
			||||||
	TCPFastOpenPassive        float64
 | 
						TCPFastOpenActiveFail     *float64
 | 
				
			||||||
	TCPFastOpenPassiveFail    float64
 | 
						TCPFastOpenPassive        *float64
 | 
				
			||||||
	TCPFastOpenListenOverflow float64
 | 
						TCPFastOpenPassiveFail    *float64
 | 
				
			||||||
	TCPFastOpenCookieReqd     float64
 | 
						TCPFastOpenListenOverflow *float64
 | 
				
			||||||
	TCPFastOpenBlackhole      float64
 | 
						TCPFastOpenCookieReqd     *float64
 | 
				
			||||||
	TCPSpuriousRtxHostQueues  float64
 | 
						TCPFastOpenBlackhole      *float64
 | 
				
			||||||
	BusyPollRxPackets         float64
 | 
						TCPSpuriousRtxHostQueues  *float64
 | 
				
			||||||
	TCPAutoCorking            float64
 | 
						BusyPollRxPackets         *float64
 | 
				
			||||||
	TCPFromZeroWindowAdv      float64
 | 
						TCPAutoCorking            *float64
 | 
				
			||||||
	TCPToZeroWindowAdv        float64
 | 
						TCPFromZeroWindowAdv      *float64
 | 
				
			||||||
	TCPWantZeroWindowAdv      float64
 | 
						TCPToZeroWindowAdv        *float64
 | 
				
			||||||
	TCPSynRetrans             float64
 | 
						TCPWantZeroWindowAdv      *float64
 | 
				
			||||||
	TCPOrigDataSent           float64
 | 
						TCPSynRetrans             *float64
 | 
				
			||||||
	TCPHystartTrainDetect     float64
 | 
						TCPOrigDataSent           *float64
 | 
				
			||||||
	TCPHystartTrainCwnd       float64
 | 
						TCPHystartTrainDetect     *float64
 | 
				
			||||||
	TCPHystartDelayDetect     float64
 | 
						TCPHystartTrainCwnd       *float64
 | 
				
			||||||
	TCPHystartDelayCwnd       float64
 | 
						TCPHystartDelayDetect     *float64
 | 
				
			||||||
	TCPACKSkippedSynRecv      float64
 | 
						TCPHystartDelayCwnd       *float64
 | 
				
			||||||
	TCPACKSkippedPAWS         float64
 | 
						TCPACKSkippedSynRecv      *float64
 | 
				
			||||||
	TCPACKSkippedSeq          float64
 | 
						TCPACKSkippedPAWS         *float64
 | 
				
			||||||
	TCPACKSkippedFinWait2     float64
 | 
						TCPACKSkippedSeq          *float64
 | 
				
			||||||
	TCPACKSkippedTimeWait     float64
 | 
						TCPACKSkippedFinWait2     *float64
 | 
				
			||||||
	TCPACKSkippedChallenge    float64
 | 
						TCPACKSkippedTimeWait     *float64
 | 
				
			||||||
	TCPWinProbe               float64
 | 
						TCPACKSkippedChallenge    *float64
 | 
				
			||||||
	TCPKeepAlive              float64
 | 
						TCPWinProbe               *float64
 | 
				
			||||||
	TCPMTUPFail               float64
 | 
						TCPKeepAlive              *float64
 | 
				
			||||||
	TCPMTUPSuccess            float64
 | 
						TCPMTUPFail               *float64
 | 
				
			||||||
	TCPWqueueTooBig           float64
 | 
						TCPMTUPSuccess            *float64
 | 
				
			||||||
 | 
						TCPWqueueTooBig           *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type IpExt struct { // nolint:revive
 | 
					type IpExt struct { // nolint:revive
 | 
				
			||||||
	InNoRoutes      float64
 | 
						InNoRoutes      *float64
 | 
				
			||||||
	InTruncatedPkts float64
 | 
						InTruncatedPkts *float64
 | 
				
			||||||
	InMcastPkts     float64
 | 
						InMcastPkts     *float64
 | 
				
			||||||
	OutMcastPkts    float64
 | 
						OutMcastPkts    *float64
 | 
				
			||||||
	InBcastPkts     float64
 | 
						InBcastPkts     *float64
 | 
				
			||||||
	OutBcastPkts    float64
 | 
						OutBcastPkts    *float64
 | 
				
			||||||
	InOctets        float64
 | 
						InOctets        *float64
 | 
				
			||||||
	OutOctets       float64
 | 
						OutOctets       *float64
 | 
				
			||||||
	InMcastOctets   float64
 | 
						InMcastOctets   *float64
 | 
				
			||||||
	OutMcastOctets  float64
 | 
						OutMcastOctets  *float64
 | 
				
			||||||
	InBcastOctets   float64
 | 
						InBcastOctets   *float64
 | 
				
			||||||
	OutBcastOctets  float64
 | 
						OutBcastOctets  *float64
 | 
				
			||||||
	InCsumErrors    float64
 | 
						InCsumErrors    *float64
 | 
				
			||||||
	InNoECTPkts     float64
 | 
						InNoECTPkts     *float64
 | 
				
			||||||
	InECT1Pkts      float64
 | 
						InECT1Pkts      *float64
 | 
				
			||||||
	InECT0Pkts      float64
 | 
						InECT0Pkts      *float64
 | 
				
			||||||
	InCEPkts        float64
 | 
						InCEPkts        *float64
 | 
				
			||||||
	ReasmOverlaps   float64
 | 
						ReasmOverlaps   *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p Proc) Netstat() (ProcNetstat, error) {
 | 
					func (p Proc) Netstat() (ProcNetstat, error) {
 | 
				
			||||||
| 
						 | 
					@ -174,14 +175,14 @@ func (p Proc) Netstat() (ProcNetstat, error) {
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return ProcNetstat{PID: p.PID}, err
 | 
							return ProcNetstat{PID: p.PID}, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	procNetstat, err := parseNetstat(bytes.NewReader(data), filename)
 | 
						procNetstat, err := parseProcNetstat(bytes.NewReader(data), filename)
 | 
				
			||||||
	procNetstat.PID = p.PID
 | 
						procNetstat.PID = p.PID
 | 
				
			||||||
	return procNetstat, err
 | 
						return procNetstat, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// parseNetstat parses the metrics from proc/<pid>/net/netstat file
 | 
					// parseProcNetstat parses the metrics from proc/<pid>/net/netstat file
 | 
				
			||||||
// and returns a ProcNetstat structure.
 | 
					// and returns a ProcNetstat structure.
 | 
				
			||||||
func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) {
 | 
					func parseProcNetstat(r io.Reader, fileName string) (ProcNetstat, error) {
 | 
				
			||||||
	var (
 | 
						var (
 | 
				
			||||||
		scanner     = bufio.NewScanner(r)
 | 
							scanner     = bufio.NewScanner(r)
 | 
				
			||||||
		procNetstat = ProcNetstat{}
 | 
							procNetstat = ProcNetstat{}
 | 
				
			||||||
| 
						 | 
					@ -194,8 +195,8 @@ func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) {
 | 
				
			||||||
		// Remove trailing :.
 | 
							// Remove trailing :.
 | 
				
			||||||
		protocol := strings.TrimSuffix(nameParts[0], ":")
 | 
							protocol := strings.TrimSuffix(nameParts[0], ":")
 | 
				
			||||||
		if len(nameParts) != len(valueParts) {
 | 
							if len(nameParts) != len(valueParts) {
 | 
				
			||||||
			return procNetstat, fmt.Errorf("mismatch field count mismatch in %s: %s",
 | 
								return procNetstat, fmt.Errorf("%w: mismatch field count mismatch in %s: %s",
 | 
				
			||||||
				fileName, protocol)
 | 
									ErrFileParse, fileName, protocol)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for i := 1; i < len(nameParts); i++ {
 | 
							for i := 1; i < len(nameParts); i++ {
 | 
				
			||||||
			value, err := strconv.ParseFloat(valueParts[i], 64)
 | 
								value, err := strconv.ParseFloat(valueParts[i], 64)
 | 
				
			||||||
| 
						 | 
					@ -208,230 +209,232 @@ func parseNetstat(r io.Reader, fileName string) (ProcNetstat, error) {
 | 
				
			||||||
			case "TcpExt":
 | 
								case "TcpExt":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "SyncookiesSent":
 | 
									case "SyncookiesSent":
 | 
				
			||||||
					procNetstat.TcpExt.SyncookiesSent = value
 | 
										procNetstat.TcpExt.SyncookiesSent = &value
 | 
				
			||||||
				case "SyncookiesRecv":
 | 
									case "SyncookiesRecv":
 | 
				
			||||||
					procNetstat.TcpExt.SyncookiesRecv = value
 | 
										procNetstat.TcpExt.SyncookiesRecv = &value
 | 
				
			||||||
				case "SyncookiesFailed":
 | 
									case "SyncookiesFailed":
 | 
				
			||||||
					procNetstat.TcpExt.SyncookiesFailed = value
 | 
										procNetstat.TcpExt.SyncookiesFailed = &value
 | 
				
			||||||
				case "EmbryonicRsts":
 | 
									case "EmbryonicRsts":
 | 
				
			||||||
					procNetstat.TcpExt.EmbryonicRsts = value
 | 
										procNetstat.TcpExt.EmbryonicRsts = &value
 | 
				
			||||||
				case "PruneCalled":
 | 
									case "PruneCalled":
 | 
				
			||||||
					procNetstat.TcpExt.PruneCalled = value
 | 
										procNetstat.TcpExt.PruneCalled = &value
 | 
				
			||||||
				case "RcvPruned":
 | 
									case "RcvPruned":
 | 
				
			||||||
					procNetstat.TcpExt.RcvPruned = value
 | 
										procNetstat.TcpExt.RcvPruned = &value
 | 
				
			||||||
				case "OfoPruned":
 | 
									case "OfoPruned":
 | 
				
			||||||
					procNetstat.TcpExt.OfoPruned = value
 | 
										procNetstat.TcpExt.OfoPruned = &value
 | 
				
			||||||
				case "OutOfWindowIcmps":
 | 
									case "OutOfWindowIcmps":
 | 
				
			||||||
					procNetstat.TcpExt.OutOfWindowIcmps = value
 | 
										procNetstat.TcpExt.OutOfWindowIcmps = &value
 | 
				
			||||||
				case "LockDroppedIcmps":
 | 
									case "LockDroppedIcmps":
 | 
				
			||||||
					procNetstat.TcpExt.LockDroppedIcmps = value
 | 
										procNetstat.TcpExt.LockDroppedIcmps = &value
 | 
				
			||||||
				case "ArpFilter":
 | 
									case "ArpFilter":
 | 
				
			||||||
					procNetstat.TcpExt.ArpFilter = value
 | 
										procNetstat.TcpExt.ArpFilter = &value
 | 
				
			||||||
				case "TW":
 | 
									case "TW":
 | 
				
			||||||
					procNetstat.TcpExt.TW = value
 | 
										procNetstat.TcpExt.TW = &value
 | 
				
			||||||
				case "TWRecycled":
 | 
									case "TWRecycled":
 | 
				
			||||||
					procNetstat.TcpExt.TWRecycled = value
 | 
										procNetstat.TcpExt.TWRecycled = &value
 | 
				
			||||||
				case "TWKilled":
 | 
									case "TWKilled":
 | 
				
			||||||
					procNetstat.TcpExt.TWKilled = value
 | 
										procNetstat.TcpExt.TWKilled = &value
 | 
				
			||||||
				case "PAWSActive":
 | 
									case "PAWSActive":
 | 
				
			||||||
					procNetstat.TcpExt.PAWSActive = value
 | 
										procNetstat.TcpExt.PAWSActive = &value
 | 
				
			||||||
				case "PAWSEstab":
 | 
									case "PAWSEstab":
 | 
				
			||||||
					procNetstat.TcpExt.PAWSEstab = value
 | 
										procNetstat.TcpExt.PAWSEstab = &value
 | 
				
			||||||
				case "DelayedACKs":
 | 
									case "DelayedACKs":
 | 
				
			||||||
					procNetstat.TcpExt.DelayedACKs = value
 | 
										procNetstat.TcpExt.DelayedACKs = &value
 | 
				
			||||||
				case "DelayedACKLocked":
 | 
									case "DelayedACKLocked":
 | 
				
			||||||
					procNetstat.TcpExt.DelayedACKLocked = value
 | 
										procNetstat.TcpExt.DelayedACKLocked = &value
 | 
				
			||||||
				case "DelayedACKLost":
 | 
									case "DelayedACKLost":
 | 
				
			||||||
					procNetstat.TcpExt.DelayedACKLost = value
 | 
										procNetstat.TcpExt.DelayedACKLost = &value
 | 
				
			||||||
				case "ListenOverflows":
 | 
									case "ListenOverflows":
 | 
				
			||||||
					procNetstat.TcpExt.ListenOverflows = value
 | 
										procNetstat.TcpExt.ListenOverflows = &value
 | 
				
			||||||
				case "ListenDrops":
 | 
									case "ListenDrops":
 | 
				
			||||||
					procNetstat.TcpExt.ListenDrops = value
 | 
										procNetstat.TcpExt.ListenDrops = &value
 | 
				
			||||||
				case "TCPHPHits":
 | 
									case "TCPHPHits":
 | 
				
			||||||
					procNetstat.TcpExt.TCPHPHits = value
 | 
										procNetstat.TcpExt.TCPHPHits = &value
 | 
				
			||||||
				case "TCPPureAcks":
 | 
									case "TCPPureAcks":
 | 
				
			||||||
					procNetstat.TcpExt.TCPPureAcks = value
 | 
										procNetstat.TcpExt.TCPPureAcks = &value
 | 
				
			||||||
				case "TCPHPAcks":
 | 
									case "TCPHPAcks":
 | 
				
			||||||
					procNetstat.TcpExt.TCPHPAcks = value
 | 
										procNetstat.TcpExt.TCPHPAcks = &value
 | 
				
			||||||
				case "TCPRenoRecovery":
 | 
									case "TCPRenoRecovery":
 | 
				
			||||||
					procNetstat.TcpExt.TCPRenoRecovery = value
 | 
										procNetstat.TcpExt.TCPRenoRecovery = &value
 | 
				
			||||||
				case "TCPSackRecovery":
 | 
									case "TCPSackRecovery":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSackRecovery = value
 | 
										procNetstat.TcpExt.TCPSackRecovery = &value
 | 
				
			||||||
				case "TCPSACKReneging":
 | 
									case "TCPSACKReneging":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSACKReneging = value
 | 
										procNetstat.TcpExt.TCPSACKReneging = &value
 | 
				
			||||||
				case "TCPSACKReorder":
 | 
									case "TCPSACKReorder":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSACKReorder = value
 | 
										procNetstat.TcpExt.TCPSACKReorder = &value
 | 
				
			||||||
				case "TCPRenoReorder":
 | 
									case "TCPRenoReorder":
 | 
				
			||||||
					procNetstat.TcpExt.TCPRenoReorder = value
 | 
										procNetstat.TcpExt.TCPRenoReorder = &value
 | 
				
			||||||
				case "TCPTSReorder":
 | 
									case "TCPTSReorder":
 | 
				
			||||||
					procNetstat.TcpExt.TCPTSReorder = value
 | 
										procNetstat.TcpExt.TCPTSReorder = &value
 | 
				
			||||||
				case "TCPFullUndo":
 | 
									case "TCPFullUndo":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFullUndo = value
 | 
										procNetstat.TcpExt.TCPFullUndo = &value
 | 
				
			||||||
				case "TCPPartialUndo":
 | 
									case "TCPPartialUndo":
 | 
				
			||||||
					procNetstat.TcpExt.TCPPartialUndo = value
 | 
										procNetstat.TcpExt.TCPPartialUndo = &value
 | 
				
			||||||
				case "TCPDSACKUndo":
 | 
									case "TCPDSACKUndo":
 | 
				
			||||||
					procNetstat.TcpExt.TCPDSACKUndo = value
 | 
										procNetstat.TcpExt.TCPDSACKUndo = &value
 | 
				
			||||||
				case "TCPLossUndo":
 | 
									case "TCPLossUndo":
 | 
				
			||||||
					procNetstat.TcpExt.TCPLossUndo = value
 | 
										procNetstat.TcpExt.TCPLossUndo = &value
 | 
				
			||||||
				case "TCPLostRetransmit":
 | 
									case "TCPLostRetransmit":
 | 
				
			||||||
					procNetstat.TcpExt.TCPLostRetransmit = value
 | 
										procNetstat.TcpExt.TCPLostRetransmit = &value
 | 
				
			||||||
				case "TCPRenoFailures":
 | 
									case "TCPRenoFailures":
 | 
				
			||||||
					procNetstat.TcpExt.TCPRenoFailures = value
 | 
										procNetstat.TcpExt.TCPRenoFailures = &value
 | 
				
			||||||
				case "TCPSackFailures":
 | 
									case "TCPSackFailures":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSackFailures = value
 | 
										procNetstat.TcpExt.TCPSackFailures = &value
 | 
				
			||||||
				case "TCPLossFailures":
 | 
									case "TCPLossFailures":
 | 
				
			||||||
					procNetstat.TcpExt.TCPLossFailures = value
 | 
										procNetstat.TcpExt.TCPLossFailures = &value
 | 
				
			||||||
				case "TCPFastRetrans":
 | 
									case "TCPFastRetrans":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFastRetrans = value
 | 
										procNetstat.TcpExt.TCPFastRetrans = &value
 | 
				
			||||||
				case "TCPSlowStartRetrans":
 | 
									case "TCPSlowStartRetrans":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSlowStartRetrans = value
 | 
										procNetstat.TcpExt.TCPSlowStartRetrans = &value
 | 
				
			||||||
				case "TCPTimeouts":
 | 
									case "TCPTimeouts":
 | 
				
			||||||
					procNetstat.TcpExt.TCPTimeouts = value
 | 
										procNetstat.TcpExt.TCPTimeouts = &value
 | 
				
			||||||
				case "TCPLossProbes":
 | 
									case "TCPLossProbes":
 | 
				
			||||||
					procNetstat.TcpExt.TCPLossProbes = value
 | 
										procNetstat.TcpExt.TCPLossProbes = &value
 | 
				
			||||||
				case "TCPLossProbeRecovery":
 | 
									case "TCPLossProbeRecovery":
 | 
				
			||||||
					procNetstat.TcpExt.TCPLossProbeRecovery = value
 | 
										procNetstat.TcpExt.TCPLossProbeRecovery = &value
 | 
				
			||||||
				case "TCPRenoRecoveryFail":
 | 
									case "TCPRenoRecoveryFail":
 | 
				
			||||||
					procNetstat.TcpExt.TCPRenoRecoveryFail = value
 | 
										procNetstat.TcpExt.TCPRenoRecoveryFail = &value
 | 
				
			||||||
				case "TCPSackRecoveryFail":
 | 
									case "TCPSackRecoveryFail":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSackRecoveryFail = value
 | 
										procNetstat.TcpExt.TCPSackRecoveryFail = &value
 | 
				
			||||||
				case "TCPRcvCollapsed":
 | 
									case "TCPRcvCollapsed":
 | 
				
			||||||
					procNetstat.TcpExt.TCPRcvCollapsed = value
 | 
										procNetstat.TcpExt.TCPRcvCollapsed = &value
 | 
				
			||||||
				case "TCPDSACKOldSent":
 | 
									case "TCPDSACKOldSent":
 | 
				
			||||||
					procNetstat.TcpExt.TCPDSACKOldSent = value
 | 
										procNetstat.TcpExt.TCPDSACKOldSent = &value
 | 
				
			||||||
				case "TCPDSACKOfoSent":
 | 
									case "TCPDSACKOfoSent":
 | 
				
			||||||
					procNetstat.TcpExt.TCPDSACKOfoSent = value
 | 
										procNetstat.TcpExt.TCPDSACKOfoSent = &value
 | 
				
			||||||
				case "TCPDSACKRecv":
 | 
									case "TCPDSACKRecv":
 | 
				
			||||||
					procNetstat.TcpExt.TCPDSACKRecv = value
 | 
										procNetstat.TcpExt.TCPDSACKRecv = &value
 | 
				
			||||||
				case "TCPDSACKOfoRecv":
 | 
									case "TCPDSACKOfoRecv":
 | 
				
			||||||
					procNetstat.TcpExt.TCPDSACKOfoRecv = value
 | 
										procNetstat.TcpExt.TCPDSACKOfoRecv = &value
 | 
				
			||||||
				case "TCPAbortOnData":
 | 
									case "TCPAbortOnData":
 | 
				
			||||||
					procNetstat.TcpExt.TCPAbortOnData = value
 | 
										procNetstat.TcpExt.TCPAbortOnData = &value
 | 
				
			||||||
				case "TCPAbortOnClose":
 | 
									case "TCPAbortOnClose":
 | 
				
			||||||
					procNetstat.TcpExt.TCPAbortOnClose = value
 | 
										procNetstat.TcpExt.TCPAbortOnClose = &value
 | 
				
			||||||
				case "TCPDeferAcceptDrop":
 | 
									case "TCPDeferAcceptDrop":
 | 
				
			||||||
					procNetstat.TcpExt.TCPDeferAcceptDrop = value
 | 
										procNetstat.TcpExt.TCPDeferAcceptDrop = &value
 | 
				
			||||||
				case "IPReversePathFilter":
 | 
									case "IPReversePathFilter":
 | 
				
			||||||
					procNetstat.TcpExt.IPReversePathFilter = value
 | 
										procNetstat.TcpExt.IPReversePathFilter = &value
 | 
				
			||||||
				case "TCPTimeWaitOverflow":
 | 
									case "TCPTimeWaitOverflow":
 | 
				
			||||||
					procNetstat.TcpExt.TCPTimeWaitOverflow = value
 | 
										procNetstat.TcpExt.TCPTimeWaitOverflow = &value
 | 
				
			||||||
				case "TCPReqQFullDoCookies":
 | 
									case "TCPReqQFullDoCookies":
 | 
				
			||||||
					procNetstat.TcpExt.TCPReqQFullDoCookies = value
 | 
										procNetstat.TcpExt.TCPReqQFullDoCookies = &value
 | 
				
			||||||
				case "TCPReqQFullDrop":
 | 
									case "TCPReqQFullDrop":
 | 
				
			||||||
					procNetstat.TcpExt.TCPReqQFullDrop = value
 | 
										procNetstat.TcpExt.TCPReqQFullDrop = &value
 | 
				
			||||||
				case "TCPRetransFail":
 | 
									case "TCPRetransFail":
 | 
				
			||||||
					procNetstat.TcpExt.TCPRetransFail = value
 | 
										procNetstat.TcpExt.TCPRetransFail = &value
 | 
				
			||||||
				case "TCPRcvCoalesce":
 | 
									case "TCPRcvCoalesce":
 | 
				
			||||||
					procNetstat.TcpExt.TCPRcvCoalesce = value
 | 
										procNetstat.TcpExt.TCPRcvCoalesce = &value
 | 
				
			||||||
 | 
									case "TCPRcvQDrop":
 | 
				
			||||||
 | 
										procNetstat.TcpExt.TCPRcvQDrop = &value
 | 
				
			||||||
				case "TCPOFOQueue":
 | 
									case "TCPOFOQueue":
 | 
				
			||||||
					procNetstat.TcpExt.TCPOFOQueue = value
 | 
										procNetstat.TcpExt.TCPOFOQueue = &value
 | 
				
			||||||
				case "TCPOFODrop":
 | 
									case "TCPOFODrop":
 | 
				
			||||||
					procNetstat.TcpExt.TCPOFODrop = value
 | 
										procNetstat.TcpExt.TCPOFODrop = &value
 | 
				
			||||||
				case "TCPOFOMerge":
 | 
									case "TCPOFOMerge":
 | 
				
			||||||
					procNetstat.TcpExt.TCPOFOMerge = value
 | 
										procNetstat.TcpExt.TCPOFOMerge = &value
 | 
				
			||||||
				case "TCPChallengeACK":
 | 
									case "TCPChallengeACK":
 | 
				
			||||||
					procNetstat.TcpExt.TCPChallengeACK = value
 | 
										procNetstat.TcpExt.TCPChallengeACK = &value
 | 
				
			||||||
				case "TCPSYNChallenge":
 | 
									case "TCPSYNChallenge":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSYNChallenge = value
 | 
										procNetstat.TcpExt.TCPSYNChallenge = &value
 | 
				
			||||||
				case "TCPFastOpenActive":
 | 
									case "TCPFastOpenActive":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFastOpenActive = value
 | 
										procNetstat.TcpExt.TCPFastOpenActive = &value
 | 
				
			||||||
				case "TCPFastOpenActiveFail":
 | 
									case "TCPFastOpenActiveFail":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFastOpenActiveFail = value
 | 
										procNetstat.TcpExt.TCPFastOpenActiveFail = &value
 | 
				
			||||||
				case "TCPFastOpenPassive":
 | 
									case "TCPFastOpenPassive":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFastOpenPassive = value
 | 
										procNetstat.TcpExt.TCPFastOpenPassive = &value
 | 
				
			||||||
				case "TCPFastOpenPassiveFail":
 | 
									case "TCPFastOpenPassiveFail":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFastOpenPassiveFail = value
 | 
										procNetstat.TcpExt.TCPFastOpenPassiveFail = &value
 | 
				
			||||||
				case "TCPFastOpenListenOverflow":
 | 
									case "TCPFastOpenListenOverflow":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFastOpenListenOverflow = value
 | 
										procNetstat.TcpExt.TCPFastOpenListenOverflow = &value
 | 
				
			||||||
				case "TCPFastOpenCookieReqd":
 | 
									case "TCPFastOpenCookieReqd":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFastOpenCookieReqd = value
 | 
										procNetstat.TcpExt.TCPFastOpenCookieReqd = &value
 | 
				
			||||||
				case "TCPFastOpenBlackhole":
 | 
									case "TCPFastOpenBlackhole":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFastOpenBlackhole = value
 | 
										procNetstat.TcpExt.TCPFastOpenBlackhole = &value
 | 
				
			||||||
				case "TCPSpuriousRtxHostQueues":
 | 
									case "TCPSpuriousRtxHostQueues":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSpuriousRtxHostQueues = value
 | 
										procNetstat.TcpExt.TCPSpuriousRtxHostQueues = &value
 | 
				
			||||||
				case "BusyPollRxPackets":
 | 
									case "BusyPollRxPackets":
 | 
				
			||||||
					procNetstat.TcpExt.BusyPollRxPackets = value
 | 
										procNetstat.TcpExt.BusyPollRxPackets = &value
 | 
				
			||||||
				case "TCPAutoCorking":
 | 
									case "TCPAutoCorking":
 | 
				
			||||||
					procNetstat.TcpExt.TCPAutoCorking = value
 | 
										procNetstat.TcpExt.TCPAutoCorking = &value
 | 
				
			||||||
				case "TCPFromZeroWindowAdv":
 | 
									case "TCPFromZeroWindowAdv":
 | 
				
			||||||
					procNetstat.TcpExt.TCPFromZeroWindowAdv = value
 | 
										procNetstat.TcpExt.TCPFromZeroWindowAdv = &value
 | 
				
			||||||
				case "TCPToZeroWindowAdv":
 | 
									case "TCPToZeroWindowAdv":
 | 
				
			||||||
					procNetstat.TcpExt.TCPToZeroWindowAdv = value
 | 
										procNetstat.TcpExt.TCPToZeroWindowAdv = &value
 | 
				
			||||||
				case "TCPWantZeroWindowAdv":
 | 
									case "TCPWantZeroWindowAdv":
 | 
				
			||||||
					procNetstat.TcpExt.TCPWantZeroWindowAdv = value
 | 
										procNetstat.TcpExt.TCPWantZeroWindowAdv = &value
 | 
				
			||||||
				case "TCPSynRetrans":
 | 
									case "TCPSynRetrans":
 | 
				
			||||||
					procNetstat.TcpExt.TCPSynRetrans = value
 | 
										procNetstat.TcpExt.TCPSynRetrans = &value
 | 
				
			||||||
				case "TCPOrigDataSent":
 | 
									case "TCPOrigDataSent":
 | 
				
			||||||
					procNetstat.TcpExt.TCPOrigDataSent = value
 | 
										procNetstat.TcpExt.TCPOrigDataSent = &value
 | 
				
			||||||
				case "TCPHystartTrainDetect":
 | 
									case "TCPHystartTrainDetect":
 | 
				
			||||||
					procNetstat.TcpExt.TCPHystartTrainDetect = value
 | 
										procNetstat.TcpExt.TCPHystartTrainDetect = &value
 | 
				
			||||||
				case "TCPHystartTrainCwnd":
 | 
									case "TCPHystartTrainCwnd":
 | 
				
			||||||
					procNetstat.TcpExt.TCPHystartTrainCwnd = value
 | 
										procNetstat.TcpExt.TCPHystartTrainCwnd = &value
 | 
				
			||||||
				case "TCPHystartDelayDetect":
 | 
									case "TCPHystartDelayDetect":
 | 
				
			||||||
					procNetstat.TcpExt.TCPHystartDelayDetect = value
 | 
										procNetstat.TcpExt.TCPHystartDelayDetect = &value
 | 
				
			||||||
				case "TCPHystartDelayCwnd":
 | 
									case "TCPHystartDelayCwnd":
 | 
				
			||||||
					procNetstat.TcpExt.TCPHystartDelayCwnd = value
 | 
										procNetstat.TcpExt.TCPHystartDelayCwnd = &value
 | 
				
			||||||
				case "TCPACKSkippedSynRecv":
 | 
									case "TCPACKSkippedSynRecv":
 | 
				
			||||||
					procNetstat.TcpExt.TCPACKSkippedSynRecv = value
 | 
										procNetstat.TcpExt.TCPACKSkippedSynRecv = &value
 | 
				
			||||||
				case "TCPACKSkippedPAWS":
 | 
									case "TCPACKSkippedPAWS":
 | 
				
			||||||
					procNetstat.TcpExt.TCPACKSkippedPAWS = value
 | 
										procNetstat.TcpExt.TCPACKSkippedPAWS = &value
 | 
				
			||||||
				case "TCPACKSkippedSeq":
 | 
									case "TCPACKSkippedSeq":
 | 
				
			||||||
					procNetstat.TcpExt.TCPACKSkippedSeq = value
 | 
										procNetstat.TcpExt.TCPACKSkippedSeq = &value
 | 
				
			||||||
				case "TCPACKSkippedFinWait2":
 | 
									case "TCPACKSkippedFinWait2":
 | 
				
			||||||
					procNetstat.TcpExt.TCPACKSkippedFinWait2 = value
 | 
										procNetstat.TcpExt.TCPACKSkippedFinWait2 = &value
 | 
				
			||||||
				case "TCPACKSkippedTimeWait":
 | 
									case "TCPACKSkippedTimeWait":
 | 
				
			||||||
					procNetstat.TcpExt.TCPACKSkippedTimeWait = value
 | 
										procNetstat.TcpExt.TCPACKSkippedTimeWait = &value
 | 
				
			||||||
				case "TCPACKSkippedChallenge":
 | 
									case "TCPACKSkippedChallenge":
 | 
				
			||||||
					procNetstat.TcpExt.TCPACKSkippedChallenge = value
 | 
										procNetstat.TcpExt.TCPACKSkippedChallenge = &value
 | 
				
			||||||
				case "TCPWinProbe":
 | 
									case "TCPWinProbe":
 | 
				
			||||||
					procNetstat.TcpExt.TCPWinProbe = value
 | 
										procNetstat.TcpExt.TCPWinProbe = &value
 | 
				
			||||||
				case "TCPKeepAlive":
 | 
									case "TCPKeepAlive":
 | 
				
			||||||
					procNetstat.TcpExt.TCPKeepAlive = value
 | 
										procNetstat.TcpExt.TCPKeepAlive = &value
 | 
				
			||||||
				case "TCPMTUPFail":
 | 
									case "TCPMTUPFail":
 | 
				
			||||||
					procNetstat.TcpExt.TCPMTUPFail = value
 | 
										procNetstat.TcpExt.TCPMTUPFail = &value
 | 
				
			||||||
				case "TCPMTUPSuccess":
 | 
									case "TCPMTUPSuccess":
 | 
				
			||||||
					procNetstat.TcpExt.TCPMTUPSuccess = value
 | 
										procNetstat.TcpExt.TCPMTUPSuccess = &value
 | 
				
			||||||
				case "TCPWqueueTooBig":
 | 
									case "TCPWqueueTooBig":
 | 
				
			||||||
					procNetstat.TcpExt.TCPWqueueTooBig = value
 | 
										procNetstat.TcpExt.TCPWqueueTooBig = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "IpExt":
 | 
								case "IpExt":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InNoRoutes":
 | 
									case "InNoRoutes":
 | 
				
			||||||
					procNetstat.IpExt.InNoRoutes = value
 | 
										procNetstat.IpExt.InNoRoutes = &value
 | 
				
			||||||
				case "InTruncatedPkts":
 | 
									case "InTruncatedPkts":
 | 
				
			||||||
					procNetstat.IpExt.InTruncatedPkts = value
 | 
										procNetstat.IpExt.InTruncatedPkts = &value
 | 
				
			||||||
				case "InMcastPkts":
 | 
									case "InMcastPkts":
 | 
				
			||||||
					procNetstat.IpExt.InMcastPkts = value
 | 
										procNetstat.IpExt.InMcastPkts = &value
 | 
				
			||||||
				case "OutMcastPkts":
 | 
									case "OutMcastPkts":
 | 
				
			||||||
					procNetstat.IpExt.OutMcastPkts = value
 | 
										procNetstat.IpExt.OutMcastPkts = &value
 | 
				
			||||||
				case "InBcastPkts":
 | 
									case "InBcastPkts":
 | 
				
			||||||
					procNetstat.IpExt.InBcastPkts = value
 | 
										procNetstat.IpExt.InBcastPkts = &value
 | 
				
			||||||
				case "OutBcastPkts":
 | 
									case "OutBcastPkts":
 | 
				
			||||||
					procNetstat.IpExt.OutBcastPkts = value
 | 
										procNetstat.IpExt.OutBcastPkts = &value
 | 
				
			||||||
				case "InOctets":
 | 
									case "InOctets":
 | 
				
			||||||
					procNetstat.IpExt.InOctets = value
 | 
										procNetstat.IpExt.InOctets = &value
 | 
				
			||||||
				case "OutOctets":
 | 
									case "OutOctets":
 | 
				
			||||||
					procNetstat.IpExt.OutOctets = value
 | 
										procNetstat.IpExt.OutOctets = &value
 | 
				
			||||||
				case "InMcastOctets":
 | 
									case "InMcastOctets":
 | 
				
			||||||
					procNetstat.IpExt.InMcastOctets = value
 | 
										procNetstat.IpExt.InMcastOctets = &value
 | 
				
			||||||
				case "OutMcastOctets":
 | 
									case "OutMcastOctets":
 | 
				
			||||||
					procNetstat.IpExt.OutMcastOctets = value
 | 
										procNetstat.IpExt.OutMcastOctets = &value
 | 
				
			||||||
				case "InBcastOctets":
 | 
									case "InBcastOctets":
 | 
				
			||||||
					procNetstat.IpExt.InBcastOctets = value
 | 
										procNetstat.IpExt.InBcastOctets = &value
 | 
				
			||||||
				case "OutBcastOctets":
 | 
									case "OutBcastOctets":
 | 
				
			||||||
					procNetstat.IpExt.OutBcastOctets = value
 | 
										procNetstat.IpExt.OutBcastOctets = &value
 | 
				
			||||||
				case "InCsumErrors":
 | 
									case "InCsumErrors":
 | 
				
			||||||
					procNetstat.IpExt.InCsumErrors = value
 | 
										procNetstat.IpExt.InCsumErrors = &value
 | 
				
			||||||
				case "InNoECTPkts":
 | 
									case "InNoECTPkts":
 | 
				
			||||||
					procNetstat.IpExt.InNoECTPkts = value
 | 
										procNetstat.IpExt.InNoECTPkts = &value
 | 
				
			||||||
				case "InECT1Pkts":
 | 
									case "InECT1Pkts":
 | 
				
			||||||
					procNetstat.IpExt.InECT1Pkts = value
 | 
										procNetstat.IpExt.InECT1Pkts = &value
 | 
				
			||||||
				case "InECT0Pkts":
 | 
									case "InECT0Pkts":
 | 
				
			||||||
					procNetstat.IpExt.InECT0Pkts = value
 | 
										procNetstat.IpExt.InECT0Pkts = &value
 | 
				
			||||||
				case "InCEPkts":
 | 
									case "InCEPkts":
 | 
				
			||||||
					procNetstat.IpExt.InCEPkts = value
 | 
										procNetstat.IpExt.InCEPkts = &value
 | 
				
			||||||
				case "ReasmOverlaps":
 | 
									case "ReasmOverlaps":
 | 
				
			||||||
					procNetstat.IpExt.ReasmOverlaps = value
 | 
										procNetstat.IpExt.ReasmOverlaps = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,7 @@ func (p Proc) Namespaces() (Namespaces, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	names, err := d.Readdirnames(-1)
 | 
						names, err := d.Readdirnames(-1)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("failed to read contents of ns dir: %w", err)
 | 
							return nil, fmt.Errorf("%s: failed to read contents of ns dir: %w", ErrFileRead, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ns := make(Namespaces, len(names))
 | 
						ns := make(Namespaces, len(names))
 | 
				
			||||||
| 
						 | 
					@ -52,13 +52,13 @@ func (p Proc) Namespaces() (Namespaces, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fields := strings.SplitN(target, ":", 2)
 | 
							fields := strings.SplitN(target, ":", 2)
 | 
				
			||||||
		if len(fields) != 2 {
 | 
							if len(fields) != 2 {
 | 
				
			||||||
			return nil, fmt.Errorf("failed to parse namespace type and inode from %q", target)
 | 
								return nil, fmt.Errorf("%w: namespace type and inode from %q", ErrFileParse, target)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		typ := fields[0]
 | 
							typ := fields[0]
 | 
				
			||||||
		inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32)
 | 
							inode, err := strconv.ParseUint(strings.Trim(fields[1], "[]"), 10, 32)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("failed to parse inode from %q: %w", fields[1], err)
 | 
								return nil, fmt.Errorf("%s: inode from %q: %w", ErrFileParse, fields[1], err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ns[name] = Namespace{typ, uint32(inode)}
 | 
							ns[name] = Namespace{typ, uint32(inode)}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,14 +61,14 @@ type PSIStats struct {
 | 
				
			||||||
func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) {
 | 
					func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) {
 | 
				
			||||||
	data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource)))
 | 
						data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource)))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %q: %w", resource, err)
 | 
							return PSIStats{}, fmt.Errorf("%s: psi_stats: unavailable for %q: %w", ErrFileRead, resource, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return parsePSIStats(resource, bytes.NewReader(data))
 | 
						return parsePSIStats(bytes.NewReader(data))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// parsePSIStats parses the specified file for pressure stall information.
 | 
					// parsePSIStats parses the specified file for pressure stall information.
 | 
				
			||||||
func parsePSIStats(resource string, r io.Reader) (PSIStats, error) {
 | 
					func parsePSIStats(r io.Reader) (PSIStats, error) {
 | 
				
			||||||
	psiStats := PSIStats{}
 | 
						psiStats := PSIStats{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	scanner := bufio.NewScanner(r)
 | 
						scanner := bufio.NewScanner(r)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -135,12 +135,12 @@ func (s *ProcSMapsRollup) parseLine(line string) error {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	vBytes := vKBytes * 1024
 | 
						vBytes := vKBytes * 1024
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s.addValue(k, v, vKBytes, vBytes)
 | 
						s.addValue(k, vBytes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *ProcSMapsRollup) addValue(k string, vString string, vUint uint64, vUintBytes uint64) {
 | 
					func (s *ProcSMapsRollup) addValue(k string, vUintBytes uint64) {
 | 
				
			||||||
	switch k {
 | 
						switch k {
 | 
				
			||||||
	case "Rss":
 | 
						case "Rss":
 | 
				
			||||||
		s.Rss += vUintBytes
 | 
							s.Rss += vUintBytes
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,100 +37,100 @@ type ProcSnmp struct {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Ip struct { // nolint:revive
 | 
					type Ip struct { // nolint:revive
 | 
				
			||||||
	Forwarding      float64
 | 
						Forwarding      *float64
 | 
				
			||||||
	DefaultTTL      float64
 | 
						DefaultTTL      *float64
 | 
				
			||||||
	InReceives      float64
 | 
						InReceives      *float64
 | 
				
			||||||
	InHdrErrors     float64
 | 
						InHdrErrors     *float64
 | 
				
			||||||
	InAddrErrors    float64
 | 
						InAddrErrors    *float64
 | 
				
			||||||
	ForwDatagrams   float64
 | 
						ForwDatagrams   *float64
 | 
				
			||||||
	InUnknownProtos float64
 | 
						InUnknownProtos *float64
 | 
				
			||||||
	InDiscards      float64
 | 
						InDiscards      *float64
 | 
				
			||||||
	InDelivers      float64
 | 
						InDelivers      *float64
 | 
				
			||||||
	OutRequests     float64
 | 
						OutRequests     *float64
 | 
				
			||||||
	OutDiscards     float64
 | 
						OutDiscards     *float64
 | 
				
			||||||
	OutNoRoutes     float64
 | 
						OutNoRoutes     *float64
 | 
				
			||||||
	ReasmTimeout    float64
 | 
						ReasmTimeout    *float64
 | 
				
			||||||
	ReasmReqds      float64
 | 
						ReasmReqds      *float64
 | 
				
			||||||
	ReasmOKs        float64
 | 
						ReasmOKs        *float64
 | 
				
			||||||
	ReasmFails      float64
 | 
						ReasmFails      *float64
 | 
				
			||||||
	FragOKs         float64
 | 
						FragOKs         *float64
 | 
				
			||||||
	FragFails       float64
 | 
						FragFails       *float64
 | 
				
			||||||
	FragCreates     float64
 | 
						FragCreates     *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Icmp struct {
 | 
					type Icmp struct { // nolint:revive
 | 
				
			||||||
	InMsgs           float64
 | 
						InMsgs           *float64
 | 
				
			||||||
	InErrors         float64
 | 
						InErrors         *float64
 | 
				
			||||||
	InCsumErrors     float64
 | 
						InCsumErrors     *float64
 | 
				
			||||||
	InDestUnreachs   float64
 | 
						InDestUnreachs   *float64
 | 
				
			||||||
	InTimeExcds      float64
 | 
						InTimeExcds      *float64
 | 
				
			||||||
	InParmProbs      float64
 | 
						InParmProbs      *float64
 | 
				
			||||||
	InSrcQuenchs     float64
 | 
						InSrcQuenchs     *float64
 | 
				
			||||||
	InRedirects      float64
 | 
						InRedirects      *float64
 | 
				
			||||||
	InEchos          float64
 | 
						InEchos          *float64
 | 
				
			||||||
	InEchoReps       float64
 | 
						InEchoReps       *float64
 | 
				
			||||||
	InTimestamps     float64
 | 
						InTimestamps     *float64
 | 
				
			||||||
	InTimestampReps  float64
 | 
						InTimestampReps  *float64
 | 
				
			||||||
	InAddrMasks      float64
 | 
						InAddrMasks      *float64
 | 
				
			||||||
	InAddrMaskReps   float64
 | 
						InAddrMaskReps   *float64
 | 
				
			||||||
	OutMsgs          float64
 | 
						OutMsgs          *float64
 | 
				
			||||||
	OutErrors        float64
 | 
						OutErrors        *float64
 | 
				
			||||||
	OutDestUnreachs  float64
 | 
						OutDestUnreachs  *float64
 | 
				
			||||||
	OutTimeExcds     float64
 | 
						OutTimeExcds     *float64
 | 
				
			||||||
	OutParmProbs     float64
 | 
						OutParmProbs     *float64
 | 
				
			||||||
	OutSrcQuenchs    float64
 | 
						OutSrcQuenchs    *float64
 | 
				
			||||||
	OutRedirects     float64
 | 
						OutRedirects     *float64
 | 
				
			||||||
	OutEchos         float64
 | 
						OutEchos         *float64
 | 
				
			||||||
	OutEchoReps      float64
 | 
						OutEchoReps      *float64
 | 
				
			||||||
	OutTimestamps    float64
 | 
						OutTimestamps    *float64
 | 
				
			||||||
	OutTimestampReps float64
 | 
						OutTimestampReps *float64
 | 
				
			||||||
	OutAddrMasks     float64
 | 
						OutAddrMasks     *float64
 | 
				
			||||||
	OutAddrMaskReps  float64
 | 
						OutAddrMaskReps  *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type IcmpMsg struct {
 | 
					type IcmpMsg struct {
 | 
				
			||||||
	InType3  float64
 | 
						InType3  *float64
 | 
				
			||||||
	OutType3 float64
 | 
						OutType3 *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Tcp struct { // nolint:revive
 | 
					type Tcp struct { // nolint:revive
 | 
				
			||||||
	RtoAlgorithm float64
 | 
						RtoAlgorithm *float64
 | 
				
			||||||
	RtoMin       float64
 | 
						RtoMin       *float64
 | 
				
			||||||
	RtoMax       float64
 | 
						RtoMax       *float64
 | 
				
			||||||
	MaxConn      float64
 | 
						MaxConn      *float64
 | 
				
			||||||
	ActiveOpens  float64
 | 
						ActiveOpens  *float64
 | 
				
			||||||
	PassiveOpens float64
 | 
						PassiveOpens *float64
 | 
				
			||||||
	AttemptFails float64
 | 
						AttemptFails *float64
 | 
				
			||||||
	EstabResets  float64
 | 
						EstabResets  *float64
 | 
				
			||||||
	CurrEstab    float64
 | 
						CurrEstab    *float64
 | 
				
			||||||
	InSegs       float64
 | 
						InSegs       *float64
 | 
				
			||||||
	OutSegs      float64
 | 
						OutSegs      *float64
 | 
				
			||||||
	RetransSegs  float64
 | 
						RetransSegs  *float64
 | 
				
			||||||
	InErrs       float64
 | 
						InErrs       *float64
 | 
				
			||||||
	OutRsts      float64
 | 
						OutRsts      *float64
 | 
				
			||||||
	InCsumErrors float64
 | 
						InCsumErrors *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Udp struct { // nolint:revive
 | 
					type Udp struct { // nolint:revive
 | 
				
			||||||
	InDatagrams  float64
 | 
						InDatagrams  *float64
 | 
				
			||||||
	NoPorts      float64
 | 
						NoPorts      *float64
 | 
				
			||||||
	InErrors     float64
 | 
						InErrors     *float64
 | 
				
			||||||
	OutDatagrams float64
 | 
						OutDatagrams *float64
 | 
				
			||||||
	RcvbufErrors float64
 | 
						RcvbufErrors *float64
 | 
				
			||||||
	SndbufErrors float64
 | 
						SndbufErrors *float64
 | 
				
			||||||
	InCsumErrors float64
 | 
						InCsumErrors *float64
 | 
				
			||||||
	IgnoredMulti float64
 | 
						IgnoredMulti *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type UdpLite struct { // nolint:revive
 | 
					type UdpLite struct { // nolint:revive
 | 
				
			||||||
	InDatagrams  float64
 | 
						InDatagrams  *float64
 | 
				
			||||||
	NoPorts      float64
 | 
						NoPorts      *float64
 | 
				
			||||||
	InErrors     float64
 | 
						InErrors     *float64
 | 
				
			||||||
	OutDatagrams float64
 | 
						OutDatagrams *float64
 | 
				
			||||||
	RcvbufErrors float64
 | 
						RcvbufErrors *float64
 | 
				
			||||||
	SndbufErrors float64
 | 
						SndbufErrors *float64
 | 
				
			||||||
	InCsumErrors float64
 | 
						InCsumErrors *float64
 | 
				
			||||||
	IgnoredMulti float64
 | 
						IgnoredMulti *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p Proc) Snmp() (ProcSnmp, error) {
 | 
					func (p Proc) Snmp() (ProcSnmp, error) {
 | 
				
			||||||
| 
						 | 
					@ -159,8 +159,8 @@ func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) {
 | 
				
			||||||
		// Remove trailing :.
 | 
							// Remove trailing :.
 | 
				
			||||||
		protocol := strings.TrimSuffix(nameParts[0], ":")
 | 
							protocol := strings.TrimSuffix(nameParts[0], ":")
 | 
				
			||||||
		if len(nameParts) != len(valueParts) {
 | 
							if len(nameParts) != len(valueParts) {
 | 
				
			||||||
			return procSnmp, fmt.Errorf("mismatch field count mismatch in %s: %s",
 | 
								return procSnmp, fmt.Errorf("%w: mismatch field count mismatch in %s: %s",
 | 
				
			||||||
				fileName, protocol)
 | 
									ErrFileParse, fileName, protocol)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for i := 1; i < len(nameParts); i++ {
 | 
							for i := 1; i < len(nameParts); i++ {
 | 
				
			||||||
			value, err := strconv.ParseFloat(valueParts[i], 64)
 | 
								value, err := strconv.ParseFloat(valueParts[i], 64)
 | 
				
			||||||
| 
						 | 
					@ -173,178 +173,178 @@ func parseSnmp(r io.Reader, fileName string) (ProcSnmp, error) {
 | 
				
			||||||
			case "Ip":
 | 
								case "Ip":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "Forwarding":
 | 
									case "Forwarding":
 | 
				
			||||||
					procSnmp.Ip.Forwarding = value
 | 
										procSnmp.Ip.Forwarding = &value
 | 
				
			||||||
				case "DefaultTTL":
 | 
									case "DefaultTTL":
 | 
				
			||||||
					procSnmp.Ip.DefaultTTL = value
 | 
										procSnmp.Ip.DefaultTTL = &value
 | 
				
			||||||
				case "InReceives":
 | 
									case "InReceives":
 | 
				
			||||||
					procSnmp.Ip.InReceives = value
 | 
										procSnmp.Ip.InReceives = &value
 | 
				
			||||||
				case "InHdrErrors":
 | 
									case "InHdrErrors":
 | 
				
			||||||
					procSnmp.Ip.InHdrErrors = value
 | 
										procSnmp.Ip.InHdrErrors = &value
 | 
				
			||||||
				case "InAddrErrors":
 | 
									case "InAddrErrors":
 | 
				
			||||||
					procSnmp.Ip.InAddrErrors = value
 | 
										procSnmp.Ip.InAddrErrors = &value
 | 
				
			||||||
				case "ForwDatagrams":
 | 
									case "ForwDatagrams":
 | 
				
			||||||
					procSnmp.Ip.ForwDatagrams = value
 | 
										procSnmp.Ip.ForwDatagrams = &value
 | 
				
			||||||
				case "InUnknownProtos":
 | 
									case "InUnknownProtos":
 | 
				
			||||||
					procSnmp.Ip.InUnknownProtos = value
 | 
										procSnmp.Ip.InUnknownProtos = &value
 | 
				
			||||||
				case "InDiscards":
 | 
									case "InDiscards":
 | 
				
			||||||
					procSnmp.Ip.InDiscards = value
 | 
										procSnmp.Ip.InDiscards = &value
 | 
				
			||||||
				case "InDelivers":
 | 
									case "InDelivers":
 | 
				
			||||||
					procSnmp.Ip.InDelivers = value
 | 
										procSnmp.Ip.InDelivers = &value
 | 
				
			||||||
				case "OutRequests":
 | 
									case "OutRequests":
 | 
				
			||||||
					procSnmp.Ip.OutRequests = value
 | 
										procSnmp.Ip.OutRequests = &value
 | 
				
			||||||
				case "OutDiscards":
 | 
									case "OutDiscards":
 | 
				
			||||||
					procSnmp.Ip.OutDiscards = value
 | 
										procSnmp.Ip.OutDiscards = &value
 | 
				
			||||||
				case "OutNoRoutes":
 | 
									case "OutNoRoutes":
 | 
				
			||||||
					procSnmp.Ip.OutNoRoutes = value
 | 
										procSnmp.Ip.OutNoRoutes = &value
 | 
				
			||||||
				case "ReasmTimeout":
 | 
									case "ReasmTimeout":
 | 
				
			||||||
					procSnmp.Ip.ReasmTimeout = value
 | 
										procSnmp.Ip.ReasmTimeout = &value
 | 
				
			||||||
				case "ReasmReqds":
 | 
									case "ReasmReqds":
 | 
				
			||||||
					procSnmp.Ip.ReasmReqds = value
 | 
										procSnmp.Ip.ReasmReqds = &value
 | 
				
			||||||
				case "ReasmOKs":
 | 
									case "ReasmOKs":
 | 
				
			||||||
					procSnmp.Ip.ReasmOKs = value
 | 
										procSnmp.Ip.ReasmOKs = &value
 | 
				
			||||||
				case "ReasmFails":
 | 
									case "ReasmFails":
 | 
				
			||||||
					procSnmp.Ip.ReasmFails = value
 | 
										procSnmp.Ip.ReasmFails = &value
 | 
				
			||||||
				case "FragOKs":
 | 
									case "FragOKs":
 | 
				
			||||||
					procSnmp.Ip.FragOKs = value
 | 
										procSnmp.Ip.FragOKs = &value
 | 
				
			||||||
				case "FragFails":
 | 
									case "FragFails":
 | 
				
			||||||
					procSnmp.Ip.FragFails = value
 | 
										procSnmp.Ip.FragFails = &value
 | 
				
			||||||
				case "FragCreates":
 | 
									case "FragCreates":
 | 
				
			||||||
					procSnmp.Ip.FragCreates = value
 | 
										procSnmp.Ip.FragCreates = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "Icmp":
 | 
								case "Icmp":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InMsgs":
 | 
									case "InMsgs":
 | 
				
			||||||
					procSnmp.Icmp.InMsgs = value
 | 
										procSnmp.Icmp.InMsgs = &value
 | 
				
			||||||
				case "InErrors":
 | 
									case "InErrors":
 | 
				
			||||||
					procSnmp.Icmp.InErrors = value
 | 
										procSnmp.Icmp.InErrors = &value
 | 
				
			||||||
				case "InCsumErrors":
 | 
									case "InCsumErrors":
 | 
				
			||||||
					procSnmp.Icmp.InCsumErrors = value
 | 
										procSnmp.Icmp.InCsumErrors = &value
 | 
				
			||||||
				case "InDestUnreachs":
 | 
									case "InDestUnreachs":
 | 
				
			||||||
					procSnmp.Icmp.InDestUnreachs = value
 | 
										procSnmp.Icmp.InDestUnreachs = &value
 | 
				
			||||||
				case "InTimeExcds":
 | 
									case "InTimeExcds":
 | 
				
			||||||
					procSnmp.Icmp.InTimeExcds = value
 | 
										procSnmp.Icmp.InTimeExcds = &value
 | 
				
			||||||
				case "InParmProbs":
 | 
									case "InParmProbs":
 | 
				
			||||||
					procSnmp.Icmp.InParmProbs = value
 | 
										procSnmp.Icmp.InParmProbs = &value
 | 
				
			||||||
				case "InSrcQuenchs":
 | 
									case "InSrcQuenchs":
 | 
				
			||||||
					procSnmp.Icmp.InSrcQuenchs = value
 | 
										procSnmp.Icmp.InSrcQuenchs = &value
 | 
				
			||||||
				case "InRedirects":
 | 
									case "InRedirects":
 | 
				
			||||||
					procSnmp.Icmp.InRedirects = value
 | 
										procSnmp.Icmp.InRedirects = &value
 | 
				
			||||||
				case "InEchos":
 | 
									case "InEchos":
 | 
				
			||||||
					procSnmp.Icmp.InEchos = value
 | 
										procSnmp.Icmp.InEchos = &value
 | 
				
			||||||
				case "InEchoReps":
 | 
									case "InEchoReps":
 | 
				
			||||||
					procSnmp.Icmp.InEchoReps = value
 | 
										procSnmp.Icmp.InEchoReps = &value
 | 
				
			||||||
				case "InTimestamps":
 | 
									case "InTimestamps":
 | 
				
			||||||
					procSnmp.Icmp.InTimestamps = value
 | 
										procSnmp.Icmp.InTimestamps = &value
 | 
				
			||||||
				case "InTimestampReps":
 | 
									case "InTimestampReps":
 | 
				
			||||||
					procSnmp.Icmp.InTimestampReps = value
 | 
										procSnmp.Icmp.InTimestampReps = &value
 | 
				
			||||||
				case "InAddrMasks":
 | 
									case "InAddrMasks":
 | 
				
			||||||
					procSnmp.Icmp.InAddrMasks = value
 | 
										procSnmp.Icmp.InAddrMasks = &value
 | 
				
			||||||
				case "InAddrMaskReps":
 | 
									case "InAddrMaskReps":
 | 
				
			||||||
					procSnmp.Icmp.InAddrMaskReps = value
 | 
										procSnmp.Icmp.InAddrMaskReps = &value
 | 
				
			||||||
				case "OutMsgs":
 | 
									case "OutMsgs":
 | 
				
			||||||
					procSnmp.Icmp.OutMsgs = value
 | 
										procSnmp.Icmp.OutMsgs = &value
 | 
				
			||||||
				case "OutErrors":
 | 
									case "OutErrors":
 | 
				
			||||||
					procSnmp.Icmp.OutErrors = value
 | 
										procSnmp.Icmp.OutErrors = &value
 | 
				
			||||||
				case "OutDestUnreachs":
 | 
									case "OutDestUnreachs":
 | 
				
			||||||
					procSnmp.Icmp.OutDestUnreachs = value
 | 
										procSnmp.Icmp.OutDestUnreachs = &value
 | 
				
			||||||
				case "OutTimeExcds":
 | 
									case "OutTimeExcds":
 | 
				
			||||||
					procSnmp.Icmp.OutTimeExcds = value
 | 
										procSnmp.Icmp.OutTimeExcds = &value
 | 
				
			||||||
				case "OutParmProbs":
 | 
									case "OutParmProbs":
 | 
				
			||||||
					procSnmp.Icmp.OutParmProbs = value
 | 
										procSnmp.Icmp.OutParmProbs = &value
 | 
				
			||||||
				case "OutSrcQuenchs":
 | 
									case "OutSrcQuenchs":
 | 
				
			||||||
					procSnmp.Icmp.OutSrcQuenchs = value
 | 
										procSnmp.Icmp.OutSrcQuenchs = &value
 | 
				
			||||||
				case "OutRedirects":
 | 
									case "OutRedirects":
 | 
				
			||||||
					procSnmp.Icmp.OutRedirects = value
 | 
										procSnmp.Icmp.OutRedirects = &value
 | 
				
			||||||
				case "OutEchos":
 | 
									case "OutEchos":
 | 
				
			||||||
					procSnmp.Icmp.OutEchos = value
 | 
										procSnmp.Icmp.OutEchos = &value
 | 
				
			||||||
				case "OutEchoReps":
 | 
									case "OutEchoReps":
 | 
				
			||||||
					procSnmp.Icmp.OutEchoReps = value
 | 
										procSnmp.Icmp.OutEchoReps = &value
 | 
				
			||||||
				case "OutTimestamps":
 | 
									case "OutTimestamps":
 | 
				
			||||||
					procSnmp.Icmp.OutTimestamps = value
 | 
										procSnmp.Icmp.OutTimestamps = &value
 | 
				
			||||||
				case "OutTimestampReps":
 | 
									case "OutTimestampReps":
 | 
				
			||||||
					procSnmp.Icmp.OutTimestampReps = value
 | 
										procSnmp.Icmp.OutTimestampReps = &value
 | 
				
			||||||
				case "OutAddrMasks":
 | 
									case "OutAddrMasks":
 | 
				
			||||||
					procSnmp.Icmp.OutAddrMasks = value
 | 
										procSnmp.Icmp.OutAddrMasks = &value
 | 
				
			||||||
				case "OutAddrMaskReps":
 | 
									case "OutAddrMaskReps":
 | 
				
			||||||
					procSnmp.Icmp.OutAddrMaskReps = value
 | 
										procSnmp.Icmp.OutAddrMaskReps = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "IcmpMsg":
 | 
								case "IcmpMsg":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InType3":
 | 
									case "InType3":
 | 
				
			||||||
					procSnmp.IcmpMsg.InType3 = value
 | 
										procSnmp.IcmpMsg.InType3 = &value
 | 
				
			||||||
				case "OutType3":
 | 
									case "OutType3":
 | 
				
			||||||
					procSnmp.IcmpMsg.OutType3 = value
 | 
										procSnmp.IcmpMsg.OutType3 = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "Tcp":
 | 
								case "Tcp":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "RtoAlgorithm":
 | 
									case "RtoAlgorithm":
 | 
				
			||||||
					procSnmp.Tcp.RtoAlgorithm = value
 | 
										procSnmp.Tcp.RtoAlgorithm = &value
 | 
				
			||||||
				case "RtoMin":
 | 
									case "RtoMin":
 | 
				
			||||||
					procSnmp.Tcp.RtoMin = value
 | 
										procSnmp.Tcp.RtoMin = &value
 | 
				
			||||||
				case "RtoMax":
 | 
									case "RtoMax":
 | 
				
			||||||
					procSnmp.Tcp.RtoMax = value
 | 
										procSnmp.Tcp.RtoMax = &value
 | 
				
			||||||
				case "MaxConn":
 | 
									case "MaxConn":
 | 
				
			||||||
					procSnmp.Tcp.MaxConn = value
 | 
										procSnmp.Tcp.MaxConn = &value
 | 
				
			||||||
				case "ActiveOpens":
 | 
									case "ActiveOpens":
 | 
				
			||||||
					procSnmp.Tcp.ActiveOpens = value
 | 
										procSnmp.Tcp.ActiveOpens = &value
 | 
				
			||||||
				case "PassiveOpens":
 | 
									case "PassiveOpens":
 | 
				
			||||||
					procSnmp.Tcp.PassiveOpens = value
 | 
										procSnmp.Tcp.PassiveOpens = &value
 | 
				
			||||||
				case "AttemptFails":
 | 
									case "AttemptFails":
 | 
				
			||||||
					procSnmp.Tcp.AttemptFails = value
 | 
										procSnmp.Tcp.AttemptFails = &value
 | 
				
			||||||
				case "EstabResets":
 | 
									case "EstabResets":
 | 
				
			||||||
					procSnmp.Tcp.EstabResets = value
 | 
										procSnmp.Tcp.EstabResets = &value
 | 
				
			||||||
				case "CurrEstab":
 | 
									case "CurrEstab":
 | 
				
			||||||
					procSnmp.Tcp.CurrEstab = value
 | 
										procSnmp.Tcp.CurrEstab = &value
 | 
				
			||||||
				case "InSegs":
 | 
									case "InSegs":
 | 
				
			||||||
					procSnmp.Tcp.InSegs = value
 | 
										procSnmp.Tcp.InSegs = &value
 | 
				
			||||||
				case "OutSegs":
 | 
									case "OutSegs":
 | 
				
			||||||
					procSnmp.Tcp.OutSegs = value
 | 
										procSnmp.Tcp.OutSegs = &value
 | 
				
			||||||
				case "RetransSegs":
 | 
									case "RetransSegs":
 | 
				
			||||||
					procSnmp.Tcp.RetransSegs = value
 | 
										procSnmp.Tcp.RetransSegs = &value
 | 
				
			||||||
				case "InErrs":
 | 
									case "InErrs":
 | 
				
			||||||
					procSnmp.Tcp.InErrs = value
 | 
										procSnmp.Tcp.InErrs = &value
 | 
				
			||||||
				case "OutRsts":
 | 
									case "OutRsts":
 | 
				
			||||||
					procSnmp.Tcp.OutRsts = value
 | 
										procSnmp.Tcp.OutRsts = &value
 | 
				
			||||||
				case "InCsumErrors":
 | 
									case "InCsumErrors":
 | 
				
			||||||
					procSnmp.Tcp.InCsumErrors = value
 | 
										procSnmp.Tcp.InCsumErrors = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "Udp":
 | 
								case "Udp":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InDatagrams":
 | 
									case "InDatagrams":
 | 
				
			||||||
					procSnmp.Udp.InDatagrams = value
 | 
										procSnmp.Udp.InDatagrams = &value
 | 
				
			||||||
				case "NoPorts":
 | 
									case "NoPorts":
 | 
				
			||||||
					procSnmp.Udp.NoPorts = value
 | 
										procSnmp.Udp.NoPorts = &value
 | 
				
			||||||
				case "InErrors":
 | 
									case "InErrors":
 | 
				
			||||||
					procSnmp.Udp.InErrors = value
 | 
										procSnmp.Udp.InErrors = &value
 | 
				
			||||||
				case "OutDatagrams":
 | 
									case "OutDatagrams":
 | 
				
			||||||
					procSnmp.Udp.OutDatagrams = value
 | 
										procSnmp.Udp.OutDatagrams = &value
 | 
				
			||||||
				case "RcvbufErrors":
 | 
									case "RcvbufErrors":
 | 
				
			||||||
					procSnmp.Udp.RcvbufErrors = value
 | 
										procSnmp.Udp.RcvbufErrors = &value
 | 
				
			||||||
				case "SndbufErrors":
 | 
									case "SndbufErrors":
 | 
				
			||||||
					procSnmp.Udp.SndbufErrors = value
 | 
										procSnmp.Udp.SndbufErrors = &value
 | 
				
			||||||
				case "InCsumErrors":
 | 
									case "InCsumErrors":
 | 
				
			||||||
					procSnmp.Udp.InCsumErrors = value
 | 
										procSnmp.Udp.InCsumErrors = &value
 | 
				
			||||||
				case "IgnoredMulti":
 | 
									case "IgnoredMulti":
 | 
				
			||||||
					procSnmp.Udp.IgnoredMulti = value
 | 
										procSnmp.Udp.IgnoredMulti = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "UdpLite":
 | 
								case "UdpLite":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InDatagrams":
 | 
									case "InDatagrams":
 | 
				
			||||||
					procSnmp.UdpLite.InDatagrams = value
 | 
										procSnmp.UdpLite.InDatagrams = &value
 | 
				
			||||||
				case "NoPorts":
 | 
									case "NoPorts":
 | 
				
			||||||
					procSnmp.UdpLite.NoPorts = value
 | 
										procSnmp.UdpLite.NoPorts = &value
 | 
				
			||||||
				case "InErrors":
 | 
									case "InErrors":
 | 
				
			||||||
					procSnmp.UdpLite.InErrors = value
 | 
										procSnmp.UdpLite.InErrors = &value
 | 
				
			||||||
				case "OutDatagrams":
 | 
									case "OutDatagrams":
 | 
				
			||||||
					procSnmp.UdpLite.OutDatagrams = value
 | 
										procSnmp.UdpLite.OutDatagrams = &value
 | 
				
			||||||
				case "RcvbufErrors":
 | 
									case "RcvbufErrors":
 | 
				
			||||||
					procSnmp.UdpLite.RcvbufErrors = value
 | 
										procSnmp.UdpLite.RcvbufErrors = &value
 | 
				
			||||||
				case "SndbufErrors":
 | 
									case "SndbufErrors":
 | 
				
			||||||
					procSnmp.UdpLite.SndbufErrors = value
 | 
										procSnmp.UdpLite.SndbufErrors = &value
 | 
				
			||||||
				case "InCsumErrors":
 | 
									case "InCsumErrors":
 | 
				
			||||||
					procSnmp.UdpLite.InCsumErrors = value
 | 
										procSnmp.UdpLite.InCsumErrors = &value
 | 
				
			||||||
				case "IgnoredMulti":
 | 
									case "IgnoredMulti":
 | 
				
			||||||
					procSnmp.UdpLite.IgnoredMulti = value
 | 
										procSnmp.UdpLite.IgnoredMulti = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,106 +36,106 @@ type ProcSnmp6 struct {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Ip6 struct { // nolint:revive
 | 
					type Ip6 struct { // nolint:revive
 | 
				
			||||||
	InReceives       float64
 | 
						InReceives       *float64
 | 
				
			||||||
	InHdrErrors      float64
 | 
						InHdrErrors      *float64
 | 
				
			||||||
	InTooBigErrors   float64
 | 
						InTooBigErrors   *float64
 | 
				
			||||||
	InNoRoutes       float64
 | 
						InNoRoutes       *float64
 | 
				
			||||||
	InAddrErrors     float64
 | 
						InAddrErrors     *float64
 | 
				
			||||||
	InUnknownProtos  float64
 | 
						InUnknownProtos  *float64
 | 
				
			||||||
	InTruncatedPkts  float64
 | 
						InTruncatedPkts  *float64
 | 
				
			||||||
	InDiscards       float64
 | 
						InDiscards       *float64
 | 
				
			||||||
	InDelivers       float64
 | 
						InDelivers       *float64
 | 
				
			||||||
	OutForwDatagrams float64
 | 
						OutForwDatagrams *float64
 | 
				
			||||||
	OutRequests      float64
 | 
						OutRequests      *float64
 | 
				
			||||||
	OutDiscards      float64
 | 
						OutDiscards      *float64
 | 
				
			||||||
	OutNoRoutes      float64
 | 
						OutNoRoutes      *float64
 | 
				
			||||||
	ReasmTimeout     float64
 | 
						ReasmTimeout     *float64
 | 
				
			||||||
	ReasmReqds       float64
 | 
						ReasmReqds       *float64
 | 
				
			||||||
	ReasmOKs         float64
 | 
						ReasmOKs         *float64
 | 
				
			||||||
	ReasmFails       float64
 | 
						ReasmFails       *float64
 | 
				
			||||||
	FragOKs          float64
 | 
						FragOKs          *float64
 | 
				
			||||||
	FragFails        float64
 | 
						FragFails        *float64
 | 
				
			||||||
	FragCreates      float64
 | 
						FragCreates      *float64
 | 
				
			||||||
	InMcastPkts      float64
 | 
						InMcastPkts      *float64
 | 
				
			||||||
	OutMcastPkts     float64
 | 
						OutMcastPkts     *float64
 | 
				
			||||||
	InOctets         float64
 | 
						InOctets         *float64
 | 
				
			||||||
	OutOctets        float64
 | 
						OutOctets        *float64
 | 
				
			||||||
	InMcastOctets    float64
 | 
						InMcastOctets    *float64
 | 
				
			||||||
	OutMcastOctets   float64
 | 
						OutMcastOctets   *float64
 | 
				
			||||||
	InBcastOctets    float64
 | 
						InBcastOctets    *float64
 | 
				
			||||||
	OutBcastOctets   float64
 | 
						OutBcastOctets   *float64
 | 
				
			||||||
	InNoECTPkts      float64
 | 
						InNoECTPkts      *float64
 | 
				
			||||||
	InECT1Pkts       float64
 | 
						InECT1Pkts       *float64
 | 
				
			||||||
	InECT0Pkts       float64
 | 
						InECT0Pkts       *float64
 | 
				
			||||||
	InCEPkts         float64
 | 
						InCEPkts         *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Icmp6 struct {
 | 
					type Icmp6 struct {
 | 
				
			||||||
	InMsgs                    float64
 | 
						InMsgs                    *float64
 | 
				
			||||||
	InErrors                  float64
 | 
						InErrors                  *float64
 | 
				
			||||||
	OutMsgs                   float64
 | 
						OutMsgs                   *float64
 | 
				
			||||||
	OutErrors                 float64
 | 
						OutErrors                 *float64
 | 
				
			||||||
	InCsumErrors              float64
 | 
						InCsumErrors              *float64
 | 
				
			||||||
	InDestUnreachs            float64
 | 
						InDestUnreachs            *float64
 | 
				
			||||||
	InPktTooBigs              float64
 | 
						InPktTooBigs              *float64
 | 
				
			||||||
	InTimeExcds               float64
 | 
						InTimeExcds               *float64
 | 
				
			||||||
	InParmProblems            float64
 | 
						InParmProblems            *float64
 | 
				
			||||||
	InEchos                   float64
 | 
						InEchos                   *float64
 | 
				
			||||||
	InEchoReplies             float64
 | 
						InEchoReplies             *float64
 | 
				
			||||||
	InGroupMembQueries        float64
 | 
						InGroupMembQueries        *float64
 | 
				
			||||||
	InGroupMembResponses      float64
 | 
						InGroupMembResponses      *float64
 | 
				
			||||||
	InGroupMembReductions     float64
 | 
						InGroupMembReductions     *float64
 | 
				
			||||||
	InRouterSolicits          float64
 | 
						InRouterSolicits          *float64
 | 
				
			||||||
	InRouterAdvertisements    float64
 | 
						InRouterAdvertisements    *float64
 | 
				
			||||||
	InNeighborSolicits        float64
 | 
						InNeighborSolicits        *float64
 | 
				
			||||||
	InNeighborAdvertisements  float64
 | 
						InNeighborAdvertisements  *float64
 | 
				
			||||||
	InRedirects               float64
 | 
						InRedirects               *float64
 | 
				
			||||||
	InMLDv2Reports            float64
 | 
						InMLDv2Reports            *float64
 | 
				
			||||||
	OutDestUnreachs           float64
 | 
						OutDestUnreachs           *float64
 | 
				
			||||||
	OutPktTooBigs             float64
 | 
						OutPktTooBigs             *float64
 | 
				
			||||||
	OutTimeExcds              float64
 | 
						OutTimeExcds              *float64
 | 
				
			||||||
	OutParmProblems           float64
 | 
						OutParmProblems           *float64
 | 
				
			||||||
	OutEchos                  float64
 | 
						OutEchos                  *float64
 | 
				
			||||||
	OutEchoReplies            float64
 | 
						OutEchoReplies            *float64
 | 
				
			||||||
	OutGroupMembQueries       float64
 | 
						OutGroupMembQueries       *float64
 | 
				
			||||||
	OutGroupMembResponses     float64
 | 
						OutGroupMembResponses     *float64
 | 
				
			||||||
	OutGroupMembReductions    float64
 | 
						OutGroupMembReductions    *float64
 | 
				
			||||||
	OutRouterSolicits         float64
 | 
						OutRouterSolicits         *float64
 | 
				
			||||||
	OutRouterAdvertisements   float64
 | 
						OutRouterAdvertisements   *float64
 | 
				
			||||||
	OutNeighborSolicits       float64
 | 
						OutNeighborSolicits       *float64
 | 
				
			||||||
	OutNeighborAdvertisements float64
 | 
						OutNeighborAdvertisements *float64
 | 
				
			||||||
	OutRedirects              float64
 | 
						OutRedirects              *float64
 | 
				
			||||||
	OutMLDv2Reports           float64
 | 
						OutMLDv2Reports           *float64
 | 
				
			||||||
	InType1                   float64
 | 
						InType1                   *float64
 | 
				
			||||||
	InType134                 float64
 | 
						InType134                 *float64
 | 
				
			||||||
	InType135                 float64
 | 
						InType135                 *float64
 | 
				
			||||||
	InType136                 float64
 | 
						InType136                 *float64
 | 
				
			||||||
	InType143                 float64
 | 
						InType143                 *float64
 | 
				
			||||||
	OutType133                float64
 | 
						OutType133                *float64
 | 
				
			||||||
	OutType135                float64
 | 
						OutType135                *float64
 | 
				
			||||||
	OutType136                float64
 | 
						OutType136                *float64
 | 
				
			||||||
	OutType143                float64
 | 
						OutType143                *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Udp6 struct { // nolint:revive
 | 
					type Udp6 struct { // nolint:revive
 | 
				
			||||||
	InDatagrams  float64
 | 
						InDatagrams  *float64
 | 
				
			||||||
	NoPorts      float64
 | 
						NoPorts      *float64
 | 
				
			||||||
	InErrors     float64
 | 
						InErrors     *float64
 | 
				
			||||||
	OutDatagrams float64
 | 
						OutDatagrams *float64
 | 
				
			||||||
	RcvbufErrors float64
 | 
						RcvbufErrors *float64
 | 
				
			||||||
	SndbufErrors float64
 | 
						SndbufErrors *float64
 | 
				
			||||||
	InCsumErrors float64
 | 
						InCsumErrors *float64
 | 
				
			||||||
	IgnoredMulti float64
 | 
						IgnoredMulti *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type UdpLite6 struct { // nolint:revive
 | 
					type UdpLite6 struct { // nolint:revive
 | 
				
			||||||
	InDatagrams  float64
 | 
						InDatagrams  *float64
 | 
				
			||||||
	NoPorts      float64
 | 
						NoPorts      *float64
 | 
				
			||||||
	InErrors     float64
 | 
						InErrors     *float64
 | 
				
			||||||
	OutDatagrams float64
 | 
						OutDatagrams *float64
 | 
				
			||||||
	RcvbufErrors float64
 | 
						RcvbufErrors *float64
 | 
				
			||||||
	SndbufErrors float64
 | 
						SndbufErrors *float64
 | 
				
			||||||
	InCsumErrors float64
 | 
						InCsumErrors *float64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p Proc) Snmp6() (ProcSnmp6, error) {
 | 
					func (p Proc) Snmp6() (ProcSnmp6, error) {
 | 
				
			||||||
| 
						 | 
					@ -182,197 +182,197 @@ func parseSNMP6Stats(r io.Reader) (ProcSnmp6, error) {
 | 
				
			||||||
			case "Ip6":
 | 
								case "Ip6":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InReceives":
 | 
									case "InReceives":
 | 
				
			||||||
					procSnmp6.Ip6.InReceives = value
 | 
										procSnmp6.Ip6.InReceives = &value
 | 
				
			||||||
				case "InHdrErrors":
 | 
									case "InHdrErrors":
 | 
				
			||||||
					procSnmp6.Ip6.InHdrErrors = value
 | 
										procSnmp6.Ip6.InHdrErrors = &value
 | 
				
			||||||
				case "InTooBigErrors":
 | 
									case "InTooBigErrors":
 | 
				
			||||||
					procSnmp6.Ip6.InTooBigErrors = value
 | 
										procSnmp6.Ip6.InTooBigErrors = &value
 | 
				
			||||||
				case "InNoRoutes":
 | 
									case "InNoRoutes":
 | 
				
			||||||
					procSnmp6.Ip6.InNoRoutes = value
 | 
										procSnmp6.Ip6.InNoRoutes = &value
 | 
				
			||||||
				case "InAddrErrors":
 | 
									case "InAddrErrors":
 | 
				
			||||||
					procSnmp6.Ip6.InAddrErrors = value
 | 
										procSnmp6.Ip6.InAddrErrors = &value
 | 
				
			||||||
				case "InUnknownProtos":
 | 
									case "InUnknownProtos":
 | 
				
			||||||
					procSnmp6.Ip6.InUnknownProtos = value
 | 
										procSnmp6.Ip6.InUnknownProtos = &value
 | 
				
			||||||
				case "InTruncatedPkts":
 | 
									case "InTruncatedPkts":
 | 
				
			||||||
					procSnmp6.Ip6.InTruncatedPkts = value
 | 
										procSnmp6.Ip6.InTruncatedPkts = &value
 | 
				
			||||||
				case "InDiscards":
 | 
									case "InDiscards":
 | 
				
			||||||
					procSnmp6.Ip6.InDiscards = value
 | 
										procSnmp6.Ip6.InDiscards = &value
 | 
				
			||||||
				case "InDelivers":
 | 
									case "InDelivers":
 | 
				
			||||||
					procSnmp6.Ip6.InDelivers = value
 | 
										procSnmp6.Ip6.InDelivers = &value
 | 
				
			||||||
				case "OutForwDatagrams":
 | 
									case "OutForwDatagrams":
 | 
				
			||||||
					procSnmp6.Ip6.OutForwDatagrams = value
 | 
										procSnmp6.Ip6.OutForwDatagrams = &value
 | 
				
			||||||
				case "OutRequests":
 | 
									case "OutRequests":
 | 
				
			||||||
					procSnmp6.Ip6.OutRequests = value
 | 
										procSnmp6.Ip6.OutRequests = &value
 | 
				
			||||||
				case "OutDiscards":
 | 
									case "OutDiscards":
 | 
				
			||||||
					procSnmp6.Ip6.OutDiscards = value
 | 
										procSnmp6.Ip6.OutDiscards = &value
 | 
				
			||||||
				case "OutNoRoutes":
 | 
									case "OutNoRoutes":
 | 
				
			||||||
					procSnmp6.Ip6.OutNoRoutes = value
 | 
										procSnmp6.Ip6.OutNoRoutes = &value
 | 
				
			||||||
				case "ReasmTimeout":
 | 
									case "ReasmTimeout":
 | 
				
			||||||
					procSnmp6.Ip6.ReasmTimeout = value
 | 
										procSnmp6.Ip6.ReasmTimeout = &value
 | 
				
			||||||
				case "ReasmReqds":
 | 
									case "ReasmReqds":
 | 
				
			||||||
					procSnmp6.Ip6.ReasmReqds = value
 | 
										procSnmp6.Ip6.ReasmReqds = &value
 | 
				
			||||||
				case "ReasmOKs":
 | 
									case "ReasmOKs":
 | 
				
			||||||
					procSnmp6.Ip6.ReasmOKs = value
 | 
										procSnmp6.Ip6.ReasmOKs = &value
 | 
				
			||||||
				case "ReasmFails":
 | 
									case "ReasmFails":
 | 
				
			||||||
					procSnmp6.Ip6.ReasmFails = value
 | 
										procSnmp6.Ip6.ReasmFails = &value
 | 
				
			||||||
				case "FragOKs":
 | 
									case "FragOKs":
 | 
				
			||||||
					procSnmp6.Ip6.FragOKs = value
 | 
										procSnmp6.Ip6.FragOKs = &value
 | 
				
			||||||
				case "FragFails":
 | 
									case "FragFails":
 | 
				
			||||||
					procSnmp6.Ip6.FragFails = value
 | 
										procSnmp6.Ip6.FragFails = &value
 | 
				
			||||||
				case "FragCreates":
 | 
									case "FragCreates":
 | 
				
			||||||
					procSnmp6.Ip6.FragCreates = value
 | 
										procSnmp6.Ip6.FragCreates = &value
 | 
				
			||||||
				case "InMcastPkts":
 | 
									case "InMcastPkts":
 | 
				
			||||||
					procSnmp6.Ip6.InMcastPkts = value
 | 
										procSnmp6.Ip6.InMcastPkts = &value
 | 
				
			||||||
				case "OutMcastPkts":
 | 
									case "OutMcastPkts":
 | 
				
			||||||
					procSnmp6.Ip6.OutMcastPkts = value
 | 
										procSnmp6.Ip6.OutMcastPkts = &value
 | 
				
			||||||
				case "InOctets":
 | 
									case "InOctets":
 | 
				
			||||||
					procSnmp6.Ip6.InOctets = value
 | 
										procSnmp6.Ip6.InOctets = &value
 | 
				
			||||||
				case "OutOctets":
 | 
									case "OutOctets":
 | 
				
			||||||
					procSnmp6.Ip6.OutOctets = value
 | 
										procSnmp6.Ip6.OutOctets = &value
 | 
				
			||||||
				case "InMcastOctets":
 | 
									case "InMcastOctets":
 | 
				
			||||||
					procSnmp6.Ip6.InMcastOctets = value
 | 
										procSnmp6.Ip6.InMcastOctets = &value
 | 
				
			||||||
				case "OutMcastOctets":
 | 
									case "OutMcastOctets":
 | 
				
			||||||
					procSnmp6.Ip6.OutMcastOctets = value
 | 
										procSnmp6.Ip6.OutMcastOctets = &value
 | 
				
			||||||
				case "InBcastOctets":
 | 
									case "InBcastOctets":
 | 
				
			||||||
					procSnmp6.Ip6.InBcastOctets = value
 | 
										procSnmp6.Ip6.InBcastOctets = &value
 | 
				
			||||||
				case "OutBcastOctets":
 | 
									case "OutBcastOctets":
 | 
				
			||||||
					procSnmp6.Ip6.OutBcastOctets = value
 | 
										procSnmp6.Ip6.OutBcastOctets = &value
 | 
				
			||||||
				case "InNoECTPkts":
 | 
									case "InNoECTPkts":
 | 
				
			||||||
					procSnmp6.Ip6.InNoECTPkts = value
 | 
										procSnmp6.Ip6.InNoECTPkts = &value
 | 
				
			||||||
				case "InECT1Pkts":
 | 
									case "InECT1Pkts":
 | 
				
			||||||
					procSnmp6.Ip6.InECT1Pkts = value
 | 
										procSnmp6.Ip6.InECT1Pkts = &value
 | 
				
			||||||
				case "InECT0Pkts":
 | 
									case "InECT0Pkts":
 | 
				
			||||||
					procSnmp6.Ip6.InECT0Pkts = value
 | 
										procSnmp6.Ip6.InECT0Pkts = &value
 | 
				
			||||||
				case "InCEPkts":
 | 
									case "InCEPkts":
 | 
				
			||||||
					procSnmp6.Ip6.InCEPkts = value
 | 
										procSnmp6.Ip6.InCEPkts = &value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "Icmp6":
 | 
								case "Icmp6":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InMsgs":
 | 
									case "InMsgs":
 | 
				
			||||||
					procSnmp6.Icmp6.InMsgs = value
 | 
										procSnmp6.Icmp6.InMsgs = &value
 | 
				
			||||||
				case "InErrors":
 | 
									case "InErrors":
 | 
				
			||||||
					procSnmp6.Icmp6.InErrors = value
 | 
										procSnmp6.Icmp6.InErrors = &value
 | 
				
			||||||
				case "OutMsgs":
 | 
									case "OutMsgs":
 | 
				
			||||||
					procSnmp6.Icmp6.OutMsgs = value
 | 
										procSnmp6.Icmp6.OutMsgs = &value
 | 
				
			||||||
				case "OutErrors":
 | 
									case "OutErrors":
 | 
				
			||||||
					procSnmp6.Icmp6.OutErrors = value
 | 
										procSnmp6.Icmp6.OutErrors = &value
 | 
				
			||||||
				case "InCsumErrors":
 | 
									case "InCsumErrors":
 | 
				
			||||||
					procSnmp6.Icmp6.InCsumErrors = value
 | 
										procSnmp6.Icmp6.InCsumErrors = &value
 | 
				
			||||||
				case "InDestUnreachs":
 | 
									case "InDestUnreachs":
 | 
				
			||||||
					procSnmp6.Icmp6.InDestUnreachs = value
 | 
										procSnmp6.Icmp6.InDestUnreachs = &value
 | 
				
			||||||
				case "InPktTooBigs":
 | 
									case "InPktTooBigs":
 | 
				
			||||||
					procSnmp6.Icmp6.InPktTooBigs = value
 | 
										procSnmp6.Icmp6.InPktTooBigs = &value
 | 
				
			||||||
				case "InTimeExcds":
 | 
									case "InTimeExcds":
 | 
				
			||||||
					procSnmp6.Icmp6.InTimeExcds = value
 | 
										procSnmp6.Icmp6.InTimeExcds = &value
 | 
				
			||||||
				case "InParmProblems":
 | 
									case "InParmProblems":
 | 
				
			||||||
					procSnmp6.Icmp6.InParmProblems = value
 | 
										procSnmp6.Icmp6.InParmProblems = &value
 | 
				
			||||||
				case "InEchos":
 | 
									case "InEchos":
 | 
				
			||||||
					procSnmp6.Icmp6.InEchos = value
 | 
										procSnmp6.Icmp6.InEchos = &value
 | 
				
			||||||
				case "InEchoReplies":
 | 
									case "InEchoReplies":
 | 
				
			||||||
					procSnmp6.Icmp6.InEchoReplies = value
 | 
										procSnmp6.Icmp6.InEchoReplies = &value
 | 
				
			||||||
				case "InGroupMembQueries":
 | 
									case "InGroupMembQueries":
 | 
				
			||||||
					procSnmp6.Icmp6.InGroupMembQueries = value
 | 
										procSnmp6.Icmp6.InGroupMembQueries = &value
 | 
				
			||||||
				case "InGroupMembResponses":
 | 
									case "InGroupMembResponses":
 | 
				
			||||||
					procSnmp6.Icmp6.InGroupMembResponses = value
 | 
										procSnmp6.Icmp6.InGroupMembResponses = &value
 | 
				
			||||||
				case "InGroupMembReductions":
 | 
									case "InGroupMembReductions":
 | 
				
			||||||
					procSnmp6.Icmp6.InGroupMembReductions = value
 | 
										procSnmp6.Icmp6.InGroupMembReductions = &value
 | 
				
			||||||
				case "InRouterSolicits":
 | 
									case "InRouterSolicits":
 | 
				
			||||||
					procSnmp6.Icmp6.InRouterSolicits = value
 | 
										procSnmp6.Icmp6.InRouterSolicits = &value
 | 
				
			||||||
				case "InRouterAdvertisements":
 | 
									case "InRouterAdvertisements":
 | 
				
			||||||
					procSnmp6.Icmp6.InRouterAdvertisements = value
 | 
										procSnmp6.Icmp6.InRouterAdvertisements = &value
 | 
				
			||||||
				case "InNeighborSolicits":
 | 
									case "InNeighborSolicits":
 | 
				
			||||||
					procSnmp6.Icmp6.InNeighborSolicits = value
 | 
										procSnmp6.Icmp6.InNeighborSolicits = &value
 | 
				
			||||||
				case "InNeighborAdvertisements":
 | 
									case "InNeighborAdvertisements":
 | 
				
			||||||
					procSnmp6.Icmp6.InNeighborAdvertisements = value
 | 
										procSnmp6.Icmp6.InNeighborAdvertisements = &value
 | 
				
			||||||
				case "InRedirects":
 | 
									case "InRedirects":
 | 
				
			||||||
					procSnmp6.Icmp6.InRedirects = value
 | 
										procSnmp6.Icmp6.InRedirects = &value
 | 
				
			||||||
				case "InMLDv2Reports":
 | 
									case "InMLDv2Reports":
 | 
				
			||||||
					procSnmp6.Icmp6.InMLDv2Reports = value
 | 
										procSnmp6.Icmp6.InMLDv2Reports = &value
 | 
				
			||||||
				case "OutDestUnreachs":
 | 
									case "OutDestUnreachs":
 | 
				
			||||||
					procSnmp6.Icmp6.OutDestUnreachs = value
 | 
										procSnmp6.Icmp6.OutDestUnreachs = &value
 | 
				
			||||||
				case "OutPktTooBigs":
 | 
									case "OutPktTooBigs":
 | 
				
			||||||
					procSnmp6.Icmp6.OutPktTooBigs = value
 | 
										procSnmp6.Icmp6.OutPktTooBigs = &value
 | 
				
			||||||
				case "OutTimeExcds":
 | 
									case "OutTimeExcds":
 | 
				
			||||||
					procSnmp6.Icmp6.OutTimeExcds = value
 | 
										procSnmp6.Icmp6.OutTimeExcds = &value
 | 
				
			||||||
				case "OutParmProblems":
 | 
									case "OutParmProblems":
 | 
				
			||||||
					procSnmp6.Icmp6.OutParmProblems = value
 | 
										procSnmp6.Icmp6.OutParmProblems = &value
 | 
				
			||||||
				case "OutEchos":
 | 
									case "OutEchos":
 | 
				
			||||||
					procSnmp6.Icmp6.OutEchos = value
 | 
										procSnmp6.Icmp6.OutEchos = &value
 | 
				
			||||||
				case "OutEchoReplies":
 | 
									case "OutEchoReplies":
 | 
				
			||||||
					procSnmp6.Icmp6.OutEchoReplies = value
 | 
										procSnmp6.Icmp6.OutEchoReplies = &value
 | 
				
			||||||
				case "OutGroupMembQueries":
 | 
									case "OutGroupMembQueries":
 | 
				
			||||||
					procSnmp6.Icmp6.OutGroupMembQueries = value
 | 
										procSnmp6.Icmp6.OutGroupMembQueries = &value
 | 
				
			||||||
				case "OutGroupMembResponses":
 | 
									case "OutGroupMembResponses":
 | 
				
			||||||
					procSnmp6.Icmp6.OutGroupMembResponses = value
 | 
										procSnmp6.Icmp6.OutGroupMembResponses = &value
 | 
				
			||||||
				case "OutGroupMembReductions":
 | 
									case "OutGroupMembReductions":
 | 
				
			||||||
					procSnmp6.Icmp6.OutGroupMembReductions = value
 | 
										procSnmp6.Icmp6.OutGroupMembReductions = &value
 | 
				
			||||||
				case "OutRouterSolicits":
 | 
									case "OutRouterSolicits":
 | 
				
			||||||
					procSnmp6.Icmp6.OutRouterSolicits = value
 | 
										procSnmp6.Icmp6.OutRouterSolicits = &value
 | 
				
			||||||
				case "OutRouterAdvertisements":
 | 
									case "OutRouterAdvertisements":
 | 
				
			||||||
					procSnmp6.Icmp6.OutRouterAdvertisements = value
 | 
										procSnmp6.Icmp6.OutRouterAdvertisements = &value
 | 
				
			||||||
				case "OutNeighborSolicits":
 | 
									case "OutNeighborSolicits":
 | 
				
			||||||
					procSnmp6.Icmp6.OutNeighborSolicits = value
 | 
										procSnmp6.Icmp6.OutNeighborSolicits = &value
 | 
				
			||||||
				case "OutNeighborAdvertisements":
 | 
									case "OutNeighborAdvertisements":
 | 
				
			||||||
					procSnmp6.Icmp6.OutNeighborAdvertisements = value
 | 
										procSnmp6.Icmp6.OutNeighborAdvertisements = &value
 | 
				
			||||||
				case "OutRedirects":
 | 
									case "OutRedirects":
 | 
				
			||||||
					procSnmp6.Icmp6.OutRedirects = value
 | 
										procSnmp6.Icmp6.OutRedirects = &value
 | 
				
			||||||
				case "OutMLDv2Reports":
 | 
									case "OutMLDv2Reports":
 | 
				
			||||||
					procSnmp6.Icmp6.OutMLDv2Reports = value
 | 
										procSnmp6.Icmp6.OutMLDv2Reports = &value
 | 
				
			||||||
				case "InType1":
 | 
									case "InType1":
 | 
				
			||||||
					procSnmp6.Icmp6.InType1 = value
 | 
										procSnmp6.Icmp6.InType1 = &value
 | 
				
			||||||
				case "InType134":
 | 
									case "InType134":
 | 
				
			||||||
					procSnmp6.Icmp6.InType134 = value
 | 
										procSnmp6.Icmp6.InType134 = &value
 | 
				
			||||||
				case "InType135":
 | 
									case "InType135":
 | 
				
			||||||
					procSnmp6.Icmp6.InType135 = value
 | 
										procSnmp6.Icmp6.InType135 = &value
 | 
				
			||||||
				case "InType136":
 | 
									case "InType136":
 | 
				
			||||||
					procSnmp6.Icmp6.InType136 = value
 | 
										procSnmp6.Icmp6.InType136 = &value
 | 
				
			||||||
				case "InType143":
 | 
									case "InType143":
 | 
				
			||||||
					procSnmp6.Icmp6.InType143 = value
 | 
										procSnmp6.Icmp6.InType143 = &value
 | 
				
			||||||
				case "OutType133":
 | 
									case "OutType133":
 | 
				
			||||||
					procSnmp6.Icmp6.OutType133 = value
 | 
										procSnmp6.Icmp6.OutType133 = &value
 | 
				
			||||||
				case "OutType135":
 | 
									case "OutType135":
 | 
				
			||||||
					procSnmp6.Icmp6.OutType135 = value
 | 
										procSnmp6.Icmp6.OutType135 = &value
 | 
				
			||||||
				case "OutType136":
 | 
									case "OutType136":
 | 
				
			||||||
					procSnmp6.Icmp6.OutType136 = value
 | 
										procSnmp6.Icmp6.OutType136 = &value
 | 
				
			||||||
				case "OutType143":
 | 
									case "OutType143":
 | 
				
			||||||
					procSnmp6.Icmp6.OutType143 = value
 | 
										procSnmp6.Icmp6.OutType143 = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "Udp6":
 | 
								case "Udp6":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InDatagrams":
 | 
									case "InDatagrams":
 | 
				
			||||||
					procSnmp6.Udp6.InDatagrams = value
 | 
										procSnmp6.Udp6.InDatagrams = &value
 | 
				
			||||||
				case "NoPorts":
 | 
									case "NoPorts":
 | 
				
			||||||
					procSnmp6.Udp6.NoPorts = value
 | 
										procSnmp6.Udp6.NoPorts = &value
 | 
				
			||||||
				case "InErrors":
 | 
									case "InErrors":
 | 
				
			||||||
					procSnmp6.Udp6.InErrors = value
 | 
										procSnmp6.Udp6.InErrors = &value
 | 
				
			||||||
				case "OutDatagrams":
 | 
									case "OutDatagrams":
 | 
				
			||||||
					procSnmp6.Udp6.OutDatagrams = value
 | 
										procSnmp6.Udp6.OutDatagrams = &value
 | 
				
			||||||
				case "RcvbufErrors":
 | 
									case "RcvbufErrors":
 | 
				
			||||||
					procSnmp6.Udp6.RcvbufErrors = value
 | 
										procSnmp6.Udp6.RcvbufErrors = &value
 | 
				
			||||||
				case "SndbufErrors":
 | 
									case "SndbufErrors":
 | 
				
			||||||
					procSnmp6.Udp6.SndbufErrors = value
 | 
										procSnmp6.Udp6.SndbufErrors = &value
 | 
				
			||||||
				case "InCsumErrors":
 | 
									case "InCsumErrors":
 | 
				
			||||||
					procSnmp6.Udp6.InCsumErrors = value
 | 
										procSnmp6.Udp6.InCsumErrors = &value
 | 
				
			||||||
				case "IgnoredMulti":
 | 
									case "IgnoredMulti":
 | 
				
			||||||
					procSnmp6.Udp6.IgnoredMulti = value
 | 
										procSnmp6.Udp6.IgnoredMulti = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			case "UdpLite6":
 | 
								case "UdpLite6":
 | 
				
			||||||
				switch key {
 | 
									switch key {
 | 
				
			||||||
				case "InDatagrams":
 | 
									case "InDatagrams":
 | 
				
			||||||
					procSnmp6.UdpLite6.InDatagrams = value
 | 
										procSnmp6.UdpLite6.InDatagrams = &value
 | 
				
			||||||
				case "NoPorts":
 | 
									case "NoPorts":
 | 
				
			||||||
					procSnmp6.UdpLite6.NoPorts = value
 | 
										procSnmp6.UdpLite6.NoPorts = &value
 | 
				
			||||||
				case "InErrors":
 | 
									case "InErrors":
 | 
				
			||||||
					procSnmp6.UdpLite6.InErrors = value
 | 
										procSnmp6.UdpLite6.InErrors = &value
 | 
				
			||||||
				case "OutDatagrams":
 | 
									case "OutDatagrams":
 | 
				
			||||||
					procSnmp6.UdpLite6.OutDatagrams = value
 | 
										procSnmp6.UdpLite6.OutDatagrams = &value
 | 
				
			||||||
				case "RcvbufErrors":
 | 
									case "RcvbufErrors":
 | 
				
			||||||
					procSnmp6.UdpLite6.RcvbufErrors = value
 | 
										procSnmp6.UdpLite6.RcvbufErrors = &value
 | 
				
			||||||
				case "SndbufErrors":
 | 
									case "SndbufErrors":
 | 
				
			||||||
					procSnmp6.UdpLite6.SndbufErrors = value
 | 
										procSnmp6.UdpLite6.SndbufErrors = &value
 | 
				
			||||||
				case "InCsumErrors":
 | 
									case "InCsumErrors":
 | 
				
			||||||
					procSnmp6.UdpLite6.InCsumErrors = value
 | 
										procSnmp6.UdpLite6.InCsumErrors = &value
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,6 @@ import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/prometheus/procfs/internal/fs"
 | 
					 | 
				
			||||||
	"github.com/prometheus/procfs/internal/util"
 | 
						"github.com/prometheus/procfs/internal/util"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,6 +101,8 @@ type ProcStat struct {
 | 
				
			||||||
	RSS int
 | 
						RSS int
 | 
				
			||||||
	// Soft limit in bytes on the rss of the process.
 | 
						// Soft limit in bytes on the rss of the process.
 | 
				
			||||||
	RSSLimit uint64
 | 
						RSSLimit uint64
 | 
				
			||||||
 | 
						// CPU number last executed on.
 | 
				
			||||||
 | 
						Processor uint
 | 
				
			||||||
	// Real-time scheduling priority, a number in the range 1 to 99 for processes
 | 
						// 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.
 | 
						// scheduled under a real-time policy, or 0, for non-real-time processes.
 | 
				
			||||||
	RTPriority uint
 | 
						RTPriority uint
 | 
				
			||||||
| 
						 | 
					@ -110,7 +111,7 @@ type ProcStat struct {
 | 
				
			||||||
	// Aggregated block I/O delays, measured in clock ticks (centiseconds).
 | 
						// Aggregated block I/O delays, measured in clock ticks (centiseconds).
 | 
				
			||||||
	DelayAcctBlkIOTicks uint64
 | 
						DelayAcctBlkIOTicks uint64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	proc fs.FS
 | 
						proc FS
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewStat returns the current status information of the process.
 | 
					// NewStat returns the current status information of the process.
 | 
				
			||||||
| 
						 | 
					@ -137,7 +138,7 @@ func (p Proc) Stat() (ProcStat, error) {
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if l < 0 || r < 0 {
 | 
						if l < 0 || r < 0 {
 | 
				
			||||||
		return ProcStat{}, fmt.Errorf("unexpected format, couldn't extract comm %q", data)
 | 
							return ProcStat{}, fmt.Errorf("%w: unexpected format, couldn't extract comm %q", ErrFileParse, data)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s.Comm = string(data[l+1 : r])
 | 
						s.Comm = string(data[l+1 : r])
 | 
				
			||||||
| 
						 | 
					@ -184,7 +185,7 @@ func (p Proc) Stat() (ProcStat, error) {
 | 
				
			||||||
		&ignoreUint64,
 | 
							&ignoreUint64,
 | 
				
			||||||
		&ignoreUint64,
 | 
							&ignoreUint64,
 | 
				
			||||||
		&ignoreInt64,
 | 
							&ignoreInt64,
 | 
				
			||||||
		&ignoreInt64,
 | 
							&s.Processor,
 | 
				
			||||||
		&s.RTPriority,
 | 
							&s.RTPriority,
 | 
				
			||||||
		&s.Policy,
 | 
							&s.Policy,
 | 
				
			||||||
		&s.DelayAcctBlkIOTicks,
 | 
							&s.DelayAcctBlkIOTicks,
 | 
				
			||||||
| 
						 | 
					@ -208,8 +209,7 @@ func (s ProcStat) ResidentMemory() int {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StartTime returns the unix timestamp of the process in seconds.
 | 
					// StartTime returns the unix timestamp of the process in seconds.
 | 
				
			||||||
func (s ProcStat) StartTime() (float64, error) {
 | 
					func (s ProcStat) StartTime() (float64, error) {
 | 
				
			||||||
	fs := FS{proc: s.proc}
 | 
						stat, err := s.proc.Stat()
 | 
				
			||||||
	stat, err := fs.Stat()
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@ package procfs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
 | 
						"sort"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +23,7 @@ import (
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ProcStatus provides status information about the process,
 | 
					// ProcStatus provides status information about the process,
 | 
				
			||||||
// read from /proc/[pid]/stat.
 | 
					// read from /proc/[pid]/status.
 | 
				
			||||||
type ProcStatus struct {
 | 
					type ProcStatus struct {
 | 
				
			||||||
	// The process ID.
 | 
						// The process ID.
 | 
				
			||||||
	PID int
 | 
						PID int
 | 
				
			||||||
| 
						 | 
					@ -31,6 +32,8 @@ type ProcStatus struct {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Thread group ID.
 | 
						// Thread group ID.
 | 
				
			||||||
	TGID int
 | 
						TGID int
 | 
				
			||||||
 | 
						// List of Pid namespace.
 | 
				
			||||||
 | 
						NSpids []uint64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Peak virtual memory size.
 | 
						// Peak virtual memory size.
 | 
				
			||||||
	VmPeak uint64 // nolint:revive
 | 
						VmPeak uint64 // nolint:revive
 | 
				
			||||||
| 
						 | 
					@ -76,6 +79,9 @@ type ProcStatus struct {
 | 
				
			||||||
	UIDs [4]string
 | 
						UIDs [4]string
 | 
				
			||||||
	// GIDs of the process (Real, effective, saved set, and filesystem GIDs)
 | 
						// GIDs of the process (Real, effective, saved set, and filesystem GIDs)
 | 
				
			||||||
	GIDs [4]string
 | 
						GIDs [4]string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// CpusAllowedList: List of cpu cores processes are allowed to run on.
 | 
				
			||||||
 | 
						CpusAllowedList []uint64
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewStatus returns the current status information of the process.
 | 
					// NewStatus returns the current status information of the process.
 | 
				
			||||||
| 
						 | 
					@ -96,10 +102,10 @@ func (p Proc) NewStatus() (ProcStatus, error) {
 | 
				
			||||||
		kv := strings.SplitN(line, ":", 2)
 | 
							kv := strings.SplitN(line, ":", 2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// removes spaces
 | 
							// removes spaces
 | 
				
			||||||
		k := string(strings.TrimSpace(kv[0]))
 | 
							k := strings.TrimSpace(kv[0])
 | 
				
			||||||
		v := string(strings.TrimSpace(kv[1]))
 | 
							v := strings.TrimSpace(kv[1])
 | 
				
			||||||
		// removes "kB"
 | 
							// removes "kB"
 | 
				
			||||||
		v = string(bytes.Trim([]byte(v), " kB"))
 | 
							v = strings.TrimSuffix(v, " kB")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// value to int when possible
 | 
							// value to int when possible
 | 
				
			||||||
		// we can skip error check here, 'cause vKBytes is not used when value is a string
 | 
							// we can skip error check here, 'cause vKBytes is not used when value is a string
 | 
				
			||||||
| 
						 | 
					@ -123,6 +129,8 @@ func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintByt
 | 
				
			||||||
		copy(s.UIDs[:], strings.Split(vString, "\t"))
 | 
							copy(s.UIDs[:], strings.Split(vString, "\t"))
 | 
				
			||||||
	case "Gid":
 | 
						case "Gid":
 | 
				
			||||||
		copy(s.GIDs[:], strings.Split(vString, "\t"))
 | 
							copy(s.GIDs[:], strings.Split(vString, "\t"))
 | 
				
			||||||
 | 
						case "NSpid":
 | 
				
			||||||
 | 
							s.NSpids = calcNSPidsList(vString)
 | 
				
			||||||
	case "VmPeak":
 | 
						case "VmPeak":
 | 
				
			||||||
		s.VmPeak = vUintBytes
 | 
							s.VmPeak = vUintBytes
 | 
				
			||||||
	case "VmSize":
 | 
						case "VmSize":
 | 
				
			||||||
| 
						 | 
					@ -161,10 +169,53 @@ func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintByt
 | 
				
			||||||
		s.VoluntaryCtxtSwitches = vUint
 | 
							s.VoluntaryCtxtSwitches = vUint
 | 
				
			||||||
	case "nonvoluntary_ctxt_switches":
 | 
						case "nonvoluntary_ctxt_switches":
 | 
				
			||||||
		s.NonVoluntaryCtxtSwitches = vUint
 | 
							s.NonVoluntaryCtxtSwitches = vUint
 | 
				
			||||||
 | 
						case "Cpus_allowed_list":
 | 
				
			||||||
 | 
							s.CpusAllowedList = calcCpusAllowedList(vString)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TotalCtxtSwitches returns the total context switch.
 | 
					// TotalCtxtSwitches returns the total context switch.
 | 
				
			||||||
func (s ProcStatus) TotalCtxtSwitches() uint64 {
 | 
					func (s ProcStatus) TotalCtxtSwitches() uint64 {
 | 
				
			||||||
	return s.VoluntaryCtxtSwitches + s.NonVoluntaryCtxtSwitches
 | 
						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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,7 +44,7 @@ func (fs FS) SysctlInts(sysctl string) ([]int, error) {
 | 
				
			||||||
		vp := util.NewValueParser(f)
 | 
							vp := util.NewValueParser(f)
 | 
				
			||||||
		values[i] = vp.Int()
 | 
							values[i] = vp.Int()
 | 
				
			||||||
		if err := vp.Err(); err != nil {
 | 
							if err := vp.Err(); err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("field %d in sysctl %s is not a valid int: %w", i, sysctl, err)
 | 
								return nil, fmt.Errorf("%s: field %d in sysctl %s is not a valid int: %w", ErrFileParse, i, sysctl, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return values, nil
 | 
						return values, nil
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,7 @@ func parseV21SlabEntry(line string) (*Slab, error) {
 | 
				
			||||||
	l := slabSpace.ReplaceAllString(line, " ")
 | 
						l := slabSpace.ReplaceAllString(line, " ")
 | 
				
			||||||
	s := strings.Split(l, " ")
 | 
						s := strings.Split(l, " ")
 | 
				
			||||||
	if len(s) != 16 {
 | 
						if len(s) != 16 {
 | 
				
			||||||
		return nil, fmt.Errorf("unable to parse: %q", line)
 | 
							return nil, fmt.Errorf("%w: unable to parse: %q", ErrFileParse, line)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	i := &Slab{Name: s[0]}
 | 
						i := &Slab{Name: s[0]}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue