Skip to main content

Observability, Diagnostics, Performance & Session Profiling

Local lab build for Advanced Module 11 · Observability, Diagnostics, Performance & Session Profiling, following the walkthrough video "Instrument EnterpriseOps end to end". The DiagnosticsPage binds a DiagnosticSnapshot (version · environment · node · theme · flags) behind a role check, shows session & health, the performance budget table (PerfBudgetPanel) and the structured log. OperationTimer times every service operation and writes one structured JSON line per operation, and one correlation id ties a click to the log line, the budget row and the status bar. The slow query from the video (pageSize 5,000 → 2,340 ms against a 400 ms budget) is diagnosed from the log field and then fixed.

Nothing here is deployed anywhere; it is a plain Wisej.NET 4 project that runs on your machine, with in-memory data.

Run it

cd "LearnWisej-Samples/Enterprise Wisej.NET Course\Module 11\EnterpriseOps"
dotnet run -f net10.0 --urls http://localhost:5211

Then open http://localhost:5211. (Visual Studio: open EnterpriseOps.slnx, press F5 — the port is in Properties/launchSettings.json.)

What to try

ControlWhat you should see
Role / secrets redacted (5) chipsRole: Manager ✓; hover the amber chip for the five redaction notes
VERSION · ENVIRONMENT · NODE · THEME cards2.4.1+sha.9e21b0, the environment, app-node-B, the active theme
Session & health cardsession count, uptime, managed heap / working set, feature flags, and the health chip (hover it for all six checks); refreshed every second by timerLive
Run query · 50Query — SearchWorkOrders ≤ 400 ms 162 ms OK ✓, one information JSON line with "pageSize":50, and the status bar … · within budget
Slow query · 5000the row goes 2,340 ms OVER ✕ on pink, the JSON line says "elapsedMs":2340,"pageSize":5000,"budget":"over", the status bar reads OperationTimer — SearchWorkOrders 2,340 ms · correlation … · OVER BUDGET
Fix page sizeback to pageSize 50 → ≈ 162 ms, the row turns green, a new correlation id in the status bar
Structured log listone JSON line per operation, correlation id last; an error entry is shown redacted
status barthe last result and its correlation id

Where things live

Module 11/
├─ EnterpriseOps.slnx
└─ EnterpriseOps/
├─ Program.cs session entry point: SessionContext.Start → Application.MainPage
├─ Startup.cs Kestrel host (app.UseWisej())
├─ Properties/AssemblyInfo.cs AssemblyInformationalVersion "2.4.1+sha.9e21b0" — the VERSION card
├─ Domain/WorkOrder.cs WorkOrder, Tenant, WorkOrderStatus, Priority
├─ Data/
│ ├─ DeploymentConfig.cs environment, node, feature flags — and the secrets kept out of the snapshot
│ └─ InMemoryWorkOrderStore.cs 150 rows; latency = 140 ms + 0.44 ms × pageSize
├─ Services/
│ ├─ SessionContext.cs per-session user/tenant + correlation-id factory + startup stopwatch
│ ├─ CommandContext.cs tenant + user + correlation id, a parameter on every call
│ ├─ Contracts.cs WorkQueueQuery, WorkQueueRow, PagedResult<T>, CommandResult, SearchResult
│ └─ WorkOrderService.cs the OperationTimer + budget verdict + structured entry per operation
├─ Diagnostics/
│ ├─ DiagnosticsPerformancePatterns.cs OperationTimer + DiagnosticSnapshot (verbatim from the lesson)
│ ├─ StructuredLog.cs LogEntry.ToJsonLine(), bounded buffer, SafeErrorMessage
│ ├─ PerformanceBudget.cs the five budget rows; Record() decides OK / OVER
│ ├─ HealthCheck.cs probes + budgets + session memory + log → one HealthReport
│ ├─ SessionMemoryAudit.cs registered holders, timer probes, verdicts and advice
│ └─ DiagnosticsService.cs CaptureSnapshot() (safe by type, with redaction notes), CaptureStats()
├─ Security/
│ ├─ AppUser.cs ana.ops (Manager), ben.tech (Technician), cara.admin (Admin)
│ ├─ AuditTrail.cs who opened diagnostics, allowed or denied, with the correlation id
│ └─ DiagnosticsAccessPolicy.cs operator roles only, decided on the server
├─ UI/
│ ├─ DiagnosticsPage.cs/.Designer.cs the screen: snapshot cards, health, budgets, structured log, status bar
│ └─ PerfBudgetPanel.cs/.Designer.cs dgvBudgets — Operation · Budget · Measured · Status, red when over
└─ docs/ the five deliverables + the correlation SVG

Service, data and diagnostics layers also write a plain server-side trace (Service: · Data: · Diagnostics: lines with the correlation id) to System.Diagnostics.Trace; it never reaches the page.