mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-12 12:56:58 +00:00
revert threadvars and add initialization to collector global instance
This commit is contained in:
parent
f048404cb7
commit
b795d8a3f5
@ -33,9 +33,9 @@ type
|
|||||||
ChangeListener* = proc (): void {.raises: [].}
|
ChangeListener* = proc (): void {.raises: [].}
|
||||||
|
|
||||||
var
|
var
|
||||||
perFutureMetrics {.threadvar.}: Table[uint, FutureMetrics]
|
perFutureMetrics: Table[uint, FutureMetrics]
|
||||||
futureSummaryMetrics {.threadvar.}: MetricsSummary
|
futureSummaryMetrics: MetricsSummary
|
||||||
onChange {.threadvar.}: ChangeListener
|
onChange: ChangeListener
|
||||||
|
|
||||||
proc getFutureSummaryMetrics*(): MetricsSummary {.gcsafe.} =
|
proc getFutureSummaryMetrics*(): MetricsSummary {.gcsafe.} =
|
||||||
## get a copy of the table of summary metrics for all futures.
|
## get a copy of the table of summary metrics for all futures.
|
||||||
|
@ -181,15 +181,12 @@ when defined(metrics):
|
|||||||
resetMetric(chronos_largest_exec_time_total)
|
resetMetric(chronos_largest_exec_time_total)
|
||||||
resetMetric(chronos_largest_exec_time_max)
|
resetMetric(chronos_largest_exec_time_max)
|
||||||
|
|
||||||
var asyncProfilerInfo* {.threadvar.}: AsyncProfilerInfo
|
var asyncProfilerInfo* {.global.}: AsyncProfilerInfo = AsyncProfilerInfo.newCollector(
|
||||||
|
perfSampler = getFutureSummaryMetrics,
|
||||||
proc initDefault(AsyncProfilerInfo: typedesc): void =
|
|
||||||
asyncProfilerInfo = AsyncProfilerInfo.newCollector(
|
|
||||||
perfSampler = asyncprofiler.getFutureSummaryMetrics,
|
|
||||||
k = 10,
|
k = 10,
|
||||||
# We want to collect metrics every 5 seconds.
|
# We want to collect metrics every 5 seconds.
|
||||||
sampleInterval = times.milliseconds(5 * 1000),
|
sampleInterval = initDuration(seconds = 5),
|
||||||
clock = proc (): Time = time.getTime(),
|
clock = proc (): Time = getTime(),
|
||||||
)
|
)
|
||||||
|
|
||||||
setChangeCallback(asyncProfilerInfo)
|
setChangeCallback(proc (): void = asyncProfilerInfo.collect())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user