Introducing new non-relay protocol request handling time metric

This commit is contained in:
NagyZoltanPeter 2025-02-14 16:34:02 +01:00
parent 81a19c397c
commit b73213e48b
No known key found for this signature in database
GPG Key ID: 16EADB9673B65368
3 changed files with 17 additions and 0 deletions

View File

@ -76,8 +76,15 @@ template checkUsageLimit*(
bodyWithinLimit, bodyRejected: untyped,
) =
if t.checkUsage(proto, conn):
let requestStartTime = Moment.now()
waku_service_requests.inc(labelValues = [proto, "served"])
bodyWithinLimit
let requestDurationSec = (Moment.now() - requestStartTime).milliseconds.float / 1000
waku_service_request_handling_duration_seconds.observe(
requestDurationSec, labelValues = [proto]
)
else:
waku_service_requests.inc(labelValues = [proto, "rejected"])
bodyRejected

View File

@ -17,3 +17,6 @@ proc setServiceLimitMetric*(service: string, limit: Option[RateLimitSetting]) =
waku_service_requests_limit.set(
limit.get().calculateLimitPerSecond(), labelValues = [service]
)
declarePublicHistogram waku_service_request_handling_duration_seconds,
"duration of non-relay service handling", ["service"]

View File

@ -43,8 +43,15 @@ template checkUsageLimit*(
bodyWithinLimit, bodyRejected: untyped,
) =
if t.checkUsage(proto):
let requestStartTime = Moment.now()
waku_service_requests.inc(labelValues = [proto, "served"])
bodyWithinLimit
let requestDurationSec = (Moment.now() - requestStartTime).milliseconds.float / 1000
waku_service_request_handling_duration_seconds.observe(
requestDurationSec, labelValues = [proto]
)
else:
waku_service_requests.inc(labelValues = [proto, "rejected"])
bodyRejected