Applies chronos conventions

This commit is contained in:
benbierens 2023-08-08 09:59:42 +02:00
parent e07f0dc049
commit ac2fabedf7
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 5 additions and 5 deletions

View File

@ -15,7 +15,7 @@ import std/[tables, strutils, heapqueue, deques]
import stew/results
import "."/[config, futures, osdefs, oserrno, osutils, timer]
when defined(chronosEnableCallbackDurationMetric):
when chronosEnableCallbackDurationMetric:
import std/monotimes
import pkg/metrics
@ -266,14 +266,14 @@ template processCallbacks(loop: untyped) =
if isSentinel(callable):
break
if not(isNil(callable.function)):
when defined(chronosEnableCallbackDurationMetric):
when chronosEnableCallbackDurationMetric:
let startTime = getMonoTime().ticks
callable.function(callable.udata)
when defined(chronosEnableCallbackDurationMetric):
when chronosEnableCallbackDurationMetric:
let durationUs = (getMonoTime().ticks - startTime) div 1000
chronosCallbackDuration.set(durationNs)
chronosCallbackDuration.set(durationUs)
proc raiseAsDefect*(exc: ref Exception, msg: string) {.noreturn, noinline.} =
# Reraise an exception as a Defect, where it's unexpected and can't be handled

View File

@ -70,7 +70,7 @@ when (NimMajor, NimMinor) >= (1, 4):
""
## OS polling engine type which is going to be used by chronos.
chronosEnableCallbackDurationMetric {.booldefine.} = false
chronosEnableCallbackDurationMetric* {.booldefine.} = defined(chronosEnableCallbackDurationMetric)
## At the cost of some performance, produce a 'chronosCallbackDuration' metric.
## Useful for detecting application stalling/blocking.