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
|
return
|
||||||
|
|
||||||
|
|
||||||
waku_archive_insert_duration_seconds.time:
|
let insertStartTime = getTime().toUnixFloat()
|
||||||
|
|
||||||
|
block:
|
||||||
let
|
let
|
||||||
msgDigest = computeDigest(msg)
|
msgDigest = computeDigest(msg)
|
||||||
msgReceivedTime = if msg.timestamp > 0: msg.timestamp
|
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
|
error "failed to insert message", err=putRes.error
|
||||||
waku_archive_errors.inc(labelValues = [insertFailure])
|
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.} =
|
proc findMessages*(w: WakuArchive, query: ArchiveQuery): ArchiveResult {.gcsafe.} =
|
||||||
## Search the archive to return a single page of messages matching the query criteria
|
## 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
|
qAscendingOrder = query.ascending
|
||||||
|
|
||||||
|
|
||||||
var queryRes: ArchiveDriverResult[seq[ArchiveRow]]
|
let queryStartTime = getTime().toUnixFloat()
|
||||||
|
|
||||||
waku_archive_query_duration_seconds.time:
|
let queryRes = w.driver.getMessages(
|
||||||
queryRes = w.driver.getMessages(
|
|
||||||
contentTopic = qContentTopics,
|
contentTopic = qContentTopics,
|
||||||
pubsubTopic = qPubSubTopic,
|
pubsubTopic = qPubSubTopic,
|
||||||
cursor = qCursor,
|
cursor = qCursor,
|
||||||
|
@ -135,6 +139,11 @@ proc findMessages*(w: WakuArchive, query: ArchiveQuery): ArchiveResult {.gcsafe.
|
||||||
ascendingOrder = qAscendingOrder
|
ascendingOrder = qAscendingOrder
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let queryDuration = getTime().toUnixFloat() - queryStartTime
|
||||||
|
waku_archive_query_duration_seconds.observe(queryDuration)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Build response
|
# Build response
|
||||||
if queryRes.isErr():
|
if queryRes.isErr():
|
||||||
return err(ArchiveError(kind: ArchiveErrorKind.DRIVER_ERROR, cause: queryRes.error))
|
return err(ArchiveError(kind: ArchiveErrorKind.DRIVER_ERROR, cause: queryRes.error))
|
||||||
|
|
Loading…
Reference in New Issue