-
Notifications
You must be signed in to change notification settings - Fork 66
feat: Parse Azure Function HttpTrigger parameters #2776
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
tippmar-nr
merged 60 commits into
main
from
feature/azure-function-http-trigger-parsing
Sep 23, 2024
Merged
Changes from 56 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
ea80daa
wip
tippmar-nr 75422d6
Initial POC implementation is working
tippmar-nr e9ce99f
New instrumentation stuff
tippmar-nr e20c363
app name tweak
tippmar-nr 3d511ad
cleanup
tippmar-nr 494684c
More cleanup
tippmar-nr 61201f4
added more trigger types
tippmar-nr 707c3d9
Cleanup, optimization
tippmar-nr c967297
Updated Serilog to latest everywhere
tippmar-nr 692236d
Minor cleanup
tippmar-nr fa2dd3e
Fix ilrepack issues for serilog
tippmar-nr ecc964a
Updated Serilog to latest everywhere
tippmar-nr a32b438
Fix ilrepack issues for serilog
tippmar-nr 7e7c482
Refactor GuidGenerator to work around ILRepack of System.Diagnostics.…
tippmar-nr f61dee6
Null checking
tippmar-nr cf4f926
Merge branch 'chore/update-serilog' into poc/azure-function-instrumen…
tippmar-nr 1304087
Visibility bypasser caching
tippmar-nr a4a0e77
Composite tests for GuidGenerator changes
tippmar-nr 7a1cd92
Fixes for GuidGenerator unit testing
tippmar-nr 6406d92
Revert composite test changes, exclude GuidGenerator
tippmar-nr 1271df5
Merge branch 'main' into chore/update-serilog
tippmar-nr 601a177
Reverting a change
tippmar-nr d3c0a22
Merge branch 'chore/update-serilog' of https://github.com/newrelic/ne…
tippmar-nr 1e892ed
Merge branch 'chore/update-serilog' into poc/azure-function-instrumen…
tippmar-nr 725c4ed
Limit profiler logging to INFO or higher when in Azure Function mode
tippmar-nr ba295aa
chore: Update Profiler NuGet Package Reference to v10.28.0.40 (#2703)
github-actions[bot] e618ce9
Merge branch 'poc/azure-function-instrumention/nugetupdate' into poc/…
tippmar-nr 2d90a9e
Merge latest from main, resolve conflicts
tippmar-nr 0279e83
Profiler updates for azure function detection
tippmar-nr d0b2c59
Merge latest from main
tippmar-nr 5dc44b4
Modify app name priority for azure function
tippmar-nr d090551
log message oops
tippmar-nr 527130b
chore: Update Profiler NuGet Package Reference to v10.29.0.32 (#2705)
github-actions[bot] 6b66651
Fix logic for determining whether to instrument in azure function mode
tippmar-nr 5bb20d0
Merge branch 'poc/azure-function-instrumentation' of https://github.c…
tippmar-nr d207723
Azure vendor info check wasn't correctly implemented
tippmar-nr 6870167
ReportedConfig tweak
tippmar-nr 3ec5ddb
Merge branch 'poc/azure-function-instrumentation' into feature/azure-…
jaffinito 129cf1f
Fixed up resourse groups and some minor changes all around.
jaffinito 9d739b5
Feature work: Azure Function Mode Config (#2723)
tippmar-nr fd03d84
Azure functions: Unit tests (#2726)
tippmar-nr 5f48908
Finish remaining todos and initial code cleanup. (#2725)
jaffinito 9483c5d
Merge branch 'main' into feature/azure-functions
tippmar-nr 37d155e
Feature work: Azure functions integration test framework (#2737)
tippmar-nr 9911b8a
Merge remote-tracking branch 'origin/main' into feature/azure-functions
tippmar-nr e41c19e
Feature work: More integration tests (#2739)
tippmar-nr 5464347
Feature work: Disable AspNetCore middleware wrapper (#2740)
tippmar-nr e53ecd1
profiler unit test fix
tippmar-nr d87e318
Merge branch 'feature/azure-functions' of https://github.com/newrelic…
tippmar-nr 557a867
Feature work: Added QueueTrigger function to integration tests (#2745)
tippmar-nr e2dadbb
Check azure site name for null and don't use as app name
tippmar-nr d3c8bb7
Parse the request method / path and response status code for HttpTrig…
tippmar-nr 2161ca0
Merge from main, resolve conflicts
tippmar-nr 9d770af
Cleanup
tippmar-nr b3a568f
Final cleanup for http trigger param parsing. Updated integration tes…
tippmar-nr e459d20
Merge branch 'feature-work/azure-function-http-parameter-parsing' int…
tippmar-nr d299f65
Update src/Agent/NewRelic/Agent/Core/Config/Configuration.cs
tippmar-nr 0359f90
PR feedback
tippmar-nr 1771b62
Merge branch 'feature/azure-function-http-trigger-parsing' of https:/…
tippmar-nr 94d4855
PR feedback, unit test update, code cleanup/formatting
tippmar-nr 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
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
58 changes: 58 additions & 0 deletions
58
...gent/Extensions/Providers/Wrapper/AzureFunction/FunctionsHttpProxyingMiddlewareWrapper.cs
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2020 New Relic, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using Microsoft.AspNetCore.Http; | ||
using NewRelic.Agent.Api; | ||
using NewRelic.Agent.Extensions.Providers.Wrapper; | ||
|
||
public class FunctionsHttpProxyingMiddlewareWrapper : IWrapper | ||
{ | ||
private const string WrapperName = "FunctionsHttpProxyingMiddlewareWrapper"; | ||
|
||
public bool IsTransactionRequired => false; | ||
|
||
public CanWrapResponse CanWrap(InstrumentedMethodInfo methodInfo) | ||
{ | ||
return new CanWrapResponse(WrapperName.Equals(methodInfo.RequestedWrapperName)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets request method / path for Azure function HttpTrigger invocations | ||
/// in apps that use the Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore package | ||
/// </summary> | ||
public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall instrumentedMethodCall, IAgent agent, ITransaction transaction) | ||
{ | ||
if (agent.Configuration.AzureFunctionModeEnabled) | ||
{ | ||
switch (instrumentedMethodCall.MethodCall.Method.MethodName) | ||
{ | ||
case "AddHttpContextToFunctionContext": | ||
var httpContext = (HttpContext)instrumentedMethodCall.MethodCall.MethodArguments[1]; | ||
|
||
agent.CurrentTransaction.SetRequestMethod(httpContext.Request.Method); | ||
agent.CurrentTransaction.SetUri(httpContext.Request.Path); | ||
break; | ||
case "TryHandleHttpResult": | ||
if (!agent.CurrentTransaction.HasHttpResponseStatusCode) // these handlers seem to get called more than once; only set the status code one time | ||
{ | ||
object result = instrumentedMethodCall.MethodCall.MethodArguments[0]; | ||
|
||
httpContext = (HttpContext)instrumentedMethodCall.MethodCall.MethodArguments[2]; | ||
bool isInvocationResult = (bool)instrumentedMethodCall.MethodCall.MethodArguments[3]; | ||
|
||
agent.CurrentTransaction.SetHttpResponseStatusCode(httpContext.Response.StatusCode); | ||
} | ||
break; | ||
case "TryHandleOutputBindingsHttpResult": | ||
if (!agent.CurrentTransaction.HasHttpResponseStatusCode) // these handlers seem to get called more than once; only set the status code one time | ||
{ | ||
httpContext = (HttpContext)instrumentedMethodCall.MethodCall.MethodArguments[1]; | ||
agent.CurrentTransaction.SetHttpResponseStatusCode(httpContext.Response.StatusCode); | ||
} | ||
break; | ||
} | ||
} | ||
|
||
return Delegates.NoOp; | ||
} | ||
} |
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
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.
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.