{"id":29675735,"url":"https://github.com/oxidecomputer/tokio-dtrace","last_synced_at":"2025-07-22T23:38:22.589Z","repository":{"id":299706314,"uuid":"1003940997","full_name":"oxidecomputer/tokio-dtrace","owner":"oxidecomputer","description":"DTrace probes for Tokio runtime events","archived":false,"fork":false,"pushed_at":"2025-07-04T19:51:26.000Z","size":30,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-19T23:33:08.514Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oxidecomputer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-17T21:55:38.000Z","updated_at":"2025-07-13T03:20:42.000Z","dependencies_parsed_at":"2025-07-04T20:29:04.224Z","dependency_job_id":"d6041544-484c-494c-aae1-75aad16159a1","html_url":"https://github.com/oxidecomputer/tokio-dtrace","commit_stats":null,"previous_names":["oxidecomputer/tokio-dtrace"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oxidecomputer/tokio-dtrace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Ftokio-dtrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Ftokio-dtrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Ftokio-dtrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Ftokio-dtrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxidecomputer","download_url":"https://codeload.github.com/oxidecomputer/tokio-dtrace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxidecomputer%2Ftokio-dtrace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266591230,"owners_count":23953082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-22T23:38:16.451Z","updated_at":"2025-07-22T23:38:22.574Z","avatar_url":"https://github.com/oxidecomputer.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tokio-dtrace\n\n[DTrace] probes for [Tokio].\n\n## Overview\n\nThis crate provides a set of DTrace [USDT probes] for the Tokio async runtime,\nusing Tokio's runtime hooks. Probes are provided for the following events:\n\n- **`tokio*:::task-spawn`: Records when a new [Tokio task] is [spawned].**\n\n  `arg0` is the [task `Id`] of the spawned task.\n- **`tokio*:::task-poll-start`: Records when the Tokio runtime begins [polling]\n  the [`Future`] for a given task.**\n  \n  `arg0` is the [task `Id`] of the task being polled.\n  \n  Along with the `tokio*:::task-poll-end` probe, this probe may be used to\n  determine the task ID of the currently running task on a given thread. This\n  may, in turn, provide context to other DTrace probes that fire during that\n  task's execution.\n- **`tokio*:::task-poll-end`: Records when the Tokio runtime has finished\n  [polling]  the [`Future`] for a given task.**\n  \n  `arg0` is the [task `Id`] of the task being polled.\n  \n  If polling the task returned [`Poll::Ready`] the poll, the \n  `tokio*:::task-terminate` probe will fire *before* the `task-poll-end`\n  probe for that poll. Otherwise, if `task-terminate` does not fire, the task\n  is still [pending].\n- **`tokio*:::task-poll-end`: Records when a task has terminated.**\n\n  `arg0` is the  [task `Id`] of the task being polled.\n- **`tokio*:::worker-thread-start`: Records when the runtime has started a new\n  worker thread, but before it starts doing work.**\n  \n  This may be used to  determine if a given thread is a Tokio worker, or\n  something else.\n- **`tokio*:::worker-thread-stop`: Records when a worker thread is about to\n  stop.**\n- **`tokio*:::worker-thread-park`: Records when a worker thread is about to\n  become idle because it has no tasks currently ready to poll.**\n  \n  Along with the `worker-thread-unpark` probe, this may be used to measure the\n  utilization of worker threads.\n- **`tokio*:::worker-thread-unpark`: Records when a parked worker thread\n  unparks to begin performing work.**\n\nA process that instruments its Tokio runtime using `tokio-dtrace` will\nregister a DTrace provider called `tokio${PID}` that is unique to that process.\nIn this example, PID 16687 is a process instrumented using this crate:\n\n```console\neliza@atrium ~/tokio-dtrace $ pfexec dtrace -l -n tokio*:::\n   ID   PROVIDER            MODULE                          FUNCTION NAME\n14552 tokio16687             basic _ZN12tokio_dtrace5hooks18on_after_task_poll17h57940106588e89baE task-poll-end\n14553 tokio16687             basic _ZN12tokio_dtrace5hooks19on_before_task_poll17h64ab06edcaab5d2bE task-poll-start\n14554 tokio16687             basic _ZN12tokio_dtrace5hooks13on_task_spawn17hb99afbe81083cd1fE task-spawn\n14555 tokio16687             basic _ZN12tokio_dtrace5hooks17on_task_terminate17hab4ccd3daf5dc91dE task-terminate\n14556 tokio16687             basic _ZN12tokio_dtrace5hooks14on_thread_park17h216f5d29c208b65bE worker-thread-park\n14557 tokio16687             basic _ZN12tokio_dtrace5hooks15on_thread_start17h43ad7d683fe84cf7E worker-thread-start\n14566 tokio16687             basic _ZN12tokio_dtrace5hooks14on_thread_stop17h30e9720722e581fdE worker-thread-stop\n14567 tokio16687             basic _ZN12tokio_dtrace5hooks16on_thread_unpark17hbba36de5355c6387E worker-thread-unpark\n```\n\nThe following D script will print each `tokio-dtrace` probe as it fires:\n\n```\ntokio*:::task-poll-start,\ntokio*:::task-poll-end,\ntokio*:::task-spawn,\ntokio*:::task-terminate\n/pid == $1/\n{\n    printf(\"thread[%4d] %s(task=%d)\\n\", tid, probename, arg0);\n}\n\ntokio*:::worker-thread-start,\ntokio*:::worker-thread-park,\ntokio*:::worker-thread-unpark,\ntokio*:::worker-thread-stop\n/pid == $1/\n{\n    printf(\"thread[%4d] %s()\\n\", tid, probename);\n}\n```\n\nMore sophisticated tracing is also possible. For example, capturing a stack\ntrace in the `task-spawn` probe can be used to associate task IDs with the\nstack frame in which the task was spawned, and the `task-poll-start` and\n`task-poll-end` probes may be used to determine the task ID of the task\ncurrently being polled when another probe is recorded. The duration of\nindividual task polls, total task runtime, and worker task idle time may also\nbe measured using these probes.\n\n[DTrace]: https://illumos.org/books/dtrace/\n[Tokio]: https://docs.rs/tokio\n[USDT probes]: https://illumos.org/books/dtrace/chp-usdt.html#chp-usdt\n[Tokio task]: https://docs.rs/tokio/latest/tokio/task/index.html\n[spawned]: https://docs.rs/tokio/latest/tokio/task/fn.spawn.html\n[task `Id`]: https://docs.rs/tokio/latest/tokio/task/struct.Id.html\n[polling]: https://doc.rust-lang.org/stable/std/future/trait.Future.html#tymethod.poll\n[`Future`]: https://doc.rust-lang.org/stable/std/future/trait.Future.html\n[`Poll::Ready`]: https://doc.rust-lang.org/stable/std/task/enum.Poll.html#variant.Ready\n[pending]:  https://doc.rust-lang.org/stable/std/task/enum.Poll.html#variant.Pending\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidecomputer%2Ftokio-dtrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxidecomputer%2Ftokio-dtrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxidecomputer%2Ftokio-dtrace/lists"}