Skip to content

Conversation

@MihaZupan
Copy link
Member

Fixes #40896

@MihaZupan MihaZupan requested a review from a team February 21, 2022 01:08
@ghost ghost assigned MihaZupan Feb 21, 2022
@MihaZupan

This comment was marked as resolved.

@ghost
Copy link

ghost commented Feb 21, 2022

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

Issue Details

Fixes #40896

Author: MihaZupan
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@azure-pipelines

This comment was marked as resolved.

@MihaZupan
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

{
if (HttpTelemetry.Log.IsEnabled() && queueDuration.IsActive)
{
HttpTelemetry.Log.Http30RequestLeftQueue(queueDuration.GetElapsedTime().TotalMilliseconds);
Copy link
Member

Choose a reason for hiding this comment

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

In case the connection gets closed in the meantime, the request will get retried on a different connection (line 224). I'm not sure what counts into the "waiting time in the queue" in such case, but this will report as request left the queue.

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be rare-ish to happen, but yes, you may see multiple RequestLeftQueue events for a given request.

Similarly with 1.1, there is a race where we would retry if the server disconnects here, logging RequestLeftQueue twice.
Similarly with resets on HTTP/2, we may re-insert the request to the queue.

I'm not sure we can/should improve that somehow. I feel it's still valuable to include the time on queue here even if the request will just end up back in the queue.

Copy link
Member

Choose a reason for hiding this comment

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

If we do similar thing with H/1.1 and H/2 then this is fine. I'm mostly trying to make sure we keep similar behavior between the protocols so that one counter doesn't mean something else based on HTTP version.

{
_stream.AbortWrite((long)Http3ErrorCode.RequestCancelled);
throw new OperationCanceledException(ex.Message, ex, cancellationToken);
throw new TaskCanceledException(ex.Message, ex, cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? Is it to unify exception types with H/2, H/1.1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, this is something that both 1.1 and 2 seem to be doing.
E.g. for 1.1:

mappedException = CancellationHelper.CreateOperationCanceledException(exception, cancellationToken);

It seems harmless enough of a change (given TCE derives from OCE), or we could update the failure tests to expect OCE instead.


_headerState = HeaderState.TrailingHeaders;

if (HttpTelemetry.Log.IsEnabled()) HttpTelemetry.Log.ResponseHeadersStop();
Copy link
Member

Choose a reason for hiding this comment

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

This is not exactly the moment when the headers get sent, but it gets muddy with the gathered buffer with content. How does this compare with H/2 and H/1.1? Is is worth trying to refine the moment or not?

Copy link
Member Author

Choose a reason for hiding this comment

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

On HTTP/2, we will actually include the time to write out the headers on the wire (code). That is because the time when the headers are sent is well-defined since we immediately serialize the action on the multiplexed connection.

On HTTP/1.1 and 3, however, the headers may not end up being sent right away, but only with the first flush of the request content, which may be under user's control.
We could report a more accurate timestamp of when the headers are actually sent, but these events being Start/Stop complicates the matter. If ThreadPool activity tracking is on, I don't see how we would get the async scope for Start/Stop to match, given Stop would result as part of the content copying outside of SendAsync.

Copy link
Member

Choose a reason for hiding this comment

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

I guess this is good enough and not worth the trouble. Especially, if we're already not pedantic about the exact times in H/1.1

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

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

Thanks!

@MihaZupan MihaZupan merged commit c4422a0 into dotnet:main Feb 23, 2022
@MihaZupan MihaZupan added this to the 7.0.0 milestone Feb 23, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpTelemetry instrumentation for HTTP/3

2 participants