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

Support to hide metrics which hasn't update for a long time #520

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

Conversation

acelyc111
Copy link

No description provided.

@acelyc111
Copy link
Author

Hi @gjasny , could you please take a look at this PR? thanks

@fluffy
Copy link

fluffy commented Sep 13, 2021

Hi @acelyc111 - I was just reading your code in this PR and it looks like exactly what I need. Is this code working well for you. I'm considering just pulling your PR into my fork. Thanks.

@acelyc111
Copy link
Author

Hi @acelyc111 - I was just reading your code in this PR and it looks like exactly what I need. Is this code working well for you. I'm considering just pulling your PR into my fork. Thanks.

@fluffy Yes it works well, feel free to try it.

@gjasny
Copy link
Collaborator

gjasny commented Sep 17, 2021

Hello,

I see some problems with this pull request:

  1. Setting last_update_ts_ is not synchronized between the updating thread and the collecting thread. A 32 bit system setting a 64 bit time_t might read funny values.

  2. std::time is not monotonic and might step backwards.

  3. The metric types have been designed for low-overhead when setting/updating. Looking at the clock every time adds a huge overhead. The included benchmark shows some numbers (on my M1 Mac Mini)

Before:
BM_Counter_Increment                              10.3 ns         10.3 ns     55964630

After:
BM_Counter_Increment                              45.3 ns         45.3 ns     15390579

Maybe a smarter algorithm could shave-off most of the overhead while also providing thread safety.

@jupp0r Do you have any comments?

Thanks,
Gregor

family.metric.push_back(std::move(CollectMetric(m.first, m.second.get())));
if (!m.second->Expired(current_ts)) {
family.metric.push_back(
std::move(CollectMetric(m.first, m.second.get())));
Copy link
Contributor

@sjanel sjanel Nov 30, 2021

Choose a reason for hiding this comment

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

This std::move is useless here. CollectMetric returns a prvalue.

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.

4 participants