Skip to content

Commit cd9e31d

Browse files
committed
decoupled the native side from DI/ER env vars to support HandsOff Config
1 parent 7786b65 commit cd9e31d

5 files changed

+46
-20
lines changed

tracer/src/Datadog.Tracer.Native/debugger_environment_variables.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ namespace environment
1616
const WSTRING internal_instrument_all_lines_enabled = WStr("DD_INTERNAL_DEBUGGER_INSTRUMENT_ALL_LINES");
1717
const WSTRING internal_instrument_all_lines_path = WStr("DD_INTERNAL_DEBUGGER_INSTRUMENT_ALL_LINES_PATH");
1818

19-
// Determines if the Dynamic Instrumentation (aka live debugger) is enabled.
19+
// Determines if the Dynamic Instrumentation (aka live debugger) product is enabled.
2020
const WSTRING dynamic_instrumentation_enabled = WStr("DD_DYNAMIC_INSTRUMENTATION_ENABLED");
2121

2222
// Determines if the Exception Replay product is enabled.
23-
const WSTRING exception_debugging_enabled = WStr("DD_EXCEPTION_DEBUGGING_ENABLED"); // Old name
2423
const WSTRING exception_replay_enabled = WStr("DD_EXCEPTION_REPLAY_ENABLED");
2524

25+
// Determines if Dynamic Instrumentation should be controlled by Stable Configuration
26+
const WSTRING dynamic_instrumentation_stable_config_enabled = WStr("DD_DYNAMIC_INSTRUMENTATION_MANAGED_ACTIVATION_ENABLED");
27+
28+
// Determines if Exception Replay should be controlled by Stable Configuration
29+
const WSTRING exception_replay_stable_config_enabled = WStr("DD_EXCEPTION_REPLAY_MANAGED_ACTIVATION_ENABLED");
30+
2631
} // namespace environment
2732
} // namespace debugger
2833

tracer/src/Datadog.Tracer.Native/debugger_environment_variables_util.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ bool IsDynamicInstrumentationEnabled()
1111

1212
bool IsExceptionReplayEnabled()
1313
{
14-
static int sValue = -1;
15-
if (sValue == -1)
16-
{
17-
const auto old_exception_replay_flag = GetEnvironmentValue(environment::exception_debugging_enabled);
18-
const auto new_exception_replay_flag = GetEnvironmentValue(environment::exception_replay_enabled);
19-
sValue = (IsTrue(old_exception_replay_flag) || IsTrue(new_exception_replay_flag)) ? 1 : 0;
20-
}
21-
22-
return sValue == 1;
14+
CheckIfTrue(GetEnvironmentValue(environment::exception_replay_enabled));
15+
}
16+
17+
bool IsDynamicInstrumentationStableConfigDisabled()
18+
{
19+
CheckIfFalse(GetEnvironmentValue(environment::dynamic_instrumentation_stable_config_enabled));
20+
}
21+
22+
bool IsExceptionReplayStableConfigDisabled()
23+
{
24+
CheckIfFalse(GetEnvironmentValue(environment::exception_replay_stable_config_enabled));
2325
}
2426

2527
bool IsDebuggerInstrumentAllEnabled()

tracer/src/Datadog.Tracer.Native/debugger_environment_variables_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace debugger
1010

1111
bool IsDynamicInstrumentationEnabled();
1212
bool IsExceptionReplayEnabled();
13+
bool IsDynamicInstrumentationStableConfigDisabled();
14+
bool IsExceptionReplayStableConfigDisabled();
1315
bool IsDebuggerInstrumentAllEnabled();
1416
bool IsDebuggerInstrumentAllLinesEnabled();
1517

tracer/src/Datadog.Tracer.Native/debugger_probes_instrumentation_requester.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,36 @@ DebuggerProbesInstrumentationRequester::DebuggerProbesInstrumentationRequester(
330330
m_work_offloader(work_offloader),
331331
m_fault_tolerant_method_duplicator(fault_tolerant_method_duplicator)
332332
{
333-
auto diEnabled = IsDynamicInstrumentationEnabled();
333+
auto diStableConfigDisabled = IsDynamicInstrumentationStableConfigDisabled();
334+
if (diStableConfigDisabled)
335+
{
336+
Logger::Info("Dynamic Instrumentation Stable Config is explicitly disabled");
337+
}
338+
339+
auto erStableConfigDisabled = IsExceptionReplayStableConfigDisabled();
340+
if (erStableConfigDisabled)
341+
{
342+
Logger::Info("Exception Replay Stable Config is explicitly disabled");
343+
}
344+
345+
auto diEnabled = !diStableConfigDisabled || IsDynamicInstrumentationEnabled();
334346
if (diEnabled == false)
335347
{
336-
Logger::Debug("Dynamic Instrumentation is disabled");
348+
Logger::Info("Dynamic Instrumentation hot standby is disabled");
337349
}
338350

339-
auto erEnabled = IsExceptionReplayEnabled();
351+
auto erEnabled = !erStableConfigDisabled || IsExceptionReplayEnabled();
340352
if (erEnabled == false)
341353
{
342-
Logger::Debug("Exception Replay is explicitly disabled");
354+
Logger::Info("Exception Replay hot standby is disabled");
343355
}
344356

345-
is_debugger_or_exception_debugging_enabled = diEnabled || erEnabled;
357+
is_debugger_or_exception_replay_hot_standby = diEnabled || erEnabled;
358+
359+
if (is_debugger_or_exception_replay_hot_standby)
360+
{
361+
Logger::Info("Dynamic Instrumentation/Exception Replay Hot Standby is on");
362+
}
346363
}
347364

348365
void DebuggerProbesInstrumentationRequester::RemoveProbes(debugger::DebuggerRemoveProbesDefinition* removeProbes,
@@ -1027,13 +1044,13 @@ void DebuggerProbesInstrumentationRequester::ModuleLoadFinished_AddMetadataToMod
10271044

10281045
HRESULT STDMETHODCALLTYPE DebuggerProbesInstrumentationRequester::ModuleLoadFinished(const ModuleID moduleId)
10291046
{
1030-
if (!is_debugger_or_exception_debugging_enabled)
1047+
if (!is_debugger_or_exception_replay_hot_standby)
10311048
{
1032-
return S_OK;
1049+
return S_OK;
10331050
}
10341051

10351052
// IMPORTANT: The call to `ModuleLoadFinished_AddMetadataToModule` must be in `ModuleLoadFinished` as mutating the
1036-
// layout of types is only feasible prior the type is loaded.s
1053+
// layout of types is only feasible prior the type is loaded.
10371054
ModuleLoadFinished_AddMetadataToModule(moduleId);
10381055
RequestRejitForLoadedModule(moduleId);
10391056
return S_OK;

tracer/src/Datadog.Tracer.Native/debugger_probes_instrumentation_requester.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class DebuggerProbesInstrumentationRequester
4040
std::shared_ptr<RejitHandler> m_rejit_handler = nullptr;
4141
std::shared_ptr<RejitWorkOffloader> m_work_offloader = nullptr;
4242
std::shared_ptr<fault_tolerant::FaultTolerantMethodDuplicator> m_fault_tolerant_method_duplicator = nullptr;
43-
bool is_debugger_or_exception_debugging_enabled = false;
43+
bool is_debugger_or_exception_replay_hot_standby = false;
4444
std::unordered_map<std::pair<std::string, mdToken>, std::vector<int>, pair_hash> explorationLineProbes;
4545
std::once_flag explorationLinesInitFlag;
4646

0 commit comments

Comments
 (0)