Skip to content

Commit 362550d

Browse files
benmwatsonBen Watsonsungam3r
authored
Update some events to Warning, add more data (#264)
* Upgrade two events to warning, and add some more data to one event. * Update src/Events.cs Co-authored-by: Ivan Maximov <sungam3r@yandex.ru> * Update src/Events.cs Co-authored-by: Ivan Maximov <sungam3r@yandex.ru> * Update src/Events.cs Co-authored-by: Ivan Maximov <sungam3r@yandex.ru> --------- Co-authored-by: Ben Watson <bewatson@microsoft.com> Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
1 parent 23e28fd commit 362550d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/Events.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ public void MemoryStreamManagerInitialized(int blockSize, int largeBufferMultipl
172172
/// Logged when a new block is created.
173173
/// </summary>
174174
/// <param name="smallPoolInUseBytes">Number of bytes in the small pool currently in use.</param>
175-
[Event(7, Level = EventLevel.Verbose)]
175+
[Event(7, Level = EventLevel.Warning, Version = 2)]
176176
public void MemoryStreamNewBlockCreated(long smallPoolInUseBytes)
177177
{
178-
if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None))
178+
if (this.IsEnabled(EventLevel.Warning, EventKeywords.None))
179179
{
180180
WriteEvent(7, smallPoolInUseBytes);
181181
}
@@ -186,10 +186,10 @@ public void MemoryStreamNewBlockCreated(long smallPoolInUseBytes)
186186
/// </summary>
187187
/// <param name="requiredSize">Requested size.</param>
188188
/// <param name="largePoolInUseBytes">Number of bytes in the large pool in use.</param>
189-
[Event(8, Level = EventLevel.Verbose, Version = 2)]
189+
[Event(8, Level = EventLevel.Warning, Version = 3)]
190190
public void MemoryStreamNewLargeBufferCreated(long requiredSize, long largePoolInUseBytes)
191191
{
192-
if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None))
192+
if (this.IsEnabled(EventLevel.Warning, EventKeywords.None))
193193
{
194194
WriteEvent(8, requiredSize, largePoolInUseBytes);
195195
}
@@ -219,13 +219,19 @@ public void MemoryStreamNonPooledLargeBufferCreated(Guid guid, string tag, long
219219
/// <param name="tag">A temporary ID for this stream, usually indicates current usage.</param>
220220
/// <param name="bufferType">Type of the buffer being discarded.</param>
221221
/// <param name="reason">Reason for the discard.</param>
222+
/// <param name="smallBlocksFree">Number of free small pool blocks.</param>
223+
/// <param name="smallPoolBytesFree">Bytes free in the small pool.</param>
224+
/// <param name="smallPoolBytesInUse">Bytes in use from the small pool.</param>
225+
/// <param name="largeBlocksFree">Number of free large pool blocks.</param>
226+
/// <param name="largePoolBytesFree">Bytes free in the large pool.</param>
227+
/// <param name="largePoolBytesInUse">Bytes in use from the large pool.</param>
222228
[Event(10, Level = EventLevel.Warning, Version = 2)]
223229
public void MemoryStreamDiscardBuffer(Guid guid, string tag, MemoryStreamBufferType bufferType,
224-
MemoryStreamDiscardReason reason)
230+
MemoryStreamDiscardReason reason, long smallBlocksFree, long smallPoolBytesFree, long smallPoolBytesInUse, long largeBlocksFree, long largePoolBytesFree, long largePoolBytesInUse)
225231
{
226-
if (this.IsEnabled())
232+
if (this.IsEnabled(EventLevel.Warning, EventKeywords.None))
227233
{
228-
WriteEvent(10, guid, tag ?? string.Empty, bufferType, reason);
234+
WriteEvent(10, guid, tag ?? string.Empty, bufferType, reason, smallBlocksFree, smallPoolBytesFree, smallPoolBytesInUse, largeBlocksFree, largePoolBytesFree, largePoolBytesInUse);
229235
}
230236
}
231237

src/RecyclableMemoryStreamManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,9 @@ internal void ReportLargeBufferCreated(Guid id, string tag, long requiredSize, b
653653

654654
internal void ReportBufferDiscarded(Guid id, string tag, Events.MemoryStreamBufferType bufferType, Events.MemoryStreamDiscardReason reason)
655655
{
656-
Events.Writer.MemoryStreamDiscardBuffer(id, tag, bufferType, reason);
656+
Events.Writer.MemoryStreamDiscardBuffer(id, tag, bufferType, reason,
657+
this.SmallBlocksFree, this.smallPoolFreeSize, this.smallPoolInUseSize,
658+
this.LargeBuffersFree, this.LargePoolFreeSize, this.LargePoolInUseSize);
657659
this.BufferDiscarded?.Invoke(this, new BufferDiscardedEventArgs(id, tag, bufferType, reason));
658660
}
659661

0 commit comments

Comments
 (0)