Provides tracing capabilities for GenericHost.


Keywords
ETW, EventSource, Logging, Tracing, c-sharp, core, diagnostics, dotnet
License
MIT
Install
Install-Package Thor.GenericHost -Version 6.0.0-preview.5

Documentation

Thor

GitHub release NuGet Package License Build Status


The Thor tracing core for .net

The tracing core contains everything to enable ETW tracing in your .net application.

Getting Started

Install Package

Here is how the Thor.Core has to be installed via NuGet on a powershell console.

Install-Package Thor.Core

Code Example

Okay, after installing our dependencies we could start writing a bit code.

How to scope (group) events together

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;
            }
        }
    }

    ...
}

Documentation

Click here to get to the documentation home of Thor Core.

Checkout the Thor Generator

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.