Skip to content

[extension/sumologicextension] Replace go-ps with gopsutil library#33403

Closed
harshshahsumo wants to merge 8 commits into
open-telemetry:mainfrom
harshshahsumo:replace_go-ps_library
Closed

[extension/sumologicextension] Replace go-ps with gopsutil library#33403
harshshahsumo wants to merge 8 commits into
open-telemetry:mainfrom
harshshahsumo:replace_go-ps_library

Conversation

@harshshahsumo
Copy link
Copy Markdown

@harshshahsumo harshshahsumo commented Jun 5, 2024

Description:
Replacing the old go-ps library to the existing widely used gopsutil library

Link to tracking Issue:
Link to the issue

Testing:
ran the go make test

Documentation:
No documentation required as its only library change

@harshshahsumo harshshahsumo requested review from a team and crobert-1 June 5, 2024 20:42
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Jun 5, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@crobert-1
Copy link
Copy Markdown
Member

Hello @harshshahsumo, thanks for your contribution! Please sign the CLA when you get a chance 👍

Comment on lines +724 to +725
e, _ := v.Name() // Ignore error
e = strings.ToLower(e)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we ignore the error? What are possible errors?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like, at least on some platforms, calling Name() can result in a syscall, so I guess the error is platform specific. IMO we should propagate these errors to the caller.

Copy link
Copy Markdown
Member

@sumo-drosiek sumo-drosiek left a comment

Choose a reason for hiding this comment

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

Comment thread .chloggen/replace_go-ps_sumologicextension.yaml Outdated
Comment thread .chloggen/replace_go-ps_sumologicextension.yaml Outdated
@Dylan-M
Copy link
Copy Markdown
Contributor

Dylan-M commented Jun 7, 2024

This is great news, as it will reduce final collector binary size due to gopsutil being in use by so many other components. Thank you.

Copy link
Copy Markdown
Member

@sumo-drosiek sumo-drosiek left a comment

Choose a reason for hiding this comment

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

LGTM, but you need to run make lint in component directory


for _, v := range p {
e := strings.ToLower(v.Executable())
e, err := v.Name()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we using the process name now, when in the past we were using the executable? I'd prefer if we replace the library without any semantic changes first.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From documentation it looks like this is for the same underlying value, or at least, the closest available (from what I can tell).

go-ps doc reference for Executable():

Executable name running this process.

gopsutil doc reference for Name():

Name returns name of the process.

@harshshahsumo Can you confirm that the same value is being returned here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought we could use https://pkg.go.dev/github.com/shirou/gopsutil/v3@v3.24.5/process#Process.Exe. It returns a full path to the executable, but it's easy to extract just the binary name. I tried to look through the implementation of https://pkg.go.dev/github.com/shirou/gopsutil/v3@v3.24.5/process#Process.Name, and it was complex enough that I'm not confident it will always give the same result.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for investigating! Sounds good to me.

I'll add a label to this PR to make sure the CI/CD actions run on Windows to make sure any path logic works properly there as well 👍

@crobert-1 crobert-1 added Run Windows Enable running windows test on a PR Skip Changelog PRs that do not require a CHANGELOG.md entry labels Jun 12, 2024
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 3, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Jul 3, 2024
Copy link
Copy Markdown
Contributor

@echlebek echlebek left a comment

Choose a reason for hiding this comment

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

@crobert-1 Anything more to do here before this can be merged? Stale bot is coming to reap 😆

@crobert-1
Copy link
Copy Markdown
Member

@crobert-1 Anything more to do here before this can be merged? Stale bot is coming to reap 😆

From my understanding, the main reason this is blocked is @swiatekm's open request. Once that has been updated and conflicts are resolved I believe it will be able to move forward.

@github-actions github-actions Bot removed the Stale label Jul 10, 2024
@github-actions
Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Jul 25, 2024
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 8, 2024

Closed as inactive. Feel free to reopen if this PR is still being worked on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension/sumologic Run Windows Enable running windows test on a PR Skip Changelog PRs that do not require a CHANGELOG.md entry Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants