Skip to content

Commit f3091f7

Browse files
noahfalkgewarren
andauthored
Update diagnostic-port details (#45669)
* Update diagnostic-port details - Include the diagnostic-port option for dotnet-gcdump which previously lacked it - Give a bit more detail about how diagnostic-port should be specified for all the tools that currently support it - Move the warnings about sharing the TMPDIR to the specific --name and --process-id arguments because it shouldn't be a requirement when specifying a full path using --diagnostic-port * Apply suggestions from code review Co-authored-by: Genevieve Warren <[email protected]>
1 parent f6e14bf commit f3091f7

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

docs/core/diagnostics/dotnet-counters.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,29 @@ dotnet-counters collect [-h|--help] [-p|--process-id] [-n|--name] [--diagnostic-
7979

8080
The ID of the process to collect counter data from.
8181

82+
> [!NOTE]
83+
> On Linux and macOS, using this option requires the target application and `dotnet-counters` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
84+
8285
- **`-n|--name <name>`**
8386

8487
The name of the process to collect counter data from.
8588

86-
- **`--diagnostic-port`**
89+
> [!NOTE]
90+
> On Linux and macOS, using this option requires the target application and `dotnet-counters` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
8791
88-
The name of the diagnostic port to create. See [using diagnostic port](#using-diagnostic-port) for how to use this option to start monitoring counters from app startup.
92+
- **`--diagnostic-port <port-address[,(listen|connect)]>`**
93+
94+
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.
95+
96+
The `port-address` differs by OS:
97+
98+
- Linux and macOS - a path to a Unix domain socket such as `/foo/tool1.socket`.
99+
- Windows - a path to a named pipe such as `\\.\pipe\my_diag_port1`.
100+
- Android, iOS, and tvOS - an IP:port such as `127.0.0.1:9000`.
101+
102+
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.
103+
104+
For information about how to use this option to start monitoring counters from app startup, see [using diagnostic port](#using-diagnostic-port).
89105

90106
- **`--refresh-interval <SECONDS>`**
91107

@@ -113,9 +129,6 @@ dotnet-counters collect [-h|--help] [-p|--process-id] [-n|--name] [--diagnostic-
113129
> [!NOTE]
114130
> 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.
115131
116-
> [!NOTE]
117-
> On Linux and macOS, this command expects the target application and `dotnet-counters` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
118-
119132
> [!NOTE]
120133
> 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.
121134

docs/core/diagnostics/dotnet-gcdump.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ dotnet-gcdump collect [-h|--help] [-p|--process-id <pid>] [-o|--output <gcdump-f
9393

9494
The process ID to collect the GC dump from.
9595

96+
> [!NOTE]
97+
> On Linux and macOS, using this option requires the target application and `dotnet-gcdump` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
98+
9699
- **`-o|--output <gcdump-file-path>`**
97100

98101
The path where collected GC dumps should be written. Defaults to *.\\YYYYMMDD\_HHMMSS\_\<pid>.gcdump*.
@@ -109,8 +112,20 @@ dotnet-gcdump collect [-h|--help] [-p|--process-id <pid>] [-o|--output <gcdump-f
109112

110113
The name of the process to collect the GC dump from.
111114

112-
> [!NOTE]
113-
> On Linux and macOS, this command expects the target application and `dotnet-gcdump` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
115+
> [!NOTE]
116+
> On Linux and macOS, using this option requires the target application and `dotnet-gcdump` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
117+
118+
- **`--diagnostic-port <port-address[,(listen|connect)]>`**
119+
120+
Sets the [diagnostic port](diagnostic-port.md) used to communicate with the process to be dumped. dotnet-gcdump and the .NET runtime inside the target process must agree on the port-address, with one listening and the other connecting. dotnet-gcdump automatically determines the correct port when attaching using the `--process-id` or `--name` options. It's usually only necessary to specify the port explicitly when communicating to a process that's running inside a container that isn't part of the current process namespace.
121+
122+
The `port-address` differs by OS:
123+
124+
- Linux and macOS - a path to a Unix domain socket such as `/foo/tool1.socket`.
125+
- Windows - a path to a named pipe such as `\\.\pipe\my_diag_port1`.
126+
- Android, iOS, and tvOS - an IP:port such as `127.0.0.1:9000`.
127+
128+
By default, dotnet-gcdump listens at the specified address. You can request dotnet-gcdump 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.
114129

115130
> [!NOTE]
116131
> To collect a GC dump using `dotnet-gcdump`, 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.

docs/core/diagnostics/dotnet-trace.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,22 @@ dotnet-trace collect [--buffersize <size>] [--clreventlevel <clreventlevel>] [--
161161

162162
The name of the process to collect the trace from.
163163

164-
- **`--diagnostic-port <path-to-port>`**
164+
> [!NOTE]
165+
> On Linux and macOS, using this option requires the target application and `dotnet-trace` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
166+
167+
- **`--diagnostic-port <port-address[,(listen|connect)]>`**
168+
169+
Sets the [diagnostic port](diagnostic-port.md) used to communicate with the process to be traced. dotnet-trace and the .NET runtime inside the target process must agree on the port-address, with one listening and the other connecting. dotnet-trace 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.
165170

166-
The name of the diagnostic port to create. See [Use diagnostic port to collect a trace from app startup](#use-diagnostic-port-to-collect-a-trace-from-app-startup) to learn how to use this option to collect a trace from app startup.
171+
The `port-address` differs by OS:
172+
173+
- Linux and macOS - a path to a Unix domain socket such as `/foo/tool1.socket`.
174+
- Windows - a path to a named pipe such as `\\.\pipe\my_diag_port1`.
175+
- Android, iOS, and tvOS - an IP:port such as `127.0.0.1:9000`.
176+
177+
By default, `dotnet-trace` listens at the specified address. You can request `dotnet-trace` 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 is listening to the `/foo/tool1.socket` Unix domain socket.
178+
179+
To learn how to use this option to collect a trace from app startup, see [Use diagnostic port to collect a trace from app startup](#use-diagnostic-port-to-collect-a-trace-from-app-startup).
167180

168181
- **`--duration <time-to-run>`**
169182

@@ -177,6 +190,9 @@ dotnet-trace collect [--buffersize <size>] [--clreventlevel <clreventlevel>] [--
177190

178191
The process ID to collect the trace from.
179192

193+
> [!NOTE]
194+
> On Linux and macOS, using this option requires the target application and `dotnet-trace` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
195+
180196
- **`--profile <profile-name>`**
181197

182198
A named pre-defined set of provider configurations that allows common tracing scenarios to be specified succinctly. The following profiles are available:
@@ -230,8 +246,6 @@ dotnet-trace collect [--buffersize <size>] [--clreventlevel <clreventlevel>] [--
230246
231247
> - Stopping the trace may take a long time (up to minutes) for large applications. The runtime needs to send over the type cache for all managed code that was captured in the trace.
232248
233-
> - On Linux and macOS, this command expects the target application and `dotnet-trace` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
234-
235249
> - To collect a trace using `dotnet-trace`, it needs to be run as the same user as the user running the target process or as root. Otherwise, the tool will fail to establish a connection with the target process.
236250
237251
> - If you experience an unhandled exception while running `dotnet-trace collect`, this results in an incomplete trace. If finding the root cause of the exception is your priority, navigate to [Collect dumps on crash](collect-dumps-crash.md). As a result of the unhandled exception, the trace is truncated when the runtime shuts down to prevent other undesired behavior such as a hang or data corruption. Even though the trace is incomplete, you can still open it to see what happened leading up to the failure. However, it will be missing Rundown information (this happens at the end of a trace) so stacks might be unresolved (depending on what providers were turned on). Open the trace by executing PerfView with the `/ContinueOnError` flag at the command line. The logs will also contain the location the exception was fired.

0 commit comments

Comments
 (0)