diff --git a/go.mod b/go.mod index a3618007..584b6c2d 100644 --- a/go.mod +++ b/go.mod @@ -8,14 +8,14 @@ require ( github.com/ava-labs/teleporter v1.0.5 github.com/aws/aws-sdk-go-v2 v1.30.4 github.com/aws/aws-sdk-go-v2/config v1.27.9 - github.com/aws/aws-sdk-go-v2/service/kms v1.35.4 + github.com/aws/aws-sdk-go-v2/service/kms v1.35.5 github.com/ethereum/go-ethereum v1.13.8 github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.34.1 github.com/pingcap/errors v0.11.4 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.20.1 + github.com/prometheus/client_golang v1.20.2 github.com/redis/go-redis/v9 v9.6.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.16.0 diff --git a/go.sum b/go.sum index 6ddab171..556ff3b2 100644 --- a/go.sum +++ b/go.sum @@ -84,8 +84,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1 h1:EyBZibR github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.1/go.mod h1:JKpmtYhhPs7D97NL/ltqz7yCkERFW5dOlHyVl66ZYF8= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6 h1:b+E7zIUHMmcB4Dckjpkapoy47W6C9QBv/zoUP+Hn8Kc= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.6/go.mod h1:S2fNV0rxrP78NhPbCZeQgY8H9jdDMeGtwcfZIRxzBqU= -github.com/aws/aws-sdk-go-v2/service/kms v1.35.4 h1:mG1MH6yPwT5gNEeBrhig3FHc4mK0QaZOXsmQUbphP6Y= -github.com/aws/aws-sdk-go-v2/service/kms v1.35.4/go.mod h1:A5CS0VRmxxj2YKYLCY08l/Zzbd01m6JZn0WzxgT1OCA= +github.com/aws/aws-sdk-go-v2/service/kms v1.35.5 h1:XUomV7SiclZl1QuXORdGcfFqHxEHET7rmNGtxTfNB+M= +github.com/aws/aws-sdk-go-v2/service/kms v1.35.5/go.mod h1:A5CS0VRmxxj2YKYLCY08l/Zzbd01m6JZn0WzxgT1OCA= github.com/aws/aws-sdk-go-v2/service/sso v1.20.3 h1:mnbuWHOcM70/OFUlZZ5rcdfA8PflGXXiefU/O+1S3+8= github.com/aws/aws-sdk-go-v2/service/sso v1.20.3/go.mod h1:5HFu51Elk+4oRBZVxmHrSds5jFXmFj8C3w7DVF2gnrs= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.3 h1:uLq0BKatTmDzWa/Nu4WO0M1AaQDaPpwTKAeByEc6WFM= @@ -518,8 +518,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= 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/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= -github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= +github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 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= diff --git a/peers/app_request_network.go b/peers/app_request_network.go index 512a32a8..c6d9d4af 100644 --- a/peers/app_request_network.go +++ b/peers/app_request_network.go @@ -61,7 +61,7 @@ func NewNetwork( } // Create the handler for handling inbound app responses - handler, err := NewRelayerExternalHandler(logger, prometheus.DefaultRegisterer) + handler, err := NewRelayerExternalHandler(logger, metrics) if err != nil { logger.Error( "Failed to create p2p network handler", diff --git a/peers/app_request_netrwork_metrics.go b/peers/app_request_network_metrics.go similarity index 67% rename from peers/app_request_netrwork_metrics.go rename to peers/app_request_network_metrics.go index 12c5ea6b..b585533e 100644 --- a/peers/app_request_netrwork_metrics.go +++ b/peers/app_request_network_metrics.go @@ -13,6 +13,8 @@ var ( type AppRequestNetworkMetrics struct { infoAPICallLatencyMS prometheus.Histogram pChainAPICallLatencyMS prometheus.Histogram + connects prometheus.Counter + disconnects prometheus.Counter } func newAppRequestNetworkMetrics(registerer prometheus.Registerer) (*AppRequestNetworkMetrics, error) { @@ -40,8 +42,32 @@ func newAppRequestNetworkMetrics(registerer prometheus.Registerer) (*AppRequestN } registerer.MustRegister(pChainAPICallLatencyMS) + connects := prometheus.NewCounter( + prometheus.CounterOpts{ + Name: "connects", + Help: "Number of connected events", + }, + ) + if connects == nil { + return nil, ErrFailedToCreateAppRequestNetworkMetrics + } + registerer.MustRegister(connects) + + disconnects := prometheus.NewCounter( + prometheus.CounterOpts{ + Name: "disconnects", + Help: "Number of disconnected events", + }, + ) + if disconnects == nil { + return nil, ErrFailedToCreateAppRequestNetworkMetrics + } + registerer.MustRegister(disconnects) + return &AppRequestNetworkMetrics{ infoAPICallLatencyMS: infoAPICallLatencyMS, pChainAPICallLatencyMS: pChainAPICallLatencyMS, + connects: connects, + disconnects: disconnects, }, nil } diff --git a/peers/external_handler.go b/peers/external_handler.go index 01c37844..be4e0518 100644 --- a/peers/external_handler.go +++ b/peers/external_handler.go @@ -30,6 +30,7 @@ type RelayerExternalHandler struct { responseChans map[uint32]chan message.InboundMessage responsesCount map[uint32]expectedResponses timeoutManager timer.AdaptiveTimeoutManager + metrics *AppRequestNetworkMetrics } // expectedResponses counts the number of responses and compares against the expected number of responses @@ -41,7 +42,7 @@ type expectedResponses struct { // Teleporter application relayer, as well as handle timeouts. func NewRelayerExternalHandler( logger logging.Logger, - registerer prometheus.Registerer, + metrics *AppRequestNetworkMetrics, ) (*RelayerExternalHandler, error) { // TODO: Leaving this static for now, but we may want to have this as a config option cfg := timer.AdaptiveTimeoutConfig{ @@ -52,7 +53,7 @@ func NewRelayerExternalHandler( TimeoutHalflife: constants.DefaultNetworkTimeoutHalflife, } - timeoutManager, err := timer.NewAdaptiveTimeoutManager(&cfg, registerer) + timeoutManager, err := timer.NewAdaptiveTimeoutManager(&cfg, prometheus.DefaultRegisterer) if err != nil { logger.Error( "Failed to create timeout manager", @@ -69,6 +70,7 @@ func NewRelayerExternalHandler( responseChans: make(map[uint32]chan message.InboundMessage), responsesCount: make(map[uint32]expectedResponses), timeoutManager: timeoutManager, + metrics: metrics, }, nil } @@ -105,6 +107,7 @@ func (h *RelayerExternalHandler) Connected(nodeID ids.NodeID, version *version.A zap.Stringer("version", version), zap.Stringer("subnetID", subnetID), ) + h.metrics.connects.Inc() } func (h *RelayerExternalHandler) Disconnected(nodeID ids.NodeID) { @@ -112,6 +115,7 @@ func (h *RelayerExternalHandler) Disconnected(nodeID ids.NodeID) { "Disconnected", zap.Stringer("nodeID", nodeID), ) + h.metrics.disconnects.Inc() } // RegisterRequestID registers an AppRequest by requestID, and marks the number of diff --git a/relayer/main/main.go b/relayer/main/main.go index 5340bba2..358561c7 100644 --- a/relayer/main/main.go +++ b/relayer/main/main.go @@ -143,6 +143,9 @@ func main() { // TODO: remove this from here once trackedSubnets are no longer referenced // by ping messages in avalanchego for _, sourceBlockchain := range cfg.SourceBlockchains { + if sourceBlockchain.GetSubnetID() == constants.PrimaryNetworkID { + continue + } trackedSubnets.Add(sourceBlockchain.GetSubnetID()) }