Skip to content

Added some kestrel event counters #21649

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

Merged
merged 10 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async Task AcceptConnectionsAsync()
_transportConnectionManager.AddConnection(id, kestrelConnection);

Log.ConnectionAccepted(connection.ConnectionId);
KestrelEventSource.Log.ConnectionQueuedStart(connection);

ThreadPool.UnsafeQueueUserWorkItem(kestrelConnection, preferLocal: false);
}
Expand Down
7 changes: 7 additions & 0 deletions src/Servers/Kestrel/Core/src/Internal/Http/Http1Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public Http1Connection(HttpConnectionContext context)

protected override void OnRequestProcessingEnded()
{
if (IsUpgraded)
{
KestrelEventSource.Log.RequestUpgradedStop(this);

ServiceContext.ConnectionManager.UpgradedConnectionCount.ReleaseOne();
}

TimeoutControl.StartDrainTimeout(MinResponseDataRate, ServerOptions.Limits.MaxResponseBufferSize);

// Prevent RequestAborted from firing. Free up unneeded feature references.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ async Task<Stream> IHttpUpgradeFeature.UpgradeAsync()

IsUpgraded = true;

KestrelEventSource.Log.RequestUpgradedStart(this);

ConnectionFeatures.Get<IDecrementConcurrentConnectionCountFeature>()?.ReleaseConnection();

StatusCode = StatusCodes.Status101SwitchingProtocols;
Expand Down
1 change: 1 addition & 0 deletions src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public string TraceIdentifier
public int LocalPort { get; set; }
public string Scheme { get; set; }
public HttpMethod Method { get; set; }
public string MethodText => ((IHttpRequestFeature)this).Method;
public string PathBase { get; set; }

public string Path { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ private void StartStream()
throw;
}

KestrelEventSource.Log.RequestQueuedStart(_currentHeadersStream, AspNetCore.Http.HttpProtocol.Http2);
// Must not allow app code to block the connection handling loop.
ThreadPool.UnsafeQueueUserWorkItem(_currentHeadersStream, preferLocal: false);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Servers/Kestrel/Core/src/Internal/Http2/Http2StreamOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
{
Expand All @@ -19,6 +20,7 @@ public Http2Stream(IHttpApplication<TContext> application, Http2StreamContext co

public override void Execute()
{
KestrelEventSource.Log.RequestQueuedStop(this, AspNetCore.Http.HttpProtocol.Http2);
// REVIEW: Should we store this in a field for easy debugging?
_ = ProcessRequestsAsync(_application);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ internal async Task InnerProcessRequestsAsync<TContext>(IHttpApplication<TContex
{
_streams[streamId] = http3Stream;
}
KestrelEventSource.Log.RequestQueuedStart(stream, AspNetCore.Http.HttpProtocol.Http3);
ThreadPool.UnsafeQueueUserWorkItem(stream, preferLocal: false);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Servers/Kestrel/Core/src/Internal/Http3/Http3StreamOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3
{
Expand All @@ -17,6 +18,8 @@ public Http3Stream(IHttpApplication<TContext> application, Http3Connection conne

public override void Execute()
{
KestrelEventSource.Log.RequestQueuedStop(this, AspNetCore.Http.HttpProtocol.Http3);

if (_requestHeaderParsingState == Http3Stream.RequestHeaderParsingState.Ready)
{
_ = ProcessRequestAsync(_application);
Expand Down
7 changes: 0 additions & 7 deletions src/Servers/Kestrel/Core/src/Internal/HttpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ public async Task ProcessRequestsAsync<TContext>(IHttpApplication<TContext> http
{
Log.LogCritical(0, ex, $"Unexpected exception in {nameof(HttpConnection)}.{nameof(ProcessRequestsAsync)}.");
}
finally
{
if (_http1Connection?.IsUpgraded == true)
{
_context.ServiceContext.ConnectionManager.UpgradedConnectionCount.ReleaseOne();
}
}
}

// For testing only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ internal async Task ExecuteAsync()

try
{
KestrelEventSource.Log.ConnectionQueuedStop(connectionContext);

Logger.ConnectionStart(connectionContext.ConnectionId);
KestrelEventSource.Log.ConnectionStart(connectionContext);

Expand Down
Loading