SQLite3 metrics: cosmetic changes

This commit is contained in:
Ștefan Talpalaru 2020-05-09 14:34:06 +02:00 committed by zah
parent 9da92b5415
commit 8ded65fe0e
1 changed files with 8 additions and 6 deletions

View File

@ -3,8 +3,8 @@
{.push raises: [Defect].}
import
os, tables, times,
chronicles, metrics, sqlite3_abi,
os,
sqlite3_abi,
./kvstore
export kvstore
@ -164,6 +164,9 @@ proc init*(
))
when defined(metrics):
import tables, times,
chronicles, metrics
type Sqlite3Info = ref object of Gauge
proc newSqlite3Info*(name: string, help: string, registry = defaultRegistry): Sqlite3Info {.raises: [Exception].} =
@ -179,11 +182,10 @@ when defined(metrics):
method collect*(collector: Sqlite3Info): Metrics =
result = initOrderedTable[Labels, seq[Metric]]()
result[@[]] = @[]
var
timestamp = getTime().toMilliseconds()
currentMem, highwaterMem: cint
let timestamp = getTime().toMilliseconds()
var currentMem, highwaterMem: int64
if (let res = sqlite3_status(SQLITE_STATUS_MEMORY_USED, currentMem.addr, highwaterMem.addr, 0); res != SQLITE_OK):
if (let res = sqlite3_status64(SQLITE_STATUS_MEMORY_USED, currentMem.addr, highwaterMem.addr, 0); res != SQLITE_OK):
error "SQLite3 error", msg = sqlite3_errstr(res)
else:
result[@[]] = @[