Skip to content
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

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
ea80daa
wip
tippmar-nr Aug 13, 2024
75422d6
Initial POC implementation is working
tippmar-nr Aug 13, 2024
e9ce99f
New instrumentation stuff
tippmar-nr Aug 13, 2024
e20c363
app name tweak
tippmar-nr Aug 14, 2024
3d511ad
cleanup
tippmar-nr Aug 14, 2024
494684c
More cleanup
tippmar-nr Aug 14, 2024
61201f4
added more trigger types
tippmar-nr Aug 14, 2024
707c3d9
Cleanup, optimization
tippmar-nr Aug 14, 2024
c967297
Updated Serilog to latest everywhere
tippmar-nr Aug 16, 2024
692236d
Minor cleanup
tippmar-nr Aug 16, 2024
fa2dd3e
Fix ilrepack issues for serilog
tippmar-nr Aug 16, 2024
ecc964a
Updated Serilog to latest everywhere
tippmar-nr Aug 16, 2024
a32b438
Fix ilrepack issues for serilog
tippmar-nr Aug 16, 2024
7e7c482
Refactor GuidGenerator to work around ILRepack of System.Diagnostics.…
tippmar-nr Aug 16, 2024
f61dee6
Null checking
tippmar-nr Aug 16, 2024
cf4f926
Merge branch 'chore/update-serilog' into poc/azure-function-instrumen…
tippmar-nr Aug 16, 2024
1304087
Visibility bypasser caching
tippmar-nr Aug 19, 2024
a4a0e77
Composite tests for GuidGenerator changes
tippmar-nr Aug 19, 2024
7a1cd92
Fixes for GuidGenerator unit testing
tippmar-nr Aug 19, 2024
6406d92
Revert composite test changes, exclude GuidGenerator
tippmar-nr Aug 20, 2024
1271df5
Merge branch 'main' into chore/update-serilog
tippmar-nr Aug 20, 2024
601a177
Reverting a change
tippmar-nr Aug 20, 2024
d3c0a22
Merge branch 'chore/update-serilog' of https://github.com/newrelic/ne…
tippmar-nr Aug 20, 2024
1e892ed
Merge branch 'chore/update-serilog' into poc/azure-function-instrumen…
tippmar-nr Aug 20, 2024
725c4ed
Limit profiler logging to INFO or higher when in Azure Function mode
tippmar-nr Aug 20, 2024
ba295aa
chore: Update Profiler NuGet Package Reference to v10.28.0.40 (#2703)
github-actions[bot] Aug 20, 2024
e618ce9
Merge branch 'poc/azure-function-instrumention/nugetupdate' into poc/…
tippmar-nr Aug 20, 2024
2d90a9e
Merge latest from main, resolve conflicts
tippmar-nr Aug 20, 2024
0279e83
Profiler updates for azure function detection
tippmar-nr Aug 20, 2024
d0b2c59
Merge latest from main
tippmar-nr Aug 20, 2024
5dc44b4
Modify app name priority for azure function
tippmar-nr Aug 20, 2024
d090551
log message oops
tippmar-nr Aug 21, 2024
527130b
chore: Update Profiler NuGet Package Reference to v10.29.0.32 (#2705)
github-actions[bot] Aug 21, 2024
6b66651
Fix logic for determining whether to instrument in azure function mode
tippmar-nr Aug 22, 2024
5bb20d0
Merge branch 'poc/azure-function-instrumentation' of https://github.c…
tippmar-nr Aug 22, 2024
d207723
Azure vendor info check wasn't correctly implemented
tippmar-nr Aug 26, 2024
6870167
ReportedConfig tweak
tippmar-nr Aug 26, 2024
3ec5ddb
Merge branch 'poc/azure-function-instrumentation' into feature/azure-…
jaffinito Aug 27, 2024
129cf1f
Fixed up resourse groups and some minor changes all around.
jaffinito Aug 29, 2024
9d739b5
Feature work: Azure Function Mode Config (#2723)
tippmar-nr Aug 30, 2024
fd03d84
Azure functions: Unit tests (#2726)
tippmar-nr Aug 30, 2024
5f48908
Finish remaining todos and initial code cleanup. (#2725)
jaffinito Aug 30, 2024
9483c5d
Merge branch 'main' into feature/azure-functions
tippmar-nr Sep 3, 2024
37d155e
Feature work: Azure functions integration test framework (#2737)
tippmar-nr Sep 5, 2024
9911b8a
Merge remote-tracking branch 'origin/main' into feature/azure-functions
tippmar-nr Sep 5, 2024
e41c19e
Feature work: More integration tests (#2739)
tippmar-nr Sep 6, 2024
5464347
Feature work: Disable AspNetCore middleware wrapper (#2740)
tippmar-nr Sep 9, 2024
e53ecd1
profiler unit test fix
tippmar-nr Sep 9, 2024
d87e318
Merge branch 'feature/azure-functions' of https://github.com/newrelic…
tippmar-nr Sep 9, 2024
557a867
Feature work: Added QueueTrigger function to integration tests (#2745)
tippmar-nr Sep 9, 2024
e2dadbb
Check azure site name for null and don't use as app name
tippmar-nr Sep 10, 2024
d3c8bb7
Parse the request method / path and response status code for HttpTrig…
tippmar-nr Sep 10, 2024
2161ca0
Merge from main, resolve conflicts
tippmar-nr Sep 17, 2024
9d770af
Cleanup
tippmar-nr Sep 18, 2024
b3a568f
Final cleanup for http trigger param parsing. Updated integration tes…
tippmar-nr Sep 18, 2024
e459d20
Merge branch 'feature-work/azure-function-http-parameter-parsing' int…
tippmar-nr Sep 18, 2024
d299f65
Update src/Agent/NewRelic/Agent/Core/Config/Configuration.cs
tippmar-nr Sep 18, 2024
0359f90
PR feedback
tippmar-nr Sep 19, 2024
1771b62
Merge branch 'feature/azure-function-http-trigger-parsing' of https:/…
tippmar-nr Sep 19, 2024
94d4855
PR feedback, unit test update, code cleanup/formatting
tippmar-nr Sep 20, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class NoOpTransaction : ITransaction, ITransactionExperimental
public bool IsValid => false;
public bool IsFinished => false;
public ISegment CurrentSegment => Segment.NoOpSegment;
public bool HasHttpResponseStatusCode => false;

public DateTime StartTime => DateTime.UtcNow;

Expand Down
2 changes: 2 additions & 0 deletions src/Agent/NewRelic/Agent/Core/Transactions/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public ISegment CurrentSegment
}
}

public bool HasHttpResponseStatusCode => TransactionMetadata.HttpResponseStatusCode.HasValue;

public ITracingState TracingState { get; private set; }

public string TraceId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public interface ITransaction
/// </summary>
ISegment CurrentSegment { get; }

bool HasHttpResponseStatusCode { get; }

/// <summary>
/// End this transaction.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2020 New Relic, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

using NewRelic.Agent.Api;
using NewRelic.Agent.Extensions.Providers.Wrapper;

namespace NewRelic.Providers.Wrapper.AzureFunction;

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)
{
dynamic httpContext;
switch (instrumentedMethodCall.MethodCall.Method.MethodName)
{
case "AddHttpContextToFunctionContext":
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
{
httpContext = instrumentedMethodCall.MethodCall.MethodArguments[2];
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 = instrumentedMethodCall.MethodCall.MethodArguments[1];
agent.CurrentTransaction.SetHttpResponseStatusCode(httpContext.Response.StatusCode);
}
break;
}
}

return Delegates.NoOp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,18 @@ SPDX-License-Identifier: Apache-2.0
<exactMethodMatcher methodName="Build" />
</match>
</tracerFactory>

<tracerFactory name="FunctionsHttpProxyingMiddlewareWrapper">
<match assemblyName="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" className="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware">
<exactMethodMatcher methodName="AddHttpContextToFunctionContext" />
</match>
<match assemblyName="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" className="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware">
<exactMethodMatcher methodName="TryHandleHttpResult" />
</match>
<match assemblyName="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" className="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware">
<exactMethodMatcher methodName="TryHandleOutputBindingsHttpResult" />
</match>

</tracerFactory>
</instrumentation>
</extension>
Loading
Loading