1
0
Fork 1
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-01-19 02:48:37 +00:00

Add egress metrics

This commit is contained in:
Tristan Deloche 2021-01-22 14:33:51 +00:00
parent 85db7f81c2
commit 191eaed364
No known key found for this signature in database
GPG key ID: B6BDB16331573E59
2 changed files with 9 additions and 2 deletions

View file

@ -63,8 +63,8 @@ class GeoIpMetricsFilter(
return {
val sourceIp =
it.headerValues("Forwarded")[0] // try Forwarded (rare but standard)
?: it.headerValues("X-Forwarded-For")[0] // X-Forwarded-For (common but technically wrong)
it.headerValues("Forwarded").firstOrNull() // try Forwarded (rare but standard)
?: it.headerValues("X-Forwarded-For").firstOrNull() // X-Forwarded-For (common but technically wrong)
?: it.source?.address // source (in case of no proxying, or with proxy-protocol)
sourceIp.apply {

View file

@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import io.micrometer.core.instrument.FunctionCounter
import io.micrometer.prometheus.PrometheusMeterRegistry
import mdnet.Constants
import mdnet.cache.CachingInputStream
@ -286,6 +287,12 @@ fun getServer(
client = client
)
FunctionCounter.builder(
"client_sent_bytes",
statistics,
{ it.get().bytesSent.toDouble() }
).register(registry)
val verifier = tokenVerifier(
tokenKey = remoteSettings.tokenKey,
shouldVerify = { chapter, _ ->