dd-trace-go icon indicating copy to clipboard operation
dd-trace-go copied to clipboard

profiler: add enable flag to control profiler activation

Open korECM opened this issue 1 year ago • 2 comments

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 to DD_TRACE_ENABLED. By default, DD_PROFILING_ENABLED is set to true, meaning profiling will be enabled if profiler.Start() is called in the application code. If DD_PROFILING_ENABLED is set to false, profiling will be disabled even if profiler.Start() is called. This allows the application code to always call profiler.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:

  • Addition of enable field in profiler config struct.
  • Update to defaultConfig function to read DD_PROFILING_ENABLED environment variable.
  • Conditional check in Start function to skip profiling if enable field in profiler config is false.
  • Unit tests for DD_PROFILING_ENABLED in options_test.go and profiler_test.go.

Reviewer's Checklist

  • [ ] Changed code has unit tests for its functionality at or near 100% coverage.
  • [ ] System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • [ ] There is a benchmark for any new code, or changes to existing code.
  • [ ] If this interacts with the agent in a new way, a system test has been added.
  • [ ] Add an appropriate team label so this PR gets put in the right place for the release notes.
  • [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

korECM avatar Aug 31 '24 08:08 korECM

Hi @felixge @nsrip-dd

I hope you're doing well! I noticed that my PR has been pending review for about a month. If you have some time, I would greatly appreciate it if you could take a look.

Thank you!

korECM avatar Oct 14 '24 07:10 korECM

@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.

felixge avatar Oct 21 '24 09:10 felixge

Thanks @korECM for contributing this 🙇. Sorry for the delays.

felixge avatar Oct 28 '24 11:10 felixge