MSHelper.Tracing.Jaeger 1.0.0

dotnet add package MSHelper.Tracing.Jaeger --version 1.0.0
NuGet\Install-Package MSHelper.Tracing.Jaeger -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MSHelper.Tracing.Jaeger" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MSHelper.Tracing.Jaeger --version 1.0.0
#r "nuget: MSHelper.Tracing.Jaeger, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MSHelper.Tracing.Jaeger as a Cake Addin
#addin nuget:?package=MSHelper.Tracing.Jaeger&version=1.0.0

// Install MSHelper.Tracing.Jaeger as a Cake Tool
#tool nuget:?package=MSHelper.Tracing.Jaeger&version=1.0.0

MSHelper.Tracing.Jaeger : Tracing distributed processes with Jaeger.

⭐ Star us on GitHub � it motivates us a lot!

Overview

Integrates application with Jaeger (end-to-end distributed tracing) using selected reporter and sampler.

Installation

This document is for the latest MSHelper.Tracing.Jaeger 1.0.0 release and later.

dotnet add package MSHelper.Tracing.Jaeger

Dependencies

-- MSHelper

Open Tracing

MSHelper does not generate any default spans for your ASP.NET Core applications. However, this can be simply achieved by plugging in Open Tracing:

Usage

Enable the instrumentation inside your Startup.cs → ConfigureServices() by calling AddOpenTracing() method on IServiceCollection:

public void ConfigureServices(this IServiceCollection services)
{
    services.AddOpenTracing();
}

Jaeger

Once your application produces spans needed for Jaeger, you need to enable reporting in a way that suits you the most.

Options

--- enabled - determines whether reporting is enabled

--- serviceName - name of the applciation that�s going to be used in Jaeger query engine

--- udpHost - host part of the Jaeger endpoint (UDP).

--- udpPort - port of the Jaeger endpoint (UDP).

--- maxPacketSize - maximum size of the UDP header packet (by default 0). This is not required.

--- sampler - The allowed values are: const, rate and probabilistic. For more details about sampling check the official Jaeger Docs.

--- maxTracesPerSecond - determines maximum number of reported traces per second. Required only for rate sampler.

--- samplingRate - determines the percentage of spans to report. Required only for probabilistic sampler.

appsettings.json

"jaeger": {
  "enabled": true,
  "serviceName": "users",
  "udpHost": "localhost",
  "udpPort": 6831,
  "maxPacketSize": 65000,
  "sampler": "const",
  "maxTracesPerSecond": 10,
  "excludePaths": ["/", "/ping", "/metrics"]
},

Usage

Inside your Startup.cs extend IMSHelperBuilder with AddJaeger() that will create the ITracer using chosen sampler and reporter:

public IServiceProvider ConfigureServices(this IServiceCollection services)
{
    services.AddOpenTracing();

    var builder = services.AddMSHelper()
        .AddJaeger();

    //other registrations    
    return builder.Build();
}

Creating custom spans

Once the ITracer got registered in Startup.cs file, you can inject it to any class you want to create custom spans (not provided by Open Tracing) as follows:

public class MyClass
{
    private readonly ITracer _tracer;

    public MyClass(ITracer tracer)
    {
        _tracer = tracer;
    }

    public void MyMethod()
    {
        using(var scope = BuildScope())
        {
            var span = scope.Span;

            try
            {
                span.Log("Starting the execution of the code");
                ///some code
            }
            catch(Exception ex)
            {
                span.Log(ex.Message);
                span.SetTag(Tags.Error, true);
            }
        }
    }

    private IScope BuildScope()
        => _tracer
            .BuildSpan("Executing important code")
            .StartActive(true);
}

Important Note:

All the MSHelper packages are for self learning purposes inspired by Devmentors.io

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MSHelper.Tracing.Jaeger:

Package Downloads
MSHelper.Tracing.Jaeger.RabbitMQ

MSHelper.Tracing.Jaeger.RabbitMQ - Tracing distributed processes with Jaeger and RabbitMQ.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 220 10/25/2022