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

return error if cpufreq's are empty #426

Merged
merged 1 commit into from Dec 22, 2022

Conversation

binjip978
Copy link
Contributor

Signed-off-by: Sergei Semenchuk pdp.eleven11@gmail.com

@binjip978
Copy link
Contributor Author

fixes prometheus/node_exporter#2198 when collector successful but empty

@@ -178,6 +180,10 @@ func (fs FS) SystemCpufreq() ([]SystemCPUCpufreqStats, error) {
return nil, err
}

if len(systemCpufreq) == 0 {
return nil, fmt.Errorf("could not find any cpufreq files")
Copy link
Member

Choose a reason for hiding this comment

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

Two issues. We need to make an identifiable error so that downstream can tell a "not found" vs a parsing error.

For example, we could return os.ErrNotExist.

Or we make a new procfs error var with errors.New().

This way we can use errors.Is().

Copy link
Member

Choose a reason for hiding this comment

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

Maybe return fmt.Errorf("could not find any cpufreq files: %w", os.ErrNotExist)?

Signed-off-by: Sergei Semenchuk <pdp.eleven11@gmail.com>
@SuperQ SuperQ merged commit 0c4b3aa into prometheus:master Dec 22, 2022
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.

None yet

3 participants