Skip to content

Commit d4ed4f7

Browse files
authored
Eliminate enum boxing allocations from Kestrel HTTP2 logging (#19277)
1 parent e0793fd commit d4ed4f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,18 @@ public virtual void HPackEncodingError(string connectionId, int streamId, HPackE
272272

273273
public void Http2FrameReceived(string connectionId, Http2Frame frame)
274274
{
275-
_http2FrameReceived(_logger, connectionId, frame.Type, frame.StreamId, frame.PayloadLength, frame.ShowFlags(), null);
275+
if (_logger.IsEnabled(LogLevel.Trace))
276+
{
277+
_http2FrameReceived(_logger, connectionId, frame.Type, frame.StreamId, frame.PayloadLength, frame.ShowFlags(), null);
278+
}
276279
}
277280

278281
public void Http2FrameSending(string connectionId, Http2Frame frame)
279282
{
280-
_http2FrameSending(_logger, connectionId, frame.Type, frame.StreamId, frame.PayloadLength, frame.ShowFlags(), null);
283+
if (_logger.IsEnabled(LogLevel.Trace))
284+
{
285+
_http2FrameSending(_logger, connectionId, frame.Type, frame.StreamId, frame.PayloadLength, frame.ShowFlags(), null);
286+
}
281287
}
282288

283289
public virtual void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)

0 commit comments

Comments
 (0)