diff --git a/go.mod b/go.mod index bfd0d59b572..dcb5608eb7e 100644 --- a/go.mod +++ b/go.mod @@ -32,11 +32,11 @@ require ( github.com/multiformats/go-multihash v0.2.3 github.com/multiformats/go-multistream v0.5.0 github.com/opentracing/opentracing-go v1.2.0 - github.com/prometheus/client_golang v1.18.0 + github.com/prometheus/client_golang v1.21.1 github.com/spf13/afero v1.6.0 github.com/spf13/cobra v1.5.0 github.com/spf13/viper v1.7.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.10.0 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/uber/jaeger-client-go v2.24.0+incompatible github.com/vmihailenco/msgpack/v5 v5.3.4 @@ -44,11 +44,11 @@ require ( gitlab.com/nolash/go-mockbytes v0.0.7 go.uber.org/atomic v1.11.0 go.uber.org/goleak v1.3.0 - golang.org/x/crypto v0.23.0 - golang.org/x/net v0.25.0 - golang.org/x/sync v0.7.0 - golang.org/x/sys v0.20.0 - golang.org/x/term v0.20.0 + golang.org/x/crypto v0.31.0 + golang.org/x/net v0.33.0 + golang.org/x/sync v0.10.0 + golang.org/x/sys v0.28.0 + golang.org/x/term v0.27.0 golang.org/x/time v0.5.0 gopkg.in/yaml.v2 v2.4.0 resenje.org/multex v0.1.0 @@ -56,8 +56,6 @@ require ( resenje.org/web v0.4.3 ) -require golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect - require ( github.com/BurntSushi/toml v1.1.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect @@ -66,7 +64,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/codahale/hdrhistogram v0.0.0-00010101000000-000000000000 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect @@ -104,7 +102,7 @@ require ( github.com/ipfs/go-log/v2 v2.5.1 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect - github.com/klauspost/compress v1.17.6 // indirect + github.com/klauspost/compress v1.17.11 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/koron/go-ssdp v0.0.4 // indirect github.com/leodido/go-urn v1.2.1 // indirect @@ -132,6 +130,7 @@ require ( github.com/multiformats/go-multibase v0.2.0 // indirect github.com/multiformats/go-multicodec v0.9.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/onsi/ginkgo/v2 v2.15.0 // indirect github.com/opencontainers/runtime-spec v1.2.0 // indirect @@ -139,9 +138,9 @@ require ( github.com/pelletier/go-toml v1.8.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.62.0 + github.com/prometheus/procfs v0.15.1 // indirect github.com/prometheus/statsd_exporter v0.22.7 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/quic-go v0.42.0 // indirect @@ -166,10 +165,11 @@ require ( go.uber.org/mock v0.4.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect + golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/text v0.15.0 // indirect - golang.org/x/tools v0.20.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/ini.v1 v1.57.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect diff --git a/go.sum b/go.sum index 6713bc320f6..32275a937db 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 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/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= @@ -528,8 +528,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= -github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.6/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -692,6 +692,8 @@ github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXS github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/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/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= @@ -761,14 +763,14 @@ github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqr github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk= +github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= @@ -780,8 +782,8 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= +github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -792,8 +794,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O 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/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/prometheus/statsd_exporter v0.22.7 h1:7Pji/i2GuhK6Lu7DHrtTkFmNBCudCPT1pX2CziuyQR0= github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= @@ -902,8 +904,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= @@ -1019,8 +1021,8 @@ golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -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.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1113,8 +1115,8 @@ golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/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.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1137,8 +1139,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ 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-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1220,13 +1222,13 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 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/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= 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.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1235,8 +1237,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -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.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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= @@ -1297,8 +1299,8 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/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-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1401,8 +1403,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/api/api.go b/pkg/api/api.go index b7cc8a45f97..4fd5390a203 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -506,6 +506,49 @@ func (s *Service) contentLengthMetricMiddleware() func(h http.Handler) http.Hand } } +func (s *Service) downloadSpeedMetricMiddleware(endpoint string) func(h http.Handler) http.Handler { + return func(h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + h.ServeHTTP(w, r) + + rw, ok := w.(*responseWriter) + if !ok { + return + } + if rw.Status() != http.StatusOK { + return + } + + speed := float64(rw.size) / time.Since(start).Seconds() + s.metrics.DownloadSpeed.WithLabelValues(endpoint).Observe(speed) + }) + } +} + +// observeUploadSpeed measures the speed of the upload and sets appropriate +// labels to the metrics. This function can be called as a deferred function in +// side of handler. This functions is not in a form of a middleware to more +// directly pass the deferred flag. +func (s *Service) observeUploadSpeed(w http.ResponseWriter, r *http.Request, start time.Time, endpoint string, deferred bool) { + rw, ok := w.(*responseWriter) + if !ok { + return + } + + if rw.Status() != http.StatusOK && rw.Status() != http.StatusCreated { + return + } + + mode := "direct" + if deferred { + mode = "deferred" + } + + speed := float64(r.ContentLength) / time.Since(start).Seconds() + s.metrics.UploadSpeed.WithLabelValues(endpoint, mode).Observe(speed) +} + // gasConfigMiddleware can be used by the APIs that allow block chain transactions to set // gas price and gas limit through the HTTP API headers. func (s *Service) gasConfigMiddleware(handlerName string) func(h http.Handler) http.Handler { diff --git a/pkg/api/bytes.go b/pkg/api/bytes.go index 066fbd384b3..4c1cd891df0 100644 --- a/pkg/api/bytes.go +++ b/pkg/api/bytes.go @@ -10,6 +10,7 @@ import ( "fmt" "net/http" "strconv" + "time" "github.com/ethersphere/bee/v2/pkg/accesscontrol" "github.com/ethersphere/bee/v2/pkg/cac" @@ -71,6 +72,8 @@ func (s *Service) bytesUploadHandler(w http.ResponseWriter, r *http.Request) { span.SetTag("tagID", tag) } + defer s.observeUploadSpeed(w, r, time.Now(), "bytes", deferred) + putter, err := s.newStamperPutter(ctx, putterOptions{ BatchID: headers.BatchID, TagID: tag, diff --git a/pkg/api/bzz.go b/pkg/api/bzz.go index 77909bc4e74..c05a73d177c 100644 --- a/pkg/api/bzz.go +++ b/pkg/api/bzz.go @@ -87,6 +87,8 @@ func (s *Service) bzzUploadHandler(w http.ResponseWriter, r *http.Request) { deferred = defaultUploadMethod(headers.Deferred) ) + defer s.observeUploadSpeed(w, r, time.Now(), "bzz", deferred) + if deferred || headers.Pin { tag, err = s.getOrCreateSessionID(headers.SwarmTag) if err != nil { diff --git a/pkg/api/metrics.go b/pkg/api/metrics.go index 7635468f4e3..6027d96fcfe 100644 --- a/pkg/api/metrics.go +++ b/pkg/api/metrics.go @@ -29,6 +29,8 @@ type metrics struct { ResponseCodeCounts *prometheus.CounterVec ContentApiDuration prometheus.HistogramVec + UploadSpeed *prometheus.HistogramVec + DownloadSpeed *prometheus.HistogramVec } func newMetrics() metrics { @@ -64,6 +66,20 @@ func newMetrics() metrics { Help: "Histogram of file upload API response durations.", Buckets: []float64{0.5, 1, 2.5, 5, 10, 30, 60}, }, []string{"filesize", "method"}), + UploadSpeed: prometheus.NewHistogramVec(prometheus.HistogramOpts{ + Namespace: m.Namespace, + Subsystem: subsystem, + Name: "upload_speed", + Help: "Histogram of upload speed in B/s.", + Buckets: []float64{0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5}, + }, []string{"endpoint", "mode"}), + DownloadSpeed: prometheus.NewHistogramVec(prometheus.HistogramOpts{ + Namespace: m.Namespace, + Subsystem: subsystem, + Name: "download_speed", + Help: "Histogram of download speed in B/s.", + Buckets: []float64{0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 7, 8, 9}, + }, []string{"endpoint"}), } } @@ -82,6 +98,14 @@ func (s *Service) Metrics() []prometheus.Collector { return m.PrometheusCollectorsFromFields(s.metrics) } +// StatusMetrics exposes metrics that are exposed on the status protocol. +func (s *Service) StatusMetrics() []prometheus.Collector { + return []prometheus.Collector{ + s.metrics.UploadSpeed, + s.metrics.DownloadSpeed, + } +} + func (s *Service) pageviewMetricsHandler(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { start := time.Now() @@ -114,18 +138,25 @@ type responseWriter struct { UpgradedResponseWriter statusCode int wroteHeader bool + size int } func newResponseWriter(w http.ResponseWriter) *responseWriter { // StatusOK is called by default if nothing else is called uw := w.(UpgradedResponseWriter) - return &responseWriter{uw, http.StatusOK, false} + return &responseWriter{uw, http.StatusOK, false, 0} } func (rw *responseWriter) Status() int { return rw.statusCode } +func (rr *responseWriter) Write(b []byte) (int, error) { + size, err := rr.UpgradedResponseWriter.Write(b) + rr.size += size + return size, err +} + func (rw *responseWriter) WriteHeader(code int) { if rw.wroteHeader { return diff --git a/pkg/api/router.go b/pkg/api/router.go index 30994f77f06..714217c9c11 100644 --- a/pkg/api/router.go +++ b/pkg/api/router.go @@ -243,6 +243,7 @@ func (s *Service) mountAPI() { handle("/bytes/{address}", jsonhttp.MethodHandler{ "GET": web.ChainHandlers( s.contentLengthMetricMiddleware(), + s.downloadSpeedMetricMiddleware("bytes"), s.newTracingHandler("bytes-download"), s.actDecryptionHandler(), web.FinalHandlerFunc(s.bytesGetHandler), @@ -325,6 +326,7 @@ func (s *Service) mountAPI() { s.contentLengthMetricMiddleware(), s.newTracingHandler("bzz-download"), s.actDecryptionHandler(), + s.downloadSpeedMetricMiddleware("bzz"), web.FinalHandlerFunc(s.bzzDownloadHandler), ), "HEAD": web.ChainHandlers( diff --git a/pkg/api/status_test.go b/pkg/api/status_test.go index 0ef4dc6c95c..c6e92bc7ddb 100644 --- a/pkg/api/status_test.go +++ b/pkg/api/status_test.go @@ -60,6 +60,7 @@ func TestGetStatus(t *testing.T) { mode.String(), ssMock, ssMock, + nil, ) statusSvc.SetSync(ssMock) @@ -86,6 +87,7 @@ func TestGetStatus(t *testing.T) { "", nil, nil, + nil, ), }) diff --git a/pkg/node/node.go b/pkg/node/node.go index 5bcf54cde5f..86a5697a2f7 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -77,6 +77,7 @@ import ( "github.com/ethersphere/bee/v2/pkg/util/syncutil" "github.com/hashicorp/go-multierror" ma "github.com/multiformats/go-multiaddr" + "github.com/prometheus/client_golang/prometheus" promc "github.com/prometheus/client_golang/prometheus" "golang.org/x/crypto/sha3" "golang.org/x/sync/errgroup" @@ -910,7 +911,16 @@ func NewBee( validStamp := postage.ValidStamp(batchStore) - nodeStatus := status.NewService(logger, p2ps, kad, beeNodeMode.String(), batchStore, localStore) + // metrics exposed on the status protocol + statusMetricsRegistry := prometheus.NewRegistry() + if localStore != nil { + statusMetricsRegistry.MustRegister(localStore.StatusMetrics()...) + } + if p2ps != nil { + statusMetricsRegistry.MustRegister(p2ps.StatusMetrics()...) + } + + nodeStatus := status.NewService(logger, p2ps, kad, beeNodeMode.String(), batchStore, localStore, statusMetricsRegistry) if err = p2ps.AddProtocol(nodeStatus.Protocol()); err != nil { return nil, fmt.Errorf("status service: %w", err) } @@ -968,6 +978,8 @@ func NewBee( retrieval := retrieval.New(swarmAddress, waitNetworkRFunc, localStore, p2ps, kad, logger, acc, pricer, tracer, o.RetrievalCaching) localStore.SetRetrievalService(retrieval) + statusMetricsRegistry.MustRegister(retrieval.StatusMetrics()...) + pusherService := pusher.New(networkID, localStore, pushSyncProtocol, batchStore, logger, warmupTime, pusher.DefaultRetryCount) b.pusherCloser = pusherService @@ -1196,6 +1208,9 @@ func NewBee( apiService.EnableFullAPI() apiService.SetRedistributionAgent(agent) + + // api metrics are constructed on api.Service.Configure + statusMetricsRegistry.MustRegister(apiService.StatusMetrics()...) } if err := kad.Start(ctx); err != nil { diff --git a/pkg/p2p/libp2p/libp2p.go b/pkg/p2p/libp2p/libp2p.go index 9055cdd8fc8..4d4c3773f92 100644 --- a/pkg/p2p/libp2p/libp2p.go +++ b/pkg/p2p/libp2p/libp2p.go @@ -563,7 +563,6 @@ func (s *Service) AddProtocol(p p2p.ProtocolSpec) (err error) { } s.host.SetStreamHandlerMatch(id, matcher, func(streamlibp2p network.Stream) { - start := time.Now() peerID := streamlibp2p.Conn().RemotePeer() overlay, found := s.peers.overlay(peerID) if !found { @@ -581,6 +580,7 @@ func (s *Service) AddProtocol(p p2p.ProtocolSpec) (err error) { stream := newStream(streamlibp2p, s.metrics) // exchange headers + headersStartTime := time.Now() ctx, cancel := context.WithTimeout(s.ctx, s.HeadersRWTimeout) defer cancel() if err := handleHeaders(ctx, ss.Headler, stream, overlay); err != nil { @@ -588,7 +588,7 @@ func (s *Service) AddProtocol(p p2p.ProtocolSpec) (err error) { _ = stream.Reset() return } - s.metrics.HeadersExchangeDuration.Observe(time.Since(start).Seconds()) + s.metrics.HeadersExchangeDuration.Observe(time.Since(headersStartTime).Seconds()) ctx, cancel = context.WithCancel(s.ctx) diff --git a/pkg/p2p/libp2p/metrics.go b/pkg/p2p/libp2p/metrics.go index 003970856d2..378ec26f6b0 100644 --- a/pkg/p2p/libp2p/metrics.go +++ b/pkg/p2p/libp2p/metrics.go @@ -123,3 +123,10 @@ func newMetrics() metrics { func (s *Service) Metrics() []prometheus.Collector { return append(m.PrometheusCollectorsFromFields(s.metrics), s.handshakeService.Metrics()...) } + +// StatusMetrics exposes metrics that are exposed on the status protocol. +func (s *Service) StatusMetrics() []prometheus.Collector { + return []prometheus.Collector{ + s.metrics.HeadersExchangeDuration, + } +} diff --git a/pkg/retrieval/metrics.go b/pkg/retrieval/metrics.go index f88f11d6c06..f987a75b2d6 100644 --- a/pkg/retrieval/metrics.go +++ b/pkg/retrieval/metrics.go @@ -105,3 +105,12 @@ func newMetrics() metrics { func (s *Service) Metrics() []prometheus.Collector { return m.PrometheusCollectorsFromFields(s.metrics) } + +// StatusMetrics exposes metrics that are exposed on the status protocol. +func (s *Service) StatusMetrics() []prometheus.Collector { + return []prometheus.Collector{ + s.metrics.RequestAttempts, + s.metrics.ChunkRetrieveTime, + s.metrics.RequestDurationTime, + } +} diff --git a/pkg/status/internal/pb/status.pb.go b/pkg/status/internal/pb/status.pb.go index d5cd8454235..225d292ab4c 100644 --- a/pkg/status/internal/pb/status.pb.go +++ b/pkg/status/internal/pb/status.pb.go @@ -64,17 +64,18 @@ var xxx_messageInfo_Get proto.InternalMessageInfo // the appropriate values that are a snapshot of the current state // of the running node. type Snapshot struct { - ReserveSize uint64 `protobuf:"varint,1,opt,name=ReserveSize,proto3" json:"ReserveSize,omitempty"` - PullsyncRate float64 `protobuf:"fixed64,2,opt,name=PullsyncRate,proto3" json:"PullsyncRate,omitempty"` - StorageRadius uint32 `protobuf:"varint,3,opt,name=StorageRadius,proto3" json:"StorageRadius,omitempty"` - ConnectedPeers uint64 `protobuf:"varint,4,opt,name=ConnectedPeers,proto3" json:"ConnectedPeers,omitempty"` - NeighborhoodSize uint64 `protobuf:"varint,5,opt,name=NeighborhoodSize,proto3" json:"NeighborhoodSize,omitempty"` - BeeMode string `protobuf:"bytes,6,opt,name=BeeMode,proto3" json:"BeeMode,omitempty"` - BatchCommitment uint64 `protobuf:"varint,7,opt,name=BatchCommitment,proto3" json:"BatchCommitment,omitempty"` - IsReachable bool `protobuf:"varint,8,opt,name=IsReachable,proto3" json:"IsReachable,omitempty"` - ReserveSizeWithinRadius uint64 `protobuf:"varint,9,opt,name=ReserveSizeWithinRadius,proto3" json:"ReserveSizeWithinRadius,omitempty"` - LastSyncedBlock uint64 `protobuf:"varint,10,opt,name=LastSyncedBlock,proto3" json:"LastSyncedBlock,omitempty"` - CommittedDepth uint32 `protobuf:"varint,11,opt,name=CommittedDepth,proto3" json:"CommittedDepth,omitempty"` + ReserveSize uint64 `protobuf:"varint,1,opt,name=ReserveSize,proto3" json:"ReserveSize,omitempty"` + PullsyncRate float64 `protobuf:"fixed64,2,opt,name=PullsyncRate,proto3" json:"PullsyncRate,omitempty"` + StorageRadius uint32 `protobuf:"varint,3,opt,name=StorageRadius,proto3" json:"StorageRadius,omitempty"` + ConnectedPeers uint64 `protobuf:"varint,4,opt,name=ConnectedPeers,proto3" json:"ConnectedPeers,omitempty"` + NeighborhoodSize uint64 `protobuf:"varint,5,opt,name=NeighborhoodSize,proto3" json:"NeighborhoodSize,omitempty"` + BeeMode string `protobuf:"bytes,6,opt,name=BeeMode,proto3" json:"BeeMode,omitempty"` + BatchCommitment uint64 `protobuf:"varint,7,opt,name=BatchCommitment,proto3" json:"BatchCommitment,omitempty"` + IsReachable bool `protobuf:"varint,8,opt,name=IsReachable,proto3" json:"IsReachable,omitempty"` + ReserveSizeWithinRadius uint64 `protobuf:"varint,9,opt,name=ReserveSizeWithinRadius,proto3" json:"ReserveSizeWithinRadius,omitempty"` + LastSyncedBlock uint64 `protobuf:"varint,10,opt,name=LastSyncedBlock,proto3" json:"LastSyncedBlock,omitempty"` + CommittedDepth uint32 `protobuf:"varint,11,opt,name=CommittedDepth,proto3" json:"CommittedDepth,omitempty"` + Metrics map[string]string `protobuf:"bytes,12,rep,name=Metrics,proto3" json:"Metrics,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *Snapshot) Reset() { *m = Snapshot{} } @@ -187,36 +188,48 @@ func (m *Snapshot) GetCommittedDepth() uint32 { return 0 } +func (m *Snapshot) GetMetrics() map[string]string { + if m != nil { + return m.Metrics + } + return nil +} + func init() { proto.RegisterType((*Get)(nil), "status.Get") proto.RegisterType((*Snapshot)(nil), "status.Snapshot") + proto.RegisterMapType((map[string]string)(nil), "status.Snapshot.MetricsEntry") } func init() { proto.RegisterFile("status.proto", fileDescriptor_dfe4fce6682daf5b) } var fileDescriptor_dfe4fce6682daf5b = []byte{ - // 332 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xd1, 0x4f, 0x4b, 0xc3, 0x30, - 0x18, 0x06, 0xf0, 0x65, 0xff, 0x97, 0x6d, 0x2a, 0xb9, 0x98, 0x83, 0x94, 0x32, 0x44, 0x8a, 0x07, - 0x2f, 0x5e, 0x3c, 0x77, 0x82, 0x08, 0x2a, 0x23, 0x3d, 0x08, 0xde, 0xd2, 0xf6, 0x65, 0x29, 0x76, - 0x49, 0x69, 0xde, 0x09, 0xf3, 0x53, 0xf8, 0x81, 0xfc, 0x00, 0x1e, 0x77, 0xf4, 0x28, 0xdb, 0x17, - 0x91, 0x65, 0x0a, 0x5b, 0xc5, 0xe3, 0xfb, 0x6b, 0x79, 0xf3, 0xe4, 0x09, 0x1d, 0x58, 0x94, 0x38, - 0xb7, 0x17, 0x45, 0x69, 0xd0, 0xb0, 0xf6, 0x76, 0x1a, 0xb5, 0x68, 0xe3, 0x06, 0x70, 0xf4, 0xde, - 0xa0, 0xdd, 0x48, 0xcb, 0xc2, 0x2a, 0x83, 0xcc, 0xa7, 0x7d, 0x01, 0x16, 0xca, 0x17, 0x88, 0xb2, - 0x57, 0xe0, 0xc4, 0x27, 0x41, 0x53, 0xec, 0x12, 0x1b, 0xd1, 0xc1, 0x64, 0x9e, 0xe7, 0x76, 0xa1, - 0x13, 0x21, 0x11, 0x78, 0xdd, 0x27, 0x01, 0x11, 0x7b, 0xc6, 0x4e, 0xe9, 0x30, 0x42, 0x53, 0xca, - 0x29, 0x08, 0x99, 0x66, 0x73, 0xcb, 0x1b, 0x3e, 0x09, 0x86, 0x62, 0x1f, 0xd9, 0x19, 0x3d, 0x18, - 0x1b, 0xad, 0x21, 0x41, 0x48, 0x27, 0x00, 0xa5, 0xe5, 0x4d, 0x77, 0x5c, 0x45, 0xd9, 0x39, 0x3d, - 0x7a, 0x80, 0x6c, 0xaa, 0x62, 0x53, 0x2a, 0x63, 0x52, 0x17, 0xac, 0xe5, 0xfe, 0xfc, 0xe3, 0x8c, - 0xd3, 0x4e, 0x08, 0x70, 0x6f, 0x52, 0xe0, 0x6d, 0x9f, 0x04, 0x3d, 0xf1, 0x3b, 0xb2, 0x80, 0x1e, - 0x86, 0x12, 0x13, 0x35, 0x36, 0xb3, 0x59, 0x86, 0x33, 0xd0, 0xc8, 0x3b, 0x6e, 0x49, 0x95, 0x37, - 0x1d, 0xdc, 0x5a, 0x01, 0x32, 0x51, 0x32, 0xce, 0x81, 0x77, 0x7d, 0x12, 0x74, 0xc5, 0x2e, 0xb1, - 0x2b, 0x7a, 0xbc, 0x53, 0xc9, 0x63, 0x86, 0x2a, 0xd3, 0x3f, 0x37, 0xed, 0xb9, 0x9d, 0xff, 0x7d, - 0xde, 0xa4, 0xb8, 0x93, 0x16, 0xa3, 0x85, 0x4e, 0x20, 0x0d, 0x73, 0x93, 0x3c, 0x73, 0xba, 0x4d, - 0x51, 0xe1, 0x6d, 0x3b, 0x9b, 0x4c, 0x08, 0xe9, 0x35, 0x14, 0xa8, 0x78, 0xdf, 0x95, 0x58, 0xd1, - 0xf0, 0xe4, 0x63, 0xe5, 0x91, 0xe5, 0xca, 0x23, 0x5f, 0x2b, 0x8f, 0xbc, 0xad, 0xbd, 0xda, 0x72, - 0xed, 0xd5, 0x3e, 0xd7, 0x5e, 0xed, 0xa9, 0x5e, 0xc4, 0x71, 0xdb, 0x3d, 0xf9, 0xe5, 0x77, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x97, 0x7e, 0x47, 0xd4, 0x02, 0x02, 0x00, 0x00, + // 400 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x8a, 0xd4, 0x40, + 0x10, 0xc6, 0xa7, 0xe7, 0xff, 0xd4, 0xcc, 0xea, 0xd2, 0x08, 0x36, 0xa2, 0x21, 0x0c, 0x22, 0xc1, + 0xc3, 0x1c, 0xf4, 0xe0, 0xb2, 0xc7, 0x59, 0x45, 0x04, 0x57, 0x96, 0x9e, 0x83, 0xe0, 0xad, 0x93, + 0x14, 0x9b, 0xb0, 0x99, 0xee, 0x90, 0xae, 0x2c, 0xc4, 0xa7, 0xf0, 0x55, 0x7c, 0x0b, 0x8f, 0x7b, + 0xf4, 0x28, 0x33, 0x2f, 0x22, 0xe9, 0xcc, 0x40, 0x26, 0xe2, 0xad, 0xeb, 0x57, 0x45, 0xf5, 0xd7, + 0xdf, 0xd7, 0xb0, 0xb0, 0xa4, 0xa8, 0xb4, 0xab, 0xbc, 0x30, 0x64, 0xf8, 0xb8, 0xa9, 0x96, 0x23, + 0x18, 0x7c, 0x44, 0x5a, 0xfe, 0x1c, 0xc2, 0x74, 0xa3, 0x55, 0x6e, 0x13, 0x43, 0xdc, 0x87, 0xb9, + 0x44, 0x8b, 0xc5, 0x3d, 0x6e, 0xd2, 0xef, 0x28, 0x98, 0xcf, 0x82, 0xa1, 0x6c, 0x23, 0xbe, 0x84, + 0xc5, 0x4d, 0x99, 0x65, 0xb6, 0xd2, 0x91, 0x54, 0x84, 0xa2, 0xef, 0xb3, 0x80, 0xc9, 0x13, 0xc6, + 0x5f, 0xc2, 0xd9, 0x86, 0x4c, 0xa1, 0x6e, 0x51, 0xaa, 0x38, 0x2d, 0xad, 0x18, 0xf8, 0x2c, 0x38, + 0x93, 0xa7, 0x90, 0xbf, 0x82, 0x47, 0x57, 0x46, 0x6b, 0x8c, 0x08, 0xe3, 0x1b, 0xc4, 0xc2, 0x8a, + 0xa1, 0xbb, 0xae, 0x43, 0xf9, 0x6b, 0x38, 0xff, 0x82, 0xe9, 0x6d, 0x12, 0x9a, 0x22, 0x31, 0x26, + 0x76, 0xc2, 0x46, 0x6e, 0xf2, 0x1f, 0xce, 0x05, 0x4c, 0xd6, 0x88, 0xd7, 0x26, 0x46, 0x31, 0xf6, + 0x59, 0x30, 0x93, 0xc7, 0x92, 0x07, 0xf0, 0x78, 0xad, 0x28, 0x4a, 0xae, 0xcc, 0x76, 0x9b, 0xd2, + 0x16, 0x35, 0x89, 0x89, 0x5b, 0xd2, 0xc5, 0xb5, 0x07, 0x9f, 0xac, 0x44, 0x15, 0x25, 0x2a, 0xcc, + 0x50, 0x4c, 0x7d, 0x16, 0x4c, 0x65, 0x1b, 0xf1, 0x0b, 0x78, 0xda, 0xb2, 0xe4, 0x6b, 0x4a, 0x49, + 0xaa, 0x0f, 0x2f, 0x9d, 0xb9, 0x9d, 0xff, 0x6b, 0xd7, 0x2a, 0x3e, 0x2b, 0x4b, 0x9b, 0x4a, 0x47, + 0x18, 0xaf, 0x33, 0x13, 0xdd, 0x09, 0x68, 0x54, 0x74, 0x70, 0xe3, 0x4e, 0xad, 0x89, 0x30, 0x7e, + 0x8f, 0x39, 0x25, 0x62, 0xee, 0x4c, 0xec, 0x50, 0xfe, 0x0e, 0x26, 0xd7, 0x48, 0x45, 0x1a, 0x59, + 0xb1, 0xf0, 0x07, 0xc1, 0xfc, 0xcd, 0x8b, 0xd5, 0x21, 0xed, 0x63, 0xa8, 0xab, 0x43, 0xff, 0x83, + 0xa6, 0xa2, 0x92, 0xc7, 0xe9, 0x67, 0x97, 0xb0, 0x68, 0x37, 0xf8, 0x39, 0x0c, 0xee, 0xb0, 0x72, + 0x91, 0xcf, 0x64, 0x7d, 0xe4, 0x4f, 0x60, 0x74, 0xaf, 0xb2, 0xb2, 0xc9, 0x78, 0x26, 0x9b, 0xe2, + 0xb2, 0x7f, 0xc1, 0xd6, 0xcf, 0x7f, 0xed, 0x3c, 0xf6, 0xb0, 0xf3, 0xd8, 0x9f, 0x9d, 0xc7, 0x7e, + 0xec, 0xbd, 0xde, 0xc3, 0xde, 0xeb, 0xfd, 0xde, 0x7b, 0xbd, 0x6f, 0xfd, 0x3c, 0x0c, 0xc7, 0xee, + 0x9f, 0xbd, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x23, 0x3c, 0xa8, 0x9b, 0x77, 0x02, 0x00, 0x00, } func (m *Get) Marshal() (dAtA []byte, err error) { @@ -262,6 +275,25 @@ func (m *Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Metrics) > 0 { + for k := range m.Metrics { + v := m.Metrics[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintStatus(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintStatus(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintStatus(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x62 + } + } if m.CommittedDepth != 0 { i = encodeVarintStatus(dAtA, i, uint64(m.CommittedDepth)) i-- @@ -388,6 +420,14 @@ func (m *Snapshot) Size() (n int) { if m.CommittedDepth != 0 { n += 1 + sovStatus(uint64(m.CommittedDepth)) } + if len(m.Metrics) > 0 { + for k, v := range m.Metrics { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovStatus(uint64(len(k))) + 1 + len(v) + sovStatus(uint64(len(v))) + n += mapEntrySize + 1 + sovStatus(uint64(mapEntrySize)) + } + } return n } @@ -432,10 +472,7 @@ func (m *Get) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStatus - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStatus } if (iNdEx + skippy) > l { @@ -694,16 +731,140 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { break } } + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metrics", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStatus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStatus + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStatus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metrics == nil { + m.Metrics = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStatus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStatus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthStatus + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthStatus + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStatus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthStatus + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthStatus + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipStatus(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStatus + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Metrics[mapkey] = mapvalue + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStatus(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthStatus - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthStatus } if (iNdEx + skippy) > l { diff --git a/pkg/status/internal/pb/status.proto b/pkg/status/internal/pb/status.proto index 7885139fd9c..c552b7fc501 100644 --- a/pkg/status/internal/pb/status.proto +++ b/pkg/status/internal/pb/status.proto @@ -26,4 +26,5 @@ message Snapshot { uint64 ReserveSizeWithinRadius = 9; uint64 LastSyncedBlock = 10; uint32 CommittedDepth = 11; + map Metrics = 12; } diff --git a/pkg/status/status.go b/pkg/status/status.go index 38cccc7bea1..7fb5e46a592 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -7,6 +7,7 @@ package status import ( "context" "fmt" + "strings" "github.com/ethersphere/bee/v2/pkg/log" "github.com/ethersphere/bee/v2/pkg/p2p" @@ -15,6 +16,8 @@ import ( "github.com/ethersphere/bee/v2/pkg/status/internal/pb" "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/ethersphere/bee/v2/pkg/topology" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/common/expfmt" ) // loggerName is the tree path name of the logger for this package. @@ -22,7 +25,7 @@ const loggerName = "status" const ( protocolName = "status" - protocolVersion = "1.1.2" + protocolVersion = "1.1.3" streamName = "status" ) @@ -53,10 +56,16 @@ type Service struct { streamer p2p.Streamer topologyDriver topologyDriver - beeMode string - reserve Reserve - sync SyncReporter - chainState postage.ChainStateGetter + beeMode string + reserve Reserve + sync SyncReporter + chainState postage.ChainStateGetter + metricsRegistry *prometheus.Registry +} + +type Metrics struct { + UploadSpeed prometheus.Histogram + DownloadSpeed prometheus.Histogram } // NewService creates a new status service. @@ -67,14 +76,16 @@ func NewService( beeMode string, chainState postage.ChainStateGetter, reserve Reserve, + metricsRegistry *prometheus.Registry, ) *Service { return &Service{ - logger: logger.WithName(loggerName).Register(), - streamer: streamer, - topologyDriver: topology, - beeMode: beeMode, - chainState: chainState, - reserve: reserve, + logger: logger.WithName(loggerName).Register(), + streamer: streamer, + topologyDriver: topology, + beeMode: beeMode, + chainState: chainState, + reserve: reserve, + metricsRegistry: metricsRegistry, } } @@ -120,6 +131,11 @@ func (s *Service) LocalSnapshot() (*Snapshot, error) { return nil, fmt.Errorf("iterate connected peers: %w", err) } + metrics, err := s.encodeMetrics() + if err != nil { + return nil, fmt.Errorf("encode metrics: %w", err) + } + return &Snapshot{ BeeMode: s.beeMode, ReserveSize: reserveSize, @@ -132,6 +148,7 @@ func (s *Service) LocalSnapshot() (*Snapshot, error) { IsReachable: s.topologyDriver.IsReachable(), LastSyncedBlock: s.chainState.GetChainState().Block, CommittedDepth: uint32(committedDepth), + Metrics: metrics, }, nil } @@ -204,3 +221,26 @@ func (s *Service) handler(ctx context.Context, _ p2p.Peer, stream p2p.Stream) er func (s *Service) SetSync(sync SyncReporter) { s.sync = sync } + +func (s *Service) encodeMetrics() (map[string]string, error) { + if s.metricsRegistry == nil { + return nil, nil + } + + metricFamilies, err := s.metricsRegistry.Gather() + if err != nil { + return nil, fmt.Errorf("gather metrics: %w", err) + } + + metrics := make(map[string]string, len(metricFamilies)) + for _, m := range metricFamilies { + var metricsBuilder strings.Builder + encoder := expfmt.NewEncoder(&metricsBuilder, expfmt.NewFormat(expfmt.TypeTextPlain)) + if err := encoder.Encode(m); err != nil { + return nil, fmt.Errorf("encode metric %s: %w", m.GetName(), err) + } + metrics[m.GetName()] = metricsBuilder.String() + } + + return metrics, nil +} diff --git a/pkg/status/status_test.go b/pkg/status/status_test.go index 5c60e887959..09213ec71d4 100644 --- a/pkg/status/status_test.go +++ b/pkg/status/status_test.go @@ -19,6 +19,7 @@ import ( "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/ethersphere/bee/v2/pkg/topology" "github.com/google/go-cmp/cmp" + "github.com/prometheus/client_golang/prometheus" ) func TestStatus(t *testing.T) { @@ -34,6 +35,58 @@ func TestStatus(t *testing.T) { IsReachable: true, LastSyncedBlock: 6092500, CommittedDepth: 1, + Metrics: map[string]string{ + "test_response_duration_seconds": `# HELP test_response_duration_seconds Histogram of API response durations. +# TYPE test_response_duration_seconds histogram +test_response_duration_seconds_bucket{test="label",le="0.01"} 1 +test_response_duration_seconds_bucket{test="label",le="0.1"} 1 +test_response_duration_seconds_bucket{test="label",le="0.25"} 2 +test_response_duration_seconds_bucket{test="label",le="0.5"} 2 +test_response_duration_seconds_bucket{test="label",le="1"} 3 +test_response_duration_seconds_bucket{test="label",le="2.5"} 4 +test_response_duration_seconds_bucket{test="label",le="5"} 4 +test_response_duration_seconds_bucket{test="label",le="10"} 6 +test_response_duration_seconds_bucket{test="label",le="+Inf"} 7 +test_response_duration_seconds_sum{test="label"} 78.15 +test_response_duration_seconds_count{test="label"} 7 +`, + "test_upload_count_total": `# HELP test_upload_count_total This metric is just for test. +# TYPE test_upload_count_total counter +test_upload_count_total 12 +`, + }, + } + + metricsRegistry := prometheus.NewRegistry() + + h := prometheus.NewHistogram(prometheus.HistogramOpts{ + Namespace: "test", + Name: "response_duration_seconds", + Help: "Histogram of API response durations.", + Buckets: []float64{0.01, 0.1, 0.25, 0.5, 1, 2.5, 5, 10}, + ConstLabels: prometheus.Labels{ + "test": "label", + }, + }) + + g := prometheus.NewCounter(prometheus.CounterOpts{ + Namespace: "test", + Help: "This metric is just for test.", + Name: "upload_count_total", + }) + + metricsRegistry.MustRegister(h) + metricsRegistry.MustRegister(g) + + for range 12 { + g.Inc() + } + + points := []float64{0.25, 5.2, 1.5, 1, 5.2, 0, 65} + var sum float64 + for _, p := range points { + h.Observe(p) + sum += p } sssMock := &statusSnapshotMock{want} @@ -47,13 +100,14 @@ func TestStatus(t *testing.T) { want.BeeMode, sssMock, sssMock, + metricsRegistry, ) peer1.SetSync(sssMock) recorder := streamtest.New(streamtest.WithProtocols(peer1.Protocol())) - peer2 := status.NewService(log.Noop, recorder, peersIterMock, "", nil, nil) + peer2 := status.NewService(log.Noop, recorder, peersIterMock, "", nil, nil, nil) address := swarm.MustParseHexAddress("ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c") @@ -127,11 +181,12 @@ func TestStatusLightNode(t *testing.T) { want.BeeMode, sssMock, nil, + nil, ) recorder := streamtest.New(streamtest.WithProtocols(peer1.Protocol())) - peer2 := status.NewService(log.Noop, recorder, peersIterMock, "", nil, nil) + peer2 := status.NewService(log.Noop, recorder, peersIterMock, "", nil, nil, nil) address := swarm.MustParseHexAddress("ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c") diff --git a/pkg/storer/internal/transaction/transaction.go b/pkg/storer/internal/transaction/transaction.go index 7fb247da391..ae97e06ce3b 100644 --- a/pkg/storer/internal/transaction/transaction.go +++ b/pkg/storer/internal/transaction/transaction.go @@ -146,6 +146,13 @@ func (s *store) Metrics() []prometheus.Collector { return m.PrometheusCollectorsFromFields(s.metrics) } +// StatusMetrics exposes metrics that are exposed on the status protocol. +func (s *store) StatusMetrics() []prometheus.Collector { + return []prometheus.Collector{ + s.metrics.MethodDuration, + } +} + func (s *store) Close() error { return errors.Join(s.bstore.Close(), s.sharky.Close()) } diff --git a/pkg/storer/storer.go b/pkg/storer/storer.go index 32223e401de..386fe1bd00f 100644 --- a/pkg/storer/storer.go +++ b/pkg/storer/storer.go @@ -605,6 +605,23 @@ func (db *DB) Metrics() []prometheus.Collector { return collectors } +// StatusMetrics exposes metrics that are exposed on the status protocol. +func (db *DB) StatusMetrics() []prometheus.Collector { + collectors := []prometheus.Collector{ + db.metrics.MethodCallsDuration, + } + + type Collector interface { + StatusMetrics() []prometheus.Collector + } + + if v, ok := db.storage.(Collector); ok { + collectors = append(collectors, v.StatusMetrics()...) + } + + return collectors +} + func (db *DB) Close() error { close(db.quit)