mirror of https://github.com/waku-org/nwaku.git
fix(archive): restore query and insert metrics duration precision
This commit is contained in:
parent
6942e466e8
commit
3474bef8e3
|
@ -95,7 +95,9 @@ proc handleMessage*(w: WakuArchive, pubsubTopic: PubsubTopic, msg: WakuMessage)
|
|||
return
|
||||
|
||||
|
||||
waku_archive_insert_duration_seconds.time:
|
||||
let insertStartTime = getTime().toUnixFloat()
|
||||
|
||||
block:
|
||||
let
|
||||
msgDigest = computeDigest(msg)
|
||||
msgReceivedTime = if msg.timestamp > 0: msg.timestamp
|
||||
|
@ -108,6 +110,9 @@ proc handleMessage*(w: WakuArchive, pubsubTopic: PubsubTopic, msg: WakuMessage)
|
|||
error "failed to insert message", err=putRes.error
|
||||
waku_archive_errors.inc(labelValues = [insertFailure])
|
||||
|
||||
let insertDuration = getTime().toUnixFloat() - insertStartTime
|
||||
waku_archive_insert_duration_seconds.observe(insertDuration)
|
||||
|
||||
|
||||
proc findMessages*(w: WakuArchive, query: ArchiveQuery): ArchiveResult {.gcsafe.} =
|
||||
## Search the archive to return a single page of messages matching the query criteria
|
||||
|
@ -122,10 +127,9 @@ proc findMessages*(w: WakuArchive, query: ArchiveQuery): ArchiveResult {.gcsafe.
|
|||
qAscendingOrder = query.ascending
|
||||
|
||||
|
||||
var queryRes: ArchiveDriverResult[seq[ArchiveRow]]
|
||||
let queryStartTime = getTime().toUnixFloat()
|
||||
|
||||
waku_archive_query_duration_seconds.time:
|
||||
queryRes = w.driver.getMessages(
|
||||
let queryRes = w.driver.getMessages(
|
||||
contentTopic = qContentTopics,
|
||||
pubsubTopic = qPubSubTopic,
|
||||
cursor = qCursor,
|
||||
|
@ -135,6 +139,11 @@ proc findMessages*(w: WakuArchive, query: ArchiveQuery): ArchiveResult {.gcsafe.
|
|||
ascendingOrder = qAscendingOrder
|
||||
)
|
||||
|
||||
let queryDuration = getTime().toUnixFloat() - queryStartTime
|
||||
waku_archive_query_duration_seconds.observe(queryDuration)
|
||||
|
||||
|
||||
|
||||
# Build response
|
||||
if queryRes.isErr():
|
||||
return err(ArchiveError(kind: ArchiveErrorKind.DRIVER_ERROR, cause: queryRes.error))
|
||||
|
|
Loading…
Reference in New Issue