Add instructions about how to collect counter data via dotnet-trace (#419)
authorSung Yoon Whang <suwhang@microsoft.com>
Thu, 8 Aug 2019 20:46:12 +0000 (13:46 -0700)
committerGitHub <noreply@github.com>
Thu, 8 Aug 2019 20:46:12 +0000 (13:46 -0700)
* Add instructions about how to collect counter data via dotnet-trace

* change wording

documentation/dotnet-trace-instructions.md

index f6f72565fa530dbf1a4f9078700025c2cb6c60ad..92a85ea26bb494a242d82f44aea54a06daf8555d 100644 (file)
@@ -37,6 +37,23 @@ Collecting to file: <Full-Path-To-Trace>/trace.nettrace
 
 - Finally, stop collection by pressing the \<Enter> key, and *dotnet-trace* will finish logging events to *trace.nettrace* file.
 
+### Using dotnet-trace to collect counter values over time
+
+If you are trying to use EventCounter for basic health monitoring in  performance-sensitive settings like production environments and you want to collect traces instead of watching them in real-time, you can do that with `dotnet-trace` as well.
+
+For example, if you want to enable and collect runtime performance counter values, you can use the following command:
+```cmd
+dotnet-trace collect --process-id <PID> --providers System.Runtime:0:1:EventCounterIntervalSec=1
+```
+
+This will tell the runtime counters to be reported once every second for lightweight health monitoring. Replacing `EventCounterIntervalSec=1` with a higher value (say 60) will allow you to collect a smaller trace with less granularity in the counter data.
+
+If you want to disable runtime events to reduce the overhead (and trace size) even further, you can use the following command to disable runtime events and managed stack profiler.
+```cmd
+dotnet-trace collect --process-id <PID> --providers System.Runtime:0:1:EventCounterIntervalSec=1,Microsoft-Windows-DotNETRuntime:0:1,Microsoft-DotNETCore-SampleProfiler:0:1
+```
+
 ## Viewing the trace captured from dotnet-trace
 
 On Windows, `.nettrace` files can be viewed on PerfView (https://github.com/microsoft/perfview) for analysis, just like traces collected with ETW or LTTng. For traces collected on Linux, you can either move the trace to a Windows machine to be viewed on PerfView.