title | description | ms.date | ms.topic |
---|---|---|---|
Extensibility - .NET TraceProcessing | In this tutorial, learn how to extend .NET TraceProcessing. | 08/19/2024 | overview |
Many kinds of trace data have built-in support in TraceProcessor, but if you have your other providers that you would like to analyze (including your own custom providers), that data is also available from the trace live while processing occurs.
Note
This part of the API is in preview and under active development. It may change in future releases.
For example, here is a simple way to get the list of providers IDs in a trace.
// Open a trace with TraceProcessor.Create() and call Run...staticvoidRun(ITraceProcessortrace){HashSet<Guid>providerIds=newHashSet<Guid>();trace.Use((e)=>providerIds.Add(e.ProviderId));trace.Process();foreach(GuidproviderIdinproviderIds){Console.WriteLine(providerId);}}
The following example shows a simplified custom data source.
// Open a trace with TraceProcessor.Create() and call Run...staticvoidRun(ITraceProcessortrace){CustomDataSourcecustomDataSource=newCustomDataSource();trace.Use(customDataSource);trace.Process();Console.WriteLine(customDataSource.Count);}classCustomDataSource:IFilteredEventConsumer{publicIReadOnlyList<Guid>ProviderIds{get;}=newGuid[]{newGuid("your provider ID")};publicintCount{get;privateset;}publicvoidProcess(EventContexteventContext){++Count;}}
In this tutorial, you learned how to extend TraceProcessor.
The next step is to learn how to load symbols for traces.