This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from primevprotocol/iowar/p2p_metrics.0
metrics: initial libp2p metrics
- Loading branch information
Showing
3 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package libp2p | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
type metrics struct { | ||
BlockedPeerCount prometheus.Counter | ||
RejectedConnectionCount prometheus.Counter | ||
FailedIncomingHandshakeCount prometheus.Counter | ||
FailedOutgoingHandshakeCount prometheus.Counter | ||
} | ||
|
||
func newMetrics(registry prometheus.Registerer, namespace string) *metrics { | ||
subsystem := "libp2p" | ||
|
||
m := &metrics{ | ||
BlockedPeerCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "blocked_peer_count", | ||
Help: "Number of blocked peers.", | ||
}), | ||
RejectedConnectionCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "rejected_connection_count", | ||
Help: "Number of rejected connection count.", | ||
}), | ||
FailedIncomingHandshakeCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "failed_incoming_handshake_count", | ||
Help: "Number of failed incoming handshake count.", | ||
}), | ||
FailedOutgoingHandshakeCount: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: namespace, | ||
Subsystem: subsystem, | ||
Name: "failed_outgoing_handshake_count", | ||
Help: "Number of failed outgoing handshake count.", | ||
}), | ||
} | ||
|
||
registry.MustRegister( | ||
m.BlockedPeerCount, | ||
m.RejectedConnectionCount, | ||
m.FailedIncomingHandshakeCount, | ||
m.FailedOutgoingHandshakeCount, | ||
) | ||
|
||
return m | ||
} |