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