From 09e98a23e06f2ececb317514a73a68b4dc63641d Mon Sep 17 00:00:00 2001
From: Marty Tippin <120425148+tippmar-nr@users.noreply.github.com>
Date: Thu, 13 Feb 2025 13:46:56 -0600
Subject: [PATCH 1/2] Revert "Add profiler support for in-process azure
functions"
This reverts commit 32165bb6051d3b56d6f257137273eb2894cf3cb9.
---
.../Profiler/Configuration/Configuration.h | 23 +------
.../ConfigurationTest/ConfigurationTest.cpp | 67 ++-----------------
2 files changed, 8 insertions(+), 82 deletions(-)
diff --git a/src/Agent/NewRelic/Profiler/Configuration/Configuration.h b/src/Agent/NewRelic/Profiler/Configuration/Configuration.h
index 77682b61a..7c00bfe69 100644
--- a/src/Agent/NewRelic/Profiler/Configuration/Configuration.h
+++ b/src/Agent/NewRelic/Profiler/Configuration/Configuration.h
@@ -644,20 +644,11 @@ namespace NewRelic { namespace Profiler { namespace Configuration {
bool IsAzureFunction() const
{
- // Azure Functions sets the FUNCTIONS_WORKER_RUNTIME environment variable when running in Azure Functions
+ // Azure Functions sets the FUNCTIONS_WORKER_RUNTIME environment variable to "dotnet-isolated" when running in the .NET worker.
auto functionsWorkerRuntime = _systemCalls->TryGetEnvironmentVariable(_X("FUNCTIONS_WORKER_RUNTIME"));
return functionsWorkerRuntime != nullptr && functionsWorkerRuntime->length() > 0;
}
- bool IsAzureFunctionInProcess() const
- {
- auto functionsWorkerRuntime = _systemCalls->TryGetEnvironmentVariable(_X("FUNCTIONS_WORKER_RUNTIME"));
-
- // "dotnet" when running in in-process mode
- // "dotnet-isolated" when running in isolated mode
- return functionsWorkerRuntime != nullptr && Strings::AreEqualCaseInsensitive(*functionsWorkerRuntime, _X("dotnet"));
- }
-
///
/// Returns 0 if the process should not be instrumented, 1 if it should be instrumented, and -1 if it is indeterminate.
///
@@ -665,18 +656,6 @@ namespace NewRelic { namespace Profiler { namespace Configuration {
{
LogInfo(_X("Azure function detected. Determining whether to instrument ") + commandLine);
- if (IsAzureFunctionInProcess())
- {
- // appPoolName starts with "~" for Azure Functions background tasks (kudu / scm)
- if (appPoolId.find(_X("~")) == 0) {
- LogInfo(_X("This application pool (") + appPoolId + _X(") has been identified as an in-process Azure Functions built-in background application and will be ignored."));
- return 0;
- }
-
- LogInfo(L"Function is running in-process. This process will be instrumented.");
- return 1;
- }
-
bool isAzureWebJobsScriptWebHost = appPoolId.length() > 0 && NewRelic::Profiler::Strings::ContainsCaseInsensitive(commandLine, appPoolId);
if (isAzureWebJobsScriptWebHost)
{
diff --git a/src/Agent/NewRelic/Profiler/ConfigurationTest/ConfigurationTest.cpp b/src/Agent/NewRelic/Profiler/ConfigurationTest/ConfigurationTest.cpp
index f7614bc94..a6648b758 100644
--- a/src/Agent/NewRelic/Profiler/ConfigurationTest/ConfigurationTest.cpp
+++ b/src/Agent/NewRelic/Profiler/ConfigurationTest/ConfigurationTest.cpp
@@ -96,7 +96,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
// tests to verify that "legacy" behavior (before azure function support) is retained.
// If NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED environment variable is not set or is set to false,
// we should behave as if no azure function support has been added.
- TEST_METHOD(isolated_azure_function_should_behave_as_legacy_if_azure_function_mode_disabled)
+ TEST_METHOD(azure_function_should_behave_as_legacy_if_azure_function_mode_disabled)
{
std::wstring configurationXml(L"\
\
@@ -113,25 +113,8 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
Assert::IsTrue(configuration.ShouldInstrument(L"functionsnethost.exe", L"", L"", L"blah blah blah FooBarBaz blah blah blah", true));
}
- TEST_METHOD(in_proc_azure_function_should_behave_as_legacy_if_azure_function_mode_disabled)
- {
- std::wstring configurationXml(L"\
- \
- \
- \
- \
- ");
-
- auto systemCalls = std::make_shared();
- systemCalls->environmentVariables[L"FUNCTIONS_WORKER_RUNTIME"] = L"dotnet";
- systemCalls->environmentVariables[L"NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED"] = L"0";
-
- Configuration configuration(configurationXml, _missingConfig, L"", systemCalls);
-
- Assert::IsTrue(configuration.ShouldInstrument(L"w3wp.exe", L"", L"someapppoolname", L"blah blah blah FooBarBaz blah blah blah", true));
- }
- TEST_METHOD(should_not_instrument_isolated_azure_function_app_pool_id_in_commandline)
+ TEST_METHOD(should_not_instrument_azure_function_app_pool_id_in_commandline)
{
std::wstring configurationXml(L"\
\
@@ -149,7 +132,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
Assert::IsFalse(configuration.ShouldInstrument(L"w3wp.exe", L"", L"FooBarBaz", L"blah blah blah FooBarBaz blah blah blah", true));
}
- TEST_METHOD(should_instrument_isolated_azure_function_fallback_to_app_pool_checking)
+ TEST_METHOD(should_instrument_azure_function_fallback_to_app_pool_checking)
{
std::wstring configurationXml(L"\
\
@@ -167,7 +150,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
Assert::IsTrue(configuration.ShouldInstrument(L"w3wp.exe", L"", L"foo", L"", true));
}
- TEST_METHOD(should_not_instrument_isolated_azure_function_func_exe_process_path)
+ TEST_METHOD(should_not_instrument_azure_function_func_exe_process_path)
{
std::wstring configurationXml(L"\
\
@@ -185,7 +168,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
Assert::IsFalse(configuration.ShouldInstrument(L"func.exe", L"", L"", L"blah blah blah FooBarBaz blah blah blah", true));
}
- TEST_METHOD(should_instrument_isolated_azure_function_functionsnethost_exe_process_path)
+ TEST_METHOD(should_instrument_azure_function_functionsnethost_exe_process_path)
{
std::wstring configurationXml(L"\
\
@@ -203,7 +186,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
Assert::IsTrue(configuration.ShouldInstrument(L"functionsnethost.exe", L"", L"", L"blah blah blah FooBarBaz blah blah blah", true));
}
- TEST_METHOD(should_instrument_isolated_azure_function_functions_worker_id_in_command_line)
+ TEST_METHOD(should_instrument_azure_function_functions_worker_id_in_command_line)
{
std::wstring configurationXml(L"\
\
@@ -221,7 +204,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
Assert::IsTrue(configuration.ShouldInstrument(L"SomeFW481FunctionApp.exe", L"", L"", L"blah blah blah --functions-worker-id FooBarBaz blah blah blah", false));
}
- TEST_METHOD(should_instrument_isolated_azure_function_worker_id_in_command_line)
+ TEST_METHOD(should_instrument_azure_function_worker_id_in_command_line)
{
std::wstring configurationXml(L"\
\
@@ -239,42 +222,6 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
Assert::IsTrue(configuration.ShouldInstrument(L"SomeFW481FunctionApp.exe", L"", L"", L"blah blah blah --worker-id FooBarBaz blah blah blah", false));
}
- TEST_METHOD(should_instrument_in_process_azure_function)
- {
- std::wstring configurationXml(L"\
- \
- \
- \
- \
-");
-
- auto systemCalls = std::make_shared();
- systemCalls->environmentVariables[L"FUNCTIONS_WORKER_RUNTIME"] = L"dotnet";
- systemCalls->environmentVariables[L"NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED"] = L"true";
-
- Configuration configuration(configurationXml, _missingConfig, L"", systemCalls);
-
- Assert::IsTrue(configuration.ShouldInstrument(L"SomeFW481FunctionApp.exe", L"", L"someapppoolname", L"blah blah blah FooBarBaz blah blah blah", false));
- }
-
- TEST_METHOD(should_not_instrument_in_process_azure_function_kudu_app_pool)
- {
- std::wstring configurationXml(L"\
- \
- \
- \
- \
-");
-
- auto systemCalls = std::make_shared();
- systemCalls->environmentVariables[L"FUNCTIONS_WORKER_RUNTIME"] = L"dotnet";
- systemCalls->environmentVariables[L"NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED"] = L"true";
-
- Configuration configuration(configurationXml, _missingConfig, L"", systemCalls);
-
- Assert::IsFalse(configuration.ShouldInstrument(L"SomeFW481FunctionApp.exe", L"", L"~somekuduapppool", L"blah blah blah FooBarBaz blah blah blah", false));
- }
-
TEST_METHOD(instrument_process)
{
ProcessesPtr processes(new Processes());
From ee710b705e8d310deedc52be40efb37fe62ef1f7 Mon Sep 17 00:00:00 2001
From: Marty Tippin <120425148+tippmar-nr@users.noreply.github.com>
Date: Thu, 13 Feb 2025 13:47:07 -0600
Subject: [PATCH 2/2] Revert "chore: Update Profiler NuGet Package Reference to
v10.36.0.9 (#2993)"
This reverts commit ceb87076479fd62a9521def750b6bcef55f1c1dd.
---
src/Agent/NewRelic/Home/Home.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Agent/NewRelic/Home/Home.csproj b/src/Agent/NewRelic/Home/Home.csproj
index e3ab62dcc..2ae7247ad 100644
--- a/src/Agent/NewRelic/Home/Home.csproj
+++ b/src/Agent/NewRelic/Home/Home.csproj
@@ -13,7 +13,7 @@
-
+