@@ -11,27 +11,30 @@ import (
1111
1212func PrometheusBouncersHasEmptyDecision (c * gin.Context ) {
1313 bouncer , _ := getBouncerFromContext (c )
14- if bouncer != nil {
15- metrics .LapiNilDecisions .With (prometheus.Labels {
16- "bouncer" : bouncer .Name ,
17- }).Inc ()
14+ if bouncer == nil {
15+ return
1816 }
17+
18+ metrics .LapiNilDecisions .With (prometheus.Labels {
19+ "bouncer" : bouncer .Name ,
20+ }).Inc ()
1921}
2022
2123func PrometheusBouncersHasNonEmptyDecision (c * gin.Context ) {
2224 bouncer , _ := getBouncerFromContext (c )
23- if bouncer != nil {
24- metrics .LapiNonNilDecisions .With (prometheus.Labels {
25- "bouncer" : bouncer .Name ,
26- }).Inc ()
25+ if bouncer == nil {
26+ return
2727 }
28+
29+ metrics .LapiNonNilDecisions .With (prometheus.Labels {
30+ "bouncer" : bouncer .Name ,
31+ }).Inc ()
2832}
2933
3034func PrometheusMachinesMiddleware () gin.HandlerFunc {
3135 return func (c * gin.Context ) {
3236 machineID , _ := getMachineIDFromContext (c )
3337 if machineID == "" {
34- c .Next ()
3538 return
3639 }
3740
@@ -47,7 +50,6 @@ func PrometheusBouncersMiddleware() gin.HandlerFunc {
4750 return func (c * gin.Context ) {
4851 bouncer , _ := getBouncerFromContext (c )
4952 if bouncer == nil {
50- c .Next ()
5153 return
5254 }
5355
@@ -70,6 +72,10 @@ func PrometheusMiddleware() gin.HandlerFunc {
7072 c .Next ()
7173
7274 elapsed := time .Since (startTime )
73- metrics .LapiResponseTime .With (prometheus.Labels {"method" : c .Request .Method , "endpoint" : c .FullPath ()}).Observe (elapsed .Seconds ())
75+ metrics .LapiResponseTime .With (
76+ prometheus.Labels {
77+ "method" : c .Request .Method ,
78+ "endpoint" : c .FullPath (),
79+ }).Observe (elapsed .Seconds ())
7480 }
7581}
0 commit comments