mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-05-17 04:09:50 +00:00
chore: add two metrics and panal (#3181)
This commit is contained in:
parent
d7d00bfd79
commit
1b532e8ab9
File diff suppressed because it is too large
Load Diff
@ -491,7 +491,7 @@ procSuite "WakuNode - RLN relay":
|
|||||||
|
|
||||||
# Helper function
|
# Helper function
|
||||||
proc waitForNullifierLog(node: WakuNode, expectedLen: int): Future[bool] {.async.} =
|
proc waitForNullifierLog(node: WakuNode, expectedLen: int): Future[bool] {.async.} =
|
||||||
for i in 0 .. 10: # Try for up to 5 seconds (10 * 500ms)
|
for i in 0 .. 100: # Try for up to 50 seconds (100 * 500ms)
|
||||||
if node.wakuRlnRelay.nullifierLog.len() == expectedLen:
|
if node.wakuRlnRelay.nullifierLog.len() == expectedLen:
|
||||||
return true
|
return true
|
||||||
await sleepAsync(500.millis)
|
await sleepAsync(500.millis)
|
||||||
|
|||||||
@ -180,6 +180,7 @@ method generateProof*(
|
|||||||
messageId: MessageId,
|
messageId: MessageId,
|
||||||
rlnIdentifier = DefaultRlnIdentifier,
|
rlnIdentifier = DefaultRlnIdentifier,
|
||||||
): GroupManagerResult[RateLimitProof] {.base, gcsafe, raises: [].} =
|
): GroupManagerResult[RateLimitProof] {.base, gcsafe, raises: [].} =
|
||||||
|
var lastProcessedEpoch {.global.}: Epoch
|
||||||
## generates a proof for the given data and epoch
|
## generates a proof for the given data and epoch
|
||||||
## the proof is generated using the current merkle root
|
## the proof is generated using the current merkle root
|
||||||
if g.idCredentials.isNone():
|
if g.idCredentials.isNone():
|
||||||
@ -201,6 +202,13 @@ method generateProof*(
|
|||||||
return err("proof generation failed: " & $error)
|
return err("proof generation failed: " & $error)
|
||||||
return ok(proof)
|
return ok(proof)
|
||||||
|
|
||||||
|
if lastProcessedEpoch != epoch:
|
||||||
|
lastProcessedEpoch = epoch
|
||||||
|
waku_rln_proof_remining.set(g.userMessageLimit.get().float64 - 1)
|
||||||
|
else:
|
||||||
|
waku_rln_proof_remining.dec()
|
||||||
|
waku_rln_proofs_generated_total.inc()
|
||||||
|
|
||||||
method isReady*(g: GroupManager): Future[bool] {.base, async.} =
|
method isReady*(g: GroupManager): Future[bool] {.base, async.} =
|
||||||
raise newException(
|
raise newException(
|
||||||
CatchableError, "isReady proc for " & $g.type & " is not implemented yet"
|
CatchableError, "isReady proc for " & $g.type & " is not implemented yet"
|
||||||
|
|||||||
@ -62,6 +62,16 @@ declarePublicGauge(
|
|||||||
"time taken to import membership credentials",
|
"time taken to import membership credentials",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
declarePublicGauge(
|
||||||
|
waku_rln_proof_remining,
|
||||||
|
"number of proofs remaining to be generated for the current epoch",
|
||||||
|
)
|
||||||
|
|
||||||
|
declarePublicGauge(
|
||||||
|
waku_rln_proofs_generated_total,
|
||||||
|
"total number of proofs generated since the node started",
|
||||||
|
)
|
||||||
|
|
||||||
type RLNMetricsLogger = proc() {.gcsafe, raises: [Defect].}
|
type RLNMetricsLogger = proc() {.gcsafe, raises: [Defect].}
|
||||||
|
|
||||||
proc getRlnMetricsLogger*(): RLNMetricsLogger =
|
proc getRlnMetricsLogger*(): RLNMetricsLogger =
|
||||||
@ -72,7 +82,8 @@ proc getRlnMetricsLogger*(): RLNMetricsLogger =
|
|||||||
var cumulativeSpamMessages = 0.float64
|
var cumulativeSpamMessages = 0.float64
|
||||||
var cumulativeInvalidMessages = 0.float64
|
var cumulativeInvalidMessages = 0.float64
|
||||||
var cumulativeValidMessages = 0.float64
|
var cumulativeValidMessages = 0.float64
|
||||||
var cumulativeProofs = 0.float64
|
var cumulativeProofsVerified = 0.float64
|
||||||
|
var cumulativeProofsGenerated = 0.float64
|
||||||
|
|
||||||
when defined(metrics):
|
when defined(metrics):
|
||||||
logMetrics = proc() =
|
logMetrics = proc() =
|
||||||
@ -87,13 +98,17 @@ proc getRlnMetricsLogger*(): RLNMetricsLogger =
|
|||||||
parseAndAccumulate(waku_rln_invalid_messages_total, cumulativeInvalidMessages)
|
parseAndAccumulate(waku_rln_invalid_messages_total, cumulativeInvalidMessages)
|
||||||
let freshValidMsgCount =
|
let freshValidMsgCount =
|
||||||
parseAndAccumulate(waku_rln_valid_messages_total, cumulativeValidMessages)
|
parseAndAccumulate(waku_rln_valid_messages_total, cumulativeValidMessages)
|
||||||
let freshProofCount =
|
let freshProofsVerifiedCount = parseAndAccumulate(
|
||||||
parseAndAccumulate(waku_rln_proof_verification_total, cumulativeProofs)
|
waku_rln_proof_verification_total, cumulativeProofsVerified
|
||||||
|
)
|
||||||
|
let freshProofsGeneratedCount =
|
||||||
|
parseAndAccumulate(waku_rln_proofs_generated_total, cumulativeProofsGenerated)
|
||||||
|
|
||||||
info "Total messages", count = freshMsgCount
|
info "Total messages", count = freshMsgCount
|
||||||
info "Total spam messages", count = freshSpamCount
|
info "Total spam messages", count = freshSpamCount
|
||||||
info "Total invalid messages", count = freshInvalidMsgCount
|
info "Total invalid messages", count = freshInvalidMsgCount
|
||||||
info "Total valid messages", count = freshValidMsgCount
|
info "Total valid messages", count = freshValidMsgCount
|
||||||
info "Total errors", count = freshErrorCount
|
info "Total errors", count = freshErrorCount
|
||||||
info "Total proofs verified", count = freshProofCount
|
info "Total proofs verified", count = freshProofsVerifiedCount
|
||||||
|
info "Total proofs generated", count = freshProofsGeneratedCount
|
||||||
return logMetrics
|
return logMetrics
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user