mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-22 11:58:36 +00:00
archive enhance logging (#3258)
This commit is contained in:
parent
998f040fdb
commit
b406b7b2ac
@ -85,65 +85,82 @@ proc new*(
|
||||
proc handleMessage*(
|
||||
self: WakuArchive, pubsubTopic: PubsubTopic, msg: WakuMessage
|
||||
) {.async.} =
|
||||
let msgHash = computeMessageHash(pubsubTopic, msg)
|
||||
let msgHashHex = msgHash.to0xHex()
|
||||
|
||||
trace "handling message",
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
msgTimestamp = msg.timestamp
|
||||
|
||||
self.validator(msg).isOkOr:
|
||||
waku_archive_errors.inc(labelValues = [error])
|
||||
trace "invalid message",
|
||||
msg_hash = computeMessageHash(pubsubTopic, msg).to0xHex(),
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp,
|
||||
error = error
|
||||
return
|
||||
|
||||
let msgHash = computeMessageHash(pubsubTopic, msg)
|
||||
let insertStartTime = getTime().toUnixFloat()
|
||||
|
||||
(await self.driver.put(msgHash, pubsubTopic, msg)).isOkOr:
|
||||
waku_archive_errors.inc(labelValues = [insertFailure])
|
||||
trace "failed to insert message",
|
||||
msg_hash = msgHash.to0xHex(),
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp,
|
||||
error = error
|
||||
return
|
||||
|
||||
trace "message archived",
|
||||
msg_hash = msgHash.to0xHex(),
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp
|
||||
|
||||
let insertDuration = getTime().toUnixFloat() - insertStartTime
|
||||
waku_archive_insert_duration_seconds.observe(insertDuration)
|
||||
|
||||
trace "message archived",
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp,
|
||||
insertDuration = insertDuration
|
||||
|
||||
proc syncMessageIngress*(
|
||||
self: WakuArchive,
|
||||
msgHash: WakuMessageHash,
|
||||
pubsubTopic: PubsubTopic,
|
||||
msg: WakuMessage,
|
||||
): Future[Result[void, string]] {.async.} =
|
||||
let insertStartTime = getTime().toUnixFloat()
|
||||
let msgHashHex = msgHash.to0xHex()
|
||||
|
||||
trace "handling message in syncMessageIngress",
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp
|
||||
|
||||
let insertStartTime = getTime().toUnixFloat()
|
||||
(await self.driver.put(msgHash, pubsubTopic, msg)).isOkOr:
|
||||
waku_archive_errors.inc(labelValues = [insertFailure])
|
||||
trace "failed to insert message",
|
||||
msg_hash = msgHash.toHex(),
|
||||
trace "failed to insert message in in syncMessageIngress",
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp,
|
||||
error = $error
|
||||
return err(error)
|
||||
|
||||
trace "message archived",
|
||||
msg_hash = msgHash.to0xHex(),
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp
|
||||
|
||||
let insertDuration = getTime().toUnixFloat() - insertStartTime
|
||||
waku_archive_insert_duration_seconds.observe(insertDuration)
|
||||
|
||||
trace "message archived in syncMessageIngress",
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp,
|
||||
insertDuration = insertDuration
|
||||
|
||||
return ok()
|
||||
|
||||
proc validateTimeRange(
|
||||
|
@ -79,10 +79,6 @@ proc new*(
|
||||
proc handleMessage*(
|
||||
self: WakuArchive, pubsubTopic: PubsubTopic, msg: WakuMessage
|
||||
) {.async.} =
|
||||
self.validator(msg).isOkOr:
|
||||
waku_legacy_archive_errors.inc(labelValues = [error])
|
||||
return
|
||||
|
||||
let
|
||||
msgDigest = computeDigest(msg)
|
||||
msgDigestHex = msgDigest.data.to0xHex()
|
||||
@ -99,26 +95,40 @@ proc handleMessage*(
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
msgTimestamp = msg.timestamp,
|
||||
usedTimestamp = msgTimestamp,
|
||||
digest = msgDigestHex
|
||||
|
||||
self.validator(msg).isOkOr:
|
||||
waku_legacy_archive_errors.inc(labelValues = [error])
|
||||
trace "invalid message",
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp,
|
||||
error = error
|
||||
return
|
||||
|
||||
let insertStartTime = getTime().toUnixFloat()
|
||||
|
||||
(await self.driver.put(pubsubTopic, msg, msgDigest, msgHash, msgTimestamp)).isOkOr:
|
||||
waku_legacy_archive_errors.inc(labelValues = [insertFailure])
|
||||
error "failed to insert message", error = error
|
||||
error "failed to insert message",
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
timestamp = msg.timestamp,
|
||||
error = error
|
||||
return
|
||||
|
||||
let insertDuration = getTime().toUnixFloat() - insertStartTime
|
||||
waku_legacy_archive_insert_duration_seconds.observe(insertDuration)
|
||||
|
||||
debug "message archived",
|
||||
msg_hash = msgHashHex,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = msg.contentTopic,
|
||||
msgTimestamp = msg.timestamp,
|
||||
usedTimestamp = msgTimestamp,
|
||||
digest = msgDigestHex
|
||||
|
||||
let insertDuration = getTime().toUnixFloat() - insertStartTime
|
||||
waku_legacy_archive_insert_duration_seconds.observe(insertDuration)
|
||||
digest = msgDigestHex,
|
||||
insertDuration = insertDuration
|
||||
|
||||
proc findMessages*(
|
||||
self: WakuArchive, query: ArchiveQuery
|
||||
|
Loading…
x
Reference in New Issue
Block a user