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

Extend SocketsHttpHandler Connection and Request telemetry #88853

Merged
merged 17 commits into from Jul 18, 2023

Conversation

antonfirsov
Copy link
Member

@antonfirsov antonfirsov commented Jul 13, 2023

Fixes #63159, fixes #85729.

Add the telemetry events proposed in #85729 and #63159 (comment), with a difference that we log remoteAddress instead of remoteEndPoint since port 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:

- 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);

@ghost
Copy link

ghost commented Jul 13, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #63159, fixes #85729.

Add the telemetry events proposed in #85729 and #63159 (comment), with a difference that we log remoteAddress instead of remoteEndPoint since port 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:

- 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);
Author: antonfirsov
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

azure-pipelines bot commented Jul 13, 2023

🤡 No commit pushedDate could be found for PR 88853 in repo dotnet/runtime 🤡

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MihaZupan MihaZupan added this to the 8.0.0 milestone Jul 14, 2023
@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member Author

@antonfirsov antonfirsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MihaZupan PTAL.

Comment on lines 46 to 49
if (_socketAddress is not null)
{
tags.Add("socket.address", _socketAddress);
}
Copy link
Member Author

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);
Copy link
Member Author

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)
Copy link
Member Author

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.

Copy link
Member

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).

}

[Event(4, Level = EventLevel.Informational, Version = 1)]
private void ConnectionEstablished(byte versionMajor, byte versionMinor, long connectionId, string scheme, string host, int port, string? socketAddress)
Copy link
Member

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).

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dotnet dotnet deleted a comment from azure-pipelines bot Jul 17, 2023
@dotnet dotnet deleted a comment from azure-pipelines bot Jul 17, 2023
@antonfirsov
Copy link
Member Author

antonfirsov commented Jul 17, 2023

Since we know that (at least for now), a CONNECT request will be done over HTTP/1.1 without a TLS layer

Not since #87638. Anyways, I pushed detection of the address for the non TLS-case in 066391d, but not sure if turning this many privates to internal was worth the feature.

A more generic remoteEndPoint may be better

Switched back the name to remoteAddress. We will have a naming dilemma if we decide to implement this in metrics, since OTel recommends the name server.socket.address.

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dotnet dotnet deleted a comment from azure-pipelines bot Jul 17, 2023
@dotnet dotnet deleted a comment from azure-pipelines bot Jul 17, 2023
@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dotnet dotnet deleted a comment from azure-pipelines bot Jul 17, 2023
@antonfirsov antonfirsov merged commit 1db1ba4 into dotnet:main Jul 18, 2023
103 of 111 checks passed
@dotnet dotnet locked as resolved and limited conversation to collaborators Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants