-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Extend SocketsHttpHandler Connection and Request telemetry #88853
Extend SocketsHttpHandler Connection and Request telemetry #88853
Conversation
also: pass around IPEndPoint instead of EndPoint
Tagging subscribers to this area: @dotnet/ncl Issue DetailsAdd the telemetry events proposed in #85729 and #63159 (comment), with a difference that we log I think the changes will not prevent us from implementing #66223, since we can move the logging out of connection constructors. Full event diff: - ConnectionEstablished(byte versionMajor, byte versionMinor)
+ ConnectionEstablished(byte versionMajor, byte versionMinor, long connectionId, string scheme, string host, int port, string? remoteAddress)
- ConnectionClosed(byte versionMajor, byte versionMinor)
+ ConnectionClosed(byte versionMajor, byte versionMinor, long connectionId)
- RequestHeadersStart()
+ RequestHeadersStart(long connectionId)
-void Redirect();
+void Redirect(string redirectUri);
|
/azp run runtime-libraries-coreclr outerloop |
🤡 No commit pushedDate could be found for PR 88853 in repo dotnet/runtime 🤡 |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/FunctionalTests/TelemetryTest.cs
Outdated
Show resolved
Hide resolved
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
@MihaZupan PTAL.
if (_socketAddress is not null) | ||
{ | ||
tags.Add("socket.address", _socketAddress); | ||
} |
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.
Edit: Reverted this to simplify Metrics naming discussions. If this is interesting enough to be added after platform complete, we can do it in a follow-up PR.
Given it's available, it looks like it makes make sense to log this also on connection metrics, unless we think it's sensitive info. With the name I'm following OTel recommendation proactively using dot notation with the assumption that we will also change the instrument names by midnight of the 17th.
@davidfowl @noahfalk any objections?
@@ -1550,6 +1554,8 @@ private async ValueTask<(Stream, TransportContext?)> ConnectAsync(HttpRequestMes | |||
|
|||
case HttpConnectionKind.Proxy: | |||
stream = await ConnectToTcpHostAsync(_proxyUri!.IdnHost, _proxyUri.Port, request, async, cancellationToken).ConfigureAwait(false); | |||
// remoteEndPoint is returned for diagnostic purposes. | |||
remoteEndPoint = GetRemoteEndPoint(stream); |
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.
I'm no longer checking for any telemetry || metrics being enabled here, since GetRemoteEndpoint
is relatively cheap to run per-connection and likely almost as expensive as the check would be.
} | ||
|
||
[Event(4, Level = EventLevel.Informational, Version = 1)] | ||
private void ConnectionEstablished(byte versionMajor, byte versionMinor, long connectionId, string scheme, string host, int port, string? socketAddress) |
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.
Also going with the socketAddress
name here.
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.
A more generic remoteEndPoint
may be better if we do decide to allow users to customize the string that is logged here (e.g. they give us a custom stream via ConnectCallback
that may not be backed by a socket at all).
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
Show resolved
Hide resolved
} | ||
|
||
[Event(4, Level = EventLevel.Informational, Version = 1)] | ||
private void ConnectionEstablished(byte versionMajor, byte versionMinor, long connectionId, string scheme, string host, int port, string? socketAddress) |
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.
A more generic remoteEndPoint
may be better if we do decide to allow users to customize the string that is logged here (e.g. they give us a custom stream via ConnectCallback
that may not be backed by a socket at all).
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
Not since #87638. Anyways, I pushed detection of the address for the non TLS-case in 066391d, but not sure if turning this many
Switched back the name to |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
Fixes #63159, fixes #85729.
Add the telemetry events proposed in #85729 and #63159 (comment), with a difference that we log
remoteAddress
instead ofremoteEndPoint
sinceport
is already logged as a separate parameter.I think the changes will not prevent us from implementing #66223, since we can move the logging out of connection constructors.
Full event diff: