Merge pull request #8826 from Bond-009/slowhttp

Fixes https://github.com/jellyfin/jellyfin/issues/7348
pull/8898/head
Joshua M. Boniface 2 years ago committed by GitHub
commit 47f1d1395c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,9 +47,10 @@ namespace Jellyfin.Server.Middleware
context.Response.OnStarting(() => context.Response.OnStarting(() =>
{ {
watch.Stop(); watch.Stop();
if (enableWarning && watch.ElapsedMilliseconds > warningThreshold) var responseTimeForCompleteRequest = watch.ElapsedMilliseconds;
if (enableWarning && responseTimeForCompleteRequest > warningThreshold && _logger.IsEnabled(LogLevel.Debug))
{ {
_logger.LogWarning( _logger.LogDebug(
"Slow HTTP Response from {Url} to {RemoteIp} in {Elapsed:g} with Status Code {StatusCode}", "Slow HTTP Response from {Url} to {RemoteIp} in {Elapsed:g} with Status Code {StatusCode}",
context.Request.GetDisplayUrl(), context.Request.GetDisplayUrl(),
context.GetNormalizedRemoteIp(), context.GetNormalizedRemoteIp(),
@ -57,7 +58,6 @@ namespace Jellyfin.Server.Middleware
context.Response.StatusCode); context.Response.StatusCode);
} }
var responseTimeForCompleteRequest = watch.ElapsedMilliseconds;
context.Response.Headers[ResponseHeaderResponseTime] = responseTimeForCompleteRequest.ToString(CultureInfo.InvariantCulture); context.Response.Headers[ResponseHeaderResponseTime] = responseTimeForCompleteRequest.ToString(CultureInfo.InvariantCulture);
return Task.CompletedTask; return Task.CompletedTask;
}); });

Loading…
Cancel
Save