Skip to content

Commit d5494e0

Browse files
committed
forgot to commit custom metrics ^^
1 parent 5152edd commit d5494e0

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package ch.derlin.bbdata.actuators
2+
3+
import io.micrometer.core.instrument.MeterRegistry
4+
import org.springframework.stereotype.Component
5+
6+
/**
7+
* date: 28.09.20
8+
* @author Lucy Linder <lucy.derlin@gmail.com>
9+
*/
10+
@Component
11+
class CustomMetrics(private val meterRegistry: MeterRegistry) {
12+
13+
/** Count the number of rejected measures in input api*/
14+
fun reject(objectId: Long) = meterRegistry
15+
.summary("ch.derlin.input.rejected",
16+
"object_id", objectId.toString()
17+
).record(1.0)
18+
19+
/** Count the number of failed login /login */
20+
fun loginFailed(username: String) = meterRegistry
21+
.summary("ch.derlin.login.failed",
22+
"username", username
23+
).record(1.0)
24+
25+
/** Count the number of failed authentication (wrong bbuser+bbtoken, not recording read-only apikeys on write endpoints) */
26+
fun authFailed(userId: Int) = meterRegistry
27+
.summary("ch.derlin.auth.failed",
28+
"user_id", userId.toString()
29+
).record(1.0)
30+
}

0 commit comments

Comments
 (0)