Voyager.Common.Proxy.Diagnostics 1.7.7

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

Voyager.Common.Proxy.Diagnostics

Diagnostics handlers for Voyager.Common.Proxy. Provides two built-in IProxyDiagnostics implementations for logging proxy operations.

Installation

dotnet add package Voyager.Common.Proxy.Diagnostics

Usage

LoggingProxyDiagnostics (via ILogger)

Uses Microsoft.Extensions.Logging with structured message templates. Works with any ILogger provider (Console, Serilog, NLog, etc.).

services.AddLogging(builder => builder.AddConsole());
services.AddProxyLoggingDiagnostics();
services.AddServiceProxy<IUserService>("https://api.example.com");

ConsoleProxyDiagnostics (direct Console.WriteLine)

Writes directly to Console.WriteLine using string interpolation. No dependency on any logging framework - useful for quick debugging or environments without a configured logging provider.

services.AddProxyConsoleDiagnostics();
services.AddServiceProxy<IUserService>("https://api.example.com");

User context (optional)

services.AddProxyRequestContext<HttpContextRequestContext>();

Log Output

The handler produces structured logs with W3C Trace Context fields for distributed tracing:

Request Starting (Debug)

Proxy request starting: GET /users/123 [IUserService.GetUserAsync] TraceId=abc123def456789012345678901234ab SpanId=1234567890abcdef ParentSpanId=(root) User=jan.kowalski Unit=12345/Agent

Request Completed - Success (Debug)

Proxy request completed: GET /users/123 200 in 45ms [IUserService.GetUserAsync] TraceId=abc123... SpanId=1234... ParentSpanId=(root) User=jan.kowalski Unit=12345/Agent

Request Completed - Failure (Warning)

Proxy request failed: GET /users/123 404 in 30ms [IUserService.GetUserAsync] Error=NotFound: User not found TraceId=abc123... SpanId=1234... ParentSpanId=(root) User=jan.kowalski Unit=12345/Agent

Request Exception (Error)

Proxy request exception: GET /users/123 in 5000ms [IUserService.GetUserAsync] Exception=HttpRequestException: Connection refused TraceId=abc123... SpanId=1234... ParentSpanId=(root) User=jan.kowalski Unit=12345/Agent

Retry Attempt (Warning)

Proxy retry attempt 1/3 for [IUserService.GetUserAsync] after Timeout: Request timed out. Waiting 1000ms. TraceId=abc123... SpanId=1234... ParentSpanId=(root) User=jan.kowalski Unit=12345/Agent

Circuit Breaker State Changed (Warning/Information)

Circuit breaker OPENED for IUserService: Closed -> Open. Failures=5. LastError=Unavailable: Connection refused User=jan.kowalski Unit=12345/Agent

W3C Trace Context

All diagnostic events include W3C Trace Context fields:

Field Description
TraceId 32-character hex ID for the entire trace (spans multiple services)
SpanId 16-character hex ID for this specific operation
ParentSpanId 16-character hex ID of the parent span (null for root spans)

When Activity.Current is available (e.g., with OpenTelemetry), trace context is automatically captured. Otherwise, new IDs are generated.

User Context

To include user information in logs, implement IProxyRequestContext:

public class HttpContextRequestContext : IProxyRequestContext
{
    private readonly IHttpContextAccessor _httpContextAccessor;

    public HttpContextRequestContext(IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = 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;
}

// Register
services.AddHttpContextAccessor();
services.AddProxyRequestContext<HttpContextRequestContext>();
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.8.0-preview 57 2/10/2026
1.7.8-preview.1 36 2/9/2026
1.7.7 84 2/6/2026
1.7.7-preview.1.1 37 2/6/2026
1.7.7-preview 59 2/10/2026