mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-12 15:54:36 +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
|
||||
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:
|
||||
return true
|
||||
await sleepAsync(500.millis)
|
||||
|
@ -180,6 +180,7 @@ method generateProof*(
|
||||
messageId: MessageId,
|
||||
rlnIdentifier = DefaultRlnIdentifier,
|
||||
): GroupManagerResult[RateLimitProof] {.base, gcsafe, raises: [].} =
|
||||
var lastProcessedEpoch {.global.}: Epoch
|
||||
## generates a proof for the given data and epoch
|
||||
## the proof is generated using the current merkle root
|
||||
if g.idCredentials.isNone():
|
||||
@ -201,6 +202,13 @@ method generateProof*(
|
||||
return err("proof generation failed: " & $error)
|
||||
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.} =
|
||||
raise newException(
|
||||
CatchableError, "isReady proc for " & $g.type & " is not implemented yet"
|
||||
|
@ -62,6 +62,16 @@ declarePublicGauge(
|
||||
"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].}
|
||||
|
||||
proc getRlnMetricsLogger*(): RLNMetricsLogger =
|
||||
@ -72,7 +82,8 @@ proc getRlnMetricsLogger*(): RLNMetricsLogger =
|
||||
var cumulativeSpamMessages = 0.float64
|
||||
var cumulativeInvalidMessages = 0.float64
|
||||
var cumulativeValidMessages = 0.float64
|
||||
var cumulativeProofs = 0.float64
|
||||
var cumulativeProofsVerified = 0.float64
|
||||
var cumulativeProofsGenerated = 0.float64
|
||||
|
||||
when defined(metrics):
|
||||
logMetrics = proc() =
|
||||
@ -87,13 +98,17 @@ proc getRlnMetricsLogger*(): RLNMetricsLogger =
|
||||
parseAndAccumulate(waku_rln_invalid_messages_total, cumulativeInvalidMessages)
|
||||
let freshValidMsgCount =
|
||||
parseAndAccumulate(waku_rln_valid_messages_total, cumulativeValidMessages)
|
||||
let freshProofCount =
|
||||
parseAndAccumulate(waku_rln_proof_verification_total, cumulativeProofs)
|
||||
let freshProofsVerifiedCount = parseAndAccumulate(
|
||||
waku_rln_proof_verification_total, cumulativeProofsVerified
|
||||
)
|
||||
let freshProofsGeneratedCount =
|
||||
parseAndAccumulate(waku_rln_proofs_generated_total, cumulativeProofsGenerated)
|
||||
|
||||
info "Total messages", count = freshMsgCount
|
||||
info "Total spam messages", count = freshSpamCount
|
||||
info "Total invalid messages", count = freshInvalidMsgCount
|
||||
info "Total valid messages", count = freshValidMsgCount
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user