mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-20 08:38:29 +00:00
debugging metrics
This commit is contained in:
parent
ce6483e328
commit
e664591596
@ -23,6 +23,8 @@ when defined(chronosDurationThreshold):
|
||||
import pkg/metrics
|
||||
|
||||
declareGauge(chronosCallbackDuration, "chronos callback duration")
|
||||
declareGauge(chronosConstant, "chronos constant")
|
||||
declareCounter(chronosCallbackCounter, "chronos callback counter")
|
||||
|
||||
export Port, SocketFlag
|
||||
export timer
|
||||
@ -226,9 +228,6 @@ type
|
||||
const chronosDurationThreshold {.intdefine.} = 0
|
||||
|
||||
template newAsyncCallback*(cbFunc: CallbackFunc, udataPtr: pointer = nil): AsyncCallback =
|
||||
# when defined(chronosDurationThreshold):
|
||||
# AsyncCallback(function: cbFunc, udata: udataPtr, location: getStackTrace())
|
||||
# else:
|
||||
AsyncCallback(function: cbFunc, udata: udataPtr)
|
||||
|
||||
when defined(chronosDurationThreshold):
|
||||
@ -337,7 +336,10 @@ template processCallbacks(loop: untyped) =
|
||||
durationNs = getMonoTime().ticks - startTime
|
||||
durationUs = durationNs div 1000
|
||||
|
||||
chronosCallbackDuration.set(durationUs.int64)
|
||||
chronosCallbackDuration.set(durationNs)
|
||||
chronosConstant.set(123)
|
||||
chronosCallbackCounter.inc()
|
||||
|
||||
if durationUs > chronosDurationThreshold:
|
||||
|
||||
# callable.location*: array[2, ptr SrcLoc]
|
||||
|
@ -17,7 +17,6 @@ type
|
||||
procedure*: cstring
|
||||
file*: cstring
|
||||
line*: int
|
||||
trace*: cstring
|
||||
|
||||
proc `$`*(loc: ptr SrcLoc): string =
|
||||
var res = $loc.file
|
||||
@ -29,15 +28,12 @@ proc `$`*(loc: ptr SrcLoc): string =
|
||||
res.add("[unspecified]")
|
||||
else:
|
||||
res.add($loc.procedure)
|
||||
res.add("[")
|
||||
res.add($loc.trace)
|
||||
res.add("]")
|
||||
res
|
||||
|
||||
proc srcLocImpl(procedure: static string,
|
||||
file: static string, line: static int): ptr SrcLoc =
|
||||
var loc {.global.} = SrcLoc(
|
||||
file: cstring(file), line: line, procedure: procedure, trace: "a"
|
||||
file: cstring(file), line: line, procedure: procedure
|
||||
)
|
||||
return addr(loc)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user