Skip to content

Conversation

simzzz
Copy link
Contributor

@simzzz simzzz commented Aug 8, 2025

Description

We used to rely on custom calculations, which may not be 100% accurate, to follow the CPU and Memory Usage of the WebSocket server.
Instead of having a custom collect function, we can use the process_cpu_seconds_total default metric for cpu and process_resident_memory_bytes for memory together with a rate function to get the percentage usage of cpu and memory.

This PR replaces custom gauges with existing default metrics (already enabled via collectDefaultMetrics()):

Related issue(s)

Fixes #3935

Testing Guide

  1. Verify custom gauges have been removed from wsMetricRegistry.ts
  2. Verify CPU/Memory gauge definitions have been removed from constants.ts
  3. Once merged, verify the Grafana dashboard has been updated

Changes from original design (optional)

N/A

Additional work needed (optional)

N/A

Checklist

  • I've assigned an assignee to this PR and related issue(s) (if applicable)
  • I've assigned a label to this PR and related issue(s) (if applicable)
  • I've assigned a milestone to this PR and related issue(s) (if applicable)
  • I've updated documentation (code comments, README, etc. if applicable)
  • I've done sufficient testing (unit, integration, etc.)

Signed-off-by: Simeon Nakov <simeon.nakov@limechain.tech>
@simzzz simzzz added this to the 0.71.0 milestone Aug 8, 2025
@simzzz simzzz self-assigned this Aug 8, 2025
@simzzz simzzz added the enhancement New feature or request label Aug 8, 2025
@simzzz simzzz requested review from a team as code owners August 8, 2025 13:50
@simzzz simzzz requested a review from Ferparishuertas August 8, 2025 13:50
Copy link

github-actions bot commented Aug 8, 2025

Test Results

 20 files  ±0  265 suites  ±0   18m 31s ⏱️ +25s
712 tests ±0  707 ✅ +1  5 💤 ±0  0 ❌  - 1 
728 runs  ±0  723 ✅ +1  5 💤 ±0  0 ❌  - 1 

Results for commit 96f533a. ± Comparison against base commit cbf18eb.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simzzz simzzz merged commit 6d8e174 into main Aug 11, 2025
54 of 56 checks passed
@simzzz simzzz deleted the 3935-remove-custom-cpu-and-memory-usage-gauge branch August 11, 2025 08:28
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main    #4176      +/-   ##
==========================================
+ Coverage   95.38%   95.56%   +0.17%     
==========================================
  Files         122      121       -1     
  Lines       20355    20220     -135     
  Branches     1737     1733       -4     
==========================================
- Hits        19416    19323      -93     
+ Misses        914      873      -41     
+ Partials       25       24       -1     
Flag Coverage Δ
config-service 98.80% <ø> (ø)
relay 90.59% <ø> (-0.01%) ⬇️
server 89.35% <ø> (+0.22%) ⬆️
ws-server 53.73% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/ws-server/src/metrics/wsMetricRegistry.ts 98.85% <100.00%> (+20.61%) ⬆️
packages/ws-server/src/utils/constants.ts 100.00% <100.00%> (ø)

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove custom CPU and Memory usage Gauge
3 participants