-
Notifications
You must be signed in to change notification settings - Fork 63
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: Use SocketsHttpHandler
to configure HttpClient
in .NET 6+
#2931
Merged
Conversation
This file contains 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
nrcventura
reviewed
Dec 20, 2024
nrcventura
reviewed
Dec 20, 2024
src/Agent/NewRelic/Agent/Core/DataTransport/Client/NRHttpClient.cs
Outdated
Show resolved
Hide resolved
nrcventura
reviewed
Jan 6, 2025
nrcventura
reviewed
Jan 6, 2025
tests/Agent/IntegrationTests/Applications/CustomAttributesWebApi/Program.cs
Outdated
Show resolved
Hide resolved
…locking refactor correctly.
nrcventura
reviewed
Jan 6, 2025
nrcventura
reviewed
Jan 6, 2025
src/Agent/NewRelic/Agent/Core/BrowserMonitoring/BrowserScriptInjectionHelper.cs
Outdated
Show resolved
Hide resolved
nrcventura
reviewed
Jan 6, 2025
...NewRelic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/BrowserInjectingStreamWrapper.cs
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2931 +/- ##
==========================================
+ Coverage 81.42% 81.49% +0.06%
==========================================
Files 465 465
Lines 29563 29639 +76
Branches 3278 3285 +7
==========================================
+ Hits 24073 24155 +82
+ Misses 4697 4689 -8
- Partials 793 795 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
nrcventura
approved these changes
Jan 7, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
NRHttpClient
to dynamically create an instance ofSocketsHttpHandler
when the app is running in .NET 6 or later, and configuredPooledConnectionTimeout
andPooledConnectionIdleTimeout
to help the agent respond better to DNS changes. The connection timeout value is hard-coded to 5 minutes, which overrides the default of "never" and is probably sufficient for our needs. I didn't see a compelling reason to add a configuration setting for this value. Resolves Update HttpClient usage to better support DNS changes on .NET/.NET Core #1845.Additional refactoring:
HttpClientWrapper.SendAsync()
to add a.ConfigureAwait(false)
which seems to help prevent deadlocks.lock()
usage withSemaphoreSlim
in several places, also aimed at helping to prevent deadlocks..ConfigureAwait(false)
in nearly all locations where we're currently doing a.GetAwaiter().GetResult()
pattern. More deadlock prevention.... harvest finished
message even if no events were sent. This will help in troubleshooting recently reported deadlocks when sending data.IHttpClientFactory.CreateClient()
toGetOrCreateClient()
to better reflect what the method does.IHttpClient
and the classes that implement itConnectionHandler.SendDataOverWire<T>()
to make exception handling a bit cleaner and more clear. Resolves Refactor nested try/catch in ConnectionHandler #2778throw
the exception again anyway.using
s inNRHttpClient
for objects that areIDisposable
(HttpRequestMessage
,ByteArrayContent
)