-
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
Activities for Http Connections, Dns, Sockets and SslStream #103922
Activities for Http Connections, Dns, Sockets and SslStream #103922
Conversation
.../System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
.../System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.IO.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.IO.cs
Outdated
Show resolved
Hide resolved
Can I ask you to show an example with the aspire dashboard? https://aspiredashboard.com/ It should be a simple docker command to run, pointing the app at it with the otlp exporter. Looking at console output for traces is quite hard. |
# Conflicts: # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs # src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionBase.cs
@davidfowl here you go: Where expanding the connection will see: A few notes:
|
Is this going to be useful in a trace? I don't know one way or the other, but it seems like it could result in a lot of noise. Is there an equivalent span that's only about setting up the connection, from the time it was requested until the time it became usable? |
I agree, we care about how long it took to connect, not how long the connection itself lasts. That feels like it could be another span, but not the most useful one. I think about this as zooming into why a request may have taken so long. |
The proposed connection span matches the semantics of the One solution to have more useful traces could be to decompose it as following:
Another is to only introduce |
The overall connection span could be useful to understand:
Many other useful things are already exposed as metrics (number of active connections, connection duration), so I agree span usefulness is limited. Regarding the noise: connections should be rare comparing to requests (if there is any significant load). The spans are reported by a different Anyway, I don't have a strong opinion on how necessary it is - it can always be added later. |
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.
Some more comments.
src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs
Outdated
Show resolved
Hide resolved
…olutionTelemetry.cs Co-authored-by: Marie Píchová <[email protected]>
…rsov/runtime into connection-activities-05
@ManickaP addressed: #103922 (comment) |
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.
Last batch of comments. Thank you for your patience!
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.IO.cs
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
static (string?, string?) GetNameAndVersionString(SslProtocols protocol) => protocol switch |
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.
SslProtocols
is flags, so is this behaving as expected? E.g. returning nothing in case there are more protocols set, or we're sure that at this point there will always be just one?
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.
EventSource telemetry does the same after acquiring the enum with GetSslProtocolInternal()
so I assumed it should be a single value after handshake completion normally. If not, our telemetry doesn't emit the protocol info.
runtime/src/libraries/System.Net.Security/src/System/Net/Security/NetSecurityTelemetry.cs
Lines 178 to 201 in f9eda07
switch (protocol) | |
{ | |
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete | |
case SslProtocols.Tls: | |
protocolSessionsOpen = ref _sessionsOpenTls10; | |
handshakeDurationCounter = _handshakeDurationTls10Counter; | |
break; | |
case SslProtocols.Tls11: | |
protocolSessionsOpen = ref _sessionsOpenTls11; | |
handshakeDurationCounter = _handshakeDurationTls11Counter; | |
break; | |
#pragma warning restore SYSLIB0039 | |
case SslProtocols.Tls12: | |
protocolSessionsOpen = ref _sessionsOpenTls12; | |
handshakeDurationCounter = _handshakeDurationTls12Counter; | |
break; | |
case SslProtocols.Tls13: | |
protocolSessionsOpen = ref _sessionsOpenTls13; | |
handshakeDurationCounter = _handshakeDurationTls13Counter; | |
break; | |
} |
@@ -15,6 +15,11 @@ namespace System.Net.Security | |||
{ | |||
public partial class SslStream | |||
{ | |||
private const string ActivitySourceName = "Experimental.System.Net.Security"; |
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.
Why isn't this part of NetSecurityTelemetry
like in Dns and Socket?
So we have:
- an extra class in Http
- part of telemetry class in Dns and Socket
- part of production class in Ssl
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.
These pieces of code evolved like dust balls in a dirty room, but there is some logic:
- In HTTP, various telemetry pillars follow complex requirements across multiple protocols and various aspects (request vs connection telemetry, Metrics vs EventSource vs Activities, http1-2 vs http3). When there is cohesion, a class has been defined to put related things into a single place, when there isn't, things were kept separate.
- In DNS and Sockets, telemetry can be tracked together across the 3 pillars
- In SSL, the Activity logic is so tiny, that I didn't bother to move it to a separate class.
I will do a second round of thinking about the last point.
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.
Moved around things a bit for SslStream
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Sockets/tests/FunctionalTests/System.Net.Sockets.Tests.csproj
Outdated
Show resolved
Hide resolved
Co-authored-by: Marie Píchová <[email protected]>
Co-authored-by: Marie Píchová <[email protected]>
Co-authored-by: Marie Píchová <[email protected]>
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
public const string RequestActivityStartName = RequestActivityName + ".Start"; | ||
public const string RequestActivityStopName = RequestActivityName + ".Stop"; | ||
|
||
public const string ConnectionsNamespace = "Experimental.System.Net.Http.Connections"; |
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.
Experimental?
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.
It turned out that our solution results is an unexpected volume of span links for tools like Azure Monitor, blowing up their UI, see open-telemetry/opentelemetry-specification#4130.
We need to work with OTel and Azure Monitor to introduce a standard way for categorizing links so visualization tools can distinguish them. The plan is to drive this work forward in order to stabilize the feature in .NET 10.
Edit: for the final design see:
#103922 (comment)
open-telemetry/semantic-conventions#1192
This is a replacement for #101814 following our agreement that Http Connection sub-operations (Dns, Socket, SslStream) should be represented with their sub-activities instead of emitting events on the Http Connection activity.
The PR implements the following activity-tree across multiple libraries:
Where
System.Net.Http.Connections.HttpConnection
doesn't have a parent (has it's own Trace ID), and every request is linked to their connection viaactivity.AddLink()
when the connection is being dispatched to a request.The 4 new activities have their own ActivitySources which have to be enabled separately. By using
OpenTelemetry.Exporter.Console
this can be done via wildcards:A sampe program & output can be found here..
Fixes #93832.
/cc @samsp-msft @noahfalk @lmolkova