-
Notifications
You must be signed in to change notification settings - Fork 457
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
tracer/option: Add envvar DD_CLIENT_HOSTNAME_ENABLED to config client hostname detection #1857
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.
Any thoughts on using the option disableHostnameDetection
that already exists here?
It's a bit confusing that the new env var DD_DISABLE_CLIENT_HOSTNAME
doesn't directly control the boolean option disableHostnameDetection
.
Most tracer config env vars are read in https://github.com/DataDog/dd-trace-go/blob/main/ddtrace/tracer/option.go and the config defaulting happens there, so by having the new env var read and applied there we keep the logic consolidated in one function newConfig
which improves readability.
I understand that you might have added the env var check in hostname.Get()
to cover the initial fill done in tracer.Start which was a nice catch but there are other options to handle it with the new suggestion
- Move the initial fill to
tracer/option.go
, and only do it ifconfig.disableHostnameDetection
isfalse
after defaulting. - The initial fill stays in
tracer.Start
but done via_ = t.hostname()
instead ofhostname.Get()
to make sureconfig.disableHostnameDetection
is checked.
Apart from that, I wanted to re-suggest a comment from the original PR about using enableHostnameDetection
instead of disableHostnameDetection
(also applies to the env var name) #1712 (comment) as I do believe it'd improve readability + less error prone, we'd get rid of double negatives like
dd-trace-go/ddtrace/tracer/tracer.go
Line 630 in 3ccf65d
if !t.config.disableHostnameDetection { |
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.
Looks great, thanks! One final suggestion to add unit test. LGMT otherwise!
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.
💯
… hostname detection (#1857) This allows users with aggressive security tools that alert on usage of cloud metadata APIs to disable this feature
What does this PR do?
Adds env var "DD_CLIENT_HOSTNAME_ENABLED" which allows users to disable client hostname detection by setting this value to
false
(Note the value defaults to true)Motivation
Some customers may need to disable this if they have aggressive security tooling that alerts on access to cloud metadata APIs.
Describe how to test/QA your changes
unit tests are good!
Reviewer's Checklist