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

process_collector: Add Platform-Specific Describe for processCollector #1625

Merged
merged 5 commits into from
Oct 7, 2024

Conversation

ying-jeanne
Copy link
Contributor

@ying-jeanne ying-jeanne commented Sep 15, 2024

This PR addresses the issue described in #1591.

Given the clarity of the ticket, I proceeded directly with the fix rather than engaging in further discussion, but please let me know if there are any questions or concerns.

In this PR, I've refactored the Describe function to be platform-specific and added tests to ensure alignment between Describe and ProcessCollect for Linux and Windows. I've also included comments to help ensure future alignment between these functions. Also defaultCollectFn and defaultDescribeFn are added to standardise behaviour for unsupported platforms.

As this is my first contribution, I would really appreciate any feedback you may have. Thank you. @bwplotka @ArthurSens @kakkoyun

@ying-jeanne ying-jeanne force-pushed the split-describe-by-platform branch from bc2ac02 to acd48a9 Compare September 15, 2024 21:31
Signed-off-by: Ying WANG <ying.wang@grafana.com>
@ying-jeanne ying-jeanne force-pushed the split-describe-by-platform branch from acd48a9 to 1a1b860 Compare September 15, 2024 21:33
Signed-off-by: Ying WANG <ying.wang@grafana.com>
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks, amazing work! 💪🏽 One nit, otherwise LGTM

CHANGELOG.md Outdated
@@ -1,5 +1,7 @@
## Unreleased

* [ENHANCEMENT] process_collector: Add Platform-Specific Describe for processCollector. #1625
Copy link
Member

Choose a reason for hiding this comment

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

Is it really a customer visible change? It might be mostly our tech-debt removal, right?

Copy link
Contributor Author

@ying-jeanne ying-jeanne Sep 29, 2024

Choose a reason for hiding this comment

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

removed in 0bfbc37

ch <- c.startTime
ch <- c.inBytes
ch <- c.outBytes
func (c *processCollector) defaultCollectFn(ch chan<- Metric) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we name this and below something like errorCollectFn and errorDescribeFn given what they do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed in 0bfbc37

@@ -20,7 +20,14 @@ func canCollectProcess() bool {
return false
}

// describe returns all descriptions of the collector for js.
Copy link
Member

Choose a reason for hiding this comment

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

Nice! I'm not sure why we have files for js and wasip1 that explicitly say "false" in can collect function, but other potentially also non supported environments will go through _other file. Maybe we can find the source of the file/blame to see why it was added vs going through _other file flow 🤔

We can do in other 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.

I think this may caused by below function is not available in js and wasip1 PR, but I think you are still right, we can at least merge those 2 since they are exactly the same today. Just left them now as they are, let me know what do you think, I can open a follow PR.

func canCollectProcess() bool {
	_, err := procfs.NewDefaultFS()
	return err == nil
}

Signed-off-by: Ying WANG <ying.wang@grafana.com>
@ying-jeanne ying-jeanne force-pushed the split-describe-by-platform branch from de6aff8 to 0bfbc37 Compare September 29, 2024 20:27
@ying-jeanne
Copy link
Contributor Author

could you take another look at this PR @bwplotka @ArthurSens @kakkoyun? thank you.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks!

@bwplotka bwplotka merged commit b2ef833 into prometheus:main Oct 7, 2024
10 checks passed
amberpixels pushed a commit to amberpixels/prometheus_client_golang that referenced this pull request Nov 29, 2024
prometheus#1625)

* process_collector: Add Platform-Specific Describe for processCollector

Signed-off-by: Ying WANG <ying.wang@grafana.com>

* add changelog entry

Signed-off-by: Ying WANG <ying.wang@grafana.com>

* Address comments

Signed-off-by: Ying WANG <ying.wang@grafana.com>

---------

Signed-off-by: Ying WANG <ying.wang@grafana.com>
Signed-off-by: Eugene <eugene@amberpixels.io>
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