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

extend histogram cortex_distributor_sample_delay_seconds_bucket to track negative delays #6838

Merged
merged 3 commits into from
Dec 11, 2023

Conversation

replay
Copy link
Contributor

@replay replay commented Dec 6, 2023

We would like to track if there are users who send us samples with timestamps which are in the future, relative to wall clock time.
This change doesn't need to be permanent, we can revert it in a few weeks from now.

Signed-off-by: Mauro Stettler <[email protected]>
@replay replay changed the title extend histogram cortex_distributor_sample_delay_seconds_bucket to also track negative deltas extend histogram cortex_distributor_sample_delay_seconds_bucket to track negative deltas Dec 6, 2023
@replay replay changed the title extend histogram cortex_distributor_sample_delay_seconds_bucket to track negative deltas extend histogram cortex_distributor_sample_delay_seconds_bucket to track negative delays Dec 6, 2023
Signed-off-by: Mauro Stettler <[email protected]>
Signed-off-by: Mauro Stettler <[email protected]>
@replay replay marked this pull request as ready for review December 6, 2023 12:34
@replay replay requested a review from a team as a code owner December 6, 2023 12:34
if delta > 0 {
d.sampleDelayHistogram.Observe(float64(delta) / 1000)
}
d.sampleDelayHistogram.Observe(float64(delta) / 1000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering how expensive it is to call Observe() for every single sample. Do you have a benchmark we can run, to compare it before vs after this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that it is safe to assume that the vast majority of samples which we receive have a delta that is > 0, because all the ones with a timestamp that is older than now will have delta > 0.

removing the delta > 0 condition will only make us also observe those where the sample timestamp is in the future relative to now, which I would expect to be a tiny fraction of all samples that we receive. so the increase in the rate of calls to .Observe() is very unlikely to be significant.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You're totally right. I initially read the code the other way. I'm good, thanks.

if delta > 0 {
d.sampleDelayHistogram.Observe(float64(delta) / 1000)
}
d.sampleDelayHistogram.Observe(float64(delta) / 1000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You're totally right. I initially read the code the other way. I'm good, thanks.

@replay replay merged commit 8b75767 into main Dec 11, 2023
@replay replay deleted the track_samples_from_the_future branch December 11, 2023 08:43
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