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

fix(nodebuilder/host): Ensure libp2p metrics are collected to prometheus #3753

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

walldiss
Copy link
Member

This PR fixes the bug of prometheus registry not being provided to libp2p constructor as well as few additional improvements of adjustment code:

  • provide Registrer to libp2p if flag is enabled
  • set global Registrer for bitswap global Injector
  • clarify telemetry enabling flag names and avoid overwrites
  • separate libp2p metrics enable logic from rest of the code base by introducing config field enableMetrics. It will enable usage of prometheus based metrics, while p2p metrics are disabled

@walldiss walldiss added the kind:fix Attached to bug-fixing PRs label Sep 19, 2024
@walldiss walldiss self-assigned this Sep 19, 2024
@codecov-commenter
Copy link

codecov-commenter commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 29.16667% with 17 lines in your changes missing coverage. Please review.

Project coverage is 45.69%. Comparing base (2469e7a) to head (e756b0f).
Report is 194 commits behind head on main.

Files with missing lines Patch % Lines
cmd/flags_misc.go 0.00% 13 Missing ⚠️
nodebuilder/p2p/host.go 0.00% 2 Missing and 1 partial ⚠️
nodebuilder/p2p/bitswap.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3753      +/-   ##
==========================================
+ Coverage   44.83%   45.69%   +0.85%     
==========================================
  Files         265      281      +16     
  Lines       14620    16066    +1446     
==========================================
+ Hits         6555     7341     +786     
- Misses       7313     7885     +572     
- Partials      752      840      +88     

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

Wondertan
Wondertan previously approved these changes Sep 19, 2024
// Set the default global registerer to the wrapped one with labels. This way all the metrics
// registered with the default registerer will be labeled with the provided labels. It is important
// because unlike libp2p metrics, bitswap metrics are registered with the default global registerer.
prometheus.DefaultRegisterer = wrapped
Copy link
Member

Choose a reason for hiding this comment

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

Aren't bitswap metrics registered on init causing this overwrite being unaffectual?

Copy link
Member Author

@walldiss walldiss Sep 19, 2024

Choose a reason for hiding this comment

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

You are right, right now it can get racy. Need to ensure order of init:

  1. update global
  2. inject bitswap Registrer
  3. start bitswap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:fix Attached to bug-fixing PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants