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

Sampling support #24

Open
hagen1778 opened this issue May 12, 2021 · 1 comment
Open

Sampling support #24

hagen1778 opened this issue May 12, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@hagen1778
Copy link
Contributor

Metrics update in application's hot path may be expensive. Some heavy-loaded web servers or processing pipelines usually serve hundreds of thousands of events per second, and to have the visibility they also increment a bunch of metrics for each event. It would be cool, if metrics package could have native sampling support. For example:

requestsTotal = metrics.NewCounterSampled("requests_total", 0.1)

Every call to requestsTotal.Inc() will have 10% chance to actually increment the counter, and 90% chance to do nothing. But when increment actually happens, it will be +=10 instead of +=1.

Workaround. Batch metrics updates in a hot path and make them periodic (e.g. every 100ms) with a fixed rate.

@valyala valyala added the enhancement New feature or request label May 17, 2021
@valyala
Copy link
Contributor

valyala commented May 17, 2021

It would be great to have performance numbers and/or cpu profiles obtained from highly loaded systems where metrics sampling could result in better performance.

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

No branches or pull requests

2 participants