Skip to content
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 @@ -40,7 +40,7 @@ public static Mock<ILatencyContext> GetLatencyContext()
return lc;
}

public class MockEventSource : EventSource
public class MockEventSource() : EventSource(throwOnEventWriteErrors: true)
{
public int OnEventInvoked;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.Tracing;
using System.Linq;
using Microsoft.Extensions.Diagnostics.Latency;
using Microsoft.Extensions.Http.Latency.Internal;
Expand Down Expand Up @@ -84,8 +85,16 @@ public void HttpRequestLatencyListener_OnEventSourceCreated_NonHttpSources()
listener.OnEventSourceCreated("test", es);
Assert.Equal(0, es.OnEventInvoked);
Assert.False(es.IsEnabled());

using var dummyListener = new DummyListener();
dummyListener.EnableEvents(es, EventLevel.LogAlways);

// EventSource seems to send the event to all listeners, even those that didn't enable the EventSource at all!
es.Write("Dummy");
}

private sealed class DummyListener : EventListener;

[Fact]
public void HttpRequestLatencyListener_OnEventSourceCreated_HttpSources()
{
Expand Down
Loading