Adding user context to request tracing in ASP.NET Core enhances troubleshooting, performance monitoring, and user behavior analysis. The post explains how to implement middleware that enriches logs with user IDs, improving the ability to track user journeys and quickly identify issues. It also discusses handling PII concerns and suggests expanding context enrichment with feature flags and tenant information.

5m read timeFrom milanjovanovic.tech
Post cover image
Table of contents
Why Add User Context to Request Tracing?Implementing User Context EnrichmentLogging Scopes and OpenTelemetryAdding the Middleware to Your ApplicationHandling PII ConcernsExpanding Context EnrichmentTakeaway

Sort: