diff --git a/examples/wasm_guest/.gitignore b/examples/wasm_guest/.gitignore new file mode 100644 index 00000000..ed3a6d1a --- /dev/null +++ b/examples/wasm_guest/.gitignore @@ -0,0 +1,7 @@ +.venv/ +dist/ +src/wit_world/ +src/componentize_py_*/ +src/poll_loop.py +src/componentize_py_types.py +src/componentize_py_runtime.pyi diff --git a/examples/wasm_guest/Makefile b/examples/wasm_guest/Makefile new file mode 100644 index 00000000..0f227df1 --- /dev/null +++ b/examples/wasm_guest/Makefile @@ -0,0 +1,19 @@ +WIT_DIR := wit +SRC_DIR := src +DIST_DIR := dist +WASM := $(DIST_DIR)/plugin.wasm + +.PHONY: bindings build clean + +bindings: + uv run componentize-py -d $(WIT_DIR) -w plugin bindings $(SRC_DIR) + +$(WASM): $(SRC_DIR)/guest_impl.py $(WIT_DIR)/processor.wit + @mkdir -p $(DIST_DIR) + $(MAKE) bindings + uv run componentize-py -d $(WIT_DIR) -w plugin componentize -p $(SRC_DIR) guest_impl -o $(WASM) + +build: $(WASM) + +clean: + rm -rf $(DIST_DIR) $(SRC_DIR)/wit_world $(SRC_DIR)/componentize_py_* diff --git a/examples/wasm_guest/README.md b/examples/wasm_guest/README.md new file mode 100644 index 00000000..ee14945c --- /dev/null +++ b/examples/wasm_guest/README.md @@ -0,0 +1,21 @@ +# sentry_streams WASM guest example + +Sample [componentize-py](https://github.com/bytecodealliance/componentize-py) guest for the +`sentry-streams:processor` WIT world used by `WasmProcessor` in the Rust Arroyo adapter. + +## Build + +```bash +make build +``` + +Produces `dist/plugin.wasm`. The WIT contract lives in +[`../../sentry_streams/wit/processor.wit`](../../sentry_streams/wit/processor.wit). + +## Guest behavior + +- `submit`: buffers the message for the next `poll` +- `submit_watermark`: buffers the watermark for the next `poll` +- `poll`: returns all buffered outputs (messages and watermarks), or `None` if empty + +Uses the host `log` import for tracing. diff --git a/examples/wasm_guest/pyproject.toml b/examples/wasm_guest/pyproject.toml new file mode 100644 index 00000000..8d46e03c --- /dev/null +++ b/examples/wasm_guest/pyproject.toml @@ -0,0 +1,11 @@ +[project] +name = "sentry-streams-wasm-guest" +version = "0.1.0" +description = "Example componentize-py guest for sentry_streams WasmProcessor" +requires-python = ">=3.11" +dependencies = [ + "componentize-py>=0.23.0", +] + +[tool.uv] +dev-dependencies = [] diff --git a/examples/wasm_guest/src/guest_impl.py b/examples/wasm_guest/src/guest_impl.py new file mode 100644 index 00000000..6adef192 --- /dev/null +++ b/examples/wasm_guest/src/guest_impl.py @@ -0,0 +1,31 @@ +"""Sample WASM processor guest: passthrough with host logging.""" + +from __future__ import annotations + +from typing import List, Optional + +from wit_world.exports import Processor as ProcessorProtocol +from wit_world.exports import processor as proc +from wit_world.imports import log as host_log + + +class Processor(ProcessorProtocol): + """Buffers submitted messages and watermarks; returns them on ``poll``.""" + + def __init__(self) -> None: + self._pending: List[proc.Output] = [] + + def submit(self, msg: proc.Message) -> None: + host_log.info(f"submit message len={len(msg.payload)}") + self._pending.append(proc.Output_Msg(value=msg)) + + def submit_watermark(self, wm: proc.Watermark) -> None: + host_log.info("submit_watermark") + self._pending.append(proc.Output_Wm(value=wm)) + + def poll(self) -> Optional[List[proc.Output]]: + if not self._pending: + return None + out = self._pending + self._pending = [] + return out diff --git a/examples/wasm_guest/uv.lock b/examples/wasm_guest/uv.lock new file mode 100644 index 00000000..6cd8c4e2 --- /dev/null +++ b/examples/wasm_guest/uv.lock @@ -0,0 +1,30 @@ +version = 1 +revision = 2 +requires-python = ">=3.11" + +[[package]] +name = "componentize-py" +version = "0.23.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ac/d6/862d195136a671671ed06363ffcb45dc38682b3b5bb4a8eaa9500464de84/componentize_py-0.23.0.tar.gz", hash = "sha256:8d5ea3dbdf6642aca4a9329be30861189c1066e1651d2ab73bb3b0f1d9871407", size = 203590, upload-time = "2026-04-15T17:25:48.104Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e2/a9/f5a3975d05cec7f3a95a6e931d73204aa3592280113effd7a0ac1f741864/componentize_py-0.23.0-cp39-abi3-macosx_10_12_x86_64.whl", hash = "sha256:bcd956598441713d1920396af9896ab19753bcb568299ff2db85f43bb65286ed", size = 16108001, upload-time = "2026-04-15T17:25:14.424Z" }, + { url = "https://files.pythonhosted.org/packages/75/9f/e4b08061e9f0c0abe61806b28f99ac094e2a19bdf312108c9b38be499d74/componentize_py-0.23.0-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:d4b9b52e548f962c9ba36f15ce9793689bd29beb18a52b3480d317fc773e4506", size = 15269777, upload-time = "2026-04-15T17:25:21.826Z" }, + { url = "https://files.pythonhosted.org/packages/f8/df/b8161bcc0b4158a7cc75d558bd9b16b67bbd27ae7511ef2d06db4bea88c3/componentize_py-0.23.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:939acedff58eba1f4864ebe9327c742e5cf52bf6e08eddfb699e82761c5ede9f", size = 16237698, upload-time = "2026-04-15T17:25:29.46Z" }, + { url = "https://files.pythonhosted.org/packages/77/8d/426f07b84efed1b98076b4193f8d29e1a5e76a2f63fbc8770b2a6f3b589a/componentize_py-0.23.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:99eaa2cc8b5d737d2b23237618332a21838f892eec7f0359b44c464659a15ecc", size = 16808229, upload-time = "2026-04-15T17:25:37.562Z" }, + { url = "https://files.pythonhosted.org/packages/bc/9c/1c725d88d33fdc99c008fde287098b037f71c18197d54477e4ed0db101b2/componentize_py-0.23.0-cp39-abi3-win_amd64.whl", hash = "sha256:1d65d73c97ea751d2dc958fba085c501e68a7c68cf4611df910b99e18fb2057e", size = 14884887, upload-time = "2026-04-15T17:25:44.983Z" }, +] + +[[package]] +name = "sentry-streams-wasm-guest" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "componentize-py" }, +] + +[package.metadata] +requires-dist = [{ name = "componentize-py", specifier = ">=0.23.0" }] + +[package.metadata.requires-dev] +dev = [] diff --git a/examples/wasm_guest/wit/processor.wit b/examples/wasm_guest/wit/processor.wit new file mode 120000 index 00000000..ca6974a6 --- /dev/null +++ b/examples/wasm_guest/wit/processor.wit @@ -0,0 +1 @@ +../../../sentry_streams/wit/processor.wit \ No newline at end of file diff --git a/sentry_streams/Cargo.lock b/sentry_streams/Cargo.lock index 6a7fe2eb..00f8e63c 100644 --- a/sentry_streams/Cargo.lock +++ b/sentry_streams/Cargo.lock @@ -186,6 +186,18 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "ambient-authority" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -257,6 +269,21 @@ version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +[[package]] +name = "ar_archive_writer" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb93bbb63b9c227414f6eb3a0adfddca591a8ce1e9b60661bb08969b87e340b" +dependencies = [ + "object 0.37.3", +] + +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + [[package]] name = "async-trait" version = "0.1.89" @@ -290,11 +317,17 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.36.7", "rustc-demangle", "windows-targets 0.52.6", ] +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "base64" version = "0.22.1" @@ -313,6 +346,15 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "block2" version = "0.6.2" @@ -327,6 +369,15 @@ name = "bumpalo" version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +dependencies = [ + "allocator-api2", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -343,12 +394,93 @@ dependencies = [ "bytes", ] +[[package]] +name = "cap-fs-ext" +version = "3.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5528f85b1e134ae811704e41ef80930f56e795923f866813255bc342cc20654" +dependencies = [ + "cap-primitives", + "cap-std", + "io-lifetimes", + "windows-sys 0.59.0", +] + +[[package]] +name = "cap-net-ext" +version = "3.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20a158160765c6a7d0d8c072a53d772e4cb243f38b04bfcf6b4939cfbe7482e7" +dependencies = [ + "cap-primitives", + "cap-std", + "rustix 1.0.7", + "smallvec", +] + +[[package]] +name = "cap-primitives" +version = "3.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6cf3aea8a5081171859ef57bc1606b1df6999df4f1110f8eef68b30098d1d3a" +dependencies = [ + "ambient-authority", + "fs-set-times", + "io-extras", + "io-lifetimes", + "ipnet", + "maybe-owned", + "rustix 1.0.7", + "rustix-linux-procfs", + "windows-sys 0.59.0", + "winx", +] + +[[package]] +name = "cap-rand" +version = "3.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8144c22e24bbcf26ade86cb6501a0916c46b7e4787abdb0045a467eb1645a1d" +dependencies = [ + "ambient-authority", + "rand 0.8.5", +] + +[[package]] +name = "cap-std" +version = "3.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6dc3090992a735d23219de5c204927163d922f42f575a0189b005c62d37549a" +dependencies = [ + "cap-primitives", + "io-extras", + "io-lifetimes", + "rustix 1.0.7", +] + +[[package]] +name = "cap-time-ext" +version = "3.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def102506ce40c11710a9b16e614af0cde8e76ae51b1f48c04b8d79f4b671a80" +dependencies = [ + "ambient-authority", + "cap-primitives", + "iana-time-zone", + "once_cell", + "rustix 1.0.7", + "winx", +] + [[package]] name = "cc" -version = "1.2.17" +version = "1.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98" dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -439,6 +571,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "cobs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" +dependencies = [ + "thiserror 2.0.17", +] + [[package]] name = "colorchoice" version = "1.0.4" @@ -480,6 +621,150 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "cpp_demangle" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2bb79cb74d735044c972aae58ed0aaa9a837e85b01106a54c39e42e97f62253" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-bforest" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e15d04a0ce86cb36ead88ad68cf693ffd6cda47052b9e0ac114bc47fd9cd23c4" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-bitset" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c6e3969a7ce267259ce244b7867c5d3bc9e65b0a87e81039588dfdeaede9f34" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-codegen" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c22032c4cb42558371cf516bb47f26cdad1819d3475c133e93c49f50ebf304e" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-bitset", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.14.5", + "log", + "regalloc2", + "rustc-hash", + "serde", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c904bc71c61b27fc57827f4a1379f29de64fe95653b620a3db77d59655eee0b8" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40180f5497572f644ce88c255480981ae2ec1d7bb4d8e0c0136a13b87a2f2ceb" + +[[package]] +name = "cranelift-control" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d132c6d0bd8a489563472afc171759da0707804a65ece7ceb15a8c6d7dd5ef" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d0d9618275474fbf679dd018ac6e009acbd6ae6850f6a67be33fb3b00b323" +dependencies = [ + "cranelift-bitset", + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-frontend" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fac41e16729107393174b0c9e3730fb072866100e1e64e80a1a963b2e484d57" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca20d576e5070044d0a72a9effc2deacf4d6aa650403189d8ea50126483944d" + +[[package]] +name = "cranelift-native" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dee82f3f1f2c4cba9177f1cc5e350fe98764379bcd29340caa7b01f85076c7" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + [[package]] name = "crossbeam-epoch" version = "0.9.18" @@ -495,6 +780,16 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "ctrlc" version = "3.4.6" @@ -557,6 +852,57 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dispatch2" version = "0.3.1" @@ -578,6 +924,24 @@ dependencies = [ "syn", ] +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "encoding_rs" version = "0.8.35" @@ -609,12 +973,35 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + [[package]] name = "fastrand" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +[[package]] +name = "fd-lock" +version = "4.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce92ff622d6dadf7349484f42c93271a0d49b7cc4d466a936405bacbe10aa78" +dependencies = [ + "cfg-if", + "rustix 1.0.7", + "windows-sys 0.59.0", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + [[package]] name = "findshlibs" version = "0.10.2" @@ -669,6 +1056,31 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs-set-times" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94e7099f6313ecacbe1256e8ff9d617b75d1bcb16a6fddef94866d225a01a14a" +dependencies = [ + "io-lifetimes", + "rustix 1.0.7", + "windows-sys 0.59.0", +] + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.31" @@ -720,18 +1132,40 @@ dependencies = [ ] [[package]] -name = "gcp_auth" -version = "0.12.3" +name = "fxhash" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf67f30198e045a039264c01fb44659ce82402d7771c50938beb41a5ac87733" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" dependencies = [ - "async-trait", - "base64", - "bytes", - "chrono", - "home", - "http 1.3.1", - "http-body-util", + "byteorder", +] + +[[package]] +name = "fxprof-processed-profile" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" +dependencies = [ + "bitflags", + "debugid", + "fxhash", + "serde", + "serde_json", +] + +[[package]] +name = "gcp_auth" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf67f30198e045a039264c01fb44659ce82402d7771c50938beb41a5ac87733" +dependencies = [ + "async-trait", + "base64 0.22.1", + "bytes", + "chrono", + "home", + "http 1.3.1", + "http-body-util", "hyper", "hyper-rustls", "hyper-util", @@ -746,6 +1180,16 @@ dependencies = [ "url", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -774,6 +1218,11 @@ name = "gimli" version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] [[package]] name = "h2" @@ -794,11 +1243,24 @@ dependencies = [ "tracing", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "foldhash 0.1.5", + "serde", +] [[package]] name = "hashbrown" @@ -959,7 +1421,7 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "futures-channel", "futures-util", @@ -1118,6 +1580,12 @@ dependencies = [ "syn", ] +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "idna" version = "1.0.3" @@ -1153,8 +1621,25 @@ checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", "hashbrown 0.15.2", + "serde", +] + +[[package]] +name = "io-extras" +version = "0.18.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2285ddfe3054097ef4b2fe909ef8c3bcd1ea52a8f0d274416caebeef39f04a65" +dependencies = [ + "io-lifetimes", + "windows-sys 0.59.0", ] +[[package]] +name = "io-lifetimes" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06432fb54d3be7964ecd3649233cddf80db2832f47fec34c01f65b3d9d774983" + [[package]] name = "ipnet" version = "2.11.0" @@ -1167,12 +1652,51 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "ittapi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b996fe614c41395cdaedf3cf408a9534851090959d90d54a535f675550b64b1" +dependencies = [ + "anyhow", + "ittapi-sys", + "log", +] + +[[package]] +name = "ittapi-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52f5385394064fa2c886205dba02598013ce83d3e92d33dbdc0c52fe0e7bf4fc" +dependencies = [ + "cc", +] + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.2", + "libc", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -1195,12 +1719,39 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "leb128" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cc46bac87ef8093eed6f272babb833b6443374399985ac8ed28471ee0918545" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "libc" version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e02f3bb43d335493c96bf3fd3a321600bf6bd07ed34bc64118e9293bdffea46c" +dependencies = [ + "libc", +] + [[package]] name = "libz-sys" version = "1.1.22" @@ -1213,6 +1764,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + [[package]] name = "linux-raw-sys" version = "0.9.3" @@ -1247,12 +1804,36 @@ version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + +[[package]] +name = "maybe-owned" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4" + [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "memfd" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad38eb12aea514a0466ea40a80fd8cc83637065948eb4a426e4aa46261175227" +dependencies = [ + "rustix 1.0.7", +] + [[package]] name = "metrics" version = "0.24.3" @@ -1381,7 +1962,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -1584,6 +2165,18 @@ name = "object" version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "crc32fast", + "hashbrown 0.15.2", + "indexmap", + "memchr", +] + +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" dependencies = [ "memchr", ] @@ -1692,6 +2285,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "pem-rfc7468" version = "1.0.0" @@ -1751,6 +2350,18 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" +[[package]] +name = "postcard" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -1784,6 +2395,28 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "psm" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645dbe486e346d9b5de3ef16ede18c26e6c70ad97418f4874b8b1889d6e761ea" +dependencies = [ + "ar_archive_writer", + "cc", +] + +[[package]] +name = "pulley-interpreter" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62d95f8575df49a2708398182f49a888cf9dc30210fb1fd2df87c889edcee75d" +dependencies = [ + "cranelift-bitset", + "log", + "sptr", + "wasmtime-math", +] + [[package]] name = "pyo3" version = "0.28.3" @@ -1959,6 +2592,26 @@ dependencies = [ "bitflags", ] +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "rdkafka" version = "0.37.0" @@ -2001,6 +2654,31 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom 0.2.15", + "libredox", + "thiserror 1.0.69", +] + +[[package]] +name = "regalloc2" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc06e6b318142614e4a48bc725abbf08ff166694835c43c9dae5a9009704639a" +dependencies = [ + "allocator-api2", + "bumpalo", + "hashbrown 0.15.2", + "log", + "rustc-hash", + "smallvec", +] + [[package]] name = "regex" version = "1.12.3" @@ -2042,7 +2720,7 @@ version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "encoding_rs", "futures-core", @@ -2086,7 +2764,7 @@ version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62e0021ea2c22aed41653bc7e1419abb2c97e038ff2c33d0e1309e49a97deec0" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "futures-channel", "futures-core", @@ -2157,6 +2835,8 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "wasmtime", + "wasmtime-wasi", ] [[package]] @@ -2165,6 +2845,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + [[package]] name = "rustc_version" version = "0.4.1" @@ -2174,6 +2860,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + [[package]] name = "rustix" version = "1.0.7" @@ -2183,10 +2882,20 @@ dependencies = [ "bitflags", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.9.3", "windows-sys 0.59.0", ] +[[package]] +name = "rustix-linux-procfs" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fc84bf7e9aa16c4f2c758f27412dc9841341e16aa682d9c7ac308fe3ee12056" +dependencies = [ + "once_cell", + "rustix 1.0.7", +] + [[package]] name = "rustls" version = "0.23.27" @@ -2307,6 +3016,10 @@ name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] [[package]] name = "sentry" @@ -2321,7 +3034,7 @@ dependencies = [ "sentry-actix", "sentry-backtrace", "sentry-contexts", - "sentry-core 0.48.1", + "sentry-core", "sentry-debug-images", "sentry-panic", "sentry-tracing", @@ -2339,7 +3052,7 @@ dependencies = [ "actix-web", "bytes", "futures-util", - "sentry-core 0.48.1", + "sentry-core", ] [[package]] @@ -2350,7 +3063,7 @@ checksum = "dc84c325ace9ca2388e510fe7d6672b5d60cd8b3bd0eb4bb4ee8314c323cd686" dependencies = [ "backtrace", "regex", - "sentry-core 0.48.1", + "sentry-core", ] [[package]] @@ -2363,23 +3076,10 @@ dependencies = [ "libc", "os_info", "rustc_version", - "sentry-core 0.48.1", + "sentry-core", "uname", ] -[[package]] -name = "sentry-core" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a75011ea1c0d5c46e9e57df03ce81f5c7f0a9e199086334a1f9c0a541e0826" -dependencies = [ - "once_cell", - "rand 0.8.5", - "sentry-types 0.32.3", - "serde", - "serde_json", -] - [[package]] name = "sentry-core" version = "0.48.1" @@ -2387,7 +3087,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f5abf20c42cb1593ec1638976e2647da55f79bccac956444c1707b6cce259a" dependencies = [ "rand 0.9.4", - "sentry-types 0.48.1", + "sentry-types", "serde", "serde_json", "url", @@ -2400,7 +3100,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b88bbe6a760d5724bb40689827e82e8db1e275947df2c59abe171bfc30bb671" dependencies = [ "findshlibs", - "sentry-core 0.48.1", + "sentry-core", ] [[package]] @@ -2410,7 +3110,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0260dcb52562b6a79ae7702312a26dba94b79fb5baee7301087529e5ca4e872e" dependencies = [ "sentry-backtrace", - "sentry-core 0.48.1", + "sentry-core", ] [[package]] @@ -2421,28 +3121,11 @@ checksum = "a1c035f3a0a8671ae1a231c5b457abb68b71acba2bf3054dab2a09a9d4ea487e" dependencies = [ "bitflags", "sentry-backtrace", - "sentry-core 0.48.1", + "sentry-core", "tracing-core", "tracing-subscriber", ] -[[package]] -name = "sentry-types" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4519c900ce734f7a0eb7aba0869dfb225a7af8820634a7dd51449e3b093cfb7c" -dependencies = [ - "debugid", - "hex", - "rand 0.8.5", - "serde", - "serde_json", - "thiserror 1.0.69", - "time", - "url", - "uuid", -] - [[package]] name = "sentry-types" version = "0.48.1" @@ -2472,7 +3155,7 @@ dependencies = [ "parking_lot", "rand 0.8.5", "rdkafka", - "sentry-core 0.32.3", + "sentry-core", "serde", "serde_json", "thiserror 1.0.69", @@ -2523,6 +3206,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2535,6 +3227,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -2544,6 +3247,15 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shellexpand" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" +dependencies = [ + "dirs", +] + [[package]] name = "shlex" version = "1.3.0" @@ -2579,6 +3291,9 @@ name = "smallvec" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +dependencies = [ + "serde", +] [[package]] name = "socket2" @@ -2601,8 +3316,14 @@ dependencies = [ ] [[package]] -name = "stable_deref_trait" -version = "1.2.0" +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" @@ -2670,6 +3391,22 @@ dependencies = [ "libc", ] +[[package]] +name = "system-interface" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4592f674ce18521c2a81483873a49596655b179f71c5e05d10c1fe66c78745" +dependencies = [ + "bitflags", + "cap-fs-ext", + "cap-std", + "fd-lock", + "io-lifetimes", + "rustix 0.38.44", + "windows-sys 0.59.0", + "winx", +] + [[package]] name = "target-lexicon" version = "0.13.5" @@ -2685,10 +3422,19 @@ dependencies = [ "fastrand", "getrandom 0.3.2", "once_cell", - "rustix", + "rustix 1.0.7", "windows-sys 0.59.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.69" @@ -2842,23 +3588,47 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" -version = "0.22.24" +version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap", + "serde", + "serde_spanned", "toml_datetime", + "toml_write", "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "tower" version = "0.5.2" @@ -2972,12 +3742,29 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "trait-variant" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70977707304198400eb4835a78f6a9f928bf41bba420deb8fdb175cd965d77a7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "try-lock" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typenum" +version = "1.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" + [[package]] name = "uname" version = "0.1.1" @@ -2999,6 +3786,12 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -3017,7 +3810,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dea7109cdcd5864d4eeb1b58a1648dc9bf520360d7af16ec26d0a9354bafcfc0" dependencies = [ - "base64", + "base64 0.22.1", "der", "log", "native-tls", @@ -3034,7 +3827,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e994ba84b0bd1b1b0cf92878b7ef898a5c1760108fe7b6010327e274917a808c" dependencies = [ - "base64", + "base64 0.22.1", "http 1.3.1", "httparse", "log", @@ -3208,6 +4001,376 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-encoder" +version = "0.221.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc8444fe4920de80a4fe5ab564fff2ae58b6b73166b89751f8c6c93509da32e5" +dependencies = [ + "leb128", + "wasmparser 0.221.3", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser 0.244.0", +] + +[[package]] +name = "wasmparser" +version = "0.221.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d06bfa36ab3ac2be0dee563380147a5b81ba10dd8885d7fbbc9eb574be67d185" +dependencies = [ + "bitflags", + "hashbrown 0.15.2", + "indexmap", + "semver", + "serde", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "indexmap", + "semver", +] + +[[package]] +name = "wasmprinter" +version = "0.221.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7343c42a97f2926c7819ff81b64012092ae954c5d83ddd30c9fcdefd97d0b283" +dependencies = [ + "anyhow", + "termcolor", + "wasmparser 0.221.3", +] + +[[package]] +name = "wasmtime" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11976a250672556d1c4c04c6d5d7656ac9192ac9edc42a4587d6c21460010e69" +dependencies = [ + "addr2line", + "anyhow", + "async-trait", + "bitflags", + "bumpalo", + "cc", + "cfg-if", + "encoding_rs", + "fxprof-processed-profile", + "gimli", + "hashbrown 0.14.5", + "indexmap", + "ittapi", + "libc", + "log", + "mach2", + "memfd", + "object 0.36.7", + "once_cell", + "paste", + "postcard", + "psm", + "pulley-interpreter", + "rayon", + "rustix 0.38.44", + "semver", + "serde", + "serde_derive", + "serde_json", + "smallvec", + "sptr", + "target-lexicon", + "trait-variant", + "wasm-encoder 0.221.3", + "wasmparser 0.221.3", + "wasmtime-asm-macros", + "wasmtime-cache", + "wasmtime-component-macro", + "wasmtime-component-util", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", + "wasmtime-math", + "wasmtime-slab", + "wasmtime-versioned-export-macros", + "wasmtime-winch", + "wat", + "windows-sys 0.59.0", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f178b0d125201fbe9f75beaf849bd3e511891f9e45ba216a5b620802ccf64f2" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-cache" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b1161c8f62880deea07358bc40cceddc019f1c81d46007bc390710b2fe24ffc" +dependencies = [ + "anyhow", + "base64 0.21.7", + "directories-next", + "log", + "postcard", + "rustix 0.38.44", + "serde", + "serde_derive", + "sha2", + "toml", + "windows-sys 0.59.0", + "zstd", +] + +[[package]] +name = "wasmtime-component-macro" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d74de6592ed945d0a602f71243982a304d5d02f1e501b638addf57f42d57dfaf" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn", + "wasmtime-component-util", + "wasmtime-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-component-util" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707dc7b3c112ab5a366b30cfe2fb5b2f8e6a0f682f16df96a5ec582bfe6f056e" + +[[package]] +name = "wasmtime-cranelift" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366be722674d4bf153290fbcbc4d7d16895cc82fb3e869f8d550ff768f9e9e87" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "cranelift-control", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "gimli", + "itertools", + "log", + "object 0.36.7", + "smallvec", + "target-lexicon", + "thiserror 1.0.69", + "wasmparser 0.221.3", + "wasmtime-environ", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-environ" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdadc1af7097347aa276a4f008929810f726b5b46946971c660b6d421e9994ad" +dependencies = [ + "anyhow", + "cpp_demangle", + "cranelift-bitset", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object 0.36.7", + "postcard", + "rustc-demangle", + "semver", + "serde", + "serde_derive", + "smallvec", + "target-lexicon", + "wasm-encoder 0.221.3", + "wasmparser 0.221.3", + "wasmprinter", + "wasmtime-component-util", +] + +[[package]] +name = "wasmtime-fiber" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccba90d4119f081bca91190485650730a617be1fff5228f8c4757ce133d21117" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "rustix 0.38.44", + "wasmtime-asm-macros", + "wasmtime-versioned-export-macros", + "windows-sys 0.59.0", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e7b61488a5ee00c35c8c22de707c36c0aecacf419a3be803a6a2ba5e860f56a" +dependencies = [ + "object 0.36.7", + "rustix 0.38.44", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec5e8552e01692e6c2e5293171704fed8abdec79d1a6995a0870ab190e5747d1" +dependencies = [ + "anyhow", + "cfg-if", + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "wasmtime-math" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29210ec2aa25e00f4d54605cedaf080f39ec01a872c5bd520ad04c67af1dde17" +dependencies = [ + "libm", +] + +[[package]] +name = "wasmtime-slab" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb5821a96fa04ac14bc7b158bb3d5cd7729a053db5a74dad396cd513a5e5ccf" + +[[package]] +name = "wasmtime-versioned-export-macros" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ff86db216dc0240462de40c8290887a613dddf9685508eb39479037ba97b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "wasmtime-wasi" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d1be69bfcab1bdac74daa7a1f9695ab992b9c8e21b9b061e7d66434097e0ca4" +dependencies = [ + "anyhow", + "async-trait", + "bitflags", + "bytes", + "cap-fs-ext", + "cap-net-ext", + "cap-rand", + "cap-std", + "cap-time-ext", + "fs-set-times", + "futures", + "io-extras", + "io-lifetimes", + "rustix 0.38.44", + "system-interface", + "thiserror 1.0.69", + "tokio", + "tracing", + "trait-variant", + "url", + "wasmtime", + "wiggle", + "windows-sys 0.59.0", +] + +[[package]] +name = "wasmtime-winch" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdbabfb8f20502d5e1d81092b9ead3682ae59988487aafcd7567387b7a43cf8f" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object 0.36.7", + "target-lexicon", + "wasmparser 0.221.3", + "wasmtime-cranelift", + "wasmtime-environ", + "winch-codegen", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8358319c2dd1e4db79e3c1c5d3a5af84956615343f9f89f4e4996a36816e06e6" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "wit-parser", +] + +[[package]] +name = "wast" +version = "35.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" +dependencies = [ + "leb128", +] + +[[package]] +name = "wast" +version = "244.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2e7b9f9e23311275920e3d6b56d64137c160cf8af4f84a7283b36cfecbf4acb" +dependencies = [ + "bumpalo", + "leb128fmt", + "memchr", + "unicode-width", + "wasm-encoder 0.244.0", +] + +[[package]] +name = "wat" +version = "1.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf35b87ed352f9ab6cd0732abde5a67dd6153dfd02c493e61459218b19456fa" +dependencies = [ + "wast 244.0.0", +] + [[package]] name = "web-sys" version = "0.3.77" @@ -3227,6 +4390,48 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "wiggle" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b9af35bc9629c52c261465320a9a07959164928b4241980ba1cf923b9e6751d" +dependencies = [ + "anyhow", + "async-trait", + "bitflags", + "thiserror 1.0.69", + "tracing", + "wasmtime", + "wiggle-macro", +] + +[[package]] +name = "wiggle-generate" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cf267dd05673912c8138f4b54acabe6bd53407d9d1536f0fadb6520dd16e101" +dependencies = [ + "anyhow", + "heck", + "proc-macro2", + "quote", + "shellexpand", + "syn", + "witx", +] + +[[package]] +name = "wiggle-macro" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c5c473d4198e6c2d377f3809f713ff0c110cab88a0805ae099a82119ee250c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wiggle-generate", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3243,12 +4448,39 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winch-codegen" +version = "29.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f849ef2c5f46cb0a20af4b4487aaa239846e52e2c03f13fa3c784684552859c" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "thiserror 1.0.69", + "wasmparser 0.221.3", + "wasmtime-cranelift", + "wasmtime-environ", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -3456,13 +4688,23 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winnow" -version = "0.7.4" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" dependencies = [ "memchr", ] +[[package]] +name = "winx" +version = "0.36.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f3fd376f71958b862e7afb20cfe5a22830e1963462f3a17f49d82a6c1d1f42d" +dependencies = [ + "bitflags", + "windows-sys 0.59.0", +] + [[package]] name = "wit-bindgen-rt" version = "0.39.0" @@ -3472,6 +4714,36 @@ dependencies = [ "bitflags", ] +[[package]] +name = "wit-parser" +version = "0.221.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "896112579ed56b4a538b07a3d16e562d101ff6265c46b515ce0c701eef16b2ac" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser 0.221.3", +] + +[[package]] +name = "witx" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e366f27a5cabcddb2706a78296a40b8fcc451e1a6aba2fc1d94b4a01bdaaef4b" +dependencies = [ + "anyhow", + "log", + "thiserror 1.0.69", + "wast 35.0.2", +] + [[package]] name = "write16" version = "1.0.0" @@ -3576,3 +4848,31 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.16+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/sentry_streams/Cargo.toml b/sentry_streams/Cargo.toml index 464d407c..4b0ed1e5 100644 --- a/sentry_streams/Cargo.toml +++ b/sentry_streams/Cargo.toml @@ -23,6 +23,8 @@ metrics = "0.24.0" metrics-exporter-dogstatsd = "0.9.0" rand = "0.8" sentry = "0.48.1" +wasmtime = { version = "29.0.0", default-features = true, features = ["component-model"] } +wasmtime-wasi = "29.0.0" [lib] name = "rust_streams" diff --git a/sentry_streams/sentry_streams/adapters/arroyo/rust_arroyo.py b/sentry_streams/sentry_streams/adapters/arroyo/rust_arroyo.py index ac3ae370..38ebcccb 100644 --- a/sentry_streams/sentry_streams/adapters/arroyo/rust_arroyo.py +++ b/sentry_streams/sentry_streams/adapters/arroyo/rust_arroyo.py @@ -62,6 +62,7 @@ Source, StreamSink, StreamSource, + WasmProcessor, ) from sentry_streams.pipeline.window import MeasurementUnit from sentry_streams.rust_streams import ( @@ -386,6 +387,9 @@ def map(self, step: Map[Any, Any], stream: Route) -> Route: """ Builds a map operator for the platform the adapter supports. """ + if isinstance(step, WasmProcessor): + return self._wasm_processor(step, stream) + assert ( stream.source in self.__consumers ), f"Stream starting at source {stream.source} not found when adding a map" @@ -439,6 +443,23 @@ def flat_map(self, step: FlatMap[Any, Any], stream: Route) -> Route: logger.info(f"Adding flatMap: {step.name} to pipeline") raise NotImplementedError + def _wasm_processor(self, step: WasmProcessor, stream: Route) -> Route: + self.__close_chain(stream) + assert ( + stream.source in self.__consumers + ), f"Stream starting at source {stream.source} not found when adding WasmProcessor" + + step_config: Mapping[str, Any] = self.steps_config.get(step.name, {}) + step.override_config(step_config) + step.validate() + + route = RustRoute(stream.source, stream.waypoints) + logger.info(f"Adding WasmProcessor: {step.name} to pipeline (module={step.module_path})") + self.__consumers[stream.source].add_step( + RuntimeOperator.WasmProcessor(route, step.module_path) + ) + return stream + def filter(self, step: Filter[Any], stream: Route) -> Route: """ Builds a filter operator for the platform the adapter supports. diff --git a/sentry_streams/sentry_streams/adapters/stream_adapter.py b/sentry_streams/sentry_streams/adapters/stream_adapter.py index f034771b..0a584ae4 100644 --- a/sentry_streams/sentry_streams/adapters/stream_adapter.py +++ b/sentry_streams/sentry_streams/adapters/stream_adapter.py @@ -31,6 +31,7 @@ Source, Step, StepType, + WasmProcessor, ) from sentry_streams.pipeline.window import MeasurementUnit @@ -173,6 +174,7 @@ def __init__(self, runtime_adapter: StreamAdapter[StreamT, StreamSinkT]): def translate_step( self, step: Step, stream: Optional[StreamT] = None ) -> Mapping[str, Union[StreamT, StreamSinkT]]: + step_name = step.name if isinstance(step, ComplexStep): overrides = self.adapter.complex_step_override() @@ -183,7 +185,6 @@ def translate_step( assert hasattr(step, "step_type") step_type = step.step_type - if step_type is StepType.SOURCE: assert isinstance(step, Source) return {step_name: self.adapter.source(step)} @@ -193,7 +194,8 @@ def translate_step( return {step_name: self.adapter.sink(step, stream)} elif step_type is StepType.MAP: - assert isinstance(step, Map) and stream is not None + # TODO: This is bad. Do not merge with this. + assert isinstance(step, (Map, WasmProcessor)) and stream is not None return {step_name: self.adapter.map(step, stream)} elif step_type is StepType.FLAT_MAP: diff --git a/sentry_streams/sentry_streams/deployment_config/wasm_processor.yaml b/sentry_streams/sentry_streams/deployment_config/wasm_processor.yaml new file mode 100644 index 00000000..93a8987d --- /dev/null +++ b/sentry_streams/sentry_streams/deployment_config/wasm_processor.yaml @@ -0,0 +1,16 @@ +env: {} + +pipeline: + adapter_config: + arroyo: + write_healthcheck: true + segments: + - steps_config: + myinput: + starts_segment: true + bootstrap_servers: ["127.0.0.1:9092"] + wasm: + module_path: /Users/filippopacifici/code/streams/examples/wasm_guest/dist/plugin.wasm + mysink: + bootstrap_servers: ["127.0.0.1:9092"] + topic: processed-profiles diff --git a/sentry_streams/sentry_streams/examples/wasm_processor.py b/sentry_streams/sentry_streams/examples/wasm_processor.py new file mode 100644 index 00000000..c5ae0dcb --- /dev/null +++ b/sentry_streams/sentry_streams/examples/wasm_processor.py @@ -0,0 +1,16 @@ +from sentry_streams.pipeline.pipeline import ( + StreamSink, + WasmProcessor, + streaming_source, +) + +pipeline = streaming_source(name="myinput", stream_name="ingest-metrics") + +( + pipeline.apply( + WasmProcessor( + "wasm", + module_path="/Users/filippopacifici/code/streams/examples/wasm_guest/dist/plugin.wasm", + ) + ).sink(StreamSink("mysink", stream_name="processed-profiles")) +) diff --git a/sentry_streams/sentry_streams/pipeline/__init__.py b/sentry_streams/sentry_streams/pipeline/__init__.py index fe28502e..eca61740 100644 --- a/sentry_streams/sentry_streams/pipeline/__init__.py +++ b/sentry_streams/sentry_streams/pipeline/__init__.py @@ -11,6 +11,7 @@ Reducer, Serializer, StreamSink, + WasmProcessor, branch, streaming_source, ) @@ -28,6 +29,7 @@ "Reducer", "Serializer", "StreamSink", + "WasmProcessor", "branch", "streaming_source", ] diff --git a/sentry_streams/sentry_streams/pipeline/pipeline.py b/sentry_streams/sentry_streams/pipeline/pipeline.py index 4f13fec6..e9357637 100644 --- a/sentry_streams/sentry_streams/pipeline/pipeline.py +++ b/sentry_streams/sentry_streams/pipeline/pipeline.py @@ -423,6 +423,27 @@ def validate(self) -> None: TransformStep = FunctionTransform +@dataclass +class WasmProcessor(Transform[bytes, bytes]): + """ + A transform step that delegates message processing to a WASM component + loaded from ``module_path``. Input and output are raw bytes messages. + + Only supported by the Rust ``rust_arroyo`` adapter. + """ + + module_path: str + step_type: StepType = StepType.MAP + + def override_config(self, loaded_config: Mapping[str, Any]) -> None: + if loaded_config.get("module_path"): + self.module_path = str(loaded_config["module_path"]) + + def validate(self) -> None: + if not self.module_path: + raise ValueError("WasmProcessor.module_path must be non-empty") + + @dataclass class Map(FunctionTransform[TIn, TOut], Generic[TIn, TOut]): """ diff --git a/sentry_streams/sentry_streams/rust_streams.pyi b/sentry_streams/sentry_streams/rust_streams.pyi index 47c01511..7cedb168 100644 --- a/sentry_streams/sentry_streams/rust_streams.pyi +++ b/sentry_streams/sentry_streams/rust_streams.pyi @@ -143,6 +143,8 @@ class RuntimeOperator: ) -> Self: ... @classmethod def PythonAdapter(cls, route: Route, delegate_Factory: RustOperatorFactory) -> Self: ... + @classmethod + def WasmProcessor(cls, route: Route, module_path: str) -> Self: ... class ArroyoConsumer: def __init__( diff --git a/sentry_streams/src/lib.rs b/sentry_streams/src/lib.rs index b8819a2b..091c56fd 100644 --- a/sentry_streams/src/lib.rs +++ b/sentry_streams/src/lib.rs @@ -24,6 +24,7 @@ mod store_sinks; mod time_helpers; mod transformer; mod utils; +mod wasm_processor; mod watermark; #[doc(hidden)] diff --git a/sentry_streams/src/operators.rs b/sentry_streams/src/operators.rs index a368be15..14fd1024 100644 --- a/sentry_streams/src/operators.rs +++ b/sentry_streams/src/operators.rs @@ -3,6 +3,7 @@ use crate::broadcaster::Broadcaster; use crate::header_filter_step::build_header_int_filter; use crate::kafka_config::PyKafkaProducerConfig; use crate::python_operator::PythonAdapter; +use crate::wasm_processor::WasmProcessor as WasmProcessorStrategy; use crate::routers::build_router; use crate::routes::{Route, RoutedValue}; use crate::sinks::StreamSink; @@ -117,6 +118,12 @@ pub enum RuntimeOperator { route: Route, delegate_factory: Py, }, + /// Delegates message processing to a WASM component loaded from ``module_path``. + #[pyo3(name = "WasmProcessor")] + WasmProcessor { + route: Route, + module_path: String, + }, } pub fn build( @@ -229,6 +236,14 @@ pub fn build( let factory = traced_with_gil!(|py| { delegate_factory.clone_ref(py) }); Box::new(PythonAdapter::new(route.clone(), factory, next)) } + RuntimeOperator::WasmProcessor { + route, + module_path, + } => Box::new(WasmProcessorStrategy::new( + route.clone(), + module_path.clone(), + next, + )), RuntimeOperator::Broadcast { route, downstream_routes, diff --git a/sentry_streams/src/wasm_processor.rs b/sentry_streams/src/wasm_processor.rs new file mode 100644 index 00000000..a80aad58 --- /dev/null +++ b/sentry_streams/src/wasm_processor.rs @@ -0,0 +1,475 @@ +//! Arroyo processing strategy that delegates message processing to a WASM guest +//! component via wasmtime. + +use crate::messages::{ + into_pyraw, PyStreamingMessage, RawMessage, RoutedValuePayload, Watermark, WatermarkMessage, +}; +use crate::routes::{Route, RoutedValue}; +use crate::utils::traced_with_gil; +use anyhow::{Context, Result}; +use sentry_arroyo::processing::strategies::{ + merge_commit_request, CommitRequest, ProcessingStrategy, StrategyError, SubmitError, +}; +use sentry_arroyo::types::{Message, Partition, Topic}; +use std::collections::{BTreeMap, VecDeque}; +use std::path::Path; +use std::sync::Mutex; +use std::time::Duration; +use tracing::{debug, error, info, warn}; +use wasmtime::component::{Component, Linker, ResourceTable}; +use wasmtime::{Config, Engine, Store}; +use wasmtime_wasi::{WasiCtx, WasiCtxBuilder, WasiView}; + +wasmtime::component::bindgen!({ + world: "plugin", + path: "wit", + async: false, +}); + +struct HostCtx { + table: ResourceTable, + wasi: WasiCtx, + step_name: String, +} + +impl WasiView for HostCtx { + fn table(&mut self) -> &mut ResourceTable { + &mut self.table + } + + fn ctx(&mut self) -> &mut WasiCtx { + &mut self.wasi + } +} + +impl sentry_streams::processor::log::Host for HostCtx { + fn debug(&mut self, message: String) { + debug!(step = %self.step_name, "{message}"); + } + + fn info(&mut self, message: String) { + info!(step = %self.step_name, "{message}"); + } + + fn warn(&mut self, message: String) { + warn!(step = %self.step_name, "{message}"); + } + + fn error(&mut self, message: String) { + error!(step = %self.step_name, "{message}"); + } +} + +type WitMessage = exports::sentry_streams::processor::processor::Message; +type WitWatermark = exports::sentry_streams::processor::processor::Watermark; +type WitOutput = exports::sentry_streams::processor::processor::Output; + +fn committable_to_wit(committable: &BTreeMap) -> Vec<((String, u64), u64)> { + committable + .iter() + .map(|(partition, offset)| { + ( + (partition.topic.as_str().to_string(), partition.index as u64), + *offset, + ) + }) + .collect() +} + +fn committable_from_wit(committable: &[((String, u64), u64)]) -> BTreeMap { + committable + .iter() + .map(|((topic, index), offset)| { + ( + Partition { + topic: Topic::new(topic), + index: *index as u16, + }, + *offset, + ) + }) + .collect() +} + +fn watermark_to_wit(watermark: &Watermark) -> WitWatermark { + WitWatermark { + committable: committable_to_wit(&watermark.committable), + timestamp: watermark.timestamp as f64, + last_message_time: watermark.last_message_time.unwrap_or(0.0), + } +} + +fn wit_watermark_to_rust(wm: &WitWatermark) -> Watermark { + Watermark::with_last_message_time( + committable_from_wit(&wm.committable), + wm.timestamp as u64, + Some(wm.last_message_time), + ) +} + +fn extract_wit_message(payload: &RoutedValuePayload) -> Result { + match payload { + RoutedValuePayload::PyStreamingMessage(PyStreamingMessage::RawMessage { content }) => { + traced_with_gil!(|py| { + let raw = content.bind(py).borrow(); + Ok(WitMessage { + headers: raw.headers.clone(), + timestamp: raw.timestamp, + payload: raw.payload.clone(), + }) + }) + } + RoutedValuePayload::PyStreamingMessage(PyStreamingMessage::PyAnyMessage { content }) => { + traced_with_gil!(|py| { + let bound = content.bind(py); + let payload = bound.borrow(); + let bytes: Vec = match payload.payload.extract::>(py) { + Ok(b) => b, + Err(_) => match payload.payload.extract::<&[u8]>(py) { + Ok(b) => b.to_vec(), + Err(e) => { + return Err(anyhow::anyhow!( + "WasmProcessor requires bytes payload, got non-bytes PyAnyMessage: {e}" + )); + } + }, + }; + Ok(WitMessage { + headers: payload.headers.clone(), + timestamp: payload.timestamp, + payload: bytes, + }) + }) + } + RoutedValuePayload::WatermarkMessage(..) => { + anyhow::bail!("expected streaming message, got watermark"); + } + } +} + +fn wit_message_to_routed(route: &Route, msg: &WitMessage, schema: Option) -> RoutedValue { + let raw = RawMessage { + payload: msg.payload.clone(), + headers: msg.headers.clone(), + timestamp: msg.timestamp, + schema, + }; + let py_msg = traced_with_gil!(|py| { + PyStreamingMessage::RawMessage { + content: into_pyraw(py, raw).expect("into_pyraw"), + } + }); + RoutedValue { + route: route.clone(), + payload: RoutedValuePayload::PyStreamingMessage(py_msg), + } +} + +fn wit_output_to_message( + route: &Route, + output: WitOutput, + schema: Option, +) -> Message { + match output { + WitOutput::Msg(msg) => { + let routed = wit_message_to_routed(route, &msg, schema); + Message::new_any_message(routed, BTreeMap::new()) + } + WitOutput::Wm(wm) => { + let watermark = wit_watermark_to_rust(&wm); + let committable = watermark.committable.clone(); + let routed = RoutedValue { + route: route.clone(), + payload: RoutedValuePayload::WatermarkMessage(WatermarkMessage::Watermark( + watermark, + )), + }; + Message::new_any_message(routed, committable) + } + } +} + +struct WasmGuest { + store: Store, + bindings: Plugin, +} + +impl WasmGuest { + fn new(module_path: &str, step_name: &str) -> Result { + let path = Path::new(module_path); + if !path.exists() { + anyhow::bail!("WASM module not found at {}", module_path); + } + + let mut config = Config::new(); + config.wasm_component_model(true); + let engine = Engine::new(&config)?; + + let component = Component::from_file(&engine, path) + .with_context(|| format!("loading WASM component from {}", module_path))?; + + let mut linker = Linker::new(&engine); + wasmtime_wasi::add_to_linker_sync(&mut linker).context("linking WASI Preview 2")?; + Plugin::add_to_linker(&mut linker, |state: &mut HostCtx| state) + .context("linking plugin host imports")?; + + let wasi = WasiCtxBuilder::new().build(); + let host = HostCtx { + table: ResourceTable::new(), + wasi, + step_name: step_name.to_string(), + }; + let mut store = Store::new(&engine, host); + let bindings = Plugin::instantiate(&mut store, &component, &linker) + .context("instantiating WASM plugin")?; + + Ok(Self { store, bindings }) + } + + fn call_submit(&mut self, msg: WitMessage) -> Result<()> { + self.bindings + .sentry_streams_processor_processor() + .call_submit(&mut self.store, &msg) + .context("guest submit")?; + Ok(()) + } + + fn call_submit_watermark(&mut self, wm: WitWatermark) -> Result<()> { + self.bindings + .sentry_streams_processor_processor() + .call_submit_watermark(&mut self.store, &wm) + .context("guest submit_watermark")?; + Ok(()) + } + + fn call_poll(&mut self) -> Result> { + let outputs = self + .bindings + .sentry_streams_processor_processor() + .call_poll(&mut self.store) + .context("guest poll")?; + Ok(outputs.unwrap_or_default()) + } +} + +/// Single-threaded WASM processor strategy. +pub struct WasmProcessor { + route: Route, + schema: Option, + guest: Mutex, + next_strategy: Box>, + pending: VecDeque>, + commit_request_carried_over: Option, +} + +impl WasmProcessor { + pub fn new( + route: Route, + module_path: String, + next_strategy: Box>, + ) -> Self { + let step_name = route + .waypoints + .last() + .cloned() + .unwrap_or_else(|| route.source.clone()); + let guest = WasmGuest::new(&module_path, &step_name) + .unwrap_or_else(|e| panic!("failed to initialize WASM guest: {e:#}")); + Self { + route, + schema: None, + guest: Mutex::new(guest), + next_strategy, + pending: VecDeque::new(), + commit_request_carried_over: None, + } + } + + fn forward_pending(&mut self) -> Result<(), StrategyError> { + while let Some(msg) = self.pending.pop_front() { + let commit_request = self.next_strategy.poll()?; + self.commit_request_carried_over = + merge_commit_request(self.commit_request_carried_over.take(), commit_request); + match self.next_strategy.submit(msg) { + Err(SubmitError::MessageRejected( + sentry_arroyo::processing::strategies::MessageRejected { message }, + )) => { + self.pending.push_front(message); + break; + } + Err(SubmitError::InvalidMessage(invalid_message)) => { + return Err(invalid_message.into()); + } + Ok(()) => {} + } + } + Ok(()) + } + + fn poll_guest_and_forward(&mut self) -> Result<(), StrategyError> { + let outputs = { + let mut guest = self + .guest + .lock() + .expect("WasmProcessor guest mutex poisoned"); + guest.call_poll().map_err(|e| { + StrategyError::Other(Box::new(std::io::Error::other(e.to_string()))) + })? + }; + for output in outputs { + let msg = wit_output_to_message(&self.route, output, self.schema.clone()); + self.pending.push_back(msg); + } + self.forward_pending() + } +} + +impl ProcessingStrategy for WasmProcessor { + fn submit(&mut self, message: Message) -> Result<(), SubmitError> { + if self.route != message.payload().route { + return self.next_strategy.submit(message); + } + + let payload = &message.payload().payload; + if let RoutedValuePayload::WatermarkMessage(WatermarkMessage::Watermark(watermark)) = + payload + { + let wit_wm = watermark_to_wit(watermark); + let mut guest = self + .guest + .lock() + .expect("WasmProcessor guest mutex poisoned"); + if let Err(e) = guest.call_submit_watermark(wit_wm) { + tracing::error!("WASM guest submit_watermark failed: {e:#}"); + panic!("WASM guest submit_watermark failed: {e:#}"); + } + return Ok(()); + } + if let RoutedValuePayload::WatermarkMessage(WatermarkMessage::PyWatermark(..)) = payload { + panic!("PyWatermark should not be submitted to WasmProcessor"); + } + + let wit_msg = extract_wit_message(payload).unwrap_or_else(|e| { + tracing::error!("WasmProcessor message conversion failed: {e:#}"); + panic!("WasmProcessor message conversion failed: {e:#}"); + }); + let mut guest = self + .guest + .lock() + .expect("WasmProcessor guest mutex poisoned"); + if let Err(e) = guest.call_submit(wit_msg) { + tracing::error!("WASM guest submit failed: {e:#}"); + panic!("WASM guest submit failed: {e:#}"); + } + Ok(()) + } + + fn poll(&mut self) -> Result, StrategyError> { + self.poll_guest_and_forward()?; + let commit_request = self.next_strategy.poll()?; + Ok(merge_commit_request( + self.commit_request_carried_over.take(), + commit_request, + )) + } + + fn terminate(&mut self) { + self.next_strategy.terminate(); + } + + fn join(&mut self, timeout: Option) -> Result, StrategyError> { + self.poll_guest_and_forward()?; + let commit_request = self.next_strategy.join(timeout)?; + Ok(merge_commit_request( + self.commit_request_carried_over.take(), + commit_request, + )) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::fake_strategy::FakeStrategy; + use crate::messages::{RoutedValuePayload, Watermark}; + use crate::testutils::{build_routed_value, make_committable}; + use pyo3::IntoPyObjectExt; + use std::sync::{Arc, Mutex}; + + fn fixture_path() -> Option { + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/wasm_passthrough.wasm"); + if path.exists() { + Some(path.to_string_lossy().into_owned()) + } else { + None + } + } + + fn make_test_watermark(route: Route) -> Message { + let committable = make_committable(2, 0); + let watermark = Watermark::new(committable.clone(), 42); + let routed_watermark = RoutedValue { + route, + payload: RoutedValuePayload::WatermarkMessage(WatermarkMessage::Watermark(watermark)), + }; + Message::new_any_message(routed_watermark, committable) + } + + #[test] + fn test_wasm_passthrough_message() { + let Some(module_path) = fixture_path() else { + eprintln!("skipping test_wasm_passthrough_message: fixture not built"); + return; + }; + crate::testutils::initialize_python(); + traced_with_gil!(|py| { + let submitted_messages = Arc::new(Mutex::new(Vec::new())); + let submitted_watermarks = Arc::new(Mutex::new(Vec::new())); + let next_step = FakeStrategy::new( + submitted_messages.clone(), + submitted_watermarks.clone(), + false, + ); + + let route = Route::new("source1".to_string(), vec!["wasm".to_string()]); + let mut processor = + WasmProcessor::new(route.clone(), module_path, Box::new(next_step)); + + let routed = build_routed_value( + py, + b"hello".to_vec().into_py_any(py).unwrap(), + "source1", + vec!["wasm".to_string()], + ); + let committable = make_committable(1, 0); + let message = Message::new_any_message(routed, committable); + processor.submit(message).unwrap(); + processor.poll().unwrap(); + + let messages = submitted_messages.lock().unwrap(); + assert_eq!(messages.len(), 1); + }); + } + + #[test] + fn test_wasm_passthrough_watermark() { + let Some(module_path) = fixture_path() else { + eprintln!("skipping test_wasm_passthrough_watermark: fixture not built"); + return; + }; + crate::testutils::initialize_python(); + let submitted_messages = Arc::new(Mutex::new(Vec::new())); + let submitted_watermarks = Arc::new(Mutex::new(Vec::new())); + let next_step = FakeStrategy::new(submitted_messages, submitted_watermarks.clone(), false); + + let route = Route::new("source1".to_string(), vec!["wasm".to_string()]); + let mut processor = WasmProcessor::new(route.clone(), module_path, Box::new(next_step)); + + let watermark = make_test_watermark(route); + processor.submit(watermark).unwrap(); + processor.poll().unwrap(); + + assert!(!submitted_watermarks.lock().unwrap().is_empty()); + } +} diff --git a/sentry_streams/tests/fixtures/wasm_passthrough.wasm b/sentry_streams/tests/fixtures/wasm_passthrough.wasm new file mode 100644 index 00000000..0407534b Binary files /dev/null and b/sentry_streams/tests/fixtures/wasm_passthrough.wasm differ diff --git a/sentry_streams/tests/pipeline/test_wasm_processor.py b/sentry_streams/tests/pipeline/test_wasm_processor.py new file mode 100644 index 00000000..b665d93a --- /dev/null +++ b/sentry_streams/tests/pipeline/test_wasm_processor.py @@ -0,0 +1,24 @@ +import pytest + +from sentry_streams.pipeline.pipeline import StreamSink, WasmProcessor, streaming_source + + +def test_wasm_processor_validate_requires_module_path() -> None: + step = WasmProcessor("wasm", module_path="") + with pytest.raises(ValueError, match="module_path"): + step.validate() + + +def test_wasm_processor_override_config_module_path() -> None: + step = WasmProcessor("wasm", module_path="default.wasm") + step.override_config({"module_path": "override.wasm"}) + assert step.module_path == "override.wasm" + + +def test_wasm_processor_pipeline_builds() -> None: + pipeline = streaming_source("myinput", "events") + ( + pipeline.apply(WasmProcessor("wasm", module_path="tests/fixtures/wasm_passthrough.wasm")) + .sink(StreamSink("mysink", stream_name="out")) + ) + assert "wasm" in pipeline.steps diff --git a/sentry_streams/tests/wasm_passthrough_guest/.cargo/config.toml b/sentry_streams/tests/wasm_passthrough_guest/.cargo/config.toml new file mode 100644 index 00000000..44634ff0 --- /dev/null +++ b/sentry_streams/tests/wasm_passthrough_guest/.cargo/config.toml @@ -0,0 +1,5 @@ +[build] +target = "wasm32-wasip2" + +[target.wasm32-wasip2] +rustflags = ["-C", "target-feature=+bulk-memory"] diff --git a/sentry_streams/tests/wasm_passthrough_guest/Cargo.lock b/sentry_streams/tests/wasm_passthrough_guest/Cargo.lock new file mode 100644 index 00000000..c5786f02 --- /dev/null +++ b/sentry_streams/tests/wasm_passthrough_guest/Cargo.lock @@ -0,0 +1,806 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "auditable-serde" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7bf8143dfc3c0258df908843e169b5cc5fcf76c7718bd66135ef4a9cd558c5" +dependencies = [ + "semver", + "serde", + "serde_json", + "topological-sort", +] + +[[package]] +name = "bitflags" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "simd-adler32" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "spdx" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e17e880bafaeb362a7b751ec46bdc5b61445a188f80e0606e68167cd540fa3" +dependencies = [ + "smallvec", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "wasm-encoder" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bb72f02e7fbf07183443b27b0f3d4144abf8c114189f2e088ed95b696a7822" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce1ef0faabbbba6674e97a56bee857ccddf942785a336c8b47b42373c922a91d" +dependencies = [ + "anyhow", + "auditable-serde", + "flate2", + "indexmap", + "serde", + "serde_derive", + "serde_json", + "spdx", + "url", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasm-passthrough-guest" +version = "0.1.0" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasmparser" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f51cad774fb3c9461ab9bccc9c62dfb7388397b5deda31bf40e8108ccd678b2" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "wit-bindgen" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10fb6648689b3929d56bbc7eb1acf70c9a42a29eb5358c67c10f54dbd5d695de" +dependencies = [ + "wit-bindgen-rt", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92fa781d4f2ff6d3f27f3cc9b74a73327b31ca0dc4a3ef25a0ce2983e0e5af9b" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db52a11d4dfb0a59f194c064055794ee6564eb1ced88c25da2cf76e50c5621" +dependencies = [ + "bitflags", + "futures", + "once_cell", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0809dc5ba19e2e98661bf32fc0addc5a3ca5bf3a6a7083aa6ba484085ff3ce" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad19eec017904e04c60719592a803ee5da76cb51c81e3f6fbf9457f59db49799" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "635c3adc595422cbf2341a17fb73a319669cc8d33deed3a48368a841df86b676" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf445ed5157046e4baf56f9138c124a0824d4d1657e7204d71886ad8ce2fc11" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "yoke" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/sentry_streams/tests/wasm_passthrough_guest/Cargo.toml b/sentry_streams/tests/wasm_passthrough_guest/Cargo.toml new file mode 100644 index 00000000..d54ecc1b --- /dev/null +++ b/sentry_streams/tests/wasm_passthrough_guest/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "wasm-passthrough-guest" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wit-bindgen = "0.41.0" diff --git a/sentry_streams/tests/wasm_passthrough_guest/Makefile b/sentry_streams/tests/wasm_passthrough_guest/Makefile new file mode 100644 index 00000000..c7265e28 --- /dev/null +++ b/sentry_streams/tests/wasm_passthrough_guest/Makefile @@ -0,0 +1,5 @@ +.PHONY: build + +build: + CARGO_TARGET_DIR=./target cargo build --release + cp target/wasm32-wasip2/release/wasm_passthrough_guest.wasm ../fixtures/wasm_passthrough.wasm diff --git a/sentry_streams/tests/wasm_passthrough_guest/README.md b/sentry_streams/tests/wasm_passthrough_guest/README.md new file mode 100644 index 00000000..0bd42368 --- /dev/null +++ b/sentry_streams/tests/wasm_passthrough_guest/README.md @@ -0,0 +1,10 @@ +# WASM passthrough test guest + +Minimal Rust component used as `tests/fixtures/wasm_passthrough.wasm` for `WasmProcessor` unit tests. +It does not embed Python (unlike the `componentize-py` guest under `examples/wasm_guest/`). + +## Build + +```bash +make -C tests/wasm_passthrough_guest build +``` diff --git a/sentry_streams/tests/wasm_passthrough_guest/src/lib.rs b/sentry_streams/tests/wasm_passthrough_guest/src/lib.rs new file mode 100644 index 00000000..f48c8214 --- /dev/null +++ b/sentry_streams/tests/wasm_passthrough_guest/src/lib.rs @@ -0,0 +1,44 @@ +//! Minimal passthrough guest for host unit tests (no embedded Python). + +wit_bindgen::generate!({ + world: "plugin", + path: "../../wit", +}); + +use std::cell::RefCell; + +struct Component; + +thread_local! { + static PENDING: RefCell> = + RefCell::new(Vec::new()); +} + +impl exports::sentry_streams::processor::processor::Guest for Component { + fn submit(msg: exports::sentry_streams::processor::processor::Message) { + PENDING.with(|p| { + p.borrow_mut() + .push(exports::sentry_streams::processor::processor::Output::Msg(msg)); + }); + } + + fn submit_watermark(wm: exports::sentry_streams::processor::processor::Watermark) { + PENDING.with(|p| { + p.borrow_mut() + .push(exports::sentry_streams::processor::processor::Output::Wm(wm)); + }); + } + + fn poll() -> Option> { + PENDING.with(|p| { + let mut pending = p.borrow_mut(); + if pending.is_empty() { + None + } else { + Some(std::mem::take(&mut *pending)) + } + }) + } +} + +export!(Component); diff --git a/sentry_streams/uv.lock b/sentry_streams/uv.lock index cce7bd35..f1ffb3e4 100644 --- a/sentry_streams/uv.lock +++ b/sentry_streams/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 2 requires-python = ">=3.11" [[package]] @@ -897,7 +897,7 @@ wheels = [ [[package]] name = "sentry-streams" -version = "0.0.52" +version = "0.0.55" source = { editable = "." } dependencies = [ { name = "click" }, diff --git a/sentry_streams/wit/processor.wit b/sentry_streams/wit/processor.wit new file mode 100644 index 00000000..ab9d4710 --- /dev/null +++ b/sentry_streams/wit/processor.wit @@ -0,0 +1,36 @@ +package sentry-streams:processor; + +interface log { + debug: func(message: string); + info: func(message: string); + warn: func(message: string); + error: func(message: string); +} + +interface processor { + record message { + headers: list>>, + timestamp: f64, + payload: list, + } + + record watermark { + committable: list, u64>>, + timestamp: f64, + last-message-time: f64, + } + + variant output { + msg(message), + wm(watermark), + } + + submit: func(msg: message); + submit-watermark: func(wm: watermark); + poll: func() -> option>; +} + +world plugin { + import log; + export processor; +}