Skip to content

Add .NET network + HTTP connection spans #1192

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

lmolkova
Copy link
Contributor

@lmolkova lmolkova commented Jun 27, 2024

This PR introduces additional network-level spans to-be emitted by .NET 9 🤞

Related to #454, #1226

In particular:

  1. DNS, TLS, and socket connect spans that track individual stages of connection establishment
  2. wrapper HTTP connection setup span for above spans
  3. wait-for-connection span that signals when a connection is not immediately available for the request
    • link that connects wait-for-connection to the connection setup
    • is expected to be off by default

On .NET every ActivitySource (aka tracer) is opt-in, so users have full control over what they are enabling.

The volume of new telemetry is expected to be low (with caveats):

image

Overall, the feature is intended to help debug issues like:

  • misconfigured connection pool
  • DNS/TLS
  • abandoned response streams (or slow response stream reading) that result in connection staying busy
  • ...

@lmolkova lmolkova force-pushed the dotnet-http-connection-spans branch from 7d7c232 to 9a4ba14 Compare July 3, 2024 00:59
@lmolkova lmolkova force-pushed the dotnet-http-connection-spans branch from 9a4ba14 to eb80b71 Compare July 6, 2024 03:51
@lmolkova lmolkova force-pushed the dotnet-http-connection-spans branch from f6f4a99 to 0e56f65 Compare July 8, 2024 19:49
@lmolkova lmolkova changed the title Add .NET HTTP connection spans Add .NET network + HTTP connection spans Jul 8, 2024
@lmolkova lmolkova marked this pull request as ready for review July 8, 2024 23:16
@lmolkova lmolkova requested review from a team July 8, 2024 23:16
@lmolkova lmolkova force-pushed the dotnet-http-connection-spans branch from ae799fd to 46d772f Compare July 11, 2024 06:41
antonfirsov added a commit to dotnet/docs that referenced this pull request Dec 10, 2024
.NET 9 introduced additions to `System.Net` distributed tracing which define a contract following OTel recommendations:
- dotnet/runtime#104251 adjusted the HTTP client request activity so it natively complies with OTel recommendations. This included adding standard tags.
- dotnet/runtime#103922 introduced activities breaking down the HTTP connection setup.

This PR documents the activities together with their attributes in a manner similar to the metrics docs added by #37213. The matching semconv PR is open-telemetry/semantic-conventions#1192. Conceptual docs are being introduced in #42830.

Moreover, the PR also adjusts certain parts of the metrics doc in order to make it more accurate, synchronize it with the activities doc and incorporate the changes from #42810.
---------

Co-authored-by: Genevieve Warren <[email protected]>
Co-authored-by: Miha Zupan <[email protected]>
@@ -16,3 +16,9 @@ groups:
as escaped base 10 integers (\DDD). Back slashes and quotes should be escaped.
Tabs, carriage returns, and line feeds should be converted to \t, \r, and
\n respectively.
- id: dns.answers
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like a request/response logging mechanism.

Is there a reason .NET prefers these as span attributes vs. Events?

Note: I don't want to open the giant can of worms of Events vs. Span Attributes. I'm just trying to understand rationale here and from the non-.NET portion of semantic conventions, I don't think this impacts choice of span-attribute vs. event-attribute for dns.answers.

Copy link
Contributor Author

@lmolkova lmolkova Apr 15, 2025

Choose a reason for hiding this comment

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

I just noticed your comment @jsuereth

what would be the reason to report dns.answers in an event?

Here's an example of this PR in action

image

DNS lookup takes 30ms and can fail, it's a valid span. And then there are a few addresses lookup returns, they make sense on the span that captures DNS lookup.

Am I missing something?

@lmolkova lmolkova moved this from In Review to Awaiting SIG approval in Semantic Conventions Triage Mar 17, 2025
@lmolkova lmolkova force-pushed the dotnet-http-connection-spans branch from e521e1d to 7e734d9 Compare April 17, 2025 15:35
@github-actions github-actions bot added the enhancement New feature or request label Apr 17, 2025
@lmolkova lmolkova moved this from Awaiting SIG approval to Needs More Approval in Semantic Conventions Triage Apr 17, 2025
It's reported as a child of *HTTP client request* span.

The span ends when the connection is obtained - it could happen when an existing connection becomes available or once
a new connection is established, so the duration of *Wait For Connection* span is different from duration of the
Copy link
Contributor Author

Choose a reason for hiding this comment

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

let's try to generalize it and try to address similar problems - concurrency, mutexes, etc, look at absl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request never stale PRs marked with this label will be never staled and automatically closed
Projects
Status: Needs More Approval
Development

Successfully merging this pull request may close these issues.

6 participants