Revert dup cpu frequency, add node_cpufreq flag - #3795
Open
rtreffer wants to merge 1 commit into
Open
Conversation
Both cpu_linux and cpufreq export cpu frequencies under the same name. This makes the metric mutually exclusive. A previous PR made it possible to enable both which can cause flapping help texts. This PR re-introduces mutual-exclusive behavior for the frequencies. A new flag `collector.cpufreq.enable-cpufreq-prefix` can be used to migrate all cpufreq metrics to node_cpufreq to avoid the collision. Signed-off-by: René Treffer <treffer@measite.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both cpu_linux and cpufreq export cpu frequencies under the same name. This makes the metric mutually exclusive.
A previous PR made it possible to enable both which can cause flapping help texts.
This PR re-introduces mutual-exclusive behavior for the frequencies. A new flag
collector.cpufreq.enable-cpufreq-prefixcan be used to migrate all cpufreq metrics to node_cpufreq to avoid the collision.Signed-off-by: René Treffer <treffer@measite.de>
See #3689
Reviewers
AI disclosure: This was written with Claude/Fable.
I did a pass over the outcome (this is under my name).
I couldn't find anything obviously wrong. I would like to highlight a few pieces though....
New flag:
--[no-]collector.cpufreq.enable-cpufreq-prefix Expose cpufreq metrics with the node_cpufreq_ prefix instead of node_cpu_. This avoids a metric name collision with the cpu collector and will be the default behavior in 2.x.This promises a future behavior change. Please check if this is the intended direction.
It might be worth a CHANGELOG entry, too.
The
descspattern used to generalize over the prefix switch is rather unique.Other collectors use
descsormetricDescsas well, but often in an untyped way.Typed + constructor time looks like a decent trade-off in this context but I would be happy to change it for a more simplistic or different approach.
Code snippets:
This all leads to a very neat diff in the end:
if stats.CpuinfoMinimumFrequency != nil { ch <- prometheus.MustNewConstMetric( - cpuFreqMinDesc, + c.descs.minHertz, prometheus.GaugeValue, float64(*stats.CpuinfoMinimumFrequency)*1000.0, stats.Name, ) }