Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add prom client #1087

Merged
merged 3 commits into from
Oct 22, 2024
Merged

chore: add prom client #1087

merged 3 commits into from
Oct 22, 2024

Conversation

chakra-guy
Copy link
Collaborator

Explanation

The current state uses a custom metrics extraction function that manually calculates and formats metrics for total connected clients and total rooms. This approach is limited in scope and requires manual maintenance to add or modify metrics.

The solution introduces the use of the Prometheus client library ('prom-client') to handle metrics collection and formatting. This change offers several advantages:

  1. Standardized metrics format compatible with Prometheus
  2. Automatic collection of numerous Node.js and process-level metrics out-of-the-box
  3. Easy addition and customization of application-specific metrics

The changes include:

  • Adding 'prom-client' as a dependency
  • Replacing the custom 'extractMetrics' function with Prometheus Registry and Gauge metrics
  • Updating the metrics endpoint to use the new Prometheus-based metrics collection
  • Adding a function to periodically update socket server metrics

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@chakra-guy chakra-guy requested a review from a team as a code owner October 21, 2024 11:48
Copy link

socket-security bot commented Oct 21, 2024

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.15%. Comparing base (dc4874c) to head (9e5d0ac).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1087   +/-   ##
=======================================
  Coverage   77.15%   77.15%           
=======================================
  Files         180      180           
  Lines        4260     4260           
  Branches     1050     1050           
=======================================
  Hits         3287     3287           
  Misses        973      973           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

abretonc7s
abretonc7s previously approved these changes Oct 22, 2024
Copy link
Collaborator

@abretonc7s abretonc7s left a comment

Choose a reason for hiding this comment

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

Approved, just one comment that we may want to rename the read to something more specific.

packages/sdk-socket-server-next/src/index.ts Outdated Show resolved Hide resolved
@chakra-guy
Copy link
Collaborator Author

@SocketSecurity ignore npm/prom-client@15.1.3

Copy link

sonarcloud bot commented Oct 22, 2024

@abretonc7s
Copy link
Collaborator

@SocketSecurity ignore npm/prom-client@15.1.3

@chakra-guy chakra-guy merged commit 91148e3 into main Oct 22, 2024
36 checks passed
@chakra-guy chakra-guy deleted the chore/add-prom-client branch October 22, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants