@@ -73,6 +73,47 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
73
73
Assert::IsFalse (configuration.ShouldInstrument (L" foo.exe" , L" " , L" " , L" " , false ));
74
74
}
75
75
76
+ // tests to verify that "legacy" behavior (before azure function support) is retained.
77
+ // If NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED environment variable is not set or is set to false,
78
+ // we should behave as if no azure function support has been added.
79
+ TEST_METHOD (azure_function_should_behave_as_legacy_if_azure_function_mode_not_specified)
80
+ {
81
+ std::wstring configurationXml (L" \
82
+ <?xml version=\" 1.0\" ?>\
83
+ <configuration>\
84
+ <log level=\" deBug\" />\
85
+ </configuration>\
86
+ " );
87
+
88
+ auto systemCalls = std::make_shared<NewRelic::Profiler::Logger::Test::SystemCalls>();
89
+ systemCalls->environmentVariables [L" FUNCTIONS_WORKER_RUNTIME" ] = L" dotnet-isolated" ;
90
+
91
+ Configuration configuration (configurationXml, _missingConfig, L" " , systemCalls);
92
+
93
+ Assert::IsTrue (configuration.ShouldInstrument (L" functionsnethost.exe" , L" " , L" " , L" blah blah blah FooBarBaz blah blah blah" , true ));
94
+ }
95
+
96
+ // tests to verify that "legacy" behavior (before azure function support) is retained.
97
+ // If NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED environment variable is not set or is set to false,
98
+ // we should behave as if no azure function support has been added.
99
+ TEST_METHOD (azure_function_should_behave_as_legacy_if_azure_function_mode_disabled)
100
+ {
101
+ std::wstring configurationXml (L" \
102
+ <?xml version=\" 1.0\" ?>\
103
+ <configuration>\
104
+ <log level=\" deBug\" />\
105
+ </configuration>\
106
+ " );
107
+
108
+ auto systemCalls = std::make_shared<NewRelic::Profiler::Logger::Test::SystemCalls>();
109
+ systemCalls->environmentVariables [L" FUNCTIONS_WORKER_RUNTIME" ] = L" dotnet-isolated" ;
110
+ systemCalls->environmentVariables [L" NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED" ] = L" 0" ;
111
+
112
+ Configuration configuration (configurationXml, _missingConfig, L" " , systemCalls);
113
+
114
+ Assert::IsTrue (configuration.ShouldInstrument (L" functionsnethost.exe" , L" " , L" " , L" blah blah blah FooBarBaz blah blah blah" , true ));
115
+ }
116
+
76
117
TEST_METHOD (should_not_instrument_azure_function_app_pool_id_in_commandline)
77
118
{
78
119
std::wstring configurationXml (L" \
@@ -84,6 +125,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
84
125
85
126
auto systemCalls = std::make_shared<NewRelic::Profiler::Logger::Test::SystemCalls>();
86
127
systemCalls->environmentVariables [L" FUNCTIONS_WORKER_RUNTIME" ] = L" dotnet-isolated" ;
128
+ systemCalls->environmentVariables [L" NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED" ] = L" true" ;
87
129
88
130
Configuration configuration (configurationXml, _missingConfig, L" " , systemCalls);
89
131
@@ -101,6 +143,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
101
143
102
144
auto systemCalls = std::make_shared<NewRelic::Profiler::Logger::Test::SystemCalls>();
103
145
systemCalls->environmentVariables [L" FUNCTIONS_WORKER_RUNTIME" ] = L" dotnet-isolated" ;
146
+ systemCalls->environmentVariables [L" NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED" ] = L" true" ;
104
147
105
148
Configuration configuration (configurationXml, _missingConfig, L" " , systemCalls);
106
149
@@ -118,6 +161,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
118
161
119
162
auto systemCalls = std::make_shared<NewRelic::Profiler::Logger::Test::SystemCalls>();
120
163
systemCalls->environmentVariables [L" FUNCTIONS_WORKER_RUNTIME" ] = L" dotnet-isolated" ;
164
+ systemCalls->environmentVariables [L" NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED" ] = L" true" ;
121
165
122
166
Configuration configuration (configurationXml, _missingConfig, L" " , systemCalls);
123
167
@@ -135,6 +179,7 @@ namespace NewRelic { namespace Profiler { namespace Configuration { namespace Te
135
179
136
180
auto systemCalls = std::make_shared<NewRelic::Profiler::Logger::Test::SystemCalls>();
137
181
systemCalls->environmentVariables [L" FUNCTIONS_WORKER_RUNTIME" ] = L" dotnet-isolated" ;
182
+ systemCalls->environmentVariables [L" NEW_RELIC_AZURE_FUNCTION_MODE_ENABLED" ] = L" true" ;
138
183
139
184
Configuration configuration (configurationXml, _missingConfig, L" " , systemCalls);
140
185
0 commit comments