WhiteBeard.Traceability 3.0.1

dotnet add package WhiteBeard.Traceability --version 3.0.1
                    
NuGet\Install-Package WhiteBeard.Traceability -Version 3.0.1
                    
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="WhiteBeard.Traceability" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WhiteBeard.Traceability" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="WhiteBeard.Traceability" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WhiteBeard.Traceability --version 3.0.1
                    
#r "nuget: WhiteBeard.Traceability, 3.0.1"
                    
#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.
#:package WhiteBeard.Traceability@3.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WhiteBeard.Traceability&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=WhiteBeard.Traceability&version=3.0.1
                    
Install as a Cake Tool

Traceability

NuGet Version Build Status License NuGet Downloads .NET Version GitHub Stars GitHub Forks

💝 Support this project

If you find this project useful, consider supporting its development:

<a href="https://www.buymeacoffee.com/almerindo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

🤖 Get help with AI

Have questions about the API, implementation, or documentation? Ask DeepWiki, an AI agent that can help you understand and use Traceability.

Ask DeepWiki


NuGet package for automatic correlation-id management in .NET applications, with support for .NET Standard 2.0+ (core), .NET 8 (ASP.NET Core), and .NET Framework 4.8+ (ASP.NET Framework).

📖 Quick Start | User Manual | Complete Documentation | Examples

Indexed Documentation (Devin DeepWiki): DeepWiki for whitebeardit/traceability

Motivation

In distributed architectures and microservices, tracking a request across multiple services is essential for debugging, monitoring, and performance analysis. The correlation-id is a unique identifier that allows you to track a request from its origin to all subsequent calls.

When to use this library?

Use Traceability when you need:

  1. Traceability in Microservices: Track a request across multiple services
  2. Simplified Debugging: Quickly identify all logs related to a request
  3. Performance Analysis: Measure total processing time across multiple services
  4. Monitoring and Observability: Correlate metrics, traces, and logs from different services

Features

  • Zero-code/Zero-config: Works automatically - just install the package!
  • ✅ Automatic correlation-id management using AsyncLocal<string>
  • ✅ Log correlation with distributed tracing via Activity.Current (when OpenTelemetry is configured externally)
  • ✅ W3C Trace Context propagation (traceparent header) when trace context is available (best-effort)
  • Portable core via .NET Standard 2.0 (works with .NET 6, 7, 8, and compatible frameworks)
  • Full support for .NET 8.0 (ASP.NET Core with automatic middleware registration)
  • Full support for .NET Framework 4.8+ (ASP.NET Web API and Traditional ASP.NET with automatic HttpModule registration)
  • Zero-code for .NET Framework 4.8: Automatic registration via PreApplicationStartMethod
  • Zero-config for .NET 8.0: Automatic middleware and HttpClient registration
  • ✅ Middleware for ASP.NET Core (.NET 8)
  • ✅ HttpModule and MessageHandler for ASP.NET (.NET Framework 4.8)
  • ✅ Automatic integration with HttpClient
  • ✅ Support for Serilog and Microsoft.Extensions.Logging
  • ✅ Integration with Polly for resilience policies
  • ✅ Automatic propagation in chained HTTP calls

Migration

Installation

dotnet add package WhiteBeard.Traceability

Quick Start

ASP.NET Core (.NET 8) - Zero Configuration

1. Install the package:

dotnet add package WhiteBeard.Traceability

2. Configure in Program.cs (just one line!):

using Traceability.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Zero configuration - everything is automatic!
// Source comes from TRACEABILITY_SERVICENAME or assembly name
// Middleware is registered automatically
// HttpClient is configured automatically
builder.Services.AddTraceability();
builder.Services.AddControllers();

var app = builder.Build();
app.MapControllers();
app.Run();

With explicit Source (optional):

builder.Services.AddTraceability("MyService");

3. Use in a Controller:

using Microsoft.AspNetCore.Mvc;
using Traceability;

[ApiController]
[Route("api/[controller]")]
public class ValuesController : ControllerBase
{
    [HttpGet]
    public IActionResult Get()
    {
        // Correlation-id is automatically available
        var correlationId = CorrelationContext.Current;
        return Ok(new { CorrelationId = correlationId });
    }
}

Result:

  • ✅ Correlation-id automatically generated on each request (if not provided via X-Correlation-Id)
  • ✅ Trace context can be propagated in HTTP calls (via traceparent) when OpenTelemetry is configured externally
  • ✅ Automatically included in logs
  • ✅ Returned in the X-Correlation-Id response header
  • ✅ Compatible with OpenTelemetry-compatible observability tools (when OpenTelemetry is configured in the application)

ASP.NET Framework 4.8 - Zero Code

1. Install the package:

Install-Package WhiteBeard.Traceability

2. That's it! No code needed!

The library automatically:

  • ✅ Registers CorrelationIdHttpModule via PreApplicationStartMethod
  • ✅ Manages correlation-id automatically

Optional: Configure Serilog

// Global.asax.cs
using Traceability.Extensions;
using Serilog;

protected void Application_Start()
{
    Log.Logger = new LoggerConfiguration()
        .WithTraceability("MyService")
        .WriteTo.Console(
            outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Source} {CorrelationId} {Message:lj}{NewLine}{Exception}")
        .CreateLogger();

    GlobalConfiguration.Configure(config =>
    {
        config.MapHttpAttributeRoutes();
    });
}

3. Use in a Controller:

using System.Web.Http;
using Traceability;

public class ValuesController : ApiController
{
    [HttpGet]
    [Route("api/values")]
    public IHttpActionResult Get()
    {
        // Correlation-id is automatically available
        var correlationId = CorrelationContext.Current;
        return Ok(new { CorrelationId = correlationId });
    }
}

Result:

  • ✅ Correlation-id automatically generated for each request
  • ✅ Trace context can be propagated in HTTP calls (via traceparent) when OpenTelemetry is configured externally
  • ✅ Automatically included in logs (if Serilog is configured)
  • ✅ Returned in the X-Correlation-Id response header

Environment Variables

To reduce verbosity, you can use environment variables:

Linux/Mac:

export TRACEABILITY_SERVICENAME="UserService"
export LOG_LEVEL="Information"

Windows PowerShell:

$env:TRACEABILITY_SERVICENAME="UserService"
$env:LOG_LEVEL="Information"

With the environment variable defined, you can use:

// Source comes automatically from TRACEABILITY_SERVICENAME
builder.Services.AddTraceability();

Documentation

Quick Examples

With Logging

// Program.cs
builder.Services.AddTraceability("MyService");
builder.Logging.AddConsole(options => options.IncludeScopes = true);

// In Controller
_logger.LogInformation("Processing request");
// Output: => CorrelationId: a1b2c3d4e5f6789012345678901234ab

With HttpClient

// Program.cs
builder.Services.AddTraceability("MyService");
builder.Services.AddHttpClient("ExternalApi", client =>
{
    client.BaseAddress = new Uri("https://api.example.com/");
});

// In Controller
var client = _httpClientFactory.CreateClient("ExternalApi");
// Correlation-id is automatically added to the header

Supported Frameworks

The package uses multi-targeting to provide the best experience for each platform:

  • .NET Standard 2.0: Portable core library (CorrelationContext, HttpClient integration, Logging enrichers, Configuration)
    • Compatible with .NET 6, 7, 8, .NET Framework 4.6.1+, and other .NET Standard 2.0 implementations
    • Provides core functionality without framework-specific dependencies
  • .NET 8.0: Full ASP.NET Core integration
    • Automatic middleware registration
    • Dependency injection extensions
    • HttpContext integration
  • .NET Framework 4.8+: Full ASP.NET Framework integration
    • Automatic HttpModule registration via PreApplicationStartMethod
    • Web API and MVC support
    • System.Web integration

Note: The package automatically selects the appropriate implementation based on your target framework. Core functionality (correlation-id management, HttpClient propagation, logging) is available on all platforms via the .NET Standard 2.0 target.

Contributing

Contributions are welcome! Please open an issue or pull request.

For developers who want to contribute:

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.1 180 1/25/2026
3.0.0 92 1/24/2026
2.4.0 92 1/24/2026
2.3.1 96 1/22/2026
2.3.0 94 1/21/2026
2.2.2 118 12/29/2025
2.2.1 94 12/29/2025
2.2.0 102 12/28/2025
2.1.2 97 12/28/2025
2.1.1 100 12/27/2025
2.1.0 148 12/26/2025
2.0.0 178 12/24/2025
1.1.0 188 12/23/2025
1.0.1 180 12/23/2025
1.0.0 182 12/23/2025