TUN-1613: improved cloudflared RegisterTunnel fail metrics
This commit is contained in:
parent
eafc89bf73
commit
541cf68608
|
@ -53,6 +53,7 @@ type TunnelMetrics struct {
|
||||||
|
|
||||||
regSuccess prometheus.Counter
|
regSuccess prometheus.Counter
|
||||||
regFail *prometheus.CounterVec
|
regFail *prometheus.CounterVec
|
||||||
|
rpcFail *prometheus.CounterVec
|
||||||
|
|
||||||
muxerMetrics *muxerMetrics
|
muxerMetrics *muxerMetrics
|
||||||
tunnelsHA tunnelsForHA
|
tunnelsHA tunnelsForHA
|
||||||
|
@ -345,6 +346,15 @@ func NewTunnelMetrics() *TunnelMetrics {
|
||||||
)
|
)
|
||||||
prometheus.MustRegister(serverLocations)
|
prometheus.MustRegister(serverLocations)
|
||||||
|
|
||||||
|
rpcFail := prometheus.NewCounterVec(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Name: "tunnel_rpc_fail",
|
||||||
|
Help: "Count of RPC connection errors by type",
|
||||||
|
},
|
||||||
|
[]string{"error"},
|
||||||
|
)
|
||||||
|
prometheus.MustRegister(rpcFail)
|
||||||
|
|
||||||
registerFail := prometheus.NewCounterVec(
|
registerFail := prometheus.NewCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: "tunnel_register_fail",
|
Name: "tunnel_register_fail",
|
||||||
|
@ -378,6 +388,7 @@ func NewTunnelMetrics() *TunnelMetrics {
|
||||||
tunnelsHA: NewTunnelsForHA(),
|
tunnelsHA: NewTunnelsForHA(),
|
||||||
regSuccess: registerSuccess,
|
regSuccess: registerSuccess,
|
||||||
regFail: registerFail,
|
regFail: registerFail,
|
||||||
|
rpcFail: rpcFail,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
raven "github.com/getsentry/raven-go"
|
raven "github.com/getsentry/raven-go"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
_ "github.com/prometheus/client_golang/prometheus"
|
_ "github.com/prometheus/client_golang/prometheus"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
@ -105,6 +106,11 @@ type clientRegisterTunnelError struct {
|
||||||
cause error
|
cause error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newClientRegisterTunnelError(cause error, counter *prometheus.CounterVec) clientRegisterTunnelError {
|
||||||
|
counter.WithLabelValues(cause.Error()).Inc()
|
||||||
|
return clientRegisterTunnelError{cause: cause}
|
||||||
|
}
|
||||||
|
|
||||||
func (e clientRegisterTunnelError) Error() string {
|
func (e clientRegisterTunnelError) Error() string {
|
||||||
return e.cause.Error()
|
return e.cause.Error()
|
||||||
}
|
}
|
||||||
|
@ -323,11 +329,11 @@ func RegisterTunnel(
|
||||||
}, nil)
|
}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// RPC stream open error
|
// RPC stream open error
|
||||||
return clientRegisterTunnelError{cause: err}
|
return newClientRegisterTunnelError(err, config.Metrics.rpcFail)
|
||||||
}
|
}
|
||||||
if !IsRPCStreamResponse(stream.Headers) {
|
if !IsRPCStreamResponse(stream.Headers) {
|
||||||
// stream response error
|
// stream response error
|
||||||
return clientRegisterTunnelError{cause: err}
|
return newClientRegisterTunnelError(err, config.Metrics.rpcFail)
|
||||||
}
|
}
|
||||||
conn := rpc.NewConn(
|
conn := rpc.NewConn(
|
||||||
tunnelrpc.NewTransportLogger(config.TransportLogger.WithField("subsystem", "rpc-register"), rpc.StreamTransport(stream)),
|
tunnelrpc.NewTransportLogger(config.TransportLogger.WithField("subsystem", "rpc-register"), rpc.StreamTransport(stream)),
|
||||||
|
@ -349,7 +355,7 @@ func RegisterTunnel(
|
||||||
LogServerInfo(serverInfoPromise.Result(), connectionID, config.Metrics, config.Logger)
|
LogServerInfo(serverInfoPromise.Result(), connectionID, config.Metrics, config.Logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// RegisterTunnel RPC failure
|
// RegisterTunnel RPC failure
|
||||||
return clientRegisterTunnelError{cause: err}
|
return newClientRegisterTunnelError(err, config.Metrics.regFail)
|
||||||
}
|
}
|
||||||
for _, logLine := range registration.LogLines {
|
for _, logLine := range registration.LogLines {
|
||||||
config.Logger.Info(logLine)
|
config.Logger.Info(logLine)
|
||||||
|
|
Loading…
Reference in New Issue