From 58c1dcf0e95f45dadb28c3cbd5cfb726d15dfa01 Mon Sep 17 00:00:00 2001 From: Marty Tippin <120425148+tippmar-nr@users.noreply.github.com> Date: Thu, 9 Nov 2023 14:44:56 -0600 Subject: [PATCH] Check both BrosserMonitoringAutoInstrument and EnableAspNetCore6PlusBrowserInjection configuration settings --- .../Wrapper/AspNetCore6Plus/AddNewRelicStartupFilter.cs | 2 +- .../AspNetCore6Plus/ResponseCompressionBodyOnWriteWrapper.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/AddNewRelicStartupFilter.cs b/src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/AddNewRelicStartupFilter.cs index 79b73213e7..e3e02620bc 100644 --- a/src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/AddNewRelicStartupFilter.cs +++ b/src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/AddNewRelicStartupFilter.cs @@ -32,7 +32,7 @@ public Action Configure(Action next) // only inject the middleware if browser injection is enabled and the request is not a gRPC request. builder.UseWhen( - context => _agent.Configuration.EnableAspNetCore6PlusBrowserInjection && context.Request.ContentType?.ToLower() != "application/grpc", + context => _agent.Configuration.BrowserMonitoringAutoInstrument && _agent.Configuration.EnableAspNetCore6PlusBrowserInjection && context.Request.ContentType?.ToLower() != "application/grpc", b => b.UseMiddleware(_agent)); next(builder); diff --git a/src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/ResponseCompressionBodyOnWriteWrapper.cs b/src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/ResponseCompressionBodyOnWriteWrapper.cs index 3834fea86b..a4de1a32d9 100644 --- a/src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/ResponseCompressionBodyOnWriteWrapper.cs +++ b/src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/ResponseCompressionBodyOnWriteWrapper.cs @@ -45,7 +45,7 @@ public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall ins var context = _contextFieldGetter.Invoke(instrumentedMethodCall.MethodCall.InvocationTarget); // only wrap the compression stream if browser injection is enabled and the request is not a gRPC request. - if (agent.Configuration.EnableAspNetCore6PlusBrowserInjection && context.Request.ContentType?.ToLower() != "application/grpc") + if (agent.Configuration.BrowserMonitoringAutoInstrument && agent.Configuration.EnableAspNetCore6PlusBrowserInjection && context.Request.ContentType?.ToLower() != "application/grpc") { // Wrap _compressionStream and replace the current value with our wrapped version // check whether we've already wrapped the stream so we don't do it twice