mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-08 02:55:05 +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: [].}
|
||||
|
||||
var
|
||||
perFutureMetrics {.threadvar.}: Table[uint, FutureMetrics]
|
||||
futureSummaryMetrics {.threadvar.}: MetricsSummary
|
||||
onChange {.threadvar.}: ChangeListener
|
||||
perFutureMetrics: Table[uint, FutureMetrics]
|
||||
futureSummaryMetrics: MetricsSummary
|
||||
onChange: ChangeListener
|
||||
|
||||
proc getFutureSummaryMetrics*(): MetricsSummary {.gcsafe.} =
|
||||
## 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_max)
|
||||
|
||||
var asyncProfilerInfo* {.threadvar.}: AsyncProfilerInfo
|
||||
|
||||
proc initDefault(AsyncProfilerInfo: typedesc): void =
|
||||
asyncProfilerInfo = AsyncProfilerInfo.newCollector(
|
||||
perfSampler = asyncprofiler.getFutureSummaryMetrics,
|
||||
var asyncProfilerInfo* {.global.}: AsyncProfilerInfo = AsyncProfilerInfo.newCollector(
|
||||
perfSampler = getFutureSummaryMetrics,
|
||||
k = 10,
|
||||
# We want to collect metrics every 5 seconds.
|
||||
sampleInterval = times.milliseconds(5 * 1000),
|
||||
clock = proc (): Time = time.getTime(),
|
||||
sampleInterval = initDuration(seconds = 5),
|
||||
clock = proc (): Time = getTime(),
|
||||
)
|
||||
|
||||
setChangeCallback(asyncProfilerInfo)
|
||||
setChangeCallback(proc (): void = asyncProfilerInfo.collect())
|
||||
|
Loading…
x
Reference in New Issue
Block a user