-
Notifications
You must be signed in to change notification settings - Fork 152
Consolidate bailout checks into native loader #7462
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,9 @@ namespace datadog::shared::nativeloader | |
const auto process_name = ::shared::GetCurrentProcessName(); | ||
Log::Debug("ProcessName: ", process_name); | ||
|
||
const auto [process_command_line , tokenized_command_line] = GetCurrentProcessCommandLine(); | ||
Log::Info("Process CommandLine: ", process_command_line); | ||
|
||
const auto& include_process_names = GetEnvironmentValues(EnvironmentVariables::IncludeProcessNames); | ||
|
||
// if there is a process inclusion list, attach clrprofiler only if this | ||
|
@@ -158,9 +161,6 @@ namespace datadog::shared::nativeloader | |
// don't give useful information, add latency, and risk triggering bugs in the runtime, | ||
// particularly around shutdown, like this one: https://github.com/dotnet/runtime/issues/55441 | ||
// Note that you should also consider adding to the SSI tracer/build/artifacts/requirements.json file | ||
const auto [process_command_line , tokenized_command_line] = GetCurrentProcessCommandLine(); | ||
Log::Info("Process CommandLine: ", process_command_line); | ||
|
||
if (!process_command_line.empty()) | ||
{ | ||
const auto isDotNetProcess = process_name == WStr("dotnet") || process_name == WStr("dotnet.exe"); | ||
|
@@ -228,6 +228,68 @@ namespace datadog::shared::nativeloader | |
"but an unsupported command was detected"); | ||
return CORPROF_E_PROFILER_CANCEL_ACTIVATION; | ||
} | ||
|
||
// Additional Special case CI Visibility checks | ||
bool is_ci_visibility_enabled = false; | ||
if (TryParseBooleanEnvironmentValue(GetEnvironmentValue(EnvironmentVariables::CiVisibilityEnabled), is_ci_visibility_enabled) | ||
&& is_ci_visibility_enabled) | ||
{ | ||
if (tokenized_command_line[1] != WStr("test") && | ||
process_command_line.find(WStr("testhost")) == WSTRING::npos && | ||
process_command_line.find(WStr("exec")) == WSTRING::npos && | ||
process_command_line.find(WStr("datacollector")) == WSTRING::npos && | ||
process_command_line.find(WStr("vstest.console.dll")) == WSTRING::npos) | ||
{ | ||
Log::Info("The Tracer Profiler has been disabled because the process is running in CI Visibility " | ||
"mode, the name is 'dotnet' but the commandline doesn't contain 'testhost' or 'datacollector' or 'vstest.console.dll' or 'exec'"); | ||
return CORPROF_E_PROFILER_CANCEL_ACTIVATION; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// AAS checks | ||
bool isRunningInAas; | ||
if (TryParseBooleanEnvironmentValue(GetEnvironmentValue(EnvironmentVariables::IsAzureAppServicesExtension), | ||
isRunningInAas) && isRunningInAas) | ||
{ | ||
Log::Info("Azure App Services detected."); | ||
|
||
const auto& app_pool_id_value = GetEnvironmentValue(EnvironmentVariables::AzureAppServicesAppPoolId); | ||
|
||
if (app_pool_id_value.size() > 1 && app_pool_id_value.at(0) == '~') | ||
{ | ||
Log::Info( | ||
"DATADOG TRACER DIAGNOSTICS - ClrProfiler disabled: ", EnvironmentVariables::AzureAppServicesAppPoolId, " ", | ||
app_pool_id_value, " is an Azure App Services infrastructure process."); | ||
return CORPROF_E_PROFILER_CANCEL_ACTIVATION; | ||
} | ||
|
||
const auto& cli_telemetry_profile_value = | ||
GetEnvironmentValue(EnvironmentVariables::AzureAppServicesCliTelemetryProfilerValue); | ||
|
||
if (cli_telemetry_profile_value == WStr("AzureKudu")) | ||
{ | ||
Log::Info("DATADOG TRACER DIAGNOSTICS - ClrProfiler disabled: ", app_pool_id_value, | ||
" is Kudu, an Azure App Services reserved process."); | ||
return CORPROF_E_PROFILER_CANCEL_ACTIVATION; | ||
} | ||
|
||
const auto& functions_worker_runtime_value = | ||
GetEnvironmentValue(EnvironmentVariables::AzureAppServicesFunctionsWorkerRuntime); | ||
|
||
if (!functions_worker_runtime_value.empty()) | ||
{ | ||
// enabled by default | ||
bool azure_functions_enabled; | ||
if (TryParseBooleanEnvironmentValue( | ||
GetEnvironmentValue( | ||
EnvironmentVariables::AzureFunctionsInstrumentationEnabled), | ||
azure_functions_enabled) && !azure_functions_enabled) | ||
{ | ||
Log::Info("DATADOG TRACER DIAGNOSTICS - ClrProfiler explicitly disabled for Azure Functions."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL we had a env var for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same 😅 |
||
return CORPROF_E_PROFILER_CANCEL_ACTIVATION; | ||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.