You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sets the [diagnostic port](diagnostic-port.md) used to communicate with the process to be monitored. dotnet-counters and the .NET runtime inside the target process must agree on the port-address, with one listening and the other connecting. dotnet-counters automatically determines the correct port when attaching using the `--process-id` or `--name` options, or when launching a process using the `-- <command>` option. It's usually only necessary to specify the port explicitly when waiting for a process that will start in the future or communicating to a process that is running inside a container that isn't part of the current process namespace.
93
+
Sets the [diagnostic port](diagnostic-port.md) used to communicate with the process to be monitored. `dotnet-counters` and the .NET runtime inside the target process must agree on the port-address, with one listening and the other connecting. `dotnet-counters` automatically determines the correct port when attaching using the `--process-id` or `--name` options, or when launching a process using the `-- <command>` option. It's usually only necessary to specify the port explicitly when waiting for a process that will start in the future or communicating to a process that's running inside a container that isn't part of the current process namespace.
94
94
95
95
The `port-address` differs by OS:
96
96
97
97
- Linux and macOS - a path to a Unix domain socket such as `/foo/tool1.socket`.
98
98
- Windows - a path to a named pipe such as `\\.\pipe\my_diag_port1`.
99
99
- Android, iOS, and tvOS - an IP:port such as `127.0.0.1:9000`.
100
-
101
-
By default, dotnet-counters listens at the specified address. You can request dotnet-counters to connect instead by appending `,connect` after the address. For example, `--diagnostic-port /foo/tool1.socket,connect` will connect to a .NET runtime process that's listening to the `/foo/tool1.socket` Unix domain socket.
100
+
101
+
By default, `dotnet-counters` listens at the specified address. You can request `dotnet-counters` to connect instead by appending `,connect` after the address. For example, `--diagnostic-port /foo/tool1.socket,connect` will connect to a .NET runtime process that's listening to the `/foo/tool1.socket` Unix domain socket.
102
102
103
103
For information about how to use this option to start monitoring counters from app startup, see [using diagnostic port](#using-diagnostic-port).
A comma-separated list of counters. Counters can be specified `provider_name[:counter_name]`. If the `provider_name` is used without a qualifying list of counters, then all counters from the provider are shown. To discover provider and counter names, consult[built-in metrics docs](https://learn.microsoft.com/dotnet/core/diagnostics/built-in-metrics). For [EventCounters](event-counters.md), `provider_name` is the name of the EventSource and for [Meters](metrics.md), `provider_name` is the name of the Meter.
111
+
A comma-separated list of counters. Counters can be specified `provider_name[:counter_name]`. If the `provider_name` is used without a qualifying list of counters, then all counters from the provider are shown. To discover provider and counter names, see[built-in metrics](built-in-metrics.md). For [EventCounters](event-counters.md), `provider_name` is the name of the EventSource and for [Meters](metrics.md), `provider_name` is the name of the Meter.
After the collection configuration parameters, the user can append `--` followed by a command to start a .NET application. `dotnet-counters`will launch a process with the provided command and collect the requested metrics. This is often useful to collect metrics for the application's startup path and can be used to diagnose or monitor issues that happen early before or shortly after the main entrypoint.
123
+
After the collection configuration parameters, the user can append `--` followed by a command to start a .NET application. `dotnet-counters`launches a process with the provided command and collect the requested metrics. This is often useful to collect metrics for the application's startup path and can be used to diagnose or monitor issues that happen early before or shortly after the main entry point.
124
124
125
125
> [!NOTE]
126
-
> Using this option monitors the first .NET process that communicates back to the tool, which means if your command launches multiple .NET applications, it will only collect the first app. Therefore, it is recommended you use this option on self-contained applications, or using the `dotnet exec <app.dll>` option.
126
+
> Using this option monitors the first .NET process that communicates back to the tool, which means if your command launches multiple .NET applications, it will only collect the first app. Therefore, it's recommended you use this option on self-contained applications, or using the `dotnet exec <app.dll>` option.
127
127
128
128
> [!NOTE]
129
-
> Launching a .NET executable via dotnet-counters will redirect its input/output and you won't be able to interact with its stdin/stdout. Exiting the tool via CTRL+C or SIGTERM will safely end both the tool and the child process. If the child process exits before the tool, the tool will exit as well. If you need to use stdin/stdout, you can use the `--diagnostic-port` option. See [Using diagnostic port](#using-diagnostic-port) for more information.
129
+
> If you launch a .NET executable via `dotnet-counters`, its input/output will be redirected and you won't be able to interact with its stdin/stdout. You can exit the tool via <kbd>Ctrl+C</kbd> or SIGTERM to safely end both the tool and the child process. If the child process exits before the tool, the tool will exit as well. If you need to use stdin/stdout, you can use the `--diagnostic-port` option. For more information, see [Using diagnostic port](#using-diagnostic-port).
130
130
131
131
> [!NOTE]
132
132
> To collect metrics using `dotnet-counters`, it needs to be run as the same user as the user running target process or as root. Otherwise, the tool will fail to establish a connection with the target process.
A comma-separated list of counters. Counters can be specified `provider_name[:counter_name]`. If the `provider_name` is used without a qualifying list of counters, then all counters from the provider are shown. To discover provider and counter names, consult[built-in metrics docs](https://learn.microsoft.com/dotnet/core/diagnostics/built-in-metrics). For [EventCounters](event-counters.md), `provider_name` is the name of the EventSource and for [Meters](metrics.md), `provider_name` is the name of the Meter.
183
+
A comma-separated list of counters. Counters can be specified `provider_name[:counter_name]`. If the `provider_name` is used without a qualifying list of counters, then all counters from the provider are shown. To discover provider and counter names, see[built-in metrics](built-in-metrics.md). For [EventCounters](event-counters.md), `provider_name` is the name of the EventSource and for [Meters](metrics.md), `provider_name` is the name of the Meter.
184
184
185
185
**`-- <command>`**
186
186
187
-
After the collection configuration parameters, the user can append `--` followed by a command to start a .NET application. `dotnet-counters` will launch a process with the provided command and monitor the requested metrics. This is often useful to collect metrics for the application's startup path and can be used to diagnose or monitor issues that happen early before or shortly after the main entrypoint.
187
+
After the collection configuration parameters, you can append `--` followed by a command to start a .NET application. `dotnet-counters` will launch a process with the provided command and monitor the requested metrics. This is often useful to collect metrics for the application's startup path and can be used to diagnose or monitor issues that happen early before or shortly after the main entry point.
188
188
189
189
> [!NOTE]
190
-
> Using this option monitors the first .NET process that communicates back to the tool, which means if your command launches multiple .NET applications, it will only collect the first app. Therefore, it is recommended you use this option on self-contained applications, or using the `dotnet exec <app.dll>` option.
190
+
> Using this option monitors the first .NET process that communicates back to the tool, which means if your command launches multiple .NET applications, it will only collect the first app. Therefore, it's recommended you use this option on self-contained applications, or using the `dotnet exec <app.dll>` option.
191
191
192
192
> [!NOTE]
193
-
> Launching a .NET executable via dotnet-counters will redirect its input/output and you won't be able to interact with its stdin/stdout. Exiting the tool via CTRL+C or SIGTERM will safely end both the tool and the child process. If the child process exits before the tool, the tool will exit as well. If you need to use stdin/stdout, you can use the `--diagnostic-port` option. See [Using diagnostic port](#using-diagnostic-port) for more information.
193
+
> Launching a .NET executable via `dotnet-counters` will redirect its input/output and you won't be able to interact with its stdin/stdout. You can exit the tool via <kbd>Ctrl+C</kbd> or SIGTERM to safely end both the tool and the child process. If the child process exits before the tool, the tool will exit as well. If you need to use stdin/stdout, you can use the `--diagnostic-port` option. For more information, see [Using diagnostic port](#using-diagnostic-port).
194
194
195
195
> [!NOTE]
196
196
> On Linux and macOS, this command expects the target application and `dotnet-counters` to share the same `TMPDIR` environment variable.
> To monitor metrics using `dotnet-counters`, it needs to be run as the same user as the user running target process or as root.
200
200
201
201
> [!NOTE]
202
-
> If you see an error message similar to the following one: `[ERROR] System.ComponentModel.Win32Exception (299): A 32 bit processes cannot access modules of a 64 bit process.`, you are trying to use `dotnet-counters` that has mismatched bitness against the target process. Make sure to download the correct bitness of the tool in the [install](#install) link.
202
+
> If you see an error message similar to the following one: `[ERROR] System.ComponentModel.Win32Exception (299): A 32 bit processes cannot access modules of a 64 bit process.`, you're trying to use `dotnet-counters` that has mismatched bitness against the target process. Make sure to download the correct bitness of the tool in the [install](#install) link.
> If the app uses .NET version 8 or lower the [System.Runtime Meter](https://learn.microsoft.com/dotnet/core/diagnostics/built-in-metrics-runtime#systemruntime)didn't exist yet and dotnet-counters will fall back to display the older [System.Runtime EventCounters](https://learn.microsoft.com/dotnet/core/diagnostics/available-counters#systemruntime-counters) instead. The UI will look slightly different as shown below.
258
+
> If the app uses .NET version 8 or lower, the [System.Runtime Meter](built-in-metrics-runtime.md#systemruntime)doesn't exist in those versions and `dotnet-counters` will fall back to display the older [System.Runtime EventCounters](available-counters.md#systemruntime-counters) instead. The UI looks slightly different, as shown here.
Suppose you start a long-running app using the command ```dotnet run --configuration Release```. In another window, you run the ```dotnet-counters ps``` command. The output you'll see is as follows. The command-line arguments, if any, are shown in `dotnet-counters` version 6.0.320703 and later.
362
+
Suppose you start a long-running app using the command ```dotnet run --configuration Release```. In another window, you run the ```dotnet-counters ps``` command. The output you see is as follows. The command-line arguments, if any, are shown in `dotnet-counters` version 6.0.320703 and later.
363
363
364
364
```dotnetcli
365
365
> dotnet-counters ps
366
-
366
+
367
367
21932 dotnet C:\Program Files\dotnet\dotnet.exe run --configuration Release
368
368
36656 dotnet C:\Program Files\dotnet\dotnet.exe
369
369
```
370
370
371
371
## Using diagnostic port
372
372
373
-
[Diagnostic port](./diagnostic-port.md) is a runtime feature that allows you to start monitoring or collecting counters from app startup. To do this using `dotnet-counters`, you can either use `dotnet-counters <collect|monitor> -- <command>` as described in the examples above, or use the `--diagnostic-port` option.
373
+
[Diagnostic port](./diagnostic-port.md) is a runtime feature that allows you to start monitoring or collecting counters from app startup. To do this using `dotnet-counters`, you can either use `dotnet-counters <collect|monitor> -- <command>` as described in the previous examples, or use the `--diagnostic-port` option.
374
374
375
375
Using `dotnet-counters <collect|monitor> -- <command>` to launch the application as a child process is the simplest way to quickly monitor it from its startup.
376
376
377
377
However, when you want to gain a finer control over the lifetime of the app being monitored (for example, monitor the app for the first 10 minutes only and continue executing) or if you need to interact with the app using the CLI, using `--diagnostic-port` option allows you to control both the target app being monitored and `dotnet-counters`.
378
378
379
-
1. The command below makes dotnet-counters create a diagnostics socket named `myport.sock` and wait for a connection.
379
+
1. The following command makes `dotnet-counters` create a diagnostics socket named `myport.sock` and wait for a connection.
@@ -396,7 +396,7 @@ However, when you want to gain a finer control over the lifetime of the app bein
396
396
> ./my-dotnet-app arg1 arg2
397
397
> ```
398
398
399
-
This should then enable `dotnet-counters` to start collecting counters on `my-dotnet-app`:
399
+
This enables `dotnet-counters` to start collecting counters on `my-dotnet-app`:
400
400
401
401
> ```output
402
402
> Waiting for connection on myport.sock
@@ -405,4 +405,4 @@ However, when you want to gain a finer control over the lifetime of the app bein
405
405
> ```
406
406
407
407
> [!IMPORTANT]
408
-
> Launching your app with `dotnet run` can be problematic because the dotnet CLI may spawn many child processes that are not your app and they can connect to `dotnet-counters` before your app, leaving your app to be suspended at run time. It is recommended you directly use a self-contained version of the app or use `dotnet exec` to launch the application.
408
+
> Launching your app with `dotnet run` can be problematic because the dotnet CLI might spawn many child processes that aren't your app and they can connect to `dotnet-counters` before your app, leaving your app to be suspended at run time. It's recommended you directly use a self-contained version of the app or use `dotnet exec` to launch the application.
0 commit comments