|
| 1 | +# tokio-console CLI |
| 2 | + |
| 3 | +🎛️ The [`tokio-console`] command-line application. |
| 4 | + |
| 5 | +[![crates.io][crates-badge]][crates-url] |
| 6 | +[![Documentation][docs-badge]][docs-url] |
| 7 | +[![Documentation (`main` branch)][docs-main-badge]][docs-main-url] |
| 8 | +[![MIT licensed][mit-badge]][mit-url] |
| 9 | +[![Build Status][actions-badge]][actions-url] |
| 10 | +[![Discord chat][discord-badge]][discord-url] |
| 11 | + |
| 12 | +[Website](https://tokio.rs) | [Chat][discord-url] | [API Documentation][docs-url] |
| 13 | + |
| 14 | +[crates-badge]: https://img.shields.io/crates/v/tokio-console.svg |
| 15 | +[crates-url]: https://crates.io/crates/tokio-console |
| 16 | +[docs-badge]: https://docs.rs/tokio-console/badge.svg |
| 17 | +[docs-url]: https://docs.rs/tokio-console |
| 18 | +[docs-main-badge]: https://img.shields.io/netlify/0e5ffd50-e1fa-416e-b147-a04dab28cfb1?label=docs%20%28main%20branch%29 |
| 19 | +[docs-main-url]: https://tokio-console.netlify.app/tokio_console/ |
| 20 | +[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg |
| 21 | +[mit-url]: ../LICENSE |
| 22 | +[actions-badge]: https://github.com/tokio-rs/console/workflows/CI/badge.svg |
| 23 | +[actions-url]:https://github.com/tokio-rs/console/actions?query=workflow%3ACI |
| 24 | +[discord-badge]: https://img.shields.io/discord/500028886025895936?logo=discord&label=discord&logoColor=white |
| 25 | + |
| 26 | +## Overview |
| 27 | + |
| 28 | +[`tokio-console`] is a debugging and profiling tool for asynchronous Rust |
| 29 | +applications, which collects and displays in-depth diagnostic data on the |
| 30 | +asynchronous tasks, resources, and operations in an application. The console |
| 31 | +system consists of two primary components: |
| 32 | + |
| 33 | +* _instrumentation_, embedded in the application, which collects data from the |
| 34 | + async runtime and exposes it over the console's [wire format] |
| 35 | +* _consumers_, which connect to the instrumented application, recieve telemetry |
| 36 | + data, and display it to the user |
| 37 | + |
| 38 | +This crate is the primary consumer of `tokio-console` telemetry, a command-line |
| 39 | +application that provides an interactive debugging interface. |
| 40 | + |
| 41 | +[wire format]: https://crates.io/crates/console-api |
| 42 | +[subscriber]: https://crates.io/crates/console-subscriber |
| 43 | +## Getting Started |
| 44 | + |
| 45 | +To use the console CLI to debug an asynchronous application, the application |
| 46 | +must first be instrumented to record `tokio-console` telemetry. The easiest way |
| 47 | +to do this is [using the `console-subscriber` crate][subscriber]. |
| 48 | + |
| 49 | +Once the application is instrumented, install the console CLI using |
| 50 | + |
| 51 | +```shell |
| 52 | +cargo install tokio-console |
| 53 | +``` |
| 54 | + |
| 55 | +Running `tokio-console` without any arguments will connect to an application on |
| 56 | +localhost listening on the default port, port 6669: |
| 57 | + |
| 58 | +```shell |
| 59 | +tokio-console |
| 60 | +``` |
| 61 | + |
| 62 | +If the application is not running locally, or was configured to listen on a |
| 63 | +different port, the console will also accept a target address as a command-like |
| 64 | +argument: |
| 65 | + |
| 66 | +```shell |
| 67 | +tokio-console http://192.168.0.42:9090 |
| 68 | +``` |
| 69 | + |
| 70 | +A DNS name can also be provided as the target address: |
| 71 | +```shell |
| 72 | +tokio-console http://my.instrumented.application.local:6669 |
| 73 | +``` |
| 74 | + |
| 75 | +When the console CLI is launched, it displays a list of all [asynchronous tasks] |
| 76 | +in the program: |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +Using the <kbd>↑</kbd> and <kbd>↓</kbd> arrow keys, an individual task can be highlighted. |
| 81 | +Pressing<kbd>enter</kbd> while a task is highlighted displays details about that |
| 82 | +task: |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +Pressing the <kbd>escape</kbd> key returns to the task list. |
| 87 | + |
| 88 | +The <kbd>r</kbd> key switches from the list of tasks to a list of [resources], |
| 89 | +such as synchronization primitives, I/O resources, et cetera: |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +Pressing the <kbd>t</kbd> key switches the view back to the task list. |
| 95 | + |
| 96 | +Like the task list view, the resource list view can be navigated using the |
| 97 | +<kbd>↑</kbd> and <kbd>↓</kbd> arrow keys. Pressing <kbd>enter</kbd> |
| 98 | +while a resource is highlighted displays details about that resource: |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +The resource details view lists the tasks currently waiting on that resource. |
| 103 | +This may be a single task, as in the [`tokio::sync::oneshot`] channel above, or |
| 104 | +a large number of tasks, such as this [`tokio::sync::Semaphore`]: |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +Like the task details view, pressing the <kbd>escape</kbd> key while viewing a resource's details |
| 109 | +returns to the resource list. |
| 110 | + |
| 111 | +[`tokio-console`]: https://github.com/tokio-rs/console |
| 112 | +[Tokio]: https://tokio.rs |
| 113 | +[asynchronous tasks]: https://tokio.rs/tokio/tutorial/spawning#tasks |
| 114 | +[resources]: https://tokio.rs/tokio/tutorial/async#async-fn-as-a-future |
| 115 | +[`tokio::sync::oneshot`]: https://docs.rs/tokio/latest/tokio/sync/oneshot/index.html |
| 116 | +[`tokio::sync::Semaphore`]: https://docs.rs/tokio/latest/tokio/sync/struct.Semaphore.html |
| 117 | + |
| 118 | +### Command-Line Arguments |
| 119 | + |
| 120 | +Running `tokio-console --help` displays a list of all available command-line |
| 121 | +arguments: |
| 122 | +```shell |
| 123 | +$ tokio-console --help |
| 124 | + |
| 125 | +tokio-console 0.1.0 |
| 126 | + |
| 127 | +USAGE: |
| 128 | + tokio-console [OPTIONS] [TARGET_ADDR] |
| 129 | + |
| 130 | +ARGS: |
| 131 | + <TARGET_ADDR> |
| 132 | + The address of a console-enabled process to connect to. |
| 133 | + |
| 134 | + This may be an IP address and port, or a DNS name. |
| 135 | + |
| 136 | + [default: http://127.0.0.1:6669] |
| 137 | + |
| 138 | +OPTIONS: |
| 139 | + --ascii-only |
| 140 | + Explicitly use only ASCII characters |
| 141 | + |
| 142 | + --colorterm <truecolor> |
| 143 | + Overrides the value of the `COLORTERM` environment variable. |
| 144 | + |
| 145 | + If this is set to `24bit` or `truecolor`, 24-bit RGB color support will be enabled. |
| 146 | + |
| 147 | + [env: COLORTERM=truecolor] |
| 148 | + [possible values: 24bit, truecolor] |
| 149 | + |
| 150 | + -h, --help |
| 151 | + Print help information |
| 152 | + |
| 153 | + --lang <LANG> |
| 154 | + Overrides the terminal's default language |
| 155 | +
|
| 156 | + [env: LANG=en_US.UTF-8] |
| 157 | + [default: en_us.UTF-8] |
| 158 | +
|
| 159 | + --log <ENV_FILTER> |
| 160 | + Log level filter for the console's internal diagnostics. |
| 161 | + |
| 162 | + The console will log to stderr if a log level filter is provided. Since the console |
| 163 | + application runs interactively, stderr should generally be redirected to a file to avoid |
| 164 | + interfering with the console's text output. |
| 165 | +
|
| 166 | + [env: RUST_LOG=] |
| 167 | + [default: off] |
| 168 | +
|
| 169 | + --no-colors |
| 170 | + Disable ANSI colors entirely |
| 171 | +
|
| 172 | + --no-duration-colors |
| 173 | + Disable color-coding for duration units |
| 174 | +
|
| 175 | + --no-terminated-colors |
| 176 | + Disable color-coding for terminated tasks |
| 177 | +
|
| 178 | + --palette <PALETTE> |
| 179 | + Explicitly set which color palette to use |
| 180 | +
|
| 181 | + [possible values: 8, 16, 256, all, off] |
| 182 | +
|
| 183 | + --retain-for <RETAIN_FOR> |
| 184 | + How long to continue displaying completed tasks and dropped resources after they have |
| 185 | + been closed. |
| 186 | +
|
| 187 | + This accepts either a duration, parsed as a combination of time spans (such as `5days |
| 188 | + 2min 2s`), or `none` to disable removing completed tasks and dropped resources. |
| 189 | +
|
| 190 | + Each time span is an integer number followed by a suffix. Supported suffixes are: |
| 191 | +
|
| 192 | + * `nsec`, `ns` -- nanoseconds |
| 193 | +
|
| 194 | + * `usec`, `us` -- microseconds |
| 195 | +
|
| 196 | + * `msec`, `ms` -- milliseconds |
| 197 | +
|
| 198 | + * `seconds`, `second`, `sec`, `s` |
| 199 | +
|
| 200 | + * `minutes`, `minute`, `min`, `m` |
| 201 | +
|
| 202 | + * `hours`, `hour`, `hr`, `h` |
| 203 | +
|
| 204 | + * `days`, `day`, `d` |
| 205 | +
|
| 206 | + * `weeks`, `week`, `w` |
| 207 | +
|
| 208 | + * `months`, `month`, `M` -- defined as 30.44 days |
| 209 | +
|
| 210 | + * `years`, `year`, `y` -- defined as 365.25 days |
| 211 | +
|
| 212 | + [default: 6s] |
| 213 | +
|
| 214 | + -V, --version |
| 215 | + Print version information |
| 216 | +``` |
| 217 | +
|
| 218 | +## Getting Help |
| 219 | +
|
| 220 | +First, see if the answer to your question can be found in the |
| 221 | +[API documentation]. If the answer is not there, there is an active community in |
| 222 | +the [Tokio Discord server][discord-url]. We would be happy to try to answer your |
| 223 | +question. You can also ask your question on [the discussions page][discussions]. |
| 224 | +
|
| 225 | +[API documentation]: https://docs.rs/tokio-console |
| 226 | +[discussions]: https://github.com/tokio-rs/console/discussions |
| 227 | +[discord-url]: https://discord.gg/tokio |
| 228 | +
|
| 229 | +## Contributing |
| 230 | +
|
| 231 | +🎈 Thanks for your help improving the project! We are so happy to have |
| 232 | +you! We have a [contributing guide][guide] to help you get involved in the Tokio |
| 233 | +console project. |
| 234 | +
|
| 235 | +[guide]: https://github.com/tokio-rs/console/blob/main/CONTRIBUTING.md |
| 236 | +
|
| 237 | +## Supported Rust Versions |
| 238 | +
|
| 239 | +The Tokio console is built against the latest stable release. The minimum |
| 240 | +supported version is 1.56. The current Tokio console version is not guaranteed |
| 241 | +to build on Rust versions earlier than the minimum supported version. |
| 242 | +
|
| 243 | +## License |
| 244 | +
|
| 245 | +This project is licensed under the [MIT license]. |
| 246 | +
|
| 247 | +[MIT license]: https://github.com/tokio-rs/console/blob/main/LICENSE |
| 248 | +
|
| 249 | +### Contribution |
| 250 | +
|
| 251 | +Unless you explicitly state otherwise, any contribution intentionally submitted |
| 252 | +for inclusion in Tokio by you, shall be licensed as MIT, without any additional |
| 253 | +terms or conditions. |
0 commit comments