The Thor tracing core for .net
The tracing core contains everything to enable ETW tracing in your .net application.
Here is how the Thor.Core
has to be installed via NuGet on a powershell console.
Install-Package Thor.Core
Okay, after installing our dependencies we could start writing a bit code.
The following code is not production ready. This code should give only an idea of how to group ETW events into an activity.
using System;
using System.Threading;
using Thor.Core;
using static Thor.Core.DefaultEventSource;
public class UserRepository
{
...
public async Task<bool> RemoveAsync(User user)
{
using (Activity.Create("Remove User"))
{
try
{
Log.Info($"Removing user with id {user.Id}");
if (await _collection.RemoveAsync(user.Id).ConfigureAwait(false))
{
Log.Info($"Removed user with id {user.Id} successfully");
return true;
}
else
{
Log.Info($"User with id {user.Id} not found");
return false;
}
}
catch (Exception ex)
{
Log.Info(ex, $"Removing user with id {user.Id} failed");
return false;
}
}
}
...
}
Click here to get to the documentation home of Thor Core.
We strongly recommend to use the Thor Generator to generate your own event sources automatically
and avoid using the DefaultEventSource
, because Semantic Tracing is much more powerful for you
in the end. Click here to get more information
about the Thor Generator.