> dotnet tool install -g dotnet-counters
You can invoke the tool using the following command: dotnet-counters
Tool 'dotnet-counters' (version '1.0.0') was successfully installed.
- > dotnet-counters monitor --process-id 1902 --refresh-interval 1 System.Runtime
-
+ > dotnet-counters monitor --process-id 1902 --refresh-interval 1 System.Runtime
+
Press p to pause, r to resume, q to quit.
System.Runtime:
CPU Usage (%) 24
1. Monitoring all counters from `System.Runtime` at a refresh interval of 3 seconds:
- > dotnet-counters monitor --process-id 1902 --refresh-interval 3 System.Runtime
+ > dotnet-counters monitor --process-id 1902 --refresh-interval 3 System.Runtime
Press p to pause, r to resume, q to quit.
System.Runtime:
CPU Usage (%) 24
2. Monitoring just CPU usage and GC heap size from `System.Runtime` at a refresh interval of 5 seconds:
- > dotnet-counters monitor --process-id 1902 --refresh-interval 5 System.Runtime[cpu-usage,gc-heap-size]
+ > dotnet-counters monitor --process-id 1902 --refresh-interval 5 System.Runtime[cpu-usage,gc-heap-size]
Press p to pause, r to resume, q to quit.
System.Runtime:
CPU Usage (%) 24
A provider consists of the name and optionally the keywords, verbosity level, and custom key/value pairs.
The string is written 'Provider[,Provider]'
- Provider format: (GUID|KnownProviderName)[:Keywords[:Level][:KeyValueArgs]]
- GUID|KnownProviderName - The provider's name
+ Provider format: KnownProviderName[:Keywords[:Level][:KeyValueArgs]]
+ KnownProviderName - The provider's name
Keywords - 8 character hex number bit mask
Level - A number in the range [0, 5]
KeyValueArgs - A semicolon separated list of key=value
Options:
-p, --process-id
The process to collect a memory dump from.
-
+
-h, --help
Show command line help
-o, --output
- The path where collected dumps should be written. Defaults to '.\dump_YYYYMMDD_HHMMSS.dmp' on Windows and
+ The path where collected dumps should be written. Defaults to '.\dump_YYYYMMDD_HHMMSS.dmp' on Windows and
'./core_YYYYMMDD_HHMMSS' on Linux where YYYYMMDD is Year/Month/Day and HHMMSS is Hour/Minute/Second. Otherwise, it is the full
path and file name of the dump.
-h, --help
Show command line help
- -c, --command <command>
+ -c, --command <command>
Run the command on start.
Examples:
- First, find out the process identifier (pid) of the .NET Core 3.0 application (using builds Preview 5 or after) to collect traces from.
- On Windows, there are options such as using the task manager or the `tasklist` command on the cmd window.
- - On Linux, the trivial option could be using `pidof` on the terminal window.
+ - On Linux, the trivial option could be using `pidof` on the terminal window.
You may also use the command `dotnet-trace list-processes` command to find out what .NET Core processes are running, along with their process IDs.
## 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.
+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.
If you would rather view the trace on a Linux machine, you can do this by changing the output format of `dotnet-trace` to `speedscope`. You can change the output file format using the `-f|--format` option - `-f speedscope` will make `dotnet-trace` to produce a speedscope file. You can currently choose between `nettrace` (the default option) and `speedscope`. Speedscope files can be opened at https://www.speedscope.app.
A provider consists of the name and optionally the keywords, verbosity level, and custom key/value pairs.
The string is written 'Provider[,Provider]'
- Provider format: (GUID|KnownProviderName)[:Keywords[:Level][:KeyValueArgs]]
- GUID|KnownProviderName - The provider's name
+ Provider format: KnownProviderName[:Keywords[:Level][:KeyValueArgs]]
+ KnownProviderName - The provider's name
Keywords - 8 character hex number bit mask
Level - A number in the range [0, 5]
0 - Always
--buffersize <Size>
Sets the size of the in-memory circular buffer in megabytes. Default 256 MB.
-
+
-f, --format
The format of the output trace file. This defaults to "nettrace" on Windows and "speedscope" on other OSes.
/// <param name="processId">The process to collect the trace from.</param>
/// <param name="output">The output path for the collected trace data.</param>
/// <param name="buffersize">Sets the size of the in-memory circular buffer in megabytes.</param>
- /// <param name="providers">A list of EventPipe providers to be enabled. This is in the form 'Provider[,Provider]', where Provider is in the form: '(GUID|KnownProviderName)[:Flags[:Level][:KeyValueArgs]]', and KeyValueArgs is in the form: '[key1=value1][;key2=value2]'</param>
+ /// <param name="providers">A list of EventPipe providers to be enabled. This is in the form 'Provider[,Provider]', where Provider is in the form: 'KnownProviderName[:Flags[:Level][:KeyValueArgs]]', and KeyValueArgs is in the form: '[key1=value1][;key2=value2]'</param>
/// <param name="profile">A named pre-defined set of provider configurations that allows common tracing scenarios to be specified succinctly.</param>
/// <param name="format">The desired format of the created trace file.</param>
/// <returns></returns>
private static Option ProvidersOption() =>
new Option(
alias: "--providers",
- description: @"A list of EventPipe providers to be enabled. This is in the form 'Provider[,Provider]', where Provider is in the form: '(GUID|KnownProviderName)[:Flags[:Level][:KeyValueArgs]]', and KeyValueArgs is in the form: '[key1=value1][;key2=value2]'",
+ description: @"A list of EventPipe providers to be enabled. This is in the form 'Provider[,Provider]', where Provider is in the form: 'KnownProviderName[:Flags[:Level][:KeyValueArgs]]', and KeyValueArgs is in the form: '[key1=value1][;key2=value2]'",
argument: new Argument<string>(defaultValue: "") { Name = "list-of-comma-separated-providers" }, // TODO: Can we specify an actual type?
isHidden: false);