Created
August 7, 2019 00:20
-
-
Save shirhatti/20fd0dac4a5a66852e7a2fa6d8918f2a to your computer and use it in GitHub Desktop.
Repro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Diagnostics.Tracing; | |
using Microsoft.Diagnostics.Tools.RuntimeClient; | |
using Microsoft.Diagnostics.Tracing; | |
namespace Repro | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var processId = Process.GetCurrentProcess().Id; | |
ulong eventPipeSessionId = 0; | |
try | |
{ | |
var providerList = new List<Provider>() | |
{ | |
new Provider( | |
name: "System.Runtime", | |
keywords: uint.MaxValue, | |
eventLevel: EventLevel.Warning, | |
filterData: "EventCounterIntervalSec=1") | |
}; | |
var configuration = new SessionConfiguration( | |
circularBufferSizeMB: 1000, | |
format: EventPipeSerializationFormat.NetPerf, | |
providers: providerList); | |
var binaryReader = EventPipeClient.CollectTracing(processId, configuration, out eventPipeSessionId); | |
var source = new EventPipeEventSource(binaryReader); | |
source.Dynamic.All += (eventData) => | |
{ | |
Console.WriteLine($"Provider = {eventData.ProviderName} ID = {eventData.ID} Name = {eventData.EventName}"); | |
}; | |
Console.CancelKeyPress += delegate (object sender, ConsoleCancelEventArgs e) | |
{ | |
EventPipeClient.StopTracing(processId, eventPipeSessionId); | |
e.Cancel = true; | |
}; | |
source.Process(); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine($"[ERROR] {ex.ToString()}"); | |
} | |
finally | |
{ | |
EventPipeClient.StopTracing(processId, eventPipeSessionId); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp3.0</TargetFramework> | |
<RestoreSources> | |
$(RestoreSources); | |
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; | |
https://api.nuget.org/v3/index.json; | |
</RestoreSources> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.42" /> | |
<PackageReference Include="Microsoft.Diagnostics.Tools.RuntimeClient" Version="3.0.0-preview7.19365.2" /> | |
</ItemGroup> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment