-
Notifications
You must be signed in to change notification settings - Fork 435
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
profiler: add enable flag to control profiler activation #2840
Conversation
Add a new 'enable' field to the profiler config, controlled by the DD_PROFILING_ENABLED environment variable. This allows users to disable profiling even when the Start() function is called. The enable flag defaults to true, maintaining backwards compatibility. When set to false, the profiler will not start, providing a simple way to toggle profiling without code changes. Update tests to cover the new functionality and add logging for the new configuration option.
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.
LGTM. @nsrip-dd could you also take a look please? Kicking of a CI run now.
Updated profiler options to automatically enable profiling if the environment variable "DD_PROFILING_ENABLED" is set to "auto". This change delegates the decision to the Datadog admission controller when "auto" is specified.
Implemented a new test to verify that no profiles are received when the profiler is disabled. This helps ensure the profiler respects the DD_PROFILING_ENABLED environment variable.
@korECM sorry about the delay here. I've blocked some time in my calendar tomorrow to follow up. Hopefully we can get this landed before end of week. |
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.
LGTM, thanks! I'll let @felixge have one more pass then this should be good to land IMO
this is more consistent with the env var that is controlling this
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.
LGTM. I pushed two commits to address some NITs. @nsrip-dd please re-review and merge if those changes look okay. 🙇
Thanks @korECM for contributing this 🙇. Sorry for the delays. |
What does this PR do?
This PR introduces a new environment variable
DD_PROFILING_ENABLED
to control the profiler's behavior in a way similar toDD_TRACE_ENABLED
. By default,DD_PROFILING_ENABLED
is set totrue
, meaning profiling will be enabled ifprofiler.Start()
is called in the application code. IfDD_PROFILING_ENABLED
is set tofalse
, profiling will be disabled even ifprofiler.Start()
is called. This allows the application code to always callprofiler.Start()
while dynamically adjusting profiling through the environment variable.Motivation
Fixes #2834
The motivation for this PR is to simplify the control of profiling behavior across multiple applications. By introducing
DD_PROFILING_ENABLED
, developers can avoid the cumbersome task of managing environment variables within the application code and instead control profiling through a single environment variable.Additional Information
This PR includes the following changes:
DD_PROFILING_ENABLED
environment variable.Start function
to skip profiling ifenable
field in profiler config isfalse
.DD_PROFILING_ENABLED
inoptions_test.go
andprofiler_test.go
.Reviewer's Checklist