tracing-chrome-0.7.2/.cargo_vcs_info.json0000644000000001360000000000100137440ustar { "git": { "sha1": "1753f9e583216f367dfc7827bd32eeeb853a0d4a" }, "path_in_vcs": "" }tracing-chrome-0.7.2/.github/workflows/push_pull.yml000064400000000000000000000022561046102023000206740ustar 00000000000000name: CI on: [push, pull_request] env: CARGO_TERM_COLOR: always jobs: test: strategy: matrix: os: [ubuntu-latest, windows-latest] rust: [stable, beta, nightly] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v2 - name: Install Rust toolchain run: | rustup update ${{ matrix.rust }} rustup default ${{ matrix.rust }} rustup component add clippy - name: Generate Cargo lockfile run: cargo generate-lockfile --verbose - name: Restore Cargo cache uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git target key: cargo-${{ matrix.rust }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/*') }} - name: Clippy run: cargo clippy --all-targets --all-features -- -D clippy::all - name: Build run: cargo build --all-targets --verbose - name: Run tests run: cargo test --verbose format: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Check format run: cargo fmt --verbose -- --check --verbose tracing-chrome-0.7.2/.github/workflows/release.yml000064400000000000000000000014631046102023000203000ustar 00000000000000name: Publish Crate on: workflow_dispatch: inputs: release_tag: description: 'Tag for the associated GitHub release.' required: true env: CARGO_TERM_COLOR: always CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build run: cargo build --all-targets --verbose - name: Test run: cargo test --verbose - name: Publish run: cargo publish --verbose - name: Create Release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.event.inputs.release_tag }} release_name: Release ${{ github.event.inputs.release_tag}} draft: false prerelease: false tracing-chrome-0.7.2/.gitignore000064400000000000000000000000561046102023000145250ustar 00000000000000/.cargo /out /target Cargo.lock /trace-*.jsontracing-chrome-0.7.2/Cargo.lock0000644000000455440000000000100117330ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "aho-corasick" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] [[package]] name = "anes" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstyle" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bumpalo" version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "cast" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "ciborium" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ "ciborium-io", "ciborium-ll", "serde", ] [[package]] name = "ciborium-io" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" [[package]] name = "ciborium-ll" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", "half", ] [[package]] name = "clap" version = "4.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstyle", "clap_lex", ] [[package]] name = "clap_lex" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "criterion" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ "anes", "cast", "ciborium", "clap", "criterion-plot", "is-terminal", "itertools", "num-traits", "once_cell", "oorandom", "plotters", "rayon", "regex", "serde", "serde_derive", "serde_json", "tinytemplate", "walkdir", ] [[package]] name = "criterion-plot" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", "itertools", ] [[package]] name = "crossbeam-deque" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crunchy" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "either" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "half" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" dependencies = [ "cfg-if", "crunchy", ] [[package]] name = "hermit-abi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "is-terminal" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", "libc", "windows-sys", ] [[package]] name = "itertools" version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "log" version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "nu-ansi-term" version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" dependencies = [ "overload", "winapi", ] [[package]] name = "num-traits" version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "overload" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "plotters" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" dependencies = [ "num-traits", "plotters-backend", "plotters-svg", "wasm-bindgen", "web-sys", ] [[package]] name = "plotters-backend" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" [[package]] name = "plotters-svg" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" dependencies = [ "plotters-backend", ] [[package]] name = "proc-macro2" version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "rayon" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", ] [[package]] name = "rayon-core" version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", ] [[package]] name = "regex" version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", "regex-automata", "regex-syntax", ] [[package]] name = "regex-automata" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ryu" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ "winapi-util", ] [[package]] name = "serde" version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", "serde", ] [[package]] name = "sharded-slab" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] [[package]] name = "smallvec" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "syn" version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "thread_local" version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", ] [[package]] name = "tinytemplate" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" dependencies = [ "serde", "serde_json", ] [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tracing-chrome" version = "0.7.2" dependencies = [ "criterion", "rayon", "serde_json", "tracing", "tracing-core", "tracing-subscriber", ] [[package]] name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", ] [[package]] name = "tracing-log" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ "log", "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "nu-ansi-term", "sharded-slab", "smallvec", "thread_local", "tracing-core", "tracing-log", ] [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "walkdir" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", ] [[package]] name = "wasm-bindgen" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" tracing-chrome-0.7.2/Cargo.toml0000644000000025210000000000100117420ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "tracing-chrome" version = "0.7.2" authors = ["Thoren Paulson "] exclude = ["/doc"] description = "A Layer for tracing-subscriber that outputs Chrome-style traces." documentation = "https://docs.rs/tracing-chrome" readme = "README.md" keywords = [ "profiling", "tracing", "flamegraph", "subscriber", ] categories = [ "asynchronous", "development-tools::debugging", "development-tools::profiling", ] license = "MIT" repository = "https://github.com/thoren-d/tracing-chrome" [[bench]] name = "overhead" harness = false [dependencies.serde_json] version = "1.0.114" [dependencies.tracing-core] version = "0.1.32" [dependencies.tracing-subscriber] version = "0.3.18" [dev-dependencies.criterion] version = "0.5.1" [dev-dependencies.rayon] version = "1.9.0" [dev-dependencies.tracing] version = "0.1.40" tracing-chrome-0.7.2/Cargo.toml.orig000064400000000000000000000013501046102023000154220ustar 00000000000000[package] name = "tracing-chrome" version = "0.7.2" authors = ["Thoren Paulson "] categories = ["asynchronous", "development-tools::debugging", "development-tools::profiling"] description = "A Layer for tracing-subscriber that outputs Chrome-style traces." documentation = "https://docs.rs/tracing-chrome" edition = "2018" keywords = ["profiling", "tracing", "flamegraph", "subscriber"] license = "MIT" readme = "README.md" repository = "https://github.com/thoren-d/tracing-chrome" exclude = ["/doc"] [dependencies] serde_json = "1.0.114" tracing-core = "0.1.32" tracing-subscriber = "0.3.18" [dev-dependencies] criterion = "0.5.1" rayon = "1.9.0" tracing = "0.1.40" [[bench]] name = "overhead" harness = false tracing-chrome-0.7.2/LICENSE000064400000000000000000000020571046102023000135450ustar 00000000000000MIT License Copyright (c) 2020 Thoren Paulson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tracing-chrome-0.7.2/README.md000064400000000000000000000026551046102023000140230ustar 00000000000000tracing-chrome ====== [![Crates.io](https://img.shields.io/crates/v/tracing-chrome)](https://crates.io/crates/tracing-chrome) [![Documentation](https://docs.rs/tracing-chrome/badge.svg)](https://docs.rs/tracing-chrome/) ![GitHub](https://img.shields.io/github/license/Antigroup/tracing-chrome) ![CI](https://github.com/thoren-d/tracing-chrome/workflows/CI/badge.svg?branch=develop) # Overview tracing-chrome is a Layer for [tracing-subscriber](https://crates.io/crates/tracing-subscriber) that outputs traces in Chrome's trace viewer format that can be viewed with `chrome://tracing` or [ui.perfetto.dev](https://ui.perfetto.dev). # Usage Add this near the beginning of `main`: ```rust use tracing_chrome::ChromeLayerBuilder; use tracing_subscriber::{registry::Registry, prelude::*}; let (chrome_layer, _guard) = ChromeLayerBuilder::new().build(); tracing_subscriber::registry().with(chrome_layer).init(); ``` When `_guard` is dropped, your trace will be in a file like `trace-1668480819035032.json`. Open that file with [ui.perfetto.dev](https://ui.perfetto.dev) (or `chrome://tracing`) and take a look at your pretty trace. ![](https://github.com/thoren-d/tracing-chrome/raw/develop/doc/images/perfetto-screenshot.png) # License Licensed under the [MIT license](http://opensource.org/licenses/MIT) ## Contributions Unless you state otherwise, any contribution intentionally submitted for inclusion in the work shall be licensed as above. tracing-chrome-0.7.2/benches/overhead.rs000064400000000000000000000060221046102023000163060ustar 00000000000000use criterion::{black_box, criterion_group, criterion_main, Criterion}; use tracing::{info, instrument}; use tracing_subscriber::prelude::*; #[instrument] fn fibonacci(n: u64) -> u64 { if n < 2 { n } else { fibonacci(n - 1) + fibonacci(n - 2) } } fn instrument_benchmark(c: &mut Criterion) { let mut group = c.benchmark_group("instrument"); group.throughput(criterion::Throughput::Elements(3)); group.bench_function("locations_and_args", |b| { let (layer, _guard) = tracing_chrome::ChromeLayerBuilder::new() .include_args(true) .include_locations(true) .writer(std::io::sink()) .build(); let _subscriber = tracing_subscriber::registry().with(layer).set_default(); b.iter(|| black_box(fibonacci(3))); }); group.bench_function("locations", |b| { let (layer, _guard) = tracing_chrome::ChromeLayerBuilder::new() .include_args(false) .include_locations(true) .writer(std::io::sink()) .build(); let _subscriber = tracing_subscriber::registry().with(layer).set_default(); b.iter(|| black_box(fibonacci(3))); }); group.bench_function("minimal", |b| { let (layer, _guard) = tracing_chrome::ChromeLayerBuilder::new() .include_args(false) .include_locations(false) .writer(std::io::sink()) .build(); let _subscriber = tracing_subscriber::registry().with(layer).set_default(); b.iter(|| black_box(fibonacci(3))); }); } fn event_benchmark(c: &mut Criterion) { let mut group = c.benchmark_group("event"); group.throughput(criterion::Throughput::Elements(1)); group.bench_function("locations_and_args", |b| { let (layer, _guard) = tracing_chrome::ChromeLayerBuilder::new() .include_args(true) .include_locations(true) .writer(std::io::sink()) .build(); let _subscriber = tracing_subscriber::registry().with(layer).set_default(); b.iter(|| { info!(arg = 42, "Something Happen"); }); }); group.bench_function("locations", |b| { let (layer, _guard) = tracing_chrome::ChromeLayerBuilder::new() .include_args(false) .include_locations(true) .writer(std::io::sink()) .build(); let _subscriber = tracing_subscriber::registry().with(layer).set_default(); b.iter(|| { info!(arg = 42, "Something Happen"); }); }); group.bench_function("minimal", |b| { let (layer, _guard) = tracing_chrome::ChromeLayerBuilder::new() .include_args(false) .include_locations(false) .writer(std::io::sink()) .build(); let _subscriber = tracing_subscriber::registry().with(layer).set_default(); b.iter(|| { info!(arg = 42, "Something Happen"); }); }); } criterion_group!(benches, instrument_benchmark, event_benchmark); criterion_main!(benches); tracing-chrome-0.7.2/examples/fibonacci.rs000064400000000000000000000032131046102023000166340ustar 00000000000000use tracing::{info, instrument}; use tracing_subscriber::prelude::*; #[instrument] fn fibonacci(n: usize) -> usize { if n < 2 { n } else { fibonacci(n - 1) + fibonacci(n - 2) } } #[instrument] fn fibonacci_parallel(n: usize) -> usize { if n < 20 { fibonacci(n - 1) + fibonacci(n - 2) } else { let (a, b) = rayon::join(|| fibonacci_parallel(n - 1), || fibonacci_parallel(n - 2)); if (a + b) > 1000 { info!("Big number!"); } a + b } } fn main() { rayon::ThreadPoolBuilder::new() .thread_name(|idx| format!("Worker {idx}")) .build_global() .expect("Failed to build thread pool."); let guard = if std::env::args().any(|arg| arg == "--no-trace") { None } else { let (chrome_layer, guard) = tracing_chrome::ChromeLayerBuilder::new() .include_args(true) .build(); tracing_subscriber::registry().with(chrome_layer).init(); Some(guard) }; let before = std::time::Instant::now(); println!("fibonacci_serial(24) -> {}", fibonacci(24)); println!("took {} s", before.elapsed().as_secs_f32()); if let Some(guard) = &guard { guard.start_new(None); } let before = std::time::Instant::now(); println!("fibonacci_parallel(24) -> {}", fibonacci_parallel(24)); println!("took {} s", before.elapsed().as_secs_f32()); if let Some(guard) = &guard { guard.start_new(None); } let before = std::time::Instant::now(); println!("fibonacci_parallel(20) -> {}", fibonacci_parallel(20)); println!("took {} s", before.elapsed().as_secs_f32()); } tracing-chrome-0.7.2/src/lib.rs000064400000000000000000000464631046102023000144540ustar 00000000000000#![doc = include_str!("../README.md")] use tracing_core::{field::Field, span, Event, Subscriber}; use tracing_subscriber::{ layer::Context, registry::{LookupSpan, SpanRef}, Layer, }; use serde_json::{json, Value as JsonValue}; use std::{ marker::PhantomData, path::Path, sync::{ atomic::{AtomicUsize, Ordering}, Arc, Mutex, }, }; use std::io::{BufWriter, Write}; use std::sync::mpsc; use std::sync::mpsc::Sender; use std::{ cell::{Cell, RefCell}, thread::JoinHandle, }; thread_local! { static OUT: RefCell>> = const { RefCell::new(None) }; static TID: RefCell> = const { RefCell::new(None) }; } type NameFn = Box) -> String + Send + Sync>; type Object = serde_json::Map; /// A [`Layer`](tracing_subscriber::Layer) that writes a Chrome trace file. pub struct ChromeLayer where S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { out: Arc>>, start: std::time::Instant, max_tid: AtomicUsize, include_args: bool, include_locations: bool, trace_style: TraceStyle, name_fn: Option>, cat_fn: Option>, _inner: PhantomData, } /// A builder for [`ChromeLayer`](crate::ChromeLayer). #[derive(Default)] pub struct ChromeLayerBuilder where S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { out_writer: Option>, name_fn: Option>, cat_fn: Option>, include_args: bool, include_locations: bool, trace_style: TraceStyle, _inner: PhantomData, } /// Decides how traces will be recorded. #[derive(Default)] pub enum TraceStyle { /// Traces will be recorded as a group of threads. /// In this style, spans should be entered and exited on the same thread. #[default] Threaded, /// Traces will recorded as a group of asynchronous operations. Async, } impl ChromeLayerBuilder where S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { pub fn new() -> Self { ChromeLayerBuilder { out_writer: None, name_fn: None, cat_fn: None, include_args: false, include_locations: true, trace_style: TraceStyle::Threaded, _inner: PhantomData, } } /// Set the file to which to output the trace. /// /// Defaults to `./trace-{unix epoch in micros}.json`. /// /// # Panics /// /// If `file` could not be opened/created. To handle errors, /// open a file and pass it to [`writer`](crate::ChromeLayerBuilder::writer) instead. pub fn file>(self, file: P) -> Self { self.writer(std::fs::File::create(file).expect("Failed to create trace file.")) } /// Supply an arbitrary writer to which to write trace contents. /// /// # Examples /// /// ```rust /// # use tracing_chrome::ChromeLayerBuilder; /// # use tracing_subscriber::prelude::*; /// let (layer, guard) = ChromeLayerBuilder::new().writer(std::io::sink()).build(); /// # tracing_subscriber::registry().with(layer).init(); /// ``` pub fn writer(mut self, writer: W) -> Self { self.out_writer = Some(Box::new(writer)); self } /// Include arguments in each trace entry. /// /// Defaults to `false`. /// /// Includes the arguments used when creating a span/event /// in the "args" section of the trace entry. pub fn include_args(mut self, include: bool) -> Self { self.include_args = include; self } /// Include file+line with each trace entry. /// /// Defaults to `true`. /// /// This can add quite a bit of data to the output so turning /// it off might be helpful when collecting larger traces. pub fn include_locations(mut self, include: bool) -> Self { self.include_locations = include; self } /// Sets the style used when recording trace events. /// /// See [`TraceStyle`](crate::TraceStyle) for details. pub fn trace_style(mut self, style: TraceStyle) -> Self { self.trace_style = style; self } /// Allows supplying a function that derives a name from /// an Event or Span. The result is used as the "name" field /// on trace entries. /// /// # Example /// ``` /// use tracing_chrome::{ChromeLayerBuilder, EventOrSpan}; /// use tracing_subscriber::{registry::Registry, prelude::*}; /// /// let (chrome_layer, _guard) = ChromeLayerBuilder::new().name_fn(Box::new(|event_or_span| { /// match event_or_span { /// EventOrSpan::Event(ev) => { ev.metadata().name().into() }, /// EventOrSpan::Span(_s) => { "span".into() }, /// } /// })).build(); /// tracing_subscriber::registry().with(chrome_layer).init() /// ``` pub fn name_fn(mut self, name_fn: NameFn) -> Self { self.name_fn = Some(name_fn); self } /// Allows supplying a function that derives a category from /// an Event or Span. The result is used as the "cat" field on /// trace entries. /// /// # Example /// ``` /// use tracing_chrome::{ChromeLayerBuilder, EventOrSpan}; /// use tracing_subscriber::{registry::Registry, prelude::*}; /// /// let (chrome_layer, _guard) = ChromeLayerBuilder::new().category_fn(Box::new(|_| { /// "my_module".into() /// })).build(); /// tracing_subscriber::registry().with(chrome_layer).init() /// ``` pub fn category_fn(mut self, cat_fn: NameFn) -> Self { self.cat_fn = Some(cat_fn); self } /// Creates a [`ChromeLayer`](crate::ChromeLayer) and associated [`FlushGuard`](crate::FlushGuard). /// /// # Panics /// /// If no file or writer was specified and the default trace file could not be opened/created. pub fn build(self) -> (ChromeLayer, FlushGuard) { ChromeLayer::new(self) } } /// This guard will signal the thread writing the trace file to stop and join it when dropped. pub struct FlushGuard { sender: Sender, handle: Cell>>, } impl FlushGuard { /// Signals the trace writing thread to flush to disk. pub fn flush(&self) { if let Some(handle) = self.handle.take() { let _ignored = self.sender.send(Message::Flush); self.handle.set(Some(handle)); } } /// Finishes the current trace and starts a new one. /// /// If a [`Write`](std::io::Write) implementation is supplied, /// the new trace is written to it. Otherwise, the new trace /// goes to `./trace-{unix epoc in micros}.json`. pub fn start_new(&self, writer: Option>) { if let Some(handle) = self.handle.take() { let _ignored = self.sender.send(Message::StartNew(writer)); self.handle.set(Some(handle)); } } } impl Drop for FlushGuard { fn drop(&mut self) { if let Some(handle) = self.handle.take() { let _ignored = self.sender.send(Message::Drop); if handle.join().is_err() { eprintln!("tracing_chrome: Trace writing thread panicked."); } } } } struct Callsite { tid: usize, name: String, target: String, file: Option<&'static str>, line: Option, args: Option>, } enum Message { Enter(f64, Callsite, Option), Event(f64, Callsite), Exit(f64, Callsite, Option), NewThread(usize, String), Flush, Drop, StartNew(Option>), } /// Represents either an [`Event`](tracing_core::Event) or [`SpanRef`](tracing_subscriber::registry::SpanRef). pub enum EventOrSpan<'a, 'b, S> where S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { Event(&'a Event<'b>), Span(&'a SpanRef<'b, S>), } fn create_default_writer() -> Box { Box::new( std::fs::File::create(format!( "./trace-{}.json", std::time::SystemTime::UNIX_EPOCH .elapsed() .unwrap() .as_micros() )) .expect("Failed to create trace file."), ) } impl ChromeLayer where S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { fn new(mut builder: ChromeLayerBuilder) -> (ChromeLayer, FlushGuard) { let (tx, rx) = mpsc::channel(); OUT.with(|val| val.replace(Some(tx.clone()))); let out_writer = builder .out_writer .unwrap_or_else(|| create_default_writer()); let handle = std::thread::spawn(move || { let mut write = BufWriter::new(out_writer); write.write_all(b"[\n").unwrap(); let mut has_started = false; let mut thread_names: Vec<(usize, String)> = Vec::new(); for msg in rx { if let Message::Flush = &msg { write.flush().unwrap(); continue; } else if let Message::Drop = &msg { break; } else if let Message::StartNew(writer) = msg { // Finish off current file write.write_all(b"\n]").unwrap(); write.flush().unwrap(); // Get or create new writer let out_writer = writer.unwrap_or_else(|| create_default_writer()); write = BufWriter::new(out_writer); write.write_all(b"[\n").unwrap(); has_started = false; // Write saved thread names for (tid, name) in thread_names.iter() { let entry = json!({ "ph": "M", "pid": 1, "name": "thread_name", "tid": *tid, "args": { "name": name, }, }); if has_started { write.write_all(b",\n").unwrap(); } serde_json::to_writer(&mut write, &entry).unwrap(); has_started = true; } continue; } let (ph, ts, callsite, id) = match &msg { Message::Enter(ts, callsite, None) => ("B", Some(ts), Some(callsite), None), Message::Enter(ts, callsite, Some(root_id)) => { ("b", Some(ts), Some(callsite), Some(root_id)) } Message::Event(ts, callsite) => ("i", Some(ts), Some(callsite), None), Message::Exit(ts, callsite, None) => ("E", Some(ts), Some(callsite), None), Message::Exit(ts, callsite, Some(root_id)) => { ("e", Some(ts), Some(callsite), Some(root_id)) } Message::NewThread(_tid, _name) => ("M", None, None, None), Message::Flush | Message::Drop | Message::StartNew(_) => { panic!("Was supposed to break by now.") } }; let mut entry = json!({ "ph": ph, "pid": 1, }); if let Message::NewThread(tid, name) = msg { thread_names.push((tid, name.clone())); entry["name"] = "thread_name".into(); entry["tid"] = tid.into(); entry["args"] = json!({ "name": name }); } else { let ts = ts.unwrap(); let callsite = callsite.unwrap(); entry["ts"] = (*ts).into(); entry["name"] = callsite.name.clone().into(); entry["cat"] = callsite.target.clone().into(); entry["tid"] = callsite.tid.into(); if let Some(&id) = id { entry["id"] = id.into(); } if ph == "i" { entry["s"] = "t".into(); } if let (Some(file), Some(line)) = (callsite.file, callsite.line) { entry[".file"] = file.into(); entry[".line"] = line.into(); } if let Some(call_args) = &callsite.args { if !call_args.is_empty() { entry["args"] = (**call_args).clone().into(); } } } if has_started { write.write_all(b",\n").unwrap(); } serde_json::to_writer(&mut write, &entry).unwrap(); has_started = true; } write.write_all(b"\n]").unwrap(); write.flush().unwrap(); }); let guard = FlushGuard { sender: tx.clone(), handle: Cell::new(Some(handle)), }; let layer = ChromeLayer { out: Arc::new(Mutex::new(tx)), start: std::time::Instant::now(), max_tid: AtomicUsize::new(0), name_fn: builder.name_fn.take(), cat_fn: builder.cat_fn.take(), include_args: builder.include_args, include_locations: builder.include_locations, trace_style: builder.trace_style, _inner: PhantomData, }; (layer, guard) } fn get_tid(&self) -> (usize, bool) { TID.with(|value| { let tid = *value.borrow(); match tid { Some(tid) => (tid, false), None => { let tid = self.max_tid.fetch_add(1, Ordering::SeqCst); value.replace(Some(tid)); (tid, true) } } }) } fn get_callsite(&self, data: EventOrSpan) -> Callsite { let (tid, new_thread) = self.get_tid(); let name = self.name_fn.as_ref().map(|name_fn| name_fn(&data)); let target = self.cat_fn.as_ref().map(|cat_fn| cat_fn(&data)); let meta = match data { EventOrSpan::Event(e) => e.metadata(), EventOrSpan::Span(s) => s.metadata(), }; let args = match data { EventOrSpan::Event(e) => { if self.include_args { let mut args = Object::new(); e.record(&mut JsonVisitor { object: &mut args }); Some(Arc::new(args)) } else { None } } EventOrSpan::Span(s) => s .extensions() .get::() .map(|e| &e.args) .cloned(), }; let name = name.unwrap_or_else(|| meta.name().into()); let target = target.unwrap_or_else(|| meta.target().into()); let (file, line) = if self.include_locations { (meta.file(), meta.line()) } else { (None, None) }; if new_thread { let name = match std::thread::current().name() { Some(name) => name.to_owned(), None => tid.to_string(), }; self.send_message(Message::NewThread(tid, name)); } Callsite { tid, name, target, file, line, args, } } fn get_root_id(span: SpanRef) -> u64 { span.scope() .from_root() .take(1) .next() .unwrap_or(span) .id() .into_u64() } fn enter_span(&self, span: SpanRef, ts: f64) { let callsite = self.get_callsite(EventOrSpan::Span(&span)); let root_id = match self.trace_style { TraceStyle::Async => Some(ChromeLayer::get_root_id(span)), _ => None, }; self.send_message(Message::Enter(ts, callsite, root_id)); } fn exit_span(&self, span: SpanRef, ts: f64) { let callsite = self.get_callsite(EventOrSpan::Span(&span)); let root_id = match self.trace_style { TraceStyle::Async => Some(ChromeLayer::get_root_id(span)), _ => None, }; self.send_message(Message::Exit(ts, callsite, root_id)); } fn get_ts(&self) -> f64 { self.start.elapsed().as_nanos() as f64 / 1000.0 } fn send_message(&self, message: Message) { OUT.with(move |val| { if val.borrow().is_some() { let _ignored = val.borrow().as_ref().unwrap().send(message); } else { let out = self.out.lock().unwrap().clone(); let _ignored = out.send(message); val.replace(Some(out)); } }); } } impl Layer for ChromeLayer where S: Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { fn on_enter(&self, id: &span::Id, ctx: Context<'_, S>) { if let TraceStyle::Async = self.trace_style { return; } let ts = self.get_ts(); self.enter_span(ctx.span(id).expect("Span not found."), ts); } fn on_record(&self, id: &span::Id, values: &span::Record<'_>, ctx: Context<'_, S>) { if self.include_args { let span = ctx.span(id).unwrap(); let mut exts = span.extensions_mut(); let args = exts.get_mut::(); if let Some(args) = args { let args = Arc::make_mut(&mut args.args); values.record(&mut JsonVisitor { object: args }); } } } fn on_event(&self, event: &Event<'_>, _ctx: Context<'_, S>) { let ts = self.get_ts(); let callsite = self.get_callsite(EventOrSpan::Event(event)); self.send_message(Message::Event(ts, callsite)); } fn on_exit(&self, id: &span::Id, ctx: Context<'_, S>) { if let TraceStyle::Async = self.trace_style { return; } let ts = self.get_ts(); self.exit_span(ctx.span(id).expect("Span not found."), ts); } fn on_new_span(&self, attrs: &span::Attributes<'_>, id: &span::Id, ctx: Context<'_, S>) { if self.include_args { let mut args = Object::new(); attrs.record(&mut JsonVisitor { object: &mut args }); ctx.span(id).unwrap().extensions_mut().insert(ArgsWrapper { args: Arc::new(args), }); } if let TraceStyle::Threaded = self.trace_style { return; } let ts = self.get_ts(); self.enter_span(ctx.span(id).expect("Span not found."), ts); } fn on_close(&self, id: span::Id, ctx: Context<'_, S>) { if let TraceStyle::Threaded = self.trace_style { return; } let ts = self.get_ts(); self.exit_span(ctx.span(&id).expect("Span not found."), ts); } } struct JsonVisitor<'a> { object: &'a mut Object, } impl<'a> tracing_subscriber::field::Visit for JsonVisitor<'a> { fn record_debug(&mut self, field: &Field, value: &dyn std::fmt::Debug) { self.object .insert(field.name().to_owned(), format!("{value:?}").into()); } } struct ArgsWrapper { args: Arc, }