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

Begin implementation for native histograms #3789

Merged
merged 26 commits into from
Jul 11, 2024

Conversation

zalegrala
Copy link
Contributor

What this PR does:

Here we add what is necessary to generate and remote-write native histograms from the metrics-generator.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@zalegrala zalegrala force-pushed the native-histograms-getting-started branch from 2f53a6d to 490b7b4 Compare June 18, 2024 17:58
@zalegrala zalegrala force-pushed the native-histograms-getting-started branch from 9d33bdf to 1bed650 Compare June 20, 2024 13:35
Copy link
Member

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

looks good. some comments to work through

modules/generator/instance_test.go Show resolved Hide resolved
modules/generator/registry/interface.go Show resolved Hide resolved
modules/generator/registry/native_histogram.go Outdated Show resolved Hide resolved

func (h *nativeHistogram) activeSeriesPerHistogramSerie() uint32 {
// TODO can we estimate this?
return 1
Copy link
Member

Choose a reason for hiding this comment

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

this is interesting. i suppose this plays into how many series prom/mimir consider a native histogram?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I think we have something to learn here, since there doesn't seem to be a clean mapping between native histograms and active series.

modules/generator/registry/native_histogram.go Outdated Show resolved Hide resolved
if err != nil {
return activeSeries, err
}
s.histogram = encodedMetric.GetHistogram()
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason to store this as a field on the struct? it seems like we only use it in this method. if that's true we should remove it from the struct

Copy link
Contributor Author

@zalegrala zalegrala Jun 27, 2024

Choose a reason for hiding this comment

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

This was added so that we could remember which histograms were sent. The Reset call below captures this, and storing the state on the struct was a way for us to get around this issue. If we don't know which buckets have had their exemplars reported, they get updated with the most recent timestamp and sent again, since the series keeps the exemplars.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, i'm not seeing this. it seems only referenced in this method which makes me think we should just use a local var. perhaps i'm missing something. we can sync on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, let's sync.

modules/generator/registry/native_histogram.go Outdated Show resolved Hide resolved
modules/generator/registry/registry.go Outdated Show resolved Hide resolved
Comment on lines +179 to +187
// NOTE: A subtle point here is that the new histogram implementation is
// chosen in the registry. This means that if the user overrides change
// from "both" to "classic", we will still be using the new histograms
// implementation. This is because the registry is not recreated when the
// overrides change. This is a tradeoff to avoid recreating the registry
// for every change in the overrides, but it does mean that even if user
// changes to "classic" histograms, we will still be using the new
// histograms implementation and want to avoid generating native
// histograms.
Copy link
Member

Choose a reason for hiding this comment

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

This will work when we switch from native or both to classic, but it will not work when we go from classic to anything else. If we initiate their tenant with classic we use the old histogram implementation, when we change the override nothing will be updated and we keep using this implementation.
To workaround this we need to recreate the processors I think so they all re-register their histograms.

But maybe something quick to fix in a follow-up PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I think let's follow up.

Copy link
Member

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

lgtm

@zalegrala zalegrala merged commit 7615301 into grafana:main Jul 11, 2024
14 checks passed
@zalegrala zalegrala deleted the native-histograms-getting-started branch July 30, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants