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

Add support for custom hostfs in linux metrics, cleanup linux code #198

Closed

Conversation

fearful-symmetry
Copy link
Contributor

closes #12

This adds a set of new public methods to system.go to allow for metrics from a custom filesystem root under linux.

The API design feels a bit awkward at points, but my goal was to make a non-breaking change that mostly followed the existing design idioms of the library.

The underlying linux implementation already had support for a custom filesystem root, but the option wasn't exposed publicly, so this is a fairly small change.

@fearful-symmetry fearful-symmetry added enhancement New feature or request Team:Elastic-Agent Label for the Agent team labels Dec 5, 2023
@fearful-symmetry fearful-symmetry self-assigned this Dec 5, 2023
@@ -52,6 +52,16 @@ func Host() (types.Host, error) {
return provider.Host()
}

// HostFS is the same as Host, but allows for a custom root hostfs mountpoint
// a custom filesystem root is only supported on linux, and this will fallback to the default provider on other platforms
func HostFS(hostfs string) (types.Host, error) {
Copy link
Member

@andrewkroh andrewkroh Dec 7, 2023

Choose a reason for hiding this comment

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

Have you considered using the option pattern to enhance the existing APIs? My initial thought is that this would better because it keeps the api surface of the package small and direct.

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 actually did think of that, but the idea of making some ...Option arg for something where there's only ever going to be a single option felt kind of deceptive or non-obvious?

Copy link
Member

Choose a reason for hiding this comment

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

It's possible that there could be more options in the future so I'm not worried about there only being a single one now. I think options this would be preferable to doubling the api surface to support this feature.

@andrewkroh
Copy link
Member

Closing this in favor of #226.

@andrewkroh andrewkroh closed this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make the "host FS" location configurable
2 participants