Skip to content

Conversation

beorn7
Copy link
Member

@beorn7 beorn7 commented Jun 4, 2019

beorn7 added 2 commits June 4, 2019 18:54
Signed-off-by: beorn7 <beorn@grafana.com>
Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7 beorn7 requested a review from gouthamve June 5, 2019 14:59

// Set up process metric collection if supported by the runtime.
if _, err := procfs.NewStat(); err == nil {
if _, err := procfs.NewDefaultFS(); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

I don't know the internals, but previously we are checking if we can ready the data correctly, but with this change we will be checking if the procfs mount exists. Not sure if that is enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, previously we also tested actually reading the proc stats.

However, that was not a guarantee that it would always work. For example, if somebody removed the read permissions on the proc files, it would fail at the next collection. Thus, we always had error handling in place to deal with that.

The initial test was mostly there to weed out platforms that have no procfs support in general so that we avoid trying it out on each collect cycle again.

Arguably, the way this change changes it is even better: If there is no procfs at all, it will prevent collection for good. If there is a procfs but it is not readable, that might be a temporary problem, so it makes sense to try on each collect cycle again. (Needless to say that all of this are very rare corner cases.)

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, 👍 This PR is good to go!

Copy link
Member

@gouthamve gouthamve left a comment

Choose a reason for hiding this comment

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

More a question than a concern in the comments. Other than that, LGTM!

@beorn7 beorn7 merged commit ea8c935 into master Jun 5, 2019
@beorn7 beorn7 deleted the beorn7/modules branch June 5, 2019 15:42
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