Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions shared/src/Datadog.Trace.ClrProfiler.Native/cor_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace datadog::shared::nativeloader
{ \
std::ostringstream hexValue; \
hexValue << std::hex << hr; \
Log::Warn("CorProfiler::", STR(EXPR), ": [Tracer] Error in ", STR(EXPR), " call: ", hexValue.str()); \
Log::Warn("CorProfiler::", STR(EXPR), ": [Instrumentation] Error in ", STR(EXPR), " call: ", hexValue.str()); \
gHR = hr; \
} \
} \
Expand Down Expand Up @@ -130,7 +130,7 @@ namespace datadog::shared::nativeloader
// process's name is on the list
if (!include_process_names.empty() && !Contains(include_process_names, process_name))
{
Log::Info("CorProfiler::Initialize ClrProfiler disabled: ", process_name, " not found in ",
Log::Info("CorProfiler::Initialize Datadog SDK disabled: ", process_name, " not found in ",
Copy link
Member

@lucaspimentel lucaspimentel Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Datadog SDK

"but the auto-instrumentation library is not an SDK!!" :trollface:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're preaching to the choir man, just give me an alternative suggestion 😂 Datadog Library? Or we can just drop SDK entirely - 'Datadog disabled" works too 🤷‍♂️

EnvironmentVariables::IncludeProcessNames, ".");
return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
}
Expand All @@ -142,7 +142,7 @@ namespace datadog::shared::nativeloader
const auto& exclude_process_names = GetEnvironmentValues(EnvironmentVariables::ExcludeProcessNames);
if (!exclude_process_names.empty() && Contains(exclude_process_names, process_name))
{
Log::Info("CorProfiler::Initialize ClrProfiler disabled: ", process_name, " found in ",
Log::Info("CorProfiler::Initialize Datadog SDK disabled: ", process_name, " found in ",
EnvironmentVariables::ExcludeProcessNames, ".");
return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
}
Expand All @@ -151,7 +151,7 @@ namespace datadog::shared::nativeloader
{
if (process_name == exclude_assembly)
{
Log::Info("CorProfiler::Initialize ClrProfiler disabled: ", process_name," found in default exclude list");
Log::Info("CorProfiler::Initialize Datadog SDK disabled: ", process_name," found in default exclude list");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but why are they called default_exclude_assemblies and exclude_assembly when it's a list of process names? 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A totally reasonable question 😅 As far as I can tell, it all traces back years ago and was essentially copy pasta. Going to do a bit more cleanup separately

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a PR to fix that (and other minor annoyances) here: #7475

return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
}
}
Expand Down Expand Up @@ -224,7 +224,7 @@ namespace datadog::shared::nativeloader

if (is_ignored_command)
{
Log::Info("The Tracer Profiler has been disabled because the process is 'dotnet' "
Log::Info("Instrumentation has been disabled because the process name is 'dotnet' "
"but an unsupported command was detected");
return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
}
Expand All @@ -240,8 +240,8 @@ namespace datadog::shared::nativeloader
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'");
Log::Info("Instrumentation disabled because the process is running in CI Visibility "
"mode and its name is 'dotnet', but the command line doesn't contain 'testhost', 'datacollector', 'vstest.console.dll', or 'exec'");
return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
}
}
Expand All @@ -261,7 +261,7 @@ namespace datadog::shared::nativeloader
if (app_pool_id_value.size() > 1 && app_pool_id_value.at(0) == '~')
{
Log::Info(
"DATADOG TRACER DIAGNOSTICS - ClrProfiler disabled: ", EnvironmentVariables::AzureAppServicesAppPoolId, " ",
"DATADOG TRACER DIAGNOSTICS - Datadog SDK disabled: ", EnvironmentVariables::AzureAppServicesAppPoolId, " ",
app_pool_id_value, " is an Azure App Services infrastructure process.");
return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
}
Expand All @@ -271,7 +271,7 @@ namespace datadog::shared::nativeloader

if (cli_telemetry_profile_value == WStr("AzureKudu"))
{
Log::Info("DATADOG TRACER DIAGNOSTICS - ClrProfiler disabled: ", app_pool_id_value,
Log::Info("DATADOG TRACER DIAGNOSTICS - Datadog SDK disabled: ", app_pool_id_value,
" is Kudu, an Azure App Services reserved process.");
return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
}
Expand All @@ -288,7 +288,7 @@ namespace datadog::shared::nativeloader
EnvironmentVariables::AzureFunctionsInstrumentationEnabled),
azure_functions_enabled) && !azure_functions_enabled)
{
Log::Info("DATADOG TRACER DIAGNOSTICS - ClrProfiler explicitly disabled for Azure Functions.");
Log::Info("DATADOG TRACER DIAGNOSTICS - Datadog SDK explicitly disabled for Azure Functions.");
return CORPROF_E_PROFILER_CANCEL_ACTIVATION;
}
}
Expand All @@ -303,7 +303,7 @@ namespace datadog::shared::nativeloader
HRESULT hr = pICorProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo4), (void**) &info4);
if (FAILED(hr))
{
Log::Warn("CorProfiler::Initialize: Failed to attach profiler, interface ICorProfilerInfo4 not found.");
Log::Warn("CorProfiler::Initialize: Failed to attach Datadog SDK, interface ICorProfilerInfo4 not found.");
// we're not recording the exact version here, we just know that at this point it's not enough
single_step_guard_rails.RecordBootstrapError(SingleStepGuardRails::NetFrameworkRuntime, inferredVersion, "incompatible_runtime");
return E_FAIL;
Expand Down Expand Up @@ -488,7 +488,7 @@ namespace datadog::shared::nativeloader

Log::Debug("CorProfiler::Initialize: *LocalMaskLow: ", local_mask_low);
Log::Debug("CorProfiler::Initialize: *LocalMaskHi : ", local_mask_hi);
Log::Info("CorProfiler::Initialize: Tracer Profiler initialized successfully.");
Log::Info("CorProfiler::Initialize: Instrumentation initialized successfully.");
}
else
{
Expand All @@ -497,7 +497,7 @@ namespace datadog::shared::nativeloader
}
else
{
Log::Warn("CorProfiler::Initialize: Error Initializing the Tracer Profiler, unloading the dynamic library.");
Log::Warn("CorProfiler::Initialize: Error Initializing the Instrumentation component, unloading the dynamic library.");
m_tracerProfiler = nullptr;
}
}
Expand Down Expand Up @@ -1163,80 +1163,80 @@ namespace datadog::shared::nativeloader
{
Log::Info(
"No ICorProfilerInfoXxx available. Null pointer was passed to CorProfilerCallback for initialization."
" No compatible Profiling API is available.");
" No compatible ICorProfiler API is available.");
return "";
}

IUnknown* tstVerProfilerInfo;
if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo12), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo12 available. Profiling API compatibility: .NET Core 5.0 or later.");
Log::Info("ICorProfilerInfo12 available. ICorProfiler API compatibility: .NET Core 5.0 or later.");
tstVerProfilerInfo->Release();
return "5.0.0";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo11), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo11 available. Profiling API compatibility: .NET Core 3.1 or later.");
Log::Info("ICorProfilerInfo11 available. ICorProfiler API compatibility: .NET Core 3.1 or later.");
tstVerProfilerInfo->Release();
return "3.1.0";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo10), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo10 available. Profiling API compatibility: .NET Core 3.0 or later.");
Log::Info("ICorProfilerInfo10 available. ICorProfiler API compatibility: .NET Core 3.0 or later.");
tstVerProfilerInfo->Release();
return "3.0.0";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo9), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo9 available. Profiling API compatibility: .NET Core 2.2 or later.");
Log::Info("ICorProfilerInfo9 available. ICorProfiler API compatibility: .NET Core 2.2 or later.");
tstVerProfilerInfo->Release();
return "2.1.0";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo8), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo8 available. Profiling API compatibility: .NET Fx 4.7.2 or later.");
Log::Info("ICorProfilerInfo8 available. ICorProfiler API compatibility: .NET Fx 4.7.2 or later.");
tstVerProfilerInfo->Release();
return "4.7.2";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo7), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo7 available. Profiling API compatibility: .NET Fx 4.6.1 or later.");
Log::Info("ICorProfilerInfo7 available. ICorProfiler API compatibility: .NET Fx 4.6.1 or later.");
tstVerProfilerInfo->Release();
return "4.6.1";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo6), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo6 available. Profiling API compatibility: .NET Fx 4.6 or later.");
Log::Info("ICorProfilerInfo6 available. ICorProfiler API compatibility: .NET Fx 4.6 or later.");
tstVerProfilerInfo->Release();
return "4.6.0";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo5), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo5 available. Profiling API compatibility: .NET Fx 4.5.2 or later.");
Log::Info("ICorProfilerInfo5 available. ICorProfiler API compatibility: .NET Fx 4.5.2 or later.");
tstVerProfilerInfo->Release();
return "4.5.2";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo4), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo4 available. Profiling API compatibility: .NET Fx 4.5 or later.");
Log::Info("ICorProfilerInfo4 available. ICorProfiler API compatibility: .NET Fx 4.5 or later.");
tstVerProfilerInfo->Release();
return "4.5.0";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo3), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo3 available. Profiling API compatibility: .NET Fx 4.0 or later.");
Log::Info("ICorProfilerInfo3 available. ICorProfiler API compatibility: .NET Fx 4.0 or later.");
tstVerProfilerInfo->Release();
return "4.0.0";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo2), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo2 available. Profiling API compatibility: .NET Fx 2.0 or later.");
Log::Info("ICorProfilerInfo2 available. ICorProfiler API compatibility: .NET Fx 2.0 or later.");
tstVerProfilerInfo->Release();
return "2.0.0";
}
else if (S_OK == corProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo), (void**) &tstVerProfilerInfo))
{
Log::Info("ICorProfilerInfo available. Profiling API compatibility: .NET Fx 2 or later.");
Log::Info("ICorProfilerInfo available. ICorProfiler API compatibility: .NET Fx 2 or later.");
tstVerProfilerInfo->Release();
return "2.0.0";
}
Expand All @@ -1245,7 +1245,7 @@ namespace datadog::shared::nativeloader
Log::Info("No ICorProfilerInfoXxx available. A valid IUnknown pointer was passed to CorProfilerCallback"
" for initialization, but QueryInterface(..) did not succeed for any of the known "
"ICorProfilerInfoXxx ifaces."
" No compatible Profiling API is available.");
" No compatible ICorProfiler API is available.");
return "";
}
}
Expand All @@ -1266,12 +1266,12 @@ namespace datadog::shared::nativeloader
{
std::ostringstream hex;
hex << std::hex << hrGRI;
Log::Info("Initializing the Profiler: Exact runtime version could not be obtained (0x", hex.str(), ")");
Log::Info("Initializing the Datadog SDK: Exact runtime version could not be obtained (0x", hex.str(), ")");
return {};
}
else
{
Log::Info("Initializing the Profiler: Reported runtime version : { clrInstanceId: ", clrInstanceId,
Log::Info("Initializing the Datadog SDK: Reported runtime version : { clrInstanceId: ", clrInstanceId,
", runtimeType:",
((runtimeType == COR_PRF_DESKTOP_CLR) ? "DESKTOP_CLR"
: (runtimeType == COR_PRF_CORE_CLR)
Expand All @@ -1287,7 +1287,7 @@ namespace datadog::shared::nativeloader
{
if (m_this == nullptr)
{
Log::Warn("The native loader library is not properly initialized. We cannot get the current AppDomain Id.");
Log::Warn("The Datadog SDK is not properly initialized. We cannot get the current AppDomain Id.");
return (AppDomainID)0;
}

Expand Down Expand Up @@ -1318,7 +1318,7 @@ namespace datadog::shared::nativeloader
{
if (m_this == nullptr)
{
Log::Warn("The native loader library is not properly initialized. We cannot get the runtime id for the AppDomain ID #", appDomain);
Log::Warn("The Datadog SDK is not properly initialized. We cannot get the runtime id for the AppDomain ID #", appDomain);
return nullptr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ namespace datadog::shared::nativeloader

if (FAILED(m_initializationResult))
{
Log::Error("Error loading all cor profiler class factories.");
Log::Error("Error loading all CorProfiler class factories.");
return m_initializationResult;
}

m_initializationResult = LoadInstance();

if (FAILED(m_initializationResult))
{
Log::Error("Error loading all cor profiler instances.");
Log::Error("Error loading all CorProfiler instances.");
return m_initializationResult;
}

Expand Down Expand Up @@ -181,7 +181,7 @@ namespace datadog::shared::nativeloader
}
else
{
Log::Warn("DynamicDispatcherImpl::LoadConfiguration: COR Profiler Type is invalid: ", type);
Log::Warn("DynamicDispatcherImpl::LoadConfiguration: CorProfiler Type is invalid: ", type);
}
}
}
Expand All @@ -200,11 +200,11 @@ namespace datadog::shared::nativeloader
{
if (result == CORPROF_E_PROFILER_CANCEL_ACTIVATION)
{
Log::Info("The continuous profiler is disabled");
Log::Info("The Continuous Profiler is disabled");
}
else
{
Log::Warn("DynamicDispatcherImpl::LoadClassFactory: Error trying to load continuous profiler class factory in: ",
Log::Warn("DynamicDispatcherImpl::LoadClassFactory: Error trying to load Continuous Profiler class factory in: ",
m_continuousProfilerInstance->GetFilePath(), ", error code: ", result);
}

Expand All @@ -229,11 +229,11 @@ namespace datadog::shared::nativeloader
{
if (result == CORPROF_E_PROFILER_CANCEL_ACTIVATION)
{
Log::Info("The tracer is disabled");
Log::Info("Instrumentation is disabled");
}
else
{
Log::Warn("DynamicDispatcherImpl::LoadClassFactory: Error trying to load tracer class factory in: ",
Log::Warn("DynamicDispatcherImpl::LoadClassFactory: Error trying to load Instrumentation class factory in: ",
m_tracerInstance->GetFilePath(), ", error code: ", result);
}

Expand Down Expand Up @@ -287,7 +287,7 @@ namespace datadog::shared::nativeloader

if (FAILED(result))
{
Log::Warn("DynamicDispatcherImpl::LoadInstance: Error trying to load the continuous profiler instance in: ",
Log::Warn("DynamicDispatcherImpl::LoadInstance: Error trying to load the Continuous Profiler instance in: ",
m_continuousProfilerInstance->GetFilePath(), ", error code: ", result);

// If we cannot load the class factory we release the instance.
Expand All @@ -309,7 +309,7 @@ namespace datadog::shared::nativeloader
HRESULT result = m_tracerInstance->LoadInstance();
if (FAILED(result))
{
Log::Warn("DynamicDispatcherImpl::LoadInstance: Error trying to load the tracer instance in: ",
Log::Warn("DynamicDispatcherImpl::LoadInstance: Error trying to load the Instrumentation instance in: ",
m_tracerInstance->GetFilePath(), ", error code: ", result);

// If we cannot load the class factory we release the instance.
Expand Down Expand Up @@ -360,7 +360,7 @@ namespace datadog::shared::nativeloader
HRESULT hr = m_continuousProfilerInstance->DllCanUnloadNow();
if (FAILED(hr))
{
Log::Warn("DynamicDispatcherImpl::DllCanUnloadNow: Error calling the continuous profiler DllCanUnloadNow in: ",
Log::Warn("DynamicDispatcherImpl::DllCanUnloadNow: Error calling the Continuous Profiler DllCanUnloadNow in: ",
m_continuousProfilerInstance->GetFilePath());
result = hr;
}
Expand All @@ -376,7 +376,7 @@ namespace datadog::shared::nativeloader
HRESULT hr = m_tracerInstance->DllCanUnloadNow();
if (FAILED(hr))
{
Log::Warn("DynamicDispatcherImpl::DllCanUnloadNow: Error calling the tracer DllCanUnloadNow in: ", m_tracerInstance->GetFilePath());
Log::Warn("DynamicDispatcherImpl::DllCanUnloadNow: Error calling the Instrumentation DllCanUnloadNow in: ", m_tracerInstance->GetFilePath());
result = hr;
}
else if (hr != S_OK)
Expand Down
Loading
Loading