-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: Parse Azure Function HttpTrigger parameters #2776
base: main
Are you sure you want to change the base?
Conversation
from code coverage.
…wrelic-dotnet-agent into chore/update-serilog
chore: Update Profiler NuGet Package Reference to v10.28.0.40. Co-authored-by: tippmar-nr <[email protected]>
…azure-function-instrumentation
* Added a config setting to disabled azure function mode by default, added a few unit tests in areas where function mode detection is used * Minor cleanup * Refactor
* Unit tests and a bug fix or two * profiler unit tests * Unit test tweak * cleanup * formatting
* Profiler update to exclude func.exe * chore: Update Profiler NuGet Package Reference to v10.29.0.54 (#2734) chore: Update Profiler NuGet Package Reference to v10.29.0.54. Co-authored-by: tippmar-nr <[email protected]> * WIP * profiler azure function detection rework * Azure function integration tests functional but not complete * Upate all_solutions workflow to install azure functions tools and test the azurefunction namespace * another install attempt * test only azure function namespace for now * Tweaks for the integration tests workflow * enable all namespaces for integration tests * cleanup * Profiler: Allow log level override in azure function mode via NEW_RELIC_AZURE_FUNCTION_LOG_LEVEL_OVERRIDE=1 * workflow tweak * chore: Update Profiler NuGet Package Reference to v10.29.0.66 (#2738) chore: Update Profiler NuGet Package Reference to v10.29.0.66. Co-authored-by: tippmar-nr <[email protected]> * integration test tw4eaks * profiler unit test update --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Integration test updates, added net6.0 and net8.0 plus a test to verify behavior when azure function mode is disabled. * Integration test rework to use different HttpTrigger invocation methods
Disable aspnetcore middleware wrapper in azure function mode, update integration tests
…/newrelic-dotnet-agent into feature/azure-functions
* Added QueueTrigger function to integration tests * Added a missing file * Minor refactor
…ts to exercise more scenarios.
…o feature/azure-function-http-trigger-parsing
...gent/NewRelic/Agent/Extensions/Providers/Wrapper/AzureFunction/InvokeFunctionAsyncWrapper.cs
Outdated
Show resolved
Hide resolved
var inputBindingFeature = _genericFunctionInputBindingFeatureGetter.Invoke(features, []); | ||
dynamic valueTask = _bindFunctionInputAsync.Invoke(inputBindingFeature, [functionContext]); | ||
|
||
valueTask.AsTask().Wait(); // BindFunctionInputAsync returns a ValueTask, so we need to convert it to a Task to wait on it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really our best option for getting access to the inputs? Feels a bit clunky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is, unfortunately, exactly what the GRPC-generated code in an Azure function app does between when the InvokeFunctionAsync()
method is called and when the actual function Run()
method is called. It's ugly, but it's all we have to work with.
public async global::System.Threading.Tasks.ValueTask ExecuteAsync(global::Microsoft.Azure.Functions.Worker.FunctionContext context)
{
var inputBindingFeature = context.Features.Get<global::Microsoft.Azure.Functions.Worker.Context.Features.IFunctionInputBindingFeature>();
var inputBindingResult = await inputBindingFeature.BindFunctionInputAsync(context);
var inputArguments = inputBindingResult.Values;
if (string.Equals(context.FunctionDefinition.EntryPoint, "AzureFunctionApp.Function1.Run", StringComparison.Ordinal))
{
var instanceType = types["AzureFunctionApp.Function1"];
var i = _functionActivator.CreateInstance(instanceType, context) as global::AzureFunctionApp.Function1;
context.GetInvocationResult().Value = await i.Run((global::Microsoft.Azure.Functions.Worker.Http.HttpRequestData)inputArguments[0]);
}
else if (string.Equals(context.FunctionDefinition.EntryPoint, "AzureFunctionApp.Function2.Run", StringComparison.Ordinal))
{
var instanceType = types["AzureFunctionApp.Function2"];
var i = _functionActivator.CreateInstance(instanceType, context) as global::AzureFunctionApp.Function2;
context.GetInvocationResult().Value = i.Run((global::Microsoft.AspNetCore.Http.HttpRequest)inputArguments[0]);
}
else if (string.Equals(context.FunctionDefinition.EntryPoint, "AzureFunctionApp.QueueTriggerFunction.Run", StringComparison.Ordinal))
{
var instanceType = types["AzureFunctionApp.QueueTriggerFunction"];
var i = _functionActivator.CreateInstance(instanceType, context) as global::AzureFunctionApp.QueueTriggerFunction;
i.Run((string)inputArguments[0]);
}
}
…/github.com/newrelic/newrelic-dotnet-agent into feature/azure-function-http-trigger-parsing
src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AzureFunction/AzureFunction.csproj
Outdated
Show resolved
Hide resolved
tests/Agent/IntegrationTests/IntegrationTests/AzureFunction/AzureFunctionHttpTriggerTests.cs
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2776 +/- ##
==========================================
- Coverage 81.24% 81.23% -0.02%
==========================================
Files 460 460
Lines 29229 29230 +1
Branches 3223 3223
==========================================
- Hits 23747 23744 -3
- Misses 4696 4698 +2
- Partials 786 788 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Implements parsing for request method, request uri and response status code for Azure Functions that utilize
HttpTrigger
.Includes updated integration tests that exercise an Azure Function app that uses the
Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore
package and one that does not, to verify that we can correctly parse the data we need in both scenarios.(Don't be scared by the ridiculously large commit history - this branch started out as a feature work branch back when the Azure Functions feature was still around...)