-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Updated dockerstatsreceiver to respect DOCKER_HOST env variable. #37589
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I also ask that you add some test to help validate the change going forward?
Mostly so the behaviour is captured as part of the tests.
func resolveDockerEndpoint(cfg *docker.Config) { | ||
// If endpoint is explicitly set in config, respect it | ||
if cfg.Endpoint != "" { | ||
return | ||
} | ||
|
||
// Check DOCKER_HOST environment variable | ||
if dockerHost := os.Getenv(dockerHostEnv); dockerHost != "" { | ||
cfg.Endpoint = dockerHost | ||
return | ||
} | ||
|
||
// Fall back to default endpoint | ||
cfg.Endpoint = defaultEndpoint | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of mutating the config object, can you add this as a method to *Config
that returns the expected value?
It should make it easier to test that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Hi @MovieStoreGuy, I would appreciate your review. This is my first time writing a test, so I’d love your feedback on whether I made any mistakes or if there’s anything I can improve. |
Description
The
dockerstatsreceiver
previously defaulted to usingunix:///var/run/docker.sock
for the Docker endpoint. While the configuration allows overriding this, it did not automatically respect theDOCKER_HOST
environment variable. This update ensures that the receiver resolves the endpoint in the following order:DOCKER_HOST
environment variable, if set.unix:///var/run/docker.sock
.Link to tracking issue
Fixes #35779