Skip to content

An ETW EventSource Tracing Core build on .Net Standard 2.0

License

Notifications You must be signed in to change notification settings

SwissLife-OSS/thor-client

Repository files navigation

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.