Slide 1

Slide 1 text

Application Diagnostics in .NET Core 3.1 David Fowler – ASP.NET Architect @davidfowl Damian Edwards – ASP.NET Program Manager @damianedwards

Slide 2

Slide 2 text

.NET diagnostics primitives • Events • This thing happened, here’s a message and some data associated with it, e.g. Request started, path: /test, query: a=b • Metrics • Here’s a number representing the current state of this thing, e.g. Requests per second: 4, CPU utilization: 36%, ThreadPool queue length: 3 • Dumps • Here’s the memory associated with the application process at a point in time, saved in a platform-specific file

Slide 3

Slide 3 text

Producing diagnostics data • ILogger – structured logging abstraction, used in ASP.NET Core • DiagnosticSource – synchronous, in-process, live objects (untyped) • Activity – auto-flowing, ephemeral diagnostics context, dist. tracing • Runtime events – details from the CLR • EventSource – produce events & metrics, built-in

Slide 4

Slide 4 text

ILogger

Slide 5

Slide 5 text

DiagnosticSource

Slide 6

Slide 6 text

EventSource

Slide 7

Slide 7 text

Collecting diagnostics data • EventListener API • DiagnosticListener API • EventPipe API • EventPipe – default “on” out-of-process diagnostics server • Effectively “ETW for .NET” that works cross-platform • dotnet CLI tools • dotnet-counters: Collect & view counters • dotnet-trace: Collect & convert events • dotnet-dump: Collect a process dump • dotnet-gcdump: Collect a managed heap dump • dotnet-sos: Installs SOS and configures LLDB for dump debugging • dotnet-symbol: Downloads symbols files for dump debugging

Slide 8

Slide 8 text

EventListener

Slide 9

Slide 9 text

DiagnosticsListener

Slide 10

Slide 10 text

EventPipe API

Slide 11

Slide 11 text

Demo: CLI tools

Slide 12

Slide 12 text

Scenarios

Slide 13

Slide 13 text

Distributed tracing • Logs share trace IDs across HTTP calls between ASP.NET Core apps by default in 3.0 • Support for W3C Trace Context • The OpenTelemetry SDK supports ASP.NET Core • Visualize with tools such as Prometheus, Jaeger, Zipkin, and Application Insights

Slide 14

Slide 14 text

App is leaking memory

Slide 15

Slide 15 text

Async diagnostics

Slide 16

Slide 16 text

App is running slowly

Slide 17

Slide 17 text

App is crashing

Slide 18

Slide 18 text

Questions & thanks! @davidfowl @damianedwards