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

refactor: Use package local metrics #1605

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SuperQ
Copy link
Contributor

@SuperQ SuperQ commented Sep 13, 2024

Part 2 (#1578)

Improve performance of metrics by moving them to the package that needs them. This reduces the overhead to a simple atomic increment for basic counters like cache hits/misses. This also uses promauto to avoid the second step of having to register metrics.

@SuperQ SuperQ force-pushed the local_metrics_2 branch 2 times, most recently from 9d1d131 to 54b3271 Compare September 13, 2024 21:23
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.85%. Comparing base (fe84ab8) to head (823c916).
Report is 147 commits behind head on main.

Files with missing lines Patch % Lines
lists/list_cache.go 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1605      +/-   ##
==========================================
- Coverage   93.88%   93.85%   -0.04%     
==========================================
  Files          78       80       +2     
  Lines        6361     6574     +213     
==========================================
+ Hits         5972     6170     +198     
- Misses        300      320      +20     
+ Partials       89       84       -5     

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

@SuperQ
Copy link
Contributor Author

SuperQ commented Sep 13, 2024

I'm working on an improvement to the tests using the client_golang testutil.

Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Oct 29, 2024
@SuperQ
Copy link
Contributor Author

SuperQ commented Oct 29, 2024

Not really stale, but I haven't had a chance to work on the coverage change.

Part 2 (0xERR0R#1578)

Improve performance of metrics by moving them to the package that needs
them. This reduces the overhead to a simple atomic increment for basic
counters like cache hits/misses. This also uses `promauto` to avoid the
second step of having to register metrics.

Signed-off-by: SuperQ <[email protected]>
@SuperQ
Copy link
Contributor Author

SuperQ commented Oct 31, 2024

@0xERR0R, how do you feel about the coverage change here?

var (
lastListGroupRefreshTimestamp = promauto.With(metrics.Reg).NewGauge(
prometheus.GaugeOpts{
Name: "blocky_last_list_group_refresh_timestamp_seconds",
Copy link
Owner

Choose a reason for hiding this comment

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

Do we have the same definition in metrics_event_publisher.go?

)
BeforeEach(func() {
var err error

sutConfig, err = config.WithDefaults[config.Downloader]()
Expect(err).Should(Succeed())

failedDownloadCountEvtChannel = make(chan string, 5)
Copy link
Owner

Choose a reason for hiding this comment

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

now we don't test if metrics counters are being incremented. Maybe we can try to read the counter value and assert it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is something we could test for. But I find it not very useful. The Prometheus client Inc() type functions are basically a simple Go atomic increment. There's basically no way for it to go wrong in a way that testing would help with.

@0xERR0R
Copy link
Owner

0xERR0R commented Nov 13, 2024

@0xERR0R, how do you feel about the coverage change here?

It is always nice to cover more code, but it is not an ultimate goal to have 100% coverage :)

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