Skip to content

Commit

Permalink
chore: disabling metrics for libwaku
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmer committed Sep 25, 2024
1 parent 711e7db commit 43165c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
6 changes: 3 additions & 3 deletions waku.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") =
extra_params &= " " & paramStr(i)
if `type` == "static":
exec "nim c" & " --out:build/" & name &
".a --threads:on --app:staticlib --opt:size --noMain --mm:refc --header " &
".a --threads:on --app:staticlib --opt:size --noMain --mm:refc --header --undef:metrics " &
extra_params & " " & srcDir & name & ".nim"
else:
exec "nim c" & " --out:build/" & name &
".so --threads:on --app:lib --opt:size --noMain --mm:refc --header " & extra_params &
" " & srcDir & name & ".nim"
".so --threads:on --app:lib --opt:size --noMain --mm:refc --header --undef:metrics " &
extra_params & " " & srcDir & name & ".nim"

proc buildMobileAndroid(srcDir = ".", params = "") =
let cpu = getEnv("CPU")
Expand Down
4 changes: 3 additions & 1 deletion waku/waku_core/time.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ proc nowInUnixFloat(): float =
proc getNowInNanosecondTime*(): Timestamp =
return getNanosecondTime(nowInUnixFloat())

template nanosecondTime*(collector: Summary | Histogram, body: untyped) =
template nanosecondTime*(
collector: Summary | Histogram | typedesc[IgnoredCollector], body: untyped
) =
when defined(metrics):
let start = nowInUnixFloat()
body
Expand Down
40 changes: 21 additions & 19 deletions waku/waku_rln_relay/protocol_metrics.nim
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,26 @@ proc getRlnMetricsLogger*(): RLNMetricsLogger =
var cumulativeValidMessages = 0.float64
var cumulativeProofs = 0.float64

logMetrics = proc() =
{.gcsafe.}:
let freshErrorCount = parseAndAccumulate(waku_rln_errors_total, cumulativeErrors)
let freshMsgCount =
parseAndAccumulate(waku_rln_messages_total, cumulativeMessages)
let freshSpamCount =
parseAndAccumulate(waku_rln_spam_messages_total, cumulativeSpamMessages)
let freshInvalidMsgCount =
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)
when defined(metrics):
logMetrics = proc() =
{.gcsafe.}:
let freshErrorCount =
parseAndAccumulate(waku_rln_errors_total, cumulativeErrors)
let freshMsgCount =
parseAndAccumulate(waku_rln_messages_total, cumulativeMessages)
let freshSpamCount =
parseAndAccumulate(waku_rln_spam_messages_total, cumulativeSpamMessages)
let freshInvalidMsgCount =
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)

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 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
return logMetrics

0 comments on commit 43165c5

Please sign in to comment.