diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f2a9612..e174c7da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - name: Install JS build deps run: | cd js - npm i + npm ci - name: Run Deno test run: | @@ -84,6 +84,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: test + args: --all-features - name: Run basic example uses: actions-rs/cargo@v1 @@ -104,3 +105,21 @@ jobs: | head -n 1 \ | jq '.resourceSpans[].scopeSpans[].spans[0].attributes[0]' \ | jq '.key == "function_name", .value.stringValue == "_start"' + + - name: Install Component CLI Deps + uses: actions-rs/cargo@v1 + with: + command: install + args: wasm-tools cargo-component + + - name: Install Just + uses: extractions/setup-just@v1 + + - name: Build wit + run: just build_wit + + - name: Component Demo + run: just component_demo + + - name: Component Demo 2 + run: just component_demo_2 diff --git a/Cargo.lock b/Cargo.lock index 9fba7f52..01f4c130 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" dependencies = [ "memchr", ] @@ -45,15 +45,15 @@ checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b" [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arbitrary" -version = "1.3.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" [[package]] name = "async-trait" @@ -63,7 +63,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", ] [[package]] @@ -72,11 +72,26 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" -version = "0.21.2" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "bincode" @@ -95,9 +110,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" @@ -110,9 +125,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" @@ -122,9 +137,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cap-fs-ext" @@ -135,7 +150,19 @@ dependencies = [ "cap-primitives", "cap-std", "io-lifetimes 2.0.2", - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "cap-net-ext" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ffc30dee200c20b4dcb80572226f42658e1d9c4b668656d7cc59c33d50e396e" +dependencies = [ + "cap-primitives", + "cap-std", + "rustix 0.38.30", + "smallvec", ] [[package]] @@ -150,8 +177,8 @@ dependencies = [ "io-lifetimes 2.0.2", "ipnet", "maybe-owned", - "rustix 0.38.8", - "windows-sys", + "rustix 0.38.30", + "windows-sys 0.48.0", "winx", ] @@ -174,7 +201,7 @@ dependencies = [ "cap-primitives", "io-extras", "io-lifetimes 2.0.2", - "rustix 0.38.8", + "rustix 0.38.30", ] [[package]] @@ -185,17 +212,18 @@ checksum = "f8f52b3c8f4abfe3252fd0a071f3004aaa3b18936ec97bdbd8763ce03aff6247" dependencies = [ "cap-primitives", "once_cell", - "rustix 0.38.8", + "rustix 0.38.30", "winx", ] [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -224,27 +252,27 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a91a1ccf6fb772808742db2f51e2179f25b1ec559cbe39ea080c72ff61caf8f" +checksum = "d819feeda4c420a18f1e28236ca0ce1177b22bf7c8a44ddee92dfe40de15bcf0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "169db1a457791bff4fd1fc585bb5cc515609647e0420a7d5c98d7700c59c2d00" +checksum = "e9b8d03d5bdbca7e5f72b0e0a0f69933ed1f09e24be6c075aa6fe3f802b0cc0c" dependencies = [ "bumpalo", "cranelift-bforest", @@ -254,7 +282,7 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli", - "hashbrown 0.13.2", + "hashbrown 0.14.1", "log", "regalloc2", "smallvec", @@ -263,42 +291,43 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3486b93751ef19e6d6eef66d2c0e83ed3d2ba01da1919ed2747f2f7bd8ba3419" +checksum = "a3fd3664e38e51649b17dc30cfdd561273fe2f590dcd013fb75d9eabc6272dfb" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86a1205ab18e7cd25dc4eca5246e56b506ced3feb8d95a8d776195e48d2cd4ef" +checksum = "4b031ec5e605828975952622b5a77d49126f20ffe88d33719a0af66b23a0fc36" [[package]] name = "cranelift-control" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b108cae0f724ddfdec1871a0dc193a607e0c2d960f083cfefaae8ccf655eff2" +checksum = "fada054d017cf2ed8f7ed2336e0517fc1b19e6825be1790de9eb00c94788362b" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "720444006240622798665bfc6aa8178e2eed556da342fda62f659c5267c3c659" +checksum = "177b6f94ae8de6348eb45bf977c79ab9e3c40fc3ac8cb7ed8109560ea39bee7d" dependencies = [ "serde", + "serde_derive", ] [[package]] name = "cranelift-frontend" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7a94c4c5508b7407e125af9d5320694b7423322e59a4ac0d07919ae254347ca" +checksum = "ebebd23a69a23e3ddea78e98ff3a2de222e88c8e045d81ef4a72f042e0d79dbd" dependencies = [ "cranelift-codegen", "log", @@ -308,15 +337,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef1f888d0845dcd6be4d625b91d9d8308f3d95bed5c5d4072ce38e1917faa505" +checksum = "1571bfc14df8966d12c6121b5325026591a4b4009e22fea0fe3765ab7cd33b96" [[package]] name = "cranelift-native" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad5966da08f1e96a3ae63be49966a85c9b249fa465f8cf1b66469a82b1004a0" +checksum = "35a69c37e0c10b46fe5527f2397ac821046efbf5f7ec112c8b84df25712f465b" dependencies = [ "cranelift-codegen", "libc", @@ -325,9 +354,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.99.2" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8635c88b424f1d232436f683a301143b36953cd98fc6f86f7bac862dfeb6f5" +checksum = "9b3fef8bbceb8cb56d3f1778b0418d75c5cf12ec571a35fc01eb41abb0227a25" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -335,7 +364,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.110.0", + "wasmparser 0.118.1", "wasmtime-types", ] @@ -348,16 +377,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -466,6 +485,7 @@ name = "dylibso-observe-sdk" version = "0.1.0" dependencies = [ "anyhow", + "env_logger", "log", "modsurfer-demangle", "prost", @@ -484,9 +504,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "encoding_rs" @@ -518,30 +538,19 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] name = "fallible-iterator" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "fastrand" @@ -559,18 +568,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b0377f1edc77dbd1118507bc7a66e4ab64d2b90c66f90726dc801e73a8c68f9" dependencies = [ "cfg-if", - "rustix 0.38.8", - "windows-sys", -] - -[[package]] -name = "file-per-thread-logger" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3cc21c33af89af0930c8cae4ade5e6fdc17b5d2c97b3d2e2edb67a1cf683f3" -dependencies = [ - "env_logger", - "log", + "rustix 0.38.30", + "windows-sys 0.48.0", ] [[package]] @@ -605,8 +604,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd738b84894214045e8414eaded76359b4a5773f0a0a56b16575110739cdcf39" dependencies = [ "io-lifetimes 2.0.2", - "rustix 0.38.8", - "windows-sys", + "rustix 0.38.30", + "windows-sys 0.48.0", ] [[package]] @@ -685,7 +684,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.2", "debugid", "fxhash", "serde", @@ -715,12 +714,12 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" dependencies = [ "fallible-iterator", - "indexmap 1.9.3", + "indexmap 2.0.2", "stable_deref_trait", ] @@ -741,9 +740,12 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +dependencies = [ + "ahash", +] [[package]] name = "heck" @@ -753,18 +755,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "humantime" @@ -800,12 +793,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown 0.14.1", "serde", ] @@ -825,7 +818,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d3c230ee517ee76b1cc593b52939ff68deda3fae9e41eca426c6b4993df51c4" dependencies = [ "io-lifetimes 2.0.2", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -834,9 +827,9 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -847,20 +840,19 @@ checksum = "bffb4def18c48926ccac55c1223e02865ce1a821751a95920448662696e7472c" [[package]] name = "ipnet" -version = "2.7.2" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes 1.0.11", - "rustix 0.37.25", - "windows-sys", + "hermit-abi", + "rustix 0.38.30", + "windows-sys 0.48.0", ] [[package]] @@ -874,15 +866,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "ittapi" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e648c437172ce7d3ac35ca11a068755072054826fa455a916b43524fa4a62a7" +checksum = "6b996fe614c41395cdaedf3cf408a9534851090959d90d54a535f675550b64b1" dependencies = [ "anyhow", "ittapi-sys", @@ -891,9 +883,9 @@ dependencies = [ [[package]] name = "ittapi-sys" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b32a4d23f72548178dde54f3c12c6b6a08598e25575c0d0fa5bd861e0dc1a5" +checksum = "52f5385394064fa2c886205dba02598013ce83d3e92d33dbdc0c52fe0e7bf4fc" dependencies = [ "cc", ] @@ -930,9 +922,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "linux-raw-sys" @@ -942,15 +934,15 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "mach" @@ -969,17 +961,17 @@ checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memfd" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.37.25", + "rustix 0.38.30", ] [[package]] @@ -1008,7 +1000,7 @@ checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1028,23 +1020,23 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi", "libc", ] [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "crc32fast", - "hashbrown 0.13.2", - "indexmap 1.9.3", + "hashbrown 0.14.1", + "indexmap 2.0.2", "memchr", ] @@ -1056,9 +1048,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "percent-encoding" @@ -1078,9 +1070,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1112,9 +1104,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -1182,17 +1174,6 @@ dependencies = [ "cc", ] -[[package]] -name = "pulldown-cmark" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" -dependencies = [ - "bitflags 1.3.2", - "memchr", - "unicase", -] - [[package]] name = "quote" version = "1.0.33" @@ -1234,9 +1215,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -1244,14 +1225,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -1285,9 +1264,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4dcbd3a2ae7fb94b5813fa0e957c6ab51bf5d0a8ee1b69e0c2d0f1e6eb8485" +checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" dependencies = [ "hashbrown 0.13.2", "log", @@ -1298,9 +1277,21 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.4" +version = "1.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" dependencies = [ "aho-corasick", "memchr", @@ -1309,9 +1300,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "ring" @@ -1351,22 +1342,22 @@ dependencies = [ "io-lifetimes 1.0.11", "libc", "linux-raw-sys 0.3.8", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "rustix" -version = "0.38.8" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.2", "errno", "itoa", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys 0.4.13", "once_cell", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1393,15 +1384,15 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" @@ -1415,35 +1406,35 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -1473,9 +1464,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", @@ -1499,18 +1490,18 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "socket2" -version = "0.4.9" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -1544,9 +1535,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -1559,21 +1550,21 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27ce32341b2c0b70c144bbf35627fdc1ef18c76ced5e5e7b3ee8b5ba6b2ab6a0" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.2", "cap-fs-ext", "cap-std", "fd-lock", "io-lifetimes 2.0.2", - "rustix 0.38.8", - "windows-sys", + "rustix 0.38.30", + "windows-sys 0.48.0", "winx", ] [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" [[package]] name = "tempfile" @@ -1586,36 +1577,36 @@ dependencies = [ "fastrand", "redox_syscall 0.3.5", "rustix 0.37.25", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", ] [[package]] @@ -1635,11 +1626,11 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.28.2" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", + "backtrace", "bytes", "libc", "mio", @@ -1647,7 +1638,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1658,7 +1649,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", ] [[package]] @@ -1685,13 +1676,13 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", ] [[package]] @@ -1705,18 +1696,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "unicase" -version = "2.6.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" @@ -1726,9 +1708,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -1741,9 +1723,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -1775,9 +1757,9 @@ dependencies = [ [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -1804,9 +1786,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ec6af51bbe8d04f2de5cd7a6d52e2b2dec67754167b70f2e863541092f09ef1" +checksum = "db014d2ced91f17d1f1a8f2b76d6ea8d731bc1dbc8c2bbaec689d6a242568e5d" dependencies = [ "anyhow", "async-trait", @@ -1817,33 +1799,32 @@ dependencies = [ "fs-set-times", "io-extras", "io-lifetimes 2.0.2", - "is-terminal", "once_cell", - "rustix 0.38.8", + "rustix 0.38.30", "system-interface", "tracing", "wasi-common", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "wasi-common" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4194b7d3bbb9f0318e5e0c5813f063284388792bd6b464257ec0d53e0fa3a6f" +checksum = "449d17849e3c83a931374442fe2deee4d6bd1ebf469719ef44192e9e82e19c89" dependencies = [ "anyhow", - "bitflags 2.4.0", + "bitflags 2.4.2", "cap-rand", "cap-std", "io-extras", "log", - "rustix 0.38.8", + "rustix 0.38.30", "thiserror", "tracing", "wasmtime", "wiggle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1867,7 +1848,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", "wasm-bindgen-shared", ] @@ -1889,7 +1870,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1902,9 +1883,18 @@ checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-encoder" -version = "0.31.1" +version = "0.38.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41763f20eafed1399fff1afb466496d3a959f58241436cfdc17e3f5ca954de16" +checksum = "d162eb64168969ae90e8668ca0593b0e47667e315aa08e717a9c9574d700d826" dependencies = [ "leb128", ] @@ -1921,39 +1911,40 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.110.0" +version = "0.118.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dfcdb72d96f01e6c85b6bf20102e7423bdbaad5c337301bab2bbf253d26413c" +checksum = "95ee9723b928e735d53000dec9eae7b07a60e490c85ab54abb66659fc61bfcd9" dependencies = [ - "indexmap 2.0.0", + "indexmap 2.0.2", "semver", ] [[package]] name = "wasmparser" -version = "0.111.0" +version = "0.120.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad71036aada3f6b09251546e97e4f4f176dd6b41cf6fa55e7e0f65e86aec319a" +checksum = "e9148127f39cbffe43efee8d5442b16ecdba21567785268daa1ec9e134389705" dependencies = [ - "indexmap 2.0.0", + "bitflags 2.4.2", + "indexmap 2.0.2", "semver", ] [[package]] name = "wasmprinter" -version = "0.2.63" +version = "0.2.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb8cc41d341939dce08ee902b50e36cd35add940f6044c94b144e8f73fe07a6" +checksum = "d8389a95eb0b3165fea0537a6988960cc23a33d9be650e63fc3d63065fe20dcb" dependencies = [ "anyhow", - "wasmparser 0.111.0", + "wasmparser 0.120.0", ] [[package]] name = "wasmtime" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4e87029cc5760db9a3774aff4708596fe90c20ed2baeef97212e98b812fd0fc" +checksum = "910fabce77e660f0e0e41cfd5f69fc8bf020a025f059718846e918db7177f469" dependencies = [ "anyhow", "async-trait", @@ -1962,19 +1953,19 @@ dependencies = [ "cfg-if", "encoding_rs", "fxprof-processed-profile", - "indexmap 2.0.0", + "indexmap 2.0.2", "libc", "log", "object", "once_cell", "paste", - "psm", "rayon", "serde", + "serde_derive", "serde_json", "target-lexicon", - "wasm-encoder", - "wasmparser 0.110.0", + "wasm-encoder 0.38.1", + "wasmparser 0.118.1", "wasmtime-cache", "wasmtime-component-macro", "wasmtime-component-util", @@ -1985,48 +1976,48 @@ dependencies = [ "wasmtime-runtime", "wasmtime-winch", "wat", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-asm-macros" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d84f68d831200016e120f2ee79d81b50cf4c4123112914aefb168d036d445d" +checksum = "37288142e9b4a61655a3bcbdc7316c2e4bb9e776b10ce3dd758f8186b4469572" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31561fbbaa86d3c042696940bc9601146bf4aaec39ae725c86b5f1358d8d7023" +checksum = "45cbd74a636f09d2108f9405c79857f061e19323e4abeed22e837cfe7b08a22b" dependencies = [ "anyhow", "base64", "bincode", "directories-next", - "file-per-thread-logger", "log", - "rustix 0.38.8", + "rustix 0.38.30", "serde", + "serde_derive", "sha2", "toml", - "windows-sys", + "windows-sys 0.52.0", "zstd", ] [[package]] name = "wasmtime-component-macro" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7e07b8da23838e870c4c092027208ac546398a2ac4f5afff33a1ea1d763ec0" +checksum = "ad63de18eb42e586386b6091f787c82707cbd5ac5e9343216dba1976190cd03a" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -2034,17 +2025,18 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f421bc59c753dcd24e39601928a0f2915adf15f40d8ba0066c4cf23f92c9a0" +checksum = "7e0a160c0c44369aa4bee6d311a8e4366943bab1651040cc8b0fcec2c9eb8906" [[package]] name = "wasmtime-cranelift" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae8ed7a4845f22be6b1ad80f33f43fa03445b03a02f2d40dca695129769cd1a" +checksum = "3734cc01b7cd37bc62fdbcd9529ca9547440052d4b3886cfdec3b8081a5d3647" dependencies = [ "anyhow", + "cfg-if", "cranelift-codegen", "cranelift-control", "cranelift-entity", @@ -2056,7 +2048,7 @@ dependencies = [ "object", "target-lexicon", "thiserror", - "wasmparser 0.110.0", + "wasmparser 0.118.1", "wasmtime-cranelift-shared", "wasmtime-environ", "wasmtime-versioned-export-macros", @@ -2064,9 +2056,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b17099f9320a1c481634d88101258917d5065717cf22b04ed75b1a8ea062b4" +checksum = "e0eb33cd30c47844aa228d4d0030587e65c1108343f311fe9f7248b5bd9cb65c" dependencies = [ "anyhow", "cranelift-codegen", @@ -2080,21 +2072,22 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b9227b1001229ff125e0f76bf1d5b9dc4895e6bcfd5cc35a56f84685964ec7" +checksum = "9a3a056b041fdea604f0972e2fae97958e7748d629a55180228348baefdfc217" dependencies = [ "anyhow", "cranelift-entity", "gimli", - "indexmap 2.0.0", + "indexmap 2.0.2", "log", "object", "serde", + "serde_derive", "target-lexicon", "thiserror", - "wasm-encoder", - "wasmparser 0.110.0", + "wasm-encoder 0.38.1", + "wasmparser 0.118.1", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -2102,23 +2095,24 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc8c8410c03a79073ea06806ccde3da4854c646bd646b3b2707b99b3746c3f70" +checksum = "43987d0977c07f15c3608c2f255870c127ffd19e35eeedb1ac1dccedf9932a42" dependencies = [ + "anyhow", "cc", "cfg-if", - "rustix 0.38.8", + "rustix 0.38.30", "wasmtime-asm-macros", "wasmtime-versioned-export-macros", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-jit" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cce606b392c321d7272928003543447119ef937a9c3ebfce5c4bb0bf6b0f5bac" +checksum = "9b3e48395ac672b386ed588d97a9612aa13a345008f26466f0dfb2a91628aa9f" dependencies = [ "addr2line", "anyhow", @@ -2130,134 +2124,141 @@ dependencies = [ "log", "object", "rustc-demangle", - "rustix 0.38.8", + "rustix 0.38.30", "serde", + "serde_derive", "target-lexicon", "wasmtime-environ", "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-jit-debug" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef27ea6c34ef888030d15560037fe7ef27a5609fbbba8e1e3e41dc4245f5bb2" +checksum = "dd21fd0f5ca68681d3d5b636eea00f182d0f9d764144469e9257fd7e3f55ae0e" dependencies = [ "object", "once_cell", - "rustix 0.38.8", + "rustix 0.38.30", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b59f94b0409221873565419168e20b5aedf18c4bd64de5c38acf8f0634efeee3" +checksum = "bdc26415bb89e9ccd3bdc498fef63aabf665c4c0dd710c107691deb9694955da" dependencies = [ "cfg-if", "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-runtime" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceb587a88ae5bb6ca248455a391aff29ac63329a404b2cdea36d91267c797db4" +checksum = "0abddaf17912aabaf39be0802d5eba9a002e956e902d1ebd438a2fe1c88769a2" dependencies = [ "anyhow", "cc", "cfg-if", "encoding_rs", - "indexmap 2.0.0", + "indexmap 2.0.2", "libc", "log", "mach", "memfd", "memoffset", "paste", - "rand", - "rustix 0.38.8", + "psm", + "rustix 0.38.30", "sptr", - "wasm-encoder", + "wasm-encoder 0.38.1", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-fiber", "wasmtime-jit-debug", "wasmtime-versioned-export-macros", - "windows-sys", + "wasmtime-wmemcheck", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-types" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77943729d4b46141538e8d0b6168915dc5f88575ecdfea26753fd3ba8bab244a" +checksum = "b35a95cdc1433729085beab42c0a5c742b431f25b17c40d7718e46df63d5ffc7" dependencies = [ "cranelift-entity", "serde", + "serde_derive", "thiserror", - "wasmparser 0.110.0", + "wasmparser 0.118.1", ] [[package]] name = "wasmtime-versioned-export-macros" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca7af9bb3ee875c4907835e607a275d10b04d15623d3aebe01afe8fbd3f85050" +checksum = "fad322733fe67e45743784d8b1df452bcb54f581572a4f1a646a4332deecbcc2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", ] [[package]] name = "wasmtime-wasi" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1070c476eee479bdfd98ee7040f21b28993cce87b8b9ced3bf84ff07d4ec3a6e" +checksum = "902cc299b73655c36679b77efdfce4bb5971992f1a4a8a436dd3809a6848ff0e" dependencies = [ "anyhow", "async-trait", - "bitflags 2.4.0", + "bitflags 2.4.2", "bytes", "cap-fs-ext", + "cap-net-ext", "cap-rand", "cap-std", "cap-time-ext", "fs-set-times", "futures", "io-extras", + "io-lifetimes 2.0.2", "libc", + "log", "once_cell", - "rustix 0.38.8", + "rustix 0.38.30", "system-interface", "thiserror", "tokio", "tracing", + "url", "wasi-cap-std-sync", "wasi-common", "wasmtime", "wiggle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "wasmtime-winch" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcdfbdbb400f63e4dfc6dd32f42c77484da58c9622cdd9e9aac238c7347afdf1" +checksum = "9e63aeca929f84560eec52c5af43bf5d623b92683b0195d9fb06da8ed860e092" dependencies = [ "anyhow", "cranelift-codegen", "gimli", "object", "target-lexicon", - "wasmparser 0.110.0", + "wasmparser 0.118.1", "wasmtime-cranelift-shared", "wasmtime-environ", "winch-codegen", @@ -2265,16 +2266,22 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "12.0.2" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14770d0820f56ba86cdd9987aef97cc3bacbb0394633c37dbfbc61ef29603a71" +checksum = "41e5675998fdc74495afdd90ad2bd221206a258075b23048af0535a969b07893" dependencies = [ "anyhow", "heck", - "indexmap 2.0.0", + "indexmap 2.0.2", "wit-parser", ] +[[package]] +name = "wasmtime-wmemcheck" +version = "17.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b20a19e10d8cb50b45412fb21192982b7ce85c0122dc33bb71f1813e25dc6e52" + [[package]] name = "wast" version = "35.0.2" @@ -2286,23 +2293,23 @@ dependencies = [ [[package]] name = "wast" -version = "63.0.0" +version = "70.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2560471f60a48b77fccefaf40796fda61c97ce1e790b59dfcec9dc3995c9f63a" +checksum = "f5d415036fe747a32b30c76c8bd6c73f69b7705fb7ebca5f16e852eef0c95802" dependencies = [ "leb128", "memchr", "unicode-width", - "wasm-encoder", + "wasm-encoder 0.40.0", ] [[package]] name = "wat" -version = "1.0.70" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdc306c2c4c2f2bf2ba69e083731d0d2a77437fc6a350a19db139636e7e416c" +checksum = "8241f34599d413d2243a21015ab43aef68bfb32a0e447c54eef8d423525ca15e" dependencies = [ - "wast 63.0.0", + "wast 70.0.1", ] [[package]] @@ -2337,13 +2344,13 @@ dependencies = [ [[package]] name = "wiggle" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1411b73e79260d74c9b10f5b7adf0f682b9f3a19a6286d60c6a67da07a9b8251" +checksum = "737728db69a7657a5f6a7bac445c02d8564d603d62c46c95edf928554e67d072" dependencies = [ "anyhow", "async-trait", - "bitflags 2.4.0", + "bitflags 2.4.2", "thiserror", "tracing", "wasmtime", @@ -2352,28 +2359,28 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f95f3125bae7b5884c92b969d1b450cc90b703a5c1fb3224e59935a13fcd4f" +checksum = "2460c7163b79ffefd9a564eaeab0a5b0e84bb91afdfeeb84d36f304ddbe08982" dependencies = [ "anyhow", "heck", "proc-macro2", "quote", "shellexpand", - "syn 2.0.29", + "syn 2.0.37", "witx", ] [[package]] name = "wiggle-macro" -version = "12.0.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ed8231ff26b8b6a996497823e73095f43f22719609aa0493d3b2975f17721a0" +checksum = "fa8d8412375ba8325d61fbae56dead51dabfaec85d620ce36427922fb9cece83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.37", "wiggle-generate", ] @@ -2395,9 +2402,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -2410,9 +2417,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.10.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9722f5d601e3ea1cab8cc23f8e4c07c57d6657a1d72ef4c3a064100cca725a20" +checksum = "9d2b346bad5397b219b4ff0a8fa7230936061ff07c61f05d589d8d81e06fb7b2" dependencies = [ "anyhow", "cranelift-codegen", @@ -2420,7 +2427,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.110.0", + "wasmparser 0.118.1", "wasmtime-environ", ] @@ -2430,90 +2437,157 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 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", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winx" -version = "0.36.1" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4857cedf8371f690bb6782a3e2b065c54d1b6661be068aaf3eac8b45e813fdf8" +checksum = "357bb8e2932df531f83b052264b050b81ba0df90ee5a59b2d1d3949f344f81e5" dependencies = [ - "bitflags 2.4.0", - "windows-sys", + "bitflags 2.4.2", + "windows-sys 0.48.0", ] [[package]] name = "wit-parser" -version = "0.9.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "541efa2046e544de53a9da1e2f6299e63079840360c9e106f1f8275a97771318" +checksum = "df4913a2219096373fd6512adead1fb77ecdaa59d7fc517972a7d30b12f625be" dependencies = [ "anyhow", "id-arena", - "indexmap 2.0.0", + "indexmap 2.0.2", "log", - "pulldown-cmark", "semver", + "serde", + "serde_derive", + "serde_json", "unicode-xid", - "url", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e0ddf8fd..668fd506 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,4 @@ [workspace] members = [ "rust" ] -exclude = [ "observe-api/rust", "observe-api/test/rust" ] +exclude = [ "observe-api/rust", "observe-api/test/rust", "corpus/" ] +resolver = "2" diff --git a/README.md b/README.md index 5046ed85..a6902593 100644 --- a/README.md +++ b/README.md @@ -138,3 +138,33 @@ One of the test adapters will output to Zipkin, defaulting to one running on localhost. docker run -d -p 9411:9411 openzipkin/zipkin + +## Component Support + +WIT is available in `wit` for the (manual) observe api and (automatic) observe instrument api. + +### Examples + +First install dependencies: + +```bash +cargo install wasm-tools cargo-component +``` + +Build the wit: + +```bash +just build_wit +``` + +Build and run `component_demo`: + +```bash +just component_demo +``` + +Build and run `component_demo_2`: + +```bash +just component_demo_2 +``` diff --git a/SDK-API-VERSIONING.md b/SDK-API-VERSIONING.md new file mode 100644 index 00000000..e8e7e226 --- /dev/null +++ b/SDK-API-VERSIONING.md @@ -0,0 +1,26 @@ +## This guide is for developers of the Observe SDK. If you are just using the SDK you may ignore this document. + +# SDK API Versioning + +To avoid confusion with users of the Instrumentation Service and the Observe API, we must be careful with API changes. Users may have modules instrumented with an older version of the Instrumentation Service or built with an older version of the API. When possible we should support the older api to avoid breaking those modules. When too painful to maintain support we should at least detect the issue pre-linking and recommend a path forward. + +## General How-To +1. If a change is non-breaking, such as an extension of the API maintaining the same signature, just change the function in all the sdks and call it a day. +2. Otherwise, implement the new version of the function with a new name in all the sdks. Generally, the new name would be `old-name-vX` where `X` is the version number. The first `vX` should be `v2`. +3. If possible keep the old function. It is preferred to modify it to use the new implementation when viable rather than maintaining duplicate implementations. **Pre-linking should warn that the old function is deprecated.** +4. If not possible or unwieldy, pre-linking should error out when a module contains a removed function. + +## Language specific notes +### Rust +Pre-linking checks are done in `rust/src/wasm_instr.rs` in `WasmInstrInfo::new` +### Go +Pre-linking checks are done in `go/wasm.go` in `parseNames` +### JS +Pre-linking checks are done in `js/src/lib/collectors/span/mod.ts` in `SpanCollector::setNames` + +## Observe API SDKs +TBD whether to change the signatures of the prototypes to match the new versions or to add new prototypes for the new versions. + +## Wasm-Instr / Instrumentation Service +Bump `WASM_INSTR_VERSION_MAJOR` and `WASM_INSTR_VERSION_MINOR` (and equivalents in Go and JS) when the observe sdk should warn when a module older than those is loaded (Such as when older versions use deprecated or removed functions). This is purely advisory information, the other SDK API Versioning checks handle whether the observe sdk will error out. + diff --git a/corpus/00-component-instr-command/Cargo.lock b/corpus/00-component-instr-command/Cargo.lock new file mode 100644 index 00000000..6f97c91f --- /dev/null +++ b/corpus/00-component-instr-command/Cargo.lock @@ -0,0 +1,85 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "component-instr-command" +version = "0.1.0" +dependencies = [ + "log", + "observe_api", + "wit-bindgen", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "observe_api" +version = "0.1.0" +dependencies = [ + "log", + "observe_instrument", +] + +[[package]] +name = "observe_instrument" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +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 = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "wit-bindgen" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b76f1d099678b4f69402a421e888bbe71bf20320c2f3f3565d0e7484dbe5bc20" +dependencies = [ + "bitflags", +] diff --git a/corpus/00-component-instr-command/Cargo.toml b/corpus/00-component-instr-command/Cargo.toml new file mode 100644 index 00000000..77e13d98 --- /dev/null +++ b/corpus/00-component-instr-command/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "component-instr-command" +version = "0.1.0" +edition = "2021" + +[package.metadata.component] +package = "example:component-instr-command" + +[package.metadata.component.target.dependencies] +"dylibso:observe" = { path = "../../wit/observe.wasm" } + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +log = "0.4.20" +wit-bindgen = { version = "0.16.0", default-features = false, features = ["realloc"]} +observe_api = { path = "../../observe-api/rust" } diff --git a/corpus/00-component-instr-command/src/bindings.rs b/corpus/00-component-instr-command/src/bindings.rs new file mode 100644 index 00000000..b4052d79 --- /dev/null +++ b/corpus/00-component-instr-command/src/bindings.rs @@ -0,0 +1,210 @@ +// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +pub mod dylibso { + pub mod observe { + + #[allow(clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum LogLevel { + Error, + Warn, + Info, + Debug, + Trace, + } + impl ::core::fmt::Debug for LogLevel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + LogLevel::Error => { + f.debug_tuple("LogLevel::Error").finish() + } + LogLevel::Warn => { + f.debug_tuple("LogLevel::Warn").finish() + } + LogLevel::Info => { + f.debug_tuple("LogLevel::Info").finish() + } + LogLevel::Debug => { + f.debug_tuple("LogLevel::Debug").finish() + } + LogLevel::Trace => { + f.debug_tuple("LogLevel::Trace").finish() + } + } + } + } + + impl LogLevel{ + pub(crate) unsafe fn _lift(val: u8) -> LogLevel{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => LogLevel::Error, + 1 => LogLevel::Warn, + 2 => LogLevel::Info, + 3 => LogLevel::Debug, + 4 => LogLevel::Trace, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum MetricFormat { + Statsd, + } + impl ::core::fmt::Debug for MetricFormat { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + MetricFormat::Statsd => { + f.debug_tuple("MetricFormat::Statsd").finish() + } + } + } + } + + impl MetricFormat{ + pub(crate) unsafe fn _lift(val: u8) -> MetricFormat{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => MetricFormat::Statsd, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[allow(unused_unsafe, clippy::all)] + pub fn metric(format: MetricFormat,name: &[u8],){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "metric"] + fn wit_import(_: i32, _: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(format.clone() as i32, ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn log(level: LogLevel,msg: &[u8],){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = msg; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "log"] + fn wit_import(_: i32, _: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(level.clone() as i32, ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_enter(name: &str,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-enter"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_tags(tags: &str,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = tags; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-tags"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_exit(){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-exit"] + fn wit_import(); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(){ unreachable!() } + wit_import(); + } + } + + } + + } +} + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:component-instr-command"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 454] = [3, 0, 23, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 109, 97, 110, 100, 0, 97, 115, 109, 13, 0, 1, 0, 7, 168, 2, 1, 65, 2, 1, 65, 2, 1, 66, 15, 1, 109, 5, 5, 101, 114, 114, 111, 114, 4, 119, 97, 114, 110, 4, 105, 110, 102, 111, 5, 100, 101, 98, 117, 103, 5, 116, 114, 97, 99, 101, 4, 0, 9, 108, 111, 103, 45, 108, 101, 118, 101, 108, 3, 0, 0, 1, 109, 1, 6, 115, 116, 97, 116, 115, 100, 4, 0, 13, 109, 101, 116, 114, 105, 99, 45, 102, 111, 114, 109, 97, 116, 3, 0, 2, 1, 112, 125, 1, 64, 2, 6, 102, 111, 114, 109, 97, 116, 3, 4, 110, 97, 109, 101, 4, 1, 0, 4, 0, 6, 109, 101, 116, 114, 105, 99, 1, 5, 1, 64, 2, 5, 108, 101, 118, 101, 108, 1, 3, 109, 115, 103, 4, 1, 0, 4, 0, 3, 108, 111, 103, 1, 6, 1, 64, 1, 4, 110, 97, 109, 101, 115, 1, 0, 4, 0, 10, 115, 112, 97, 110, 45, 101, 110, 116, 101, 114, 1, 7, 1, 64, 1, 4, 116, 97, 103, 115, 115, 1, 0, 4, 0, 9, 115, 112, 97, 110, 45, 116, 97, 103, 115, 1, 8, 1, 64, 0, 1, 0, 4, 0, 9, 115, 112, 97, 110, 45, 101, 120, 105, 116, 1, 9, 3, 1, 19, 100, 121, 108, 105, 98, 115, 111, 58, 111, 98, 115, 101, 114, 118, 101, 47, 97, 112, 105, 5, 0, 4, 1, 55, 101, 120, 97, 109, 112, 108, 101, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 109, 97, 110, 100, 47, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 109, 97, 110, 100, 4, 0, 11, 29, 1, 0, 23, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 109, 97, 110, 100, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_section() {} diff --git a/corpus/00-component-instr-command/src/main.rs b/corpus/00-component-instr-command/src/main.rs new file mode 100644 index 00000000..bc1d43bc --- /dev/null +++ b/corpus/00-component-instr-command/src/main.rs @@ -0,0 +1,9 @@ +mod bindings; +use observe_api::*; + +fn main() { + span_enter("hello world"); + log(log::Level::Info, "hello world"); + span_exit(); + println!("Hello, world!"); +} diff --git a/corpus/00-component-instr-command/wit/component.wit b/corpus/00-component-instr-command/wit/component.wit new file mode 100644 index 00000000..7af736b3 --- /dev/null +++ b/corpus/00-component-instr-command/wit/component.wit @@ -0,0 +1,5 @@ +package example:component-instr-command; + +world component-instr-command { + import dylibso:observe/api; +} diff --git a/corpus/01-component-instr-component/Cargo.lock b/corpus/01-component-instr-component/Cargo.lock new file mode 100644 index 00000000..8810d14d --- /dev/null +++ b/corpus/01-component-instr-component/Cargo.lock @@ -0,0 +1,85 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "component-instr-component" +version = "0.1.0" +dependencies = [ + "log", + "observe_api", + "wit-bindgen", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "observe_api" +version = "0.1.0" +dependencies = [ + "log", + "observe_instrument", +] + +[[package]] +name = "observe_instrument" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +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 = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "wit-bindgen" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b76f1d099678b4f69402a421e888bbe71bf20320c2f3f3565d0e7484dbe5bc20" +dependencies = [ + "bitflags", +] diff --git a/corpus/01-component-instr-component/Cargo.toml b/corpus/01-component-instr-component/Cargo.toml new file mode 100644 index 00000000..30ab3177 --- /dev/null +++ b/corpus/01-component-instr-component/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "component-instr-component" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +log = "0.4.20" +wit-bindgen = { version = "0.16.0", default-features = false, features = ["realloc"]} +observe_api = { path = "../../observe-api/rust" } + +[lib] +crate-type = ["cdylib"] + +[package.metadata.component] +package = "component:component-instr-component" + +[package.metadata.component.dependencies] + +[package.metadata.component.target.dependencies] +"dylibso:observe" = { path = "../../wit/observe.wasm" } diff --git a/corpus/01-component-instr-component/src/bindings.rs b/corpus/01-component-instr-component/src/bindings.rs new file mode 100644 index 00000000..a7ae6034 --- /dev/null +++ b/corpus/01-component-instr-component/src/bindings.rs @@ -0,0 +1,266 @@ +// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! +const _: () = { + + #[doc(hidden)] + #[export_name = "hello-world"] + #[allow(non_snake_case)] + unsafe extern "C" fn __export_hello_world() -> i32 { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + + // Before executing any other code, use this function to run all static + // constructors, if they have not yet been run. This is a hack required + // to work around wasi-libc ctors calling import functions to initialize + // the environment. + // + // This functionality will be removed once rust 1.69.0 is stable, at which + // point wasi-libc will no longer have this behavior. + // + // See + // https://github.com/bytecodealliance/preview2-prototyping/issues/99 + // for more details. + #[cfg(target_arch="wasm32")] + wit_bindgen::rt::run_ctors_once(); + + let result0 = <_GuestImpl as Guest>::hello_world(); + let ptr1 = _RET_AREA.0.as_mut_ptr() as i32; + let vec2 = (result0.into_bytes()).into_boxed_slice(); + let ptr2 = vec2.as_ptr() as i32; + let len2 = vec2.len() as i32; + ::core::mem::forget(vec2); + *((ptr1 + 4) as *mut i32) = len2; + *((ptr1 + 0) as *mut i32) = ptr2; + ptr1 + } + + const _: () = { + #[doc(hidden)] + #[export_name = "cabi_post_hello-world"] + #[allow(non_snake_case)] + unsafe extern "C" fn __post_return_hello_world(arg0: i32,) { + let l0 = *((arg0 + 0) as *const i32); + let l1 = *((arg0 + 4) as *const i32); + wit_bindgen::rt::dealloc(l0, (l1) as usize, 1); + } + }; +}; +use super::Component as _GuestImpl; +pub trait Guest { + fn hello_world() -> wit_bindgen::rt::string::String; +} + +#[allow(unused_imports)] +use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + +#[repr(align(4))] +struct _RetArea([u8; 8]); +static mut _RET_AREA: _RetArea = _RetArea([0; 8]); +pub mod dylibso { + pub mod observe { + + #[allow(clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum LogLevel { + Error, + Warn, + Info, + Debug, + Trace, + } + impl ::core::fmt::Debug for LogLevel { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + LogLevel::Error => { + f.debug_tuple("LogLevel::Error").finish() + } + LogLevel::Warn => { + f.debug_tuple("LogLevel::Warn").finish() + } + LogLevel::Info => { + f.debug_tuple("LogLevel::Info").finish() + } + LogLevel::Debug => { + f.debug_tuple("LogLevel::Debug").finish() + } + LogLevel::Trace => { + f.debug_tuple("LogLevel::Trace").finish() + } + } + } + } + + impl LogLevel{ + pub(crate) unsafe fn _lift(val: u8) -> LogLevel{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => LogLevel::Error, + 1 => LogLevel::Warn, + 2 => LogLevel::Info, + 3 => LogLevel::Debug, + 4 => LogLevel::Trace, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum MetricFormat { + Statsd, + } + impl ::core::fmt::Debug for MetricFormat { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + MetricFormat::Statsd => { + f.debug_tuple("MetricFormat::Statsd").finish() + } + } + } + } + + impl MetricFormat{ + pub(crate) unsafe fn _lift(val: u8) -> MetricFormat{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => MetricFormat::Statsd, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[allow(unused_unsafe, clippy::all)] + pub fn metric(format: MetricFormat,name: &[u8],){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "metric"] + fn wit_import(_: i32, _: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(format.clone() as i32, ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn log(level: LogLevel,msg: &[u8],){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = msg; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "log"] + fn wit_import(_: i32, _: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(level.clone() as i32, ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_enter(name: &str,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-enter"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_tags(tags: &str,){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + let vec0 = tags; + let ptr0 = vec0.as_ptr() as i32; + let len0 = vec0.len() as i32; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-tags"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(ptr0, len0); + } + } + #[allow(unused_unsafe, clippy::all)] + pub fn span_exit(){ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "dylibso:observe/api")] + extern "C" { + #[link_name = "span-exit"] + fn wit_import(); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(){ unreachable!() } + wit_import(); + } + } + + } + + } +} + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:example"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 508] = [3, 0, 7, 101, 120, 97, 109, 112, 108, 101, 0, 97, 115, 109, 13, 0, 1, 0, 7, 177, 2, 1, 65, 2, 1, 65, 4, 1, 66, 15, 1, 109, 5, 5, 101, 114, 114, 111, 114, 4, 119, 97, 114, 110, 4, 105, 110, 102, 111, 5, 100, 101, 98, 117, 103, 5, 116, 114, 97, 99, 101, 4, 0, 9, 108, 111, 103, 45, 108, 101, 118, 101, 108, 3, 0, 0, 1, 109, 1, 6, 115, 116, 97, 116, 115, 100, 4, 0, 13, 109, 101, 116, 114, 105, 99, 45, 102, 111, 114, 109, 97, 116, 3, 0, 2, 1, 112, 125, 1, 64, 2, 6, 102, 111, 114, 109, 97, 116, 3, 4, 110, 97, 109, 101, 4, 1, 0, 4, 0, 6, 109, 101, 116, 114, 105, 99, 1, 5, 1, 64, 2, 5, 108, 101, 118, 101, 108, 1, 3, 109, 115, 103, 4, 1, 0, 4, 0, 3, 108, 111, 103, 1, 6, 1, 64, 1, 4, 110, 97, 109, 101, 115, 1, 0, 4, 0, 10, 115, 112, 97, 110, 45, 101, 110, 116, 101, 114, 1, 7, 1, 64, 1, 4, 116, 97, 103, 115, 115, 1, 0, 4, 0, 9, 115, 112, 97, 110, 45, 116, 97, 103, 115, 1, 8, 1, 64, 0, 1, 0, 4, 0, 9, 115, 112, 97, 110, 45, 101, 120, 105, 116, 1, 9, 3, 1, 19, 100, 121, 108, 105, 98, 115, 111, 58, 111, 98, 115, 101, 114, 118, 101, 47, 97, 112, 105, 5, 0, 1, 64, 0, 0, 115, 4, 0, 11, 104, 101, 108, 108, 111, 45, 119, 111, 114, 108, 100, 1, 1, 4, 1, 43, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 47, 101, 120, 97, 109, 112, 108, 101, 4, 0, 11, 13, 1, 0, 7, 101, 120, 97, 109, 112, 108, 101, 3, 0, 0, 0, 93, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 34, 119, 111, 114, 108, 100, 115, 34, 58, 123, 34, 101, 120, 97, 109, 112, 108, 101, 34, 58, 123, 34, 100, 111, 99, 115, 34, 58, 34, 65, 110, 32, 101, 120, 97, 109, 112, 108, 101, 32, 119, 111, 114, 108, 100, 32, 102, 111, 114, 32, 116, 104, 101, 32, 99, 111, 109, 112, 111, 110, 101, 110, 116, 32, 116, 111, 32, 116, 97, 114, 103, 101, 116, 46, 34, 125, 125, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_section() {} diff --git a/corpus/01-component-instr-component/src/lib.rs b/corpus/01-component-instr-component/src/lib.rs new file mode 100644 index 00000000..c92ef628 --- /dev/null +++ b/corpus/01-component-instr-component/src/lib.rs @@ -0,0 +1,17 @@ +mod bindings; + +use observe_api::*; + +use bindings::Guest; + +struct Component; + +impl Guest for Component { + /// Say hello! + fn hello_world() -> String { + span_enter("hello world"); + log(log::Level::Info, "hello world"); + span_exit(); + "Hello, World!".to_string() + } +} diff --git a/corpus/01-component-instr-component/wit/world.wit b/corpus/01-component-instr-component/wit/world.wit new file mode 100644 index 00000000..db86e211 --- /dev/null +++ b/corpus/01-component-instr-component/wit/world.wit @@ -0,0 +1,7 @@ +package component:component-instr-component; + +/// An example world for the component to target. +world example { + import dylibso:observe/api; + export hello-world: func() -> string; +} diff --git a/corpus/02-component-instr-combined/Cargo.lock b/corpus/02-component-instr-combined/Cargo.lock new file mode 100644 index 00000000..b06a795a --- /dev/null +++ b/corpus/02-component-instr-combined/Cargo.lock @@ -0,0 +1,25 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "combined" +version = "0.1.0" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wit-bindgen" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b76f1d099678b4f69402a421e888bbe71bf20320c2f3f3565d0e7484dbe5bc20" +dependencies = [ + "bitflags", +] diff --git a/corpus/02-component-instr-combined/Cargo.toml b/corpus/02-component-instr-combined/Cargo.toml new file mode 100644 index 00000000..575d0ddc --- /dev/null +++ b/corpus/02-component-instr-combined/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "combined" +version = "0.1.0" +edition = "2021" + +[package.metadata.component] +package = "component:combined" + +[package.metadata.component.dependencies] +"component:component-instr-component" = { path = "../01-component-instr-component/target/wasm32-wasi/debug/component_instr_component.wasm" } + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +wit-bindgen = { version = "0.16.0", default-features = false, features = ["realloc"]} \ No newline at end of file diff --git a/corpus/02-component-instr-combined/config.yml b/corpus/02-component-instr-combined/config.yml new file mode 100644 index 00000000..e59933c3 --- /dev/null +++ b/corpus/02-component-instr-combined/config.yml @@ -0,0 +1,4 @@ +dependencies: + component-instr-component: + path: ../01-component-instr-component/target/wasm32-wasi/debug/component_instr_component.wasm + diff --git a/corpus/02-component-instr-combined/src/bindings.rs b/corpus/02-component-instr-combined/src/bindings.rs new file mode 100644 index 00000000..7ad2b179 --- /dev/null +++ b/corpus/02-component-instr-combined/src/bindings.rs @@ -0,0 +1,49 @@ +// Generated by `wit-bindgen` 0.16.0. DO NOT EDIT! + +#[allow(clippy::all)] +pub mod component_instr_component { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::__link_section; + #[allow(unused_unsafe, clippy::all)] + pub fn hello_world() -> wit_bindgen::rt::string::String{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[repr(align(4))] + struct RetArea([u8; 8]); + let mut ret_area = ::core::mem::MaybeUninit::::uninit(); + let ptr0 = ret_area.as_mut_ptr() as i32; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component-instr-component")] + extern "C" { + #[link_name = "hello-world"] + fn wit_import(_: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ){ unreachable!() } + wit_import(ptr0); + let l1 = *((ptr0 + 0) as *const i32); + let l2 = *((ptr0 + 4) as *const i32); + let len3 = l2 as usize; + let bytes3 = Vec::from_raw_parts(l1 as *mut _, len3, len3); + wit_bindgen::rt::string_lift(bytes3) + } + } + +} + + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:combined"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 219] = [3, 0, 8, 99, 111, 109, 98, 105, 110, 101, 100, 0, 97, 115, 109, 13, 0, 1, 0, 7, 92, 1, 65, 2, 1, 65, 2, 1, 66, 2, 1, 64, 0, 0, 115, 4, 0, 11, 104, 101, 108, 108, 111, 45, 119, 111, 114, 108, 100, 1, 0, 3, 0, 25, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 105, 110, 115, 116, 114, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 5, 0, 4, 1, 27, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 99, 111, 109, 98, 105, 110, 101, 100, 47, 99, 111, 109, 98, 105, 110, 101, 100, 4, 0, 11, 14, 1, 0, 8, 99, 111, 109, 98, 105, 110, 101, 100, 3, 0, 0, 0, 16, 12, 112, 97, 99, 107, 97, 103, 101, 45, 100, 111, 99, 115, 0, 123, 125, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 49, 56, 46, 50, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 54, 46, 48]; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_section() {} diff --git a/corpus/02-component-instr-combined/src/main.rs b/corpus/02-component-instr-combined/src/main.rs new file mode 100644 index 00000000..b9e007a3 --- /dev/null +++ b/corpus/02-component-instr-combined/src/main.rs @@ -0,0 +1,7 @@ +mod bindings; + +use bindings::component_instr_component::hello_world; + +fn main() { + println!("calling component: \"{}\"", hello_world()); +} diff --git a/go/event.go b/go/event.go index 2865cf74..a755ac6a 100644 --- a/go/event.go +++ b/go/event.go @@ -16,6 +16,7 @@ const ( RawMetric RawSpanTags RawLog + RawUnknownEvent ) type EventKind int @@ -29,7 +30,7 @@ const ( Log ) -type MetricFormat int +type MetricFormat uint const ( StatsdFormat MetricFormat = 1 @@ -106,7 +107,7 @@ type MemoryGrowEvent struct { Time time.Time } -type LogLevel int +type LogLevel uint const ( Error LogLevel = 1 diff --git a/go/listener.go b/go/listener.go index 9aeeb9b3..22c3b1da 100644 --- a/go/listener.go +++ b/go/listener.go @@ -27,27 +27,43 @@ func (t *TraceCtx) Before(ctx context.Context, _ api.Module, def api.FunctionDef name := def.Name() switch name { + case "enter": + fallthrough case "instrument_enter": event.Kind = RawEnter event.FunctionIndex = uint32(inputs[0]) event.FunctionName = t.names[event.FunctionIndex] + case "exit": + fallthrough case "instrument_exit": event.Kind = RawExit event.FunctionIndex = uint32(inputs[0]) event.FunctionName = t.names[event.FunctionIndex] + case "memory-grow": + fallthrough case "instrument_memory_grow": event.Kind = RawMemoryGrow event.MemoryGrowAmount = uint32(inputs[0]) // manual events + case "span-enter": + fallthrough case "span_enter": event.Kind = RawEnter + case "span-exit": + fallthrough case "span_exit": event.Kind = RawExit + case "span-tags": + fallthrough case "span_tags": event.Kind = RawSpanTags - default: + case "metric": + return + case "log": return + default: + event.Kind = RawUnknownEvent } for stack.Next() { f := stack.Function() diff --git a/go/test/count_vowels.instr.wasm b/go/test/count_vowels.instr.wasm deleted file mode 100644 index f4b3fc4d..00000000 Binary files a/go/test/count_vowels.instr.wasm and /dev/null differ diff --git a/go/trace_ctx.go b/go/trace_ctx.go index b1af61bd..de4c60fb 100644 --- a/go/trace_ctx.go +++ b/go/trace_ctx.go @@ -81,25 +81,23 @@ func (t *TraceCtx) withListener(ctx context.Context) context.Context { func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error { ctx = t.withListener(ctx) - if r.Module("dylibso_observe") != nil { + if r.Module("dylibso_observe") != nil || r.Module("dylibso:observe/instrument") != nil || + r.Module("dylibso:observe/api") != nil { return nil } - observe := r.NewHostModuleBuilder("dylibso_observe") - functions := observe.NewFunctionBuilder() - - functions.WithFunc(func(ctx context.Context, m api.Module, i int32) { + enterFunc := func(ctx context.Context, m api.Module, i uint32) { start := time.Now() ev := <-t.raw t.enter(ev, start) - }).Export("instrument_enter") + } - functions.WithFunc(func(ctx context.Context, m api.Module, ptr uint64, len uint32) { + spanEnterFunc := func(ctx context.Context, m api.Module, ptr uint32, len uint32) { start := time.Now() ev := <-t.raw - functionName, ok := m.Memory().Read(uint32(ptr), len) + functionName, ok := m.Memory().Read(ptr, len) if !ok { log.Printf("span_enter: failed to read memory at offset %v with length %v\n", ptr, len) } @@ -107,23 +105,27 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error { ev.FunctionName = string(functionName) t.enter(ev, start) - }).Export("span_enter") + } - functions.WithFunc(func(ctx context.Context, i int32) { + oldSpanEnterFunc := func(ctx context.Context, m api.Module, ptr uint64, len uint32) { + spanEnterFunc(ctx, m, uint32(ptr), len) + } + + exitFunc := func(ctx context.Context, i uint32) { end := time.Now() ev := <-t.raw t.exit(ev, end) - }).Export("instrument_exit") + } - functions.WithFunc(func(ctx context.Context, m api.Module) { + spanExitFunc := func(ctx context.Context, m api.Module) { end := time.Now() ev := <-t.raw t.exit(ev, end) - }).Export("span_exit") + } - functions.WithFunc(func(ctx context.Context, amt int32) { + memoryGrowFunc := func(ctx context.Context, amt uint32) { ev := <-t.raw if ev.Kind != RawMemoryGrow { log.Println("Expected event", MemoryGrow, "but got", ev.Kind) @@ -148,11 +150,11 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error { } fn.within = append(fn.within, event) t.pushFunction(fn) - }).Export("instrument_memory_grow") + } - functions.WithFunc(func(ctx context.Context, m api.Module, f int32, ptr int64, len int32) { + metricFunc := func(ctx context.Context, m api.Module, f uint32, ptr uint32, len uint32) { format := MetricFormat(f) - buffer, ok := m.Memory().Read(uint32(ptr), uint32(len)) + buffer, ok := m.Memory().Read(ptr, len) if !ok { log.Printf("metric: failed to read memory at offset %v with length %v\n", ptr, len) } @@ -164,17 +166,21 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error { } t.events = append(t.events, event) - }).Export("metric") + } + + oldMetricFunc := func(ctx context.Context, m api.Module, f uint32, ptr uint64, len uint32) { + metricFunc(ctx, m, f, uint32(ptr), len) + } - functions.WithFunc(func(ctx context.Context, m api.Module, ptr int64, len int32) { - buffer, ok := m.Memory().Read(uint32(ptr), uint32(len)) + spanTagsFunc := func(ctx context.Context, m api.Module, ptr uint32, len uint32) { + buffer, ok := m.Memory().Read(ptr, len) if !ok { - log.Printf("metric: failed to read memory at offset %v with length %v\n", ptr, len) + log.Printf("span-tags: failed to read memory at offset %v with length %v\n", ptr, len) } ev := <-t.raw if ev.Kind != RawSpanTags { - log.Println("Expected event", Metric, "but got", ev.Kind) + log.Println("Expected event", SpanTags, "but got", ev.Kind) return } @@ -192,18 +198,22 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error { fn.within = append(fn.within, event) t.pushFunction(fn) - }).Export("span_tags") + } + + oldSpanTagsFunc := func(ctx context.Context, m api.Module, ptr uint64, len uint32) { + spanTagsFunc(ctx, m, uint32(ptr), len) + } - functions.WithFunc(func(ctx context.Context, m api.Module, l int32, ptr int64, len int32) { - if l < int32(Error) || l > int32(Debug) { + logFunc := func(ctx context.Context, m api.Module, l uint32, ptr uint32, len uint32) { + if l < uint32(Error) || l > uint32(Debug) { log.Printf("log: invalid log level %v\n", l) } level := LogLevel(l) - buffer, ok := m.Memory().Read(uint32(ptr), uint32(len)) + buffer, ok := m.Memory().Read(ptr, len) if !ok { - log.Printf("metric: failed to read memory at offset %v with length %v\n", ptr, len) + log.Printf("log: failed to read memory at offset %v with length %v\n", ptr, len) } event := LogEvent{ @@ -213,12 +223,58 @@ func (t *TraceCtx) init(ctx context.Context, r wazero.Runtime) error { } t.events = append(t.events, event) - }).Export("log") + } - _, err := observe.Instantiate(ctx) - if err != nil { - return err + oldLogFunc := func(ctx context.Context, m api.Module, l uint32, ptr uint64, len uint32) { + logFunc(ctx, m, l, uint32(ptr), len) + } + + // instrument api + { + instrument := r.NewHostModuleBuilder("dylibso:observe/instrument") + instrFunctions := instrument.NewFunctionBuilder() + instrFunctions.WithFunc(enterFunc).Export("enter") + instrFunctions.WithFunc(exitFunc).Export("exit") + instrFunctions.WithFunc(memoryGrowFunc).Export("memory-grow") + _, err := instrument.Instantiate(ctx) + if err != nil { + return err + } } + + // manual api + { + api := r.NewHostModuleBuilder("dylibso:observe/api") + apiFunctions := api.NewFunctionBuilder() + apiFunctions.WithFunc(spanEnterFunc).Export("span-enter") + apiFunctions.WithFunc(spanExitFunc).Export("span-exit") + apiFunctions.WithFunc(spanTagsFunc).Export("span-tags") + apiFunctions.WithFunc(metricFunc).Export("metric") + apiFunctions.WithFunc(logFunc).Export("log") + _, err := api.Instantiate(ctx) + if err != nil { + return err + } + } + + //old api (combined instrument and manual api) + { + observe := r.NewHostModuleBuilder("dylibso_observe") + observeFunctions := observe.NewFunctionBuilder() + observeFunctions.WithFunc(enterFunc).Export("instrument_enter") + observeFunctions.WithFunc(exitFunc).Export("instrument_exit") + observeFunctions.WithFunc(memoryGrowFunc).Export("instrument_memory_grow") + observeFunctions.WithFunc(oldSpanEnterFunc).Export("span_enter") + observeFunctions.WithFunc(spanExitFunc).Export("span_exit") + observeFunctions.WithFunc(oldSpanTagsFunc).Export("span_tags") + observeFunctions.WithFunc(oldMetricFunc).Export("metric") + observeFunctions.WithFunc(oldLogFunc).Export("log") + _, err := observe.Instantiate(ctx) + if err != nil { + return err + } + } + return nil } diff --git a/go/wasm.go b/go/wasm.go index 367125b2..7f0768c8 100644 --- a/go/wasm.go +++ b/go/wasm.go @@ -1,57 +1,13 @@ package observe import ( - "bytes" "errors" - "fmt" + "log" "github.com/tetratelabs/wabin/binary" - "github.com/tetratelabs/wabin/leb128" "github.com/tetratelabs/wabin/wasm" ) -const wasmInstrVersionMajor = 0 -const wasmInstrVersionMinor = 0 // TODO: bump this to match compiler when ready - -var errorNoCompatibilityVersion = errors.New("No compatibility versions in module") - -// make sure that our function was instrumented with a compatible -// version of wasm-instr -func checkVersion(m *wasm.Module) error { - var minorGlobal *wasm.Export = nil - var majorGlobal *wasm.Export = nil - for _, export := range m.ExportSection { - if export.Type != wasm.ExternTypeGlobal { - continue - } - - if export.Name == "wasm_instr_version_minor" { - minorGlobal = export - } else if export.Name == "wasm_instr_version_major" { - majorGlobal = export - } - } - - if minorGlobal == nil || majorGlobal == nil { - return errorNoCompatibilityVersion - } - - minor, _, err := leb128.DecodeUint32(bytes.NewReader(m.GlobalSection[minorGlobal.Index].Init.Data)) - if err != nil { - return err - } - major, _, err := leb128.DecodeUint32(bytes.NewReader(m.GlobalSection[majorGlobal.Index].Init.Data)) - if err != nil { - return err - } - - if major != wasmInstrVersionMajor || minor < wasmInstrVersionMinor { - return errors.New(fmt.Sprintf("Expected instrumentation version >= %d.%d but got %d.%d", wasmInstrVersionMajor, wasmInstrVersionMinor, major, minor)) - } - - return nil -} - // Parse the names of the functions out of the // names custom section in the wasm binary. func parseNames(data []byte) (map[uint32]string, error) { @@ -61,11 +17,6 @@ func parseNames(data []byte) (map[uint32]string, error) { return nil, err } - // Check for version globals - if err := checkVersion(m); err != nil && err != errorNoCompatibilityVersion { - return nil, err - } - if m.NameSection == nil { return nil, errors.New("Name section not found") } @@ -76,5 +27,16 @@ func parseNames(data []byte) (map[uint32]string, error) { names[v.Index] = v.Name } + warnOnDylibsoObserve := true + for _, item := range m.ImportSection { + if item.Module == "dylibso_observe" { + if warnOnDylibsoObserve { + warnOnDylibsoObserve = false + log.Println("Module uses deprecated namespace \"dylibso_observe\"!\n" + + "Please consider reinstrumenting with newer wasm-instr or Observe API!") + } + } + } + return names, nil } diff --git a/js/packages/observe-sdk-datadog/test/web/count_vowels.instr.wasm b/js/packages/observe-sdk-datadog/test/web/count_vowels.instr.wasm index f4b3fc4d..f5cc40de 100644 Binary files a/js/packages/observe-sdk-datadog/test/web/count_vowels.instr.wasm and b/js/packages/observe-sdk-datadog/test/web/count_vowels.instr.wasm differ diff --git a/js/packages/observe-sdk-honeycomb/test/web/count_vowels.instr.wasm b/js/packages/observe-sdk-honeycomb/test/web/count_vowels.instr.wasm index f4b3fc4d..f5cc40de 100644 Binary files a/js/packages/observe-sdk-honeycomb/test/web/count_vowels.instr.wasm and b/js/packages/observe-sdk-honeycomb/test/web/count_vowels.instr.wasm differ diff --git a/js/packages/observe-sdk-honeycomb/test/web/test.c.instr.wasm b/js/packages/observe-sdk-honeycomb/test/web/test.c.instr.wasm index 5be1d3a2..a01e9d35 100644 Binary files a/js/packages/observe-sdk-honeycomb/test/web/test.c.instr.wasm and b/js/packages/observe-sdk-honeycomb/test/web/test.c.instr.wasm differ diff --git a/js/packages/observe-sdk-lightstep/test/web/count_vowels.instr.wasm b/js/packages/observe-sdk-lightstep/test/web/count_vowels.instr.wasm index f4b3fc4d..f5cc40de 100644 Binary files a/js/packages/observe-sdk-lightstep/test/web/count_vowels.instr.wasm and b/js/packages/observe-sdk-lightstep/test/web/count_vowels.instr.wasm differ diff --git a/js/packages/observe-sdk-lightstep/test/web/test.c.instr.wasm b/js/packages/observe-sdk-lightstep/test/web/test.c.instr.wasm index 5be1d3a2..a01e9d35 100644 Binary files a/js/packages/observe-sdk-lightstep/test/web/test.c.instr.wasm and b/js/packages/observe-sdk-lightstep/test/web/test.c.instr.wasm differ diff --git a/js/packages/observe-sdk-stdout/test/web/count_vowels.instr.wasm b/js/packages/observe-sdk-stdout/test/web/count_vowels.instr.wasm index f4b3fc4d..f5cc40de 100644 Binary files a/js/packages/observe-sdk-stdout/test/web/count_vowels.instr.wasm and b/js/packages/observe-sdk-stdout/test/web/count_vowels.instr.wasm differ diff --git a/js/src/lib/collectors/span/mod.ts b/js/src/lib/collectors/span/mod.ts index 83dd9d81..0a43550f 100644 --- a/js/src/lib/collectors/span/mod.ts +++ b/js/src/lib/collectors/span/mod.ts @@ -57,6 +57,23 @@ export class SpanCollector implements Collector { mangledNames.forEach((value, key) => { this.names.set(key, demangle(value)); }); + + let warnOnDylibsoObserve = true; + for (const iName of WebAssembly.Module.imports(module)) { + if (iName.module === 'dylibso_observe') { + if (warnOnDylibsoObserve) { + warnOnDylibsoObserve = false; + console.warn("Module uses deprecated namespace \"dylibso_observe\"!\n" + + "Please consider reinstrumenting with newer wasm-instr!"); + } + const apiNames = new Set(["span_enter", "span_tags", "metric", "log", "span_exit"]); + if (apiNames.has(iName.name)) { + throw new Error("js sdk does not yet support Observe API"); + } + } else if (iName.module === 'dylibso:observe/api') { + throw new Error("js sdk does not yet support Observe API"); + } + } } public send(to: Adapter): void { @@ -123,6 +140,11 @@ export class SpanCollector implements Collector { public getImportObject(): WebAssembly.Imports { return { + "dylibso:observe/instrument": { + "enter": this.instrumentEnter, + "exit": this.instrumentExit, + "memory-grow": this.instrumentMemoryGrow, + }, "dylibso_observe": { "instrument_enter": this.instrumentEnter, "instrument_exit": this.instrumentExit, diff --git a/js/test-data/rust_fib_instr.wasm b/js/test-data/rust_fib_instr.wasm index 3812739c..f61c46e2 100644 Binary files a/js/test-data/rust_fib_instr.wasm and b/js/test-data/rust_fib_instr.wasm differ diff --git a/js/test-data/test.c.instr.wasm b/js/test-data/test.c.instr.wasm index 5be1d3a2..a01e9d35 100644 Binary files a/js/test-data/test.c.instr.wasm and b/js/test-data/test.c.instr.wasm differ diff --git a/justfile b/justfile new file mode 100644 index 00000000..cae06c7e --- /dev/null +++ b/justfile @@ -0,0 +1,28 @@ +_help: + @just --list + +_edit: + @$EDITOR {{justfile()}} + +build_wit: + wasm-tools component wit wit/observe.wit -w -o wit/observe.wasm + +component_demo: + #!/bin/bash + set -eou pipefail + (cd corpus/00-component-instr-command; cargo component build) + (cd rust/; cargo run -F component-model --example otel-stdout-components ../corpus/00-component-instr-command/target/wasm32-wasi/debug/component-instr-command.wasm) + +component_demo_2: + #!/bin/bash + set -eou pipefail + (cd corpus/01-component-instr-component; cargo component build) + (cd corpus/02-component-instr-combined; + + cargo component build + wasm-tools compose -c config.yml target/wasm32-wasi/debug/combined.wasm -o target/wasm32-wasi/debug/final.wasm + ) + (cd rust/; cargo run -F component-model --example otel-stdout-components ../corpus/02-component-instr-combined/target/wasm32-wasi/debug/final.wasm) + +local_instr instr_path="../wasm-instr/wasm-instr": + for i in test/*.c.wasm; do o=${i%.wasm}; {{ instr_path }} $i > $o.instr.wasm; done diff --git a/observe-api/README.md b/observe-api/README.md index 4ba8d56d..0f0735e4 100644 --- a/observe-api/README.md +++ b/observe-api/README.md @@ -5,11 +5,11 @@ This acts as the contract between the host and the guest layer. All data flows i from the guest to the host. Most of these APIs are simply ways to pass observability data as strings to the host layer. -* `dylibso_observe.metric(i32, i64, i32)` -* `dylibso_observe.log(i32, i64, i32)` -* `dylibso_observe.span_enter(i64, i32)` -* `dylibso_observe.span_exit()` -* `dylibso_observe.span_tags(i64, i32)` +* `dylibso:observe/api.metric(i32, i32, i32)` +* `dylibso:observe/api.log(i32, i32, i32)` +* `dylibso:observe/api.span-enter(i32, i32)` +* `dylibso:observe/api.span-exit()` +* `dylibso:observe/api.span-tags(i32, i32)` Ideally, you will not call this API layer directly but instead use language specific bindings to call them. And for end users, eventually, open source observability clients will *export* data to this layer. diff --git a/observe-api/c/observe_api.c b/observe-api/c/observe_api.c index a83ed326..ae61d8bd 100644 --- a/observe-api/c/observe_api.c +++ b/observe-api/c/observe_api.c @@ -5,22 +5,22 @@ #include void span_enter(const char *name) { - const uint64_t uint64_ptr = (uint64_t)name; + const uint32_t uint32_ptr = (uint32_t)name; const uint32_t uint32_length = strlen(name); - _span_enter(uint64_ptr, uint32_length); + _span_enter(uint32_ptr, uint32_length); } void span_exit(void) { _span_exit(); } void metric(const char *metric) { - const uint64_t uint64_ptr = (uint64_t)metric; + const uint32_t uint32_ptr = (uint32_t)metric; const uint32_t uint32_length = strlen(metric); - _metric(1, uint64_ptr, uint32_length); + _metric(1, uint32_ptr, uint32_length); } void write_log(const enum DO_LOG_LEVEL level, const char *msg) { - const uint64_t uint64_ptr = (uint64_t)msg; + const uint32_t uint32_ptr = (uint32_t)msg; const uint32_t uint32_length = strlen(msg); const uint32_t uint32_level = level; - _log(uint32_level, uint64_ptr, uint32_length); + _log(uint32_level, uint32_ptr, uint32_length); } diff --git a/observe-api/c/observe_api.h b/observe-api/c/observe_api.h index 42b34451..e28318d3 100644 --- a/observe-api/c/observe_api.h +++ b/observe-api/c/observe_api.h @@ -5,20 +5,21 @@ #define IMPORT(a, b) __attribute__((import_module(a), import_name(b))) -IMPORT("dylibso_observe", "metric") -extern void _metric(uint32_t, uint64_t, uint32_t); -IMPORT("dylibso_observe", "log") -extern void _log(uint32_t, uint64_t, uint32_t); -IMPORT("dylibso_observe", "span_enter") -extern void _span_enter(uint64_t, uint32_t); -IMPORT("dylibso_observe", "span_exit") +IMPORT("dylibso:observe/api", "metric") +extern void _metric(uint32_t, uint32_t, uint32_t); +IMPORT("dylibso:observe/api", "log") +extern void _log(uint32_t, uint32_t, uint32_t); +IMPORT("dylibso:observe/api", "span-enter") +extern void _span_enter(uint32_t, uint32_t); +IMPORT("dylibso:observe/api", "span-exit") extern void _span_exit(void); enum DO_LOG_LEVEL { - DO_LL_ERROR = 1, - DO_LL_WARN = 2, - DO_LL_INFO = 3, - DO_LL_DEBUG = 4 + DO_LL_ERROR = 0, + DO_LL_WARN = 1, + DO_LL_INFO = 2, + DO_LL_DEBUG = 3, + DO_LL_TRACE = 4 }; void span_enter(const char *name); diff --git a/observe-api/rust/src/lib.rs b/observe-api/rust/src/lib.rs index 8fcbd509..34b733b1 100644 --- a/observe-api/rust/src/lib.rs +++ b/observe-api/rust/src/lib.rs @@ -1,23 +1,23 @@ pub use observe_instrument::instrument; -#[link(wasm_import_module = "dylibso_observe")] +#[link(wasm_import_module = "dylibso:observe/api")] extern "C" { #[link_name = "metric"] - fn _metric(format: u32, ptr: u64, len: u32); + fn _metric(format: u32, ptr: u32, len: u32); #[link_name = "log"] - fn _log(level: u32, ptr: u64, len: u32); - #[link_name = "span_enter"] - fn _span_enter(ptr: u64, len: u32); - #[link_name = "span_tags"] - fn _span_tags(ptr: u64, len: u32); - #[link_name = "span_exit"] + fn _log(level: u32, ptr: u32, len: u32); + #[link_name = "span-enter"] + fn _span_enter(ptr: u32, len: u32); + #[link_name = "span-tags"] + fn _span_tags(ptr: u32, len: u32); + #[link_name = "span-exit"] fn _span_exit(); } pub fn log(level: log::Level, message: &str) { let level = level as u32; - let ptr = message.as_ptr() as *const u8; - let ptr = ptr as u64; + let ptr = message.as_ptr(); + let ptr = ptr as u32; let len = message.len() as u32; unsafe { _log(level, ptr, len) }; } @@ -28,23 +28,23 @@ pub enum MetricFormat { pub fn metric(format: MetricFormat, message: &str) { let format = format as u32; - let ptr = message.as_ptr() as *const u8; - let ptr = ptr as u64; + let ptr = message.as_ptr(); + let ptr = ptr as u32; let len = message.len() as u32; unsafe { _metric(format, ptr, len) }; } pub fn span_enter(name: &str) { - let ptr = name.as_ptr() as *const u8; - let ptr = ptr as u64; + let ptr = name.as_ptr(); + let ptr = ptr as u32; let len = name.len() as u32; unsafe { _span_enter(ptr, len) }; } pub fn span_tags(tags: Vec<&str>) { let tags = tags.join(","); - let ptr = tags.as_ptr() as *const u8; - let ptr = ptr as u64; + let ptr = tags.as_ptr(); + let ptr = ptr as u32; let len = tags.len() as u32; unsafe { _span_tags(ptr, len) }; } diff --git a/observe-api/test/c_guest.wasm b/observe-api/test/c_guest.wasm index aa3004c7..fc79289d 100755 Binary files a/observe-api/test/c_guest.wasm and b/observe-api/test/c_guest.wasm differ diff --git a/observe-api/test/cxx_guest.wasm b/observe-api/test/cxx_guest.wasm index 6c5b5eae..27a5e69e 100755 Binary files a/observe-api/test/cxx_guest.wasm and b/observe-api/test/cxx_guest.wasm differ diff --git a/observe-api/test/rust_guest.wasm b/observe-api/test/rust_guest.wasm index 81b8886b..298c4f6a 100755 Binary files a/observe-api/test/rust_guest.wasm and b/observe-api/test/rust_guest.wasm differ diff --git a/proto/opentelemetry/proto/trace/v1/trace.proto b/proto/opentelemetry/proto/trace/v1/trace.proto index b2869edc..3d50d60a 100644 --- a/proto/opentelemetry/proto/trace/v1/trace.proto +++ b/proto/opentelemetry/proto/trace/v1/trace.proto @@ -170,10 +170,12 @@ message Span { // attributes is a collection of key/value pairs. Note, global attributes // like server name can be set using the resource API. Examples of attributes: // + // ```text // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" // "/http/server_latency": 300 // "example.com/myattribute": true // "example.com/score": 10.239 + // ``` // // The OpenTelemetry API specification further restricts the allowed value types: // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 17382bde..adc4bfe9 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -3,14 +3,17 @@ name = "dylibso-observe-sdk" version = "0.1.0" edition = "2021" +[features] +component-model = ["wasmtime/component-model", "wasmtime/async"] + [lib] # not testing docs because the prost generated structs fail doctest = false [dependencies] anyhow = "1" -wasmtime = ">= 8" -wasmtime-wasi = ">= 8" +wasmtime = ">= 17.0.0, < 18.0.0" +wasmtime-wasi = ">= 17.0.0, < 18.0.0" tokio = { version = "1", features = ["sync", "rt-multi-thread", "macros"] } rand = "0" modsurfer-demangle = { git = "https://github.com/dylibso/modsurfer" } @@ -22,6 +25,7 @@ ureq = "2" url = "2" wasmparser = "0.107.0" prost = "0.11.9" +env_logger = "0.10.0" [build-dependencies] prost-build = { version = "0.11.9" } diff --git a/rust/examples/basic.rs b/rust/examples/basic.rs index 7a161388..5154baf9 100644 --- a/rust/examples/basic.rs +++ b/rust/examples/basic.rs @@ -2,6 +2,9 @@ use dylibso_observe_sdk::adapter::stdout::StdoutAdapter; #[tokio::main] pub async fn main() -> anyhow::Result<()> { + env_logger::init_from_env( + env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "warn"), + ); let args: Vec<_> = std::env::args().skip(1).collect(); let data = std::fs::read(&args[0])?; let function_name = "_start"; diff --git a/rust/examples/otel-stdout-components.rs b/rust/examples/otel-stdout-components.rs new file mode 100644 index 00000000..679fae2b --- /dev/null +++ b/rust/examples/otel-stdout-components.rs @@ -0,0 +1,88 @@ +use dylibso_observe_sdk::{ + adapter::otelstdout::OtelStdoutAdapter, + context::component::{ObserveSdk, ObserveSdkView}, +}; + +use wasmtime_wasi::preview2::{ResourceTable, WasiCtx, WasiView}; + +struct State { + table: ResourceTable, + wasi_ctx: WasiCtx, + observe_sdk: ObserveSdk, +} + +impl WasiView for State { + fn table(&self) -> &ResourceTable { + &self.table + } + + fn table_mut(&mut self) -> &mut ResourceTable { + &mut self.table + } + + fn ctx(&self) -> &WasiCtx { + &self.wasi_ctx + } + + fn ctx_mut(&mut self) -> &mut WasiCtx { + &mut self.wasi_ctx + } +} + +impl ObserveSdkView for State { + fn sdk_mut(&mut self) -> &mut ObserveSdk { + &mut self.observe_sdk + } +} + +#[tokio::main] +pub async fn main() -> anyhow::Result<()> { + let args: Vec<_> = std::env::args().skip(1).collect(); + let data = std::fs::read(&args[0])?; + let mut config = wasmtime::Config::new(); + + config.async_support(true); + config.wasm_component_model(true); + + // Create instance + let engine = wasmtime::Engine::new(&config)?; + let component = wasmtime::component::Component::new(&engine, &data)?; + + let table = ResourceTable::new(); + + // Setup WASI + let wasi_ctx = wasmtime_wasi::preview2::WasiCtxBuilder::new() + .inherit_stdio() + .args(&args.clone()) + .build(); + + let mut linker = wasmtime::component::Linker::new(&engine); + + let adapter = OtelStdoutAdapter::create(); + let observe_sdk = adapter.build_observe_sdk(&data, Default::default())?; + + let state = State { + table, + wasi_ctx, + observe_sdk, + }; + let mut store = wasmtime::Store::new(&engine, state); + + wasmtime_wasi::preview2::command::add_to_linker(&mut linker)?; + dylibso_observe_sdk::context::component::add_to_linker(&mut linker)?; + + // get the function and run it, the events pop into the queue as the function is running + let (cmd, _) = wasmtime_wasi::preview2::command::Command::instantiate_async( + &mut store, &component, &linker, + ) + .await?; + let run = cmd.wasi_cli_run(); + if let Err(()) = run.call_run(&mut store).await? { + println!("encountered error"); + }; + + let state = store.into_data(); + state.observe_sdk.shutdown().await?; + + Ok(()) +} diff --git a/rust/src/adapter/mod.rs b/rust/src/adapter/mod.rs index 7106108a..3cc18498 100644 --- a/rust/src/adapter/mod.rs +++ b/rust/src/adapter/mod.rs @@ -14,6 +14,12 @@ use crate::{ Event, TelemetryId, TraceEvent, }; +#[cfg(feature = "component-model")] +use crate::{ + context::{component::ObserveSdk, InstrumentationContext}, + wasm_instr::WasmInstrInfo, +}; + use self::datadog::DatadogMetadata; pub mod datadog; @@ -183,6 +189,21 @@ impl AdapterHandle { Ok(TraceContext { collector }) } + #[cfg(feature = "component-model")] + /// Given a slice representing a Wasm component and [`Options`], create an [`ObserveSdk`]. + pub fn build_observe_sdk(&self, data: &[u8], options: Options) -> Result { + let (ctx, collector, collector_rx) = InstrumentationContext::new(options); + let wasm_instr_info = WasmInstrInfo::new(data)?; + + Collector::start(collector_rx, self.clone()); + let bindings = ObserveSdk { + instr_context: ctx, + wasm_instr_info, + trace_context: TraceContext { collector }, + }; + Ok(bindings) + } + pub fn try_send(&self, event: TraceEvent) -> Result<()> { self.adapter_tx.try_send(event)?; Ok(()) diff --git a/rust/src/context.rs b/rust/src/context.rs index 116720c0..4d8eda52 100644 --- a/rust/src/context.rs +++ b/rust/src/context.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Context, Result}; -use log::{error, warn}; +use log::error; use modsurfer_demangle::demangle_function_name; use std::{ collections::HashMap, @@ -36,7 +36,7 @@ pub struct InstrumentationContext { } impl InstrumentationContext { - fn new( + pub(crate) fn new( options: Options, ) -> ( Arc>, @@ -268,8 +268,8 @@ pub(crate) fn metric( let ptr = input .get(1) .context("Missing ptr arg")? - .i64() - .context("Could not cast ptr arg to i64")?; + .i32() + .context("Could not cast ptr arg to i32")?; let len = input .get(2) @@ -302,8 +302,8 @@ pub(crate) fn span_tags( let ptr = input .get(0) .context("Missing ptr arg")? - .i64() - .context("Could not cast ptr arg to i64")?; + .i32() + .context("Could not cast ptr arg to i32")?; let len = input .get(1) @@ -347,8 +347,8 @@ pub(crate) fn log_write( let ptr = input .get(1) .context("Missing ptr arg")? - .i64() - .context("Could not cast ptr arg to i64")?; + .i32() + .context("Could not cast ptr arg to i32")?; let len = input .get(2) @@ -381,8 +381,8 @@ pub(crate) fn span_enter( let ptr = input .get(0) .context("Missing ptr arg")? - .i64() - .context("Could not cast ptr arg to i64")?; + .i32() + .context("Could not cast ptr arg to i32")?; let len = input .get(1) @@ -420,8 +420,6 @@ pub(crate) fn span_exit( Ok(()) } -const MODULE_NAME: &str = "dylibso_observe"; - type EventChannel = (Sender, Receiver); /// Link observability import functions required by instrumented wasm code @@ -432,21 +430,16 @@ pub fn add_to_linker( ) -> Result { let (ctx, events_tx, events_rx) = InstrumentationContext::new(options); - // load the static wasm-instr info + // + // Dylibso Observe Instrument API + // let wasm_instr_info = WasmInstrInfo::new(data)?; - - // check that the version number is supported with this SDK - // TODO decide what to do about this error? - if let Err(e) = wasm_instr_info.check_version() { - warn!("{}", e); - } - let t = FuncType::new([ValType::I32], []); let enter_ctx = ctx.clone(); linker.func_new( - MODULE_NAME, - "instrument_enter", + "dylibso:observe/instrument", + "enter", t.clone(), move |_caller: Caller, params, results| { instrument_enter( @@ -460,26 +453,49 @@ pub fn add_to_linker( let exit_ctx = ctx.clone(); linker.func_new( - MODULE_NAME, - "instrument_exit", + "dylibso:observe/instrument", + "exit", t.clone(), move |_caller, params, results| instrument_exit(params, results, exit_ctx.clone()), )?; let grow_ctx = ctx.clone(); linker.func_new( - MODULE_NAME, - "instrument_memory_grow", + "dylibso:observe/instrument", + "memory-grow", t, move |_caller, params, results| instrument_memory_grow(params, results, grow_ctx.clone()), )?; - let t = FuncType::new([ValType::I64, ValType::I32], []); + // aliases to support old naming + linker.alias( + "dylibso:observe/instrument", + "enter", + "dylibso_observe", + "instrument_enter", + )?; + linker.alias( + "dylibso:observe/instrument", + "exit", + "dylibso_observe", + "instrument_exit", + )?; + linker.alias( + "dylibso:observe/instrument", + "memory-grow", + "dylibso_observe", + "instrument_memory_grow", + )?; + + // + // Dylibso Observe API + // + let t = FuncType::new([ValType::I32, ValType::I32], []); let span_enter_ctx = ctx.clone(); linker.func_new( - MODULE_NAME, - "span_enter", + "dylibso:observe/api", + "span-enter", t.clone(), move |mut caller, params, results| { span_enter(&mut caller, params, results, span_enter_ctx.clone()) @@ -488,35 +504,38 @@ pub fn add_to_linker( let span_tags_ctx = ctx.clone(); linker.func_new( - MODULE_NAME, - "span_tags", + "dylibso:observe/api", + "span-tags", t.clone(), move |mut caller, params, results| { span_tags(&mut caller, params, results, span_tags_ctx.clone()) }, )?; - let t = FuncType::new([ValType::I32, ValType::I64, ValType::I32], []); + let t = FuncType::new([ValType::I32, ValType::I32, ValType::I32], []); let metric_ctx = ctx.clone(); linker.func_new( - MODULE_NAME, + "dylibso:observe/api", "metric", t.clone(), move |mut caller, params, results| metric(&mut caller, params, results, metric_ctx.clone()), )?; let log_ctx = ctx.clone(); - linker.func_new(MODULE_NAME, "log", t, move |mut caller, params, results| { - log_write(&mut caller, params, results, log_ctx.clone()) - })?; + linker.func_new( + "dylibso:observe/api", + "log", + t, + move |mut caller, params, results| log_write(&mut caller, params, results, log_ctx.clone()), + )?; let t = FuncType::new([], []); let span_exit_ctx = ctx.clone(); linker.func_new( - MODULE_NAME, - "span_exit", + "dylibso:observe/api", + "span-exit", t, move |mut caller, params, results| { span_exit(&mut caller, params, results, span_exit_ctx.clone()) @@ -529,3 +548,263 @@ pub fn add_to_linker( linker.allow_unknown_exports(true); Ok((events_tx, events_rx)) } + +#[cfg(feature = "component-model")] +pub mod component { + //! # Component Model Observability + //! + //! Available via `feature = "component-model"`. + //! + //! This module exposes host observability capabilities to the component model. By using this + //! module, hosts can provide support for guest components which depend on the + //! `dylibso:observe/api` and `dylibso:observe/instrument` WIT interfaces. + //! + //! ## Integrating + //! + //! Like Wasmtime's [`wasmtime_wasi::preview2`] module, Observability support involves three steps: + //! + //! 1. Adding an [`ObserveSdk`] member to your host's [`wasmtime::Store`] state struct. + //! 2. Providing access to that member by implementing [`ObserveSdkView`] for your host's state + //! struct. + //! 3. Adding the host bindings to the [`wasmtime::component::Linker`]. + //! + //! ```rust + //! use dylibso_observe_sdk::context::component::{ ObserveSdk, ObserveSdkView }; + //! + //! struct MyState { + //! // Step 1: add a member to your state... + //! sdk: ObserveSdk, + //! } + //! + //! // Step 2: implement the view trait for your state. + //! impl ObserveSdkView for MyState { + //! fn sdk_mut(&mut self) -> &mut ObserveSdk { + //! &mut self.sdk + //! } + //! } + //! ``` + //! + //! Once you've completed step 1 and 2, you can add host bindings like so: + //! + //! ```no_run + //! # use dylibso_observe_sdk::context::component::{ ObserveSdk, ObserveSdkView }; + //! # struct MyState { + //! # sdk: ObserveSdk, + //! # } + //! # impl ObserveSdkView for MyState { + //! # fn sdk_mut(&mut self) -> &mut ObserveSdk { + //! # &mut self.sdk + //! # } + //! # } + //! # #[tokio::main] + //! # async fn main() -> anyhow::Result<()> { + //! use dylibso_observe_sdk::adapter::otelstdout::OtelStdoutAdapter; + //! + //! // (Setup: Read a Wasm module from stdin.) + //! let args: Vec<_> = std::env::args().skip(1).collect(); + //! let wasm_data = std::fs::read(&args[0])?; + //! let mut config = wasmtime::Config::new(); + //! + //! config.async_support(true); + //! config.wasm_component_model(true); + //! let engine = wasmtime::Engine::new(&config)?; + //! let component = wasmtime::component::Component::new(&engine, &wasm_data)?; + //! let mut linker = wasmtime::component::Linker::new(&engine); + //! + //! // All adapters have component support, OtelStdoutAdapter just happens to be + //! // easiest to use as an example: + //! let adapter = OtelStdoutAdapter::create(); + //! + //! // Use the adapter to create observe_sdk bindings which you can then pass to your state. + //! let observe_sdk = adapter.build_observe_sdk(&wasm_data, Default::default())?; + //! + //! // Create your state and wrap it in a wasmtime::Store. + //! let state = MyState { + //! sdk: observe_sdk + //! }; + //! let mut store = wasmtime::Store::new(&engine, state); + //! + //! // ...Then add it to the linker. + //! dylibso_observe_sdk::context::component::add_to_linker(&mut linker)?; + //! + //! # let (cmd, _) = wasmtime_wasi::preview2::command::Command::instantiate_async(&mut store, &component, &linker).await?; + //! # let run = cmd.wasi_cli_run(); + //! // Once you're done with wasm, call `shutdown()`, which shuts down the collector associated + //! // with the Observe SDK. + //! let state = store.into_data(); + //! state.sdk.shutdown().await?; + //! # Ok(()) + //! # } + //! ``` + //! + //! To see an example integrating both Wasi preview 2 and the Observe SDK, see + //! `rust/examples/otel-stdout-components.rs` in the [observe sdk + //! repo](https://github.com/dylibso/observe-sdk/). + use crate::adapter::TraceContext; + + use super::*; + use wasmtime::component::Linker; + + /// Provide access to [`ObserveSdk`] from a [`wasmtime::Store`]'s inner object. + /// + /// ```rust + /// use dylibso_observe_sdk::context::component::{ ObserveSdk, ObserveSdkView }; + /// + /// struct MyState { + /// sdk: ObserveSdk, + /// } + /// + /// impl ObserveSdkView for MyState { + /// fn sdk_mut(&mut self) -> &mut ObserveSdk { + /// &mut self.sdk + /// } + /// } + /// ``` + pub trait ObserveSdkView { + fn sdk_mut(&mut self) -> &mut ObserveSdk; + } + + // Hide the bindgen-generated modules from rustdoc by using an "internal" module. + mod internal { + wasmtime::component::bindgen!({ + interfaces: r#" + import dylibso:observe/api; + import dylibso:observe/instrument; + "#, + path: "../wit", + async: false + }); + } + + use internal::dylibso::observe::api::{Host as ApiHost, LogLevel, MetricFormat}; + use internal::dylibso::observe::instrument::Host as InstrumentHost; + + /// A data structure backing ObserveSdk bindings: contains private information mapping + /// function ids to names and contexts for collector channels. + /// + /// Instantiate by calling + /// [`AdapterHandle::build_observe_sdk`](crate::adapter::AdapterHandle::build_observe_sdk) + /// using any adapter type: + /// + /// ```no_run + /// # use dylibso_observe_sdk::context::component::ObserveSdk; + /// use dylibso_observe_sdk::adapter::zipkin::ZipkinAdapter; + /// # fn main() -> anyhow::Result<()> { + /// let args: Vec<_> = std::env::args().skip(1).collect(); + /// let wasm_data = std::fs::read(&args[0])?; + /// let zipkin = ZipkinAdapter::create(); + /// + /// // NB: the ": ObserveSdk" type annotation here isn't necessary, it's just to indicate the + /// // return type. + /// let observe_sdk: ObserveSdk = zipkin.build_observe_sdk(&wasm_data, + /// Default::default()).unwrap(); + /// # Ok(()) + /// # } + /// ``` + pub struct ObserveSdk { + pub(crate) instr_context: Arc>, + pub(crate) wasm_instr_info: WasmInstrInfo, + pub(crate) trace_context: TraceContext, + } + + impl ObserveSdk { + /// Shut down the trace collector. Once the collector is shut down this instance + /// should no longer be used. `shutdown` may be called multiple times but will emit + /// warnings on subsequent calls. + pub async fn shutdown(&self) -> Result<()> { + self.trace_context.shutdown().await; + Ok(()) + } + } + + impl TryInto for MetricFormat { + type Error = anyhow::Error; + + fn try_into(self) -> std::result::Result { + #[allow(unreachable_patterns)] + match self { + MetricFormat::Statsd => Ok(super::MetricFormat::Statsd), + _ => bail!("Illegal metric format value"), + } + } + } + + impl ApiHost for ObserveSdk { + fn metric(&mut self, format: MetricFormat, name: Vec) -> wasmtime::Result<()> { + if let Ok(mut cont) = self.instr_context.lock() { + cont.metric(format.try_into()?, name.as_slice())?; + } + Ok(()) + } + + fn log(&mut self, level: LogLevel, msg: Vec) -> wasmtime::Result<()> { + if let Ok(mut cont) = self.instr_context.lock() { + cont.log_write(level as u8, msg.as_slice())?; + } + Ok(()) + } + + fn span_enter(&mut self, name: String) -> wasmtime::Result<()> { + if let Ok(mut cont) = self.instr_context.lock() { + cont.enter(0u32, Some(name.as_str()))?; + } + Ok(()) + } + + fn span_tags(&mut self, tags: String) -> wasmtime::Result<()> { + let tags: Vec = tags.split(',').map(|xs| xs.to_string()).collect(); + if let Ok(mut cont) = self.instr_context.lock() { + cont.span_tags(tags)?; + } + Ok(()) + } + + fn span_exit(&mut self) -> wasmtime::Result<()> { + if let Ok(mut cont) = self.instr_context.lock() { + cont.exit(0u32)?; + } + Ok(()) + } + } + + impl InstrumentHost for ObserveSdk { + fn memory_grow(&mut self, amount_in_pages: u32) -> wasmtime::Result<()> { + if let Ok(mut cont) = self.instr_context.lock() { + cont.allocate(amount_in_pages)?; + } + Ok(()) + } + + fn enter(&mut self, func_id: u32) -> wasmtime::Result<()> { + let printname = self.wasm_instr_info.function_names.get(&func_id); + if let Ok(mut cont) = self.instr_context.lock() { + cont.enter(func_id, printname.map(|x| x.as_str()))?; + } + Ok(()) + } + + fn exit(&mut self, func_id: u32) -> wasmtime::Result<()> { + if let Ok(mut cont) = self.instr_context.lock() { + cont.exit(func_id)?; + } + Ok(()) + } + } + + /// Make ObserveSdk host bindings available to the component model + /// [`wasmtime::component::Linker`]. Assumes that [`ObserveSdkView`] has been implemented to + /// map from the [`wasmtime::Store`] to an instance of [`ObserveSdk`]. + pub fn add_to_linker(linker: &mut Linker) -> Result<()> + where + T: ObserveSdkView + 'static, + { + internal::dylibso::observe::api::add_to_linker(linker, |s| -> &mut ObserveSdk { + s.sdk_mut() + })?; + + internal::dylibso::observe::instrument::add_to_linker(linker, |s| -> &mut ObserveSdk { + s.sdk_mut() + })?; + Ok(()) + } +} diff --git a/rust/src/wasm_instr.rs b/rust/src/wasm_instr.rs index f7bba14d..bcdf810b 100644 --- a/rust/src/wasm_instr.rs +++ b/rust/src/wasm_instr.rs @@ -6,42 +6,17 @@ use anyhow::{bail, Result}; // WASM_INSTR_VERSION_MAJOR must match the instrumented wasm // wasmInstrVersionMinor must be <= the value in instrumented wasm pub const WASM_INSTR_VERSION_MAJOR: u32 = 0; -pub const WASM_INSTR_VERSION_MINOR: u32 = 0; // TODO: bump this to match compiler when ready +pub const WASM_INSTR_VERSION_MINOR: u32 = 4; // TODO: bump this to match compiler when ready // Static info from instrumentation pub struct WasmInstrInfo { pub function_names: HashMap, - pub maj_version: Option, - pub min_version: Option, } impl WasmInstrInfo { - pub fn check_version(&self) -> Result<()> { - if self.maj_version.is_none() && self.min_version.is_none() { - // likely this is an uninstrumented module, or not instrumented with automation - return Ok(()); - } - let maj_num = self.maj_version.unwrap(); - let min_num = self.min_version.unwrap(); - - if maj_num != WASM_INSTR_VERSION_MAJOR { - bail!("wasm wasm-instr major version {maj_num} is not equal to {WASM_INSTR_VERSION_MAJOR}!") - } - - if min_num < WASM_INSTR_VERSION_MINOR { - bail!( - "wasm wasm-instr minor version {min_num} is less than {WASM_INSTR_VERSION_MINOR}!" - ); - } - - Ok(()) - } - pub fn new(data: &[u8]) -> Result { let mut function_names = HashMap::new(); - let mut maj_index: Option = None; - let mut min_index: Option = None; - let mut globals = HashMap::::new(); + let mut warn_on_dylibso_observe = true; let parser = wasmparser::Parser::new(0); for payload in parser.parse_all(data) { match payload? { @@ -60,60 +35,32 @@ impl WasmInstrInfo { continue; } } - wasmparser::Payload::GlobalSection(globalsec) => { - for (i, aglob) in globalsec.into_iter().enumerate() { - let glob = aglob.unwrap(); - if glob.ty.content_type != wasmparser::ValType::I32 { - continue; - } - let mut reader = glob.init_expr.get_binary_reader(); - let opcode = match reader.read_u8() { - Ok(opcode) => opcode, - Err(_) => continue, - }; - // i32.const - if opcode != 0x41 { - continue; - } - // due to binaryen limitations u32 version values are encoded as a signed LEB128 - // integers so they must be casted back to unsigned - let iv = reader.read_var_i32().unwrap(); - let uv = iv as u32; - globals.insert(i as u32, uv); - } - } - wasmparser::Payload::ExportSection(exportsec) => { - for export in exportsec.into_iter() { - let export = export?; - if export.kind != wasmparser::ExternalKind::Global { - continue; - } - match export.name { - "wasm_instr_version_major" => { - maj_index = Some(export.index); + wasmparser::Payload::ImportSection(importsec) => { + for import in importsec.into_iter() { + let import = import?; + if import.module == "dylibso_observe" { + if warn_on_dylibso_observe { + warn_on_dylibso_observe = false; + log::warn!( + "Module uses deprecated namespace \"dylibso_observe\"! +Please rebuild your module using the updated Observe API or reinstrument with the new version of wasm-instr." + ); } - "wasm_instr_version_minor" => { - min_index = Some(export.index); + for fname in ["span_enter", "span_tags", "metric", "log", "span_exit"] { + if import.name == fname { + bail!( + "Module uses old version of Observe API! +Please rebuild your module using the updated Observe API." + ); + } } - _ => {} } } } _ => (), } } - let maj_version = match maj_index { - Some(maj_index) => Some(*globals.get(&maj_index).unwrap()), - None => None, - }; - let min_version = match min_index { - Some(min_index) => Some(*globals.get(&min_index).unwrap()), - None => None, - }; - return Ok(Self { - function_names, - maj_version, - min_version, - }); + + return Ok(Self { function_names }); } } diff --git a/test/kitchensink.c b/test/kitchensink.c index a89e18a1..1116564e 100644 --- a/test/kitchensink.c +++ b/test/kitchensink.c @@ -5,13 +5,13 @@ #define IMPORT(a, b) __attribute__((import_module(a), import_name(b))) -IMPORT("dylibso_observe", "metric") +IMPORT("dylibso:observe/api", "metric") extern void metric(uint32_t, uint64_t, uint32_t); -IMPORT("dylibso_observe", "log") +IMPORT("dylibso:observe/api", "log") extern void log_write(uint32_t, uint64_t, uint32_t); -IMPORT("dylibso_observe", "span_enter") +IMPORT("dylibso:observe/api", "span-enter") extern void span_enter(uint64_t, uint32_t); -IMPORT("dylibso_observe", "span_exit") extern void span_exit(); +IMPORT("dylibso:observe/api", "span-exit") extern void span_exit(); void custom_span_enter(char name[]) { uintptr_t ptr = (uintptr_t)name; diff --git a/test/kitchensink.c.instr.wasm b/test/kitchensink.c.instr.wasm index 8de14111..0607f08e 100644 Binary files a/test/kitchensink.c.instr.wasm and b/test/kitchensink.c.instr.wasm differ diff --git a/test/nested.c.instr.wasm b/test/nested.c.instr.wasm index 7f74c7f7..285bad64 100644 Binary files a/test/nested.c.instr.wasm and b/test/nested.c.instr.wasm differ diff --git a/test/test.c.instr.wasm b/test/test.c.instr.wasm index 5be1d3a2..38320fb4 100644 Binary files a/test/test.c.instr.wasm and b/test/test.c.instr.wasm differ diff --git a/wit/observe.wasm b/wit/observe.wasm new file mode 100644 index 00000000..735a3c9e Binary files /dev/null and b/wit/observe.wasm differ diff --git a/wit/observe.wit b/wit/observe.wit new file mode 100644 index 00000000..bcf4a862 --- /dev/null +++ b/wit/observe.wit @@ -0,0 +1,27 @@ +package dylibso:observe; + +interface api { + enum log-level { + error, + warn, + info, + debug, + trace + } + + enum metric-format { + statsd, + } + + metric: func(format: metric-format, name: list); + log: func(level: log-level, msg: list); + span-enter: func(name: string); + span-tags: func(tags: string); + span-exit: func(); +} + +interface instrument { + memory-grow: func(amount-in-pages: u32); + enter: func(func-id: u32); + exit: func(func-id: u32); +}