metrics: reduce complexity for AddLoginResult method

fix a gocyclo warning
This commit is contained in:
Nicola Murino 2021-02-28 12:23:48 +01:00
parent a6e36e7cad
commit 901cafc6da
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB

View file

@ -830,9 +830,7 @@ func AddLoginAttempt(authMethod string) {
}
}
// AddLoginResult increments the metrics for login results
func AddLoginResult(authMethod string, err error) {
if err == nil {
func incLoginOK(authMethod string) {
totalLoginOK.Inc()
switch authMethod {
case loginMethodPublicKey:
@ -850,7 +848,9 @@ func AddLoginResult(authMethod string, err error) {
default:
totalPasswordLoginOK.Inc()
}
} else {
}
func incLoginFailed(authMethod string) {
totalLoginFailed.Inc()
switch authMethod {
case loginMethodPublicKey:
@ -869,6 +869,14 @@ func AddLoginResult(authMethod string, err error) {
totalPasswordLoginFailed.Inc()
}
}
// AddLoginResult increments the metrics for login results
func AddLoginResult(authMethod string, err error) {
if err == nil {
incLoginOK(authMethod)
} else {
incLoginFailed(authMethod)
}
}
// AddNoAuthTryed increments the metric for clients disconnected