From acbc1114636d7ef6390df2383da41cd8957f44a8 Mon Sep 17 00:00:00 2001 From: Dan Ramich Date: Tue, 28 Jan 2020 16:12:30 -0700 Subject: [PATCH] Move session metrics to remotedialer --- metrics/register.go | 12 --- metrics/session_manager.go | 204 ------------------------------------- 2 files changed, 216 deletions(-) delete mode 100644 metrics/session_manager.go diff --git a/metrics/register.go b/metrics/register.go index d5b11f177..2e857e705 100644 --- a/metrics/register.go +++ b/metrics/register.go @@ -16,17 +16,5 @@ func init() { // Generic controller metrics prometheus.MustRegister(TotalHandlerExecution) prometheus.MustRegister(TotalHandlerFailure) - - // Session metrics - prometheus.MustRegister(TotalAddWS) - prometheus.MustRegister(TotalRemoveWS) - prometheus.MustRegister(TotalAddConnectionsForWS) - prometheus.MustRegister(TotalRemoveConnectionsForWS) - prometheus.MustRegister(TotalTransmitBytesOnWS) - prometheus.MustRegister(TotalTransmitErrorBytesOnWS) - prometheus.MustRegister(TotalReceiveBytesOnWS) - prometheus.MustRegister(TotalAddPeerAttempt) - prometheus.MustRegister(TotalPeerConnected) - prometheus.MustRegister(TotalPeerDisConnected) } } diff --git a/metrics/session_manager.go b/metrics/session_manager.go deleted file mode 100644 index d639cc9d3..000000000 --- a/metrics/session_manager.go +++ /dev/null @@ -1,204 +0,0 @@ -package metrics - -import ( - "github.com/prometheus/client_golang/prometheus" -) - -const MetricsSessionServerEnv = "NORMAN_SESSION_SERVER_METRICS" - -var ( - TotalAddWS = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_add_websocket_session", - Help: "Total count of added websocket sessions", - }, - []string{"clientkey", "peer"}) - - TotalRemoveWS = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_remove_websocket_session", - Help: "Total count of removed websocket sessions", - }, - []string{"clientkey", "peer"}) - - TotalAddConnectionsForWS = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_add_connections", - Help: "Total count of added connections", - }, - []string{"clientkey", "proto", "addr"}, - ) - - TotalRemoveConnectionsForWS = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_remove_connections", - Help: "Total count of removed connections", - }, - []string{"clientkey", "proto", "addr"}, - ) - - TotalTransmitBytesOnWS = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_transmit_bytes", - Help: "Total bytes transmited", - }, - []string{"clientkey"}, - ) - - TotalTransmitErrorBytesOnWS = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_transmit_error_bytes", - Help: "Total error bytes transmited", - }, - []string{"clientkey"}, - ) - - TotalReceiveBytesOnWS = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_receive_bytes", - Help: "Total bytes recieved", - }, - []string{"clientkey"}, - ) - - TotalAddPeerAttempt = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_peer_ws_attempt", - Help: "Total count of attempts to establish websocket session to other rancher-server", - }, - []string{"peer"}, - ) - TotalPeerConnected = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_peer_ws_connected", - Help: "Total count of connected websocket sessions to other rancher-server", - }, - []string{"peer"}, - ) - TotalPeerDisConnected = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: "session_server", - Name: "total_peer_ws_disconnected", - Help: "Total count of disconnected websocket sessions from other rancher-server", - }, - []string{"peer"}, - ) -) - -func IncSMTotalAddWS(clientKey string, peer bool) { - var peerStr string - if peer { - peerStr = "true" - } else { - peerStr = "false" - } - if prometheusMetrics { - TotalAddWS.With( - prometheus.Labels{ - "clientkey": clientKey, - "peer": peerStr, - }).Inc() - } -} - -func IncSMTotalRemoveWS(clientKey string, peer bool) { - var peerStr string - if prometheusMetrics { - if peer { - peerStr = "true" - } else { - peerStr = "false" - } - TotalRemoveWS.With( - prometheus.Labels{ - "clientkey": clientKey, - "peer": peerStr, - }).Inc() - } -} - -func AddSMTotalTransmitErrorBytesOnWS(clientKey string, size float64) { - if prometheusMetrics { - TotalTransmitErrorBytesOnWS.With( - prometheus.Labels{ - "clientkey": clientKey, - }).Add(size) - } -} - -func AddSMTotalTransmitBytesOnWS(clientKey string, size float64) { - if prometheusMetrics { - TotalTransmitBytesOnWS.With( - prometheus.Labels{ - "clientkey": clientKey, - }).Add(size) - } -} - -func AddSMTotalReceiveBytesOnWS(clientKey string, size float64) { - if prometheusMetrics { - TotalReceiveBytesOnWS.With( - prometheus.Labels{ - "clientkey": clientKey, - }).Add(size) - } -} - -func IncSMTotalAddConnectionsForWS(clientKey, proto, addr string) { - if prometheusMetrics { - TotalAddConnectionsForWS.With( - prometheus.Labels{ - "clientkey": clientKey, - "proto": proto, - "addr": addr, - }).Inc() - } -} - -func IncSMTotalRemoveConnectionsForWS(clientKey, proto, addr string) { - if prometheusMetrics { - TotalRemoveConnectionsForWS.With( - prometheus.Labels{ - "clientkey": clientKey, - "proto": proto, - "addr": addr, - }).Inc() - } -} - -func IncSMTotalAddPeerAttempt(peer string) { - if prometheusMetrics { - TotalAddPeerAttempt.With( - prometheus.Labels{ - "peer": peer, - }).Inc() - } -} - -func IncSMTotalPeerConnected(peer string) { - if prometheusMetrics { - TotalPeerConnected.With( - prometheus.Labels{ - "peer": peer, - }).Inc() - } -} - -func IncSMTotalPeerDisConnected(peer string) { - if prometheusMetrics { - TotalPeerDisConnected.With( - prometheus.Labels{ - "peer": peer, - }).Inc() - - } -}