Coder Social home page Coder Social logo

swisslife-oss / thor-client Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 527 KB

An ETW EventSource Tracing Core build on .Net Standard 2.0

License: MIT License

C# 99.63% Dockerfile 0.37%
eventsource etw core tracing diagnostics dotnet logging c-sharp

thor-client's Introduction

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.

thor-client's People

Contributors

glucaci avatar michaelstaib avatar rstaib avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

glucaci

thor-client's Issues

EventHubTransmitter dispose issues

Random exeption when disposing EventHubTransmitter:
System.ObjectDisposedException : The CancellationTokenSource has been disposed.
on line _disposeToken?.Dispose();

Also observed random exception in the same dispose method on:
_transmission?.Dispose(); with exception A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled)

HttpClientFactory

Description

As of version 2.1 .Net core offers HTTP client factories to get fine-grained control over the creation of HTTP clients. This does not only mean to have a unique way of creating HTTP clients which in turn is good for enforcing best practice. But also helps by running code before and after each HTTP message request is executed. This is in particular good for tracing, because we need to create the activity before running the actual request and destroy the activity after receiving the response..

The goal of this Issue is to create a HTTP client factory that injects a tracing HTTP message handler into the HTTP client. Whereas the HTTP message handler does nothing else than creating a HTTP client activity, storing the activity id in a HTTP request header, executing the HTTP request, waiting for the HTTP response status and closing the HTTP client activity afterwards.

Acceptance Criteria

  • A HTTP client factory that creates a HTTP client with a specific HTTP message handler
  • The HTTP client and message handler must be reused
  • Every request made by the HTTP client must create a HTTP client activity which encompasses the actual HTTP request
  • The HTTP request must have a header (Thor-ActivityId) that contains the HTTP client activity id

Attachment Transmission for Azure BLOB Storage

Acceptance Criteria

  • Attachments must be stored in Azure BLOB Storage
  • Attachments must be stored in the same way as before (.Net classic) to avoid incompatibility issues on the server-side
  • The Azure BLOB Storage connection string must be configurable through .Net core options

Readme

Readme needs content.

Integrate GenericHost

Integrate GenericHost into Clients and refine namespaces (Thor.Extensions and Thor.Hosting)

Complex Type Tracing

ETW messages support a maximum message size of 64KB and does not support complex payloads. However, sometimes this limit exceeds in case of a SOAP message for example or it is needed to log a complex type like a POCO. Therefore a different mechanism is needed to ensure those gigantic messages or complex types can be traced as well.

Custom Provider Registration

The tracing session does not contain any custom EventSources. There must be a way to configure custom prefixes in order to realize loading custom EventSources. The prefix refers to the assembly name. An assembly's name that starts with the prefix will be loaded into the tracing session.

Documentation

The documentation repository has to be filled with content.

Load automatically all DiagnosticSources for current application

Resolve per convention entry assembly name prefix (e.g. MyProduct.MyaApp) and add it to allow prefixed on the session, to enable all application specific diagnostic sources without configuration.

Afterwords user can still use configuration for additional diagnostic sources which he wants to trace.

Maybe for resolver user can pass regex for extracting the prefix from assembly name, to don't have to strict convention on assembly name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.