Voyager.Common.Proxy.Diagnostics.TraceContext 1.8.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Voyager.Common.Proxy.Diagnostics.TraceContext --version 1.8.0
                    
NuGet\Install-Package Voyager.Common.Proxy.Diagnostics.TraceContext -Version 1.8.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="Voyager.Common.Proxy.Diagnostics.TraceContext" Version="1.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Voyager.Common.Proxy.Diagnostics.TraceContext" Version="1.8.0" />
                    
Directory.Packages.props
<PackageReference Include="Voyager.Common.Proxy.Diagnostics.TraceContext" />
                    
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 Voyager.Common.Proxy.Diagnostics.TraceContext --version 1.8.0
                    
#r "nuget: Voyager.Common.Proxy.Diagnostics.TraceContext, 1.8.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.
#:package Voyager.Common.Proxy.Diagnostics.TraceContext@1.8.0
                    
#: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=Voyager.Common.Proxy.Diagnostics.TraceContext&version=1.8.0
                    
Install as a Cake Addin
#tool nuget:?package=Voyager.Common.Proxy.Diagnostics.TraceContext&version=1.8.0
                    
Install as a Cake Tool

Voyager.Common.Proxy.Diagnostics.TraceContext

Integration package that adds W3C Trace Context propagation to Voyager.Common.Proxy diagnostics.

Installation

dotnet add package Voyager.Common.Proxy.Diagnostics.TraceContext

Usage

Implement ITraceContextAccessor

This package provides an ITraceContextAccessor interface that you need to implement to provide trace context:

public class MyTraceContextAccessor : ITraceContextAccessor
{
    public string? TraceId => Activity.Current?.TraceId.ToString();
    public string? SpanId => Activity.Current?.SpanId.ToString();
    public string? ParentSpanId => Activity.Current?.ParentSpanId.ToString();
}

ASP.NET Core

// Program.cs
var builder = WebApplication.CreateBuilder(args);

// Register your trace context accessor
builder.Services.AddSingleton<ITraceContextAccessor, MyTraceContextAccessor>();

// Add proxy with TraceContext integration
builder.Services.AddProxyTraceContext();  // <-- Adds IProxyRequestContext with trace info
builder.Services.AddServiceProxy<IUserService>("https://api.example.com");
builder.Services.AddProxyLoggingDiagnostics();

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

With Existing User Context

If you already have a custom IProxyRequestContext for user information:

// Your existing user context
public class HttpContextRequestContext : IProxyRequestContext
{
    private readonly IHttpContextAccessor _httpContextAccessor;

    public string? UserLogin => _httpContextAccessor.HttpContext?.User?.Identity?.Name;
    public string? UnitId => _httpContextAccessor.HttpContext?.User?.FindFirst("unit_id")?.Value;
    public string? UnitType => "Agent";
    public IReadOnlyDictionary<string, string>? CustomProperties => null;
}

// Registration - wraps your context with trace information
builder.Services.AddSingleton<ITraceContextAccessor, MyTraceContextAccessor>();
builder.Services.AddProxyTraceContext<HttpContextRequestContext>();

OWIN (.NET Framework 4.8)

// Startup.cs
public void Configuration(IAppBuilder app)
{
    // Create accessor (implement ITraceContextAccessor)
    var accessor = new MyTraceContextAccessor();

    // Proxy with TraceContext
    app.Use(ServiceProxyOwinMiddleware.Create<IVIPService>(options =>
    {
        options.ServiceFactory = () => container.Resolve<IVIPService>();
        options.RequestContextFactory = OwinTraceContextExtensions.CreateRequestContextFactory(accessor);
        options.DiagnosticsHandlers = new IProxyDiagnostics[]
        {
            new LoggingProxyDiagnostics(logger)
        };
    }));
}

How It Works

This package provides:

Component Description
ITraceContextAccessor Interface for providing trace context from your tracing infrastructure
TraceContextProxyRequestContext Wraps IProxyRequestContext and adds trace info from ITraceContextAccessor
TraceContextHelper Extracts TraceId/SpanId/ParentSpanId from ITraceContextAccessor
AddProxyTraceContext() DI extension for ASP.NET Core
OwinTraceContextExtensions Factory helpers for OWIN integration

Trace Context Fields

The integration adds these W3C Trace Context fields to diagnostic events via CustomProperties:

Field Description
trace.id 32-character hex ID for the entire distributed trace
span.id 16-character hex ID for this specific operation
parent.span.id 16-character hex ID of the parent span (null for root spans)
  • Voyager.Common.Proxy.Diagnostics - Logging diagnostics handler
  • Voyager.Common.Proxy.Client - Client-side proxy
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 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 Framework net48 is compatible.  net481 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
1.9.0-preview.1 28 2/19/2026
1.8.0 44 2/18/2026
1.8.0-review.3 38 2/19/2026
1.8.0-preview.3 35 2/19/2026
1.8.0-preview.2.1 29 2/18/2026
1.8.0-preview.2 29 2/18/2026
1.8.0-preview 77 2/10/2026
1.7.8-preview.3 32 2/18/2026
1.7.8-preview.2 33 2/17/2026
1.7.8-preview.1 41 2/9/2026
1.7.7 93 2/6/2026
1.7.7-preview.1.1 45 2/6/2026
1.7.7-preview 87 2/10/2026