-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add incoming/outgoing connections metrics (#959)
* Add incoming/outgoing connections metrics * Move IncomingConnectionsStatsHandler to the net package * Set IncomingConnectionTimestamp properly and rename GroupConnections to OutgoingConnections * Add finer-grained outgoing connection tracking * Replace OutgoingConnectionTimestamp with OutgoingConnectionState * Fix logic when emitting the outgoing connections metric * Bump CI
- Loading branch information
Showing
4 changed files
with
91 additions
and
30 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
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,33 @@ | ||
package net | ||
|
||
import ( | ||
"context" | ||
|
||
"google.golang.org/grpc/stats" | ||
|
||
"github.com/drand/drand/metrics" | ||
) | ||
|
||
type incomingConnectionsStatsHandler struct { | ||
stats.Handler | ||
} | ||
|
||
func (h incomingConnectionsStatsHandler) TagRPC(ctx context.Context, tagInfo *stats.RPCTagInfo) context.Context { | ||
// no-op | ||
return ctx | ||
} | ||
|
||
func (h incomingConnectionsStatsHandler) HandleRPC(ctx context.Context, rpcStats stats.RPCStats) { | ||
// no-op | ||
} | ||
|
||
func (h incomingConnectionsStatsHandler) TagConn(ctx context.Context, tagInfo *stats.ConnTagInfo) context.Context { | ||
metrics.IncomingConnectionTimestamp.WithLabelValues(tagInfo.RemoteAddr.String()).SetToCurrentTime() | ||
return ctx | ||
} | ||
|
||
func (h incomingConnectionsStatsHandler) HandleConn(ctx context.Context, connStats stats.ConnStats) { | ||
// no-op | ||
} | ||
|
||
var IncomingConnectionsStatsHandler = incomingConnectionsStatsHandler{} |