Diagnostics and incident triage
Diagnostics and incident triage
Incident triage is a bounded investigation: establish the user impact, compare the affected interval to a baseline, form testable hypotheses, and gather the lowest-risk evidence that can distinguish them.
Begin with the affected route, regions, time window, symptom and change history. Use request rate, error rate, latency distribution and saturation (CPU, thread pool queue, memory, dependency pool occupancy) together. Correlation with a deployment suggests a hypothesis, not proof. For example, low CPU with long database spans suggests waiting on a dependency, but queue growth may also be caused by thread blocking or capacity limits. Use dotnet-counters for low-overhead initial counter inspection, dotnet-trace for a focused EventPipe trace, dotnet-gcdump for managed heap graph investigation (it can induce a full GC), and dotnet-dump for a deeper memory/process snapshot. These commands require approved tools and a synthetic target; inspect installed versions/help first. Dumps, traces and diagnostic ports can expose credentials and memory contents; never upload unrestricted artifacts, attach to unrelated processes, expose ports, or collect on production by default. Choose a brief collection interval, private directory, disk/memory budget and cleanup owner. Use debugger breakpoints only in an isolated reproducer because suspending threads changes timing. Health checks are not a complete SLI: liveness answers whether the process should be restarted under policy; readiness answers whether it can accept its intended traffic. A dependency outage need not imply process failure. Review the separate diagnostic runbook before any tool execution. These examples analyze fictional timelines and show actual local health-check registration, not measured production incidents. See lab-fixtures/diagnostics-v28/README.md for a finite synthetic target and diagnostic tool review checklist.
Baseline: .NET 10 / C# 14. All C# results below are reasoned, not executed. Models, in-process integrations and actual runtime or UI tests are distinguished.
Separate a latency symptom from a hypothesis
The three rows are invented aggregate measurements, not observed telemetry. Find a high-latency interval with high dependency duration and modest CPU.
Inspect the archived Fixture.csproj and use only an approved .NET 10 SDK. Build and run in an isolated lab with finite time and resource limits.
using System;var windows = new[] { (Name: "baseline", P95: 120, DbP95: 40, Cpu: 30), (Name: "change", P95: 680, DbP95: 510, Cpu: 35), (Name: "later", P95: 640, DbP95: 490, Cpu: 36) };foreach (var w in windows) if (w.P95 > 500 && w.DbP95 > 400 && w.Cpu < 60) Console.WriteLine($"{w.Name}: investigate dependency waiting");Console.WriteLine("cause not established");Expected result (not executed):
change: investigate dependency waitinglater: investigate dependency waitingcause not establishedSeparate percentiles cannot be subtracted to compute the remaining latency. Inspect spans from the same requests, dependency errors and pool occupancy before acting.
Evaluate liveness and readiness separately
Use ASP.NET Core health-check services directly, without opening a network listener. A synthetic dependency is unavailable.
Inspect the archived Fixture.csproj and use only an approved .NET 10 SDK. Build and run in an isolated lab with finite time and resource limits. Requires the ASP.NET Core 10 shared framework.
using System;using System.Linq;using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Diagnostics.HealthChecks;var services = new ServiceCollection();services.AddLogging();services.AddHealthChecks() .AddCheck("self", () => HealthCheckResult.Healthy(), tags: new[] { "live" }) .AddCheck("stock-db", () => HealthCheckResult.Unhealthy("synthetic outage"), tags: new[] { "ready" });using var provider = services.BuildServiceProvider();var checks = provider.GetRequiredService<HealthCheckService>();var live = await checks.CheckHealthAsync(r => r.Tags.Contains("live"));var ready = await checks.CheckHealthAsync(r => r.Tags.Contains("ready"));if (live.Status != HealthStatus.Healthy || ready.Status != HealthStatus.Unhealthy) throw new Exception("probe policy");Console.WriteLine($"live={live.Status}; ready={ready.Status}");Expected result (not executed):
live=Healthy; ready=UnhealthyThis calls the registered health checks, not HTTP endpoints or an orchestrator. ASP.NET Core endpoints can filter tags and map health status to HTTP status. Keep diagnostic detail private.
Choose bounded evidence for each symptom
Model a diagnostic policy rather than launching a collector. The allowed target is an explicitly identified synthetic process.
Inspect the archived Fixture.csproj and use only an approved .NET 10 SDK. Build and run in an isolated lab with finite time and resource limits.
using System;string Plan(string symptom, bool synthetic, bool approved) { if (!synthetic || !approved) return "stop: approval and synthetic target required"; return symptom switch { "cpu" => "counters then bounded trace", "heap" => "counters then review heap collection impact", _ => "inspect request telemetry first" };}Console.WriteLine(Plan("cpu", true, true));Console.WriteLine(Plan("heap", true, true));Console.WriteLine(Plan("heap", false, true));Expected result (not executed):
counters then bounded tracecounters then review heap collection impactstop: approval and synthetic target requiredThis policy only selects a next step. It does not start a tool, attach to a PID or establish the cause. Deep collections require their own explicit resource and privacy review.
Apply the concept
A fictional API has increased p95 latency after a deployment, stable error rate, and rising connection-pool wait. Draft a three-step triage and one mitigation verification.
Use the manual practice and knowledge check. Do not deploy or publish these fixtures.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Diagnostics and incident triage — knowledge check
Apply the lesson concepts to the following scenarios.
What does low CPU plus high dependency latency establish?
Which tool is a reasonable initial counter inspection?
Why restrict dump access?
What can gcdump collection do?
What should a dependency-only outage often affect?