I'd like to log the hostcalls a wasm module running on wasmtime is making. I can see there's a call hook API that I can use to invoke a function whenever a hostcall is invoked. But I can't see a way to determine the name of the host function invoked. Is it possible to get the name of the host function invoked within the function provided to call_hook
or an alternative API that would expose this information?
It's true that the import name is not available to the call hook and I don't think there's other means by which you can get this right now. That being said I don't think this is something that we can easily support because functions are hooked up as values to one another which means that there's not necessarily a defined name in the embedding api for a particular function.
Is this something possible you can inject into the host functions themselves or are you looking to primarily hook this at the engine level? One thing we might be able to do is to auto-inject hooks at the Linker
layer rather than the Store
layer
I don't think we can inject this into the host functions themselves. Right now, it's mostly calls out to WASI functions that we want to log rather than logging proprietary calls that we've implemented ourselves. I'm not sure if there's a clean way for us to implement a decorator pattern that would include our logging with how the WASI calls are wired up in wasmtime. Doing it at the engine level would be one approach that helps get around that.
Sorry forgot to respond earlier today, mind opening an issue to track this? There are a few ways we could go about this and having something on file as a place to discuss would be good
I've opened this Github issue to track this.
Jeff Charles has marked this topic as resolved.
Last updated: Nov 22 2024 at 16:03 UTC