Allgemein

Open Source Whamm: Use WebAssembly To Monitor and Fix Running Apps

Open Source Whamm: Use WebAssembly To Monitor and Fix Running Apps

Whamm is designed to allow users to instrument their WebAssembly (or Wasm) applications with a programming language or code, or let them program their WebAssembly applications in modules directly. With it, they can debug and monitor their applications within WebAssembly modules.

If you have Homebrew already installed, updates will be installed automatically as Whamm is installed. This command downloads and installs Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Download the latest release for your platform from the Releases page.

Clone the Whamm repo:

git clone https://github.com/ejrgilbert/whamm.git

Rust is required, and even if you don’t know Rust very well — I certainly don’t — once it’s installed, you can play around with Whamm. I downloaded and installed Rust on my Mac by accessing it at this trusted site with this command (which I highly recommend doing):

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

I then ran these commands to make sure that Rust is available for all terminal sessions. This is necessary because Rust is incredibly complicated to use, is extremely logical, or both:

grep -q ".cargo/env" ~/.zshrc 2>/dev/null || echo 'source "$HOME/.cargo/env"' >> ~/.zshrc && echo "Added to ~/.zshrc - will work in new terminals"

Build the source code:

cargo build --release

When I first prompted Whamm to build the source code, I received an error message:

The fact that I had not installed the WebAssembly target was the source of the error. So, I installed the WebAssembly target as a fix:

cd ~/whamm && rustup target add wasm32-wasip1

I attempted to build the source code again:

cargo build --release

And success!

Add the built binary to your PATH. This binary should be located at:

target/release/whamm

Once you do that, nifty things you can do with Whamm and Wasm are listed neatly. You can use the command line interface (CLI), as indicated, as reference for all of the various commands on offer. These include — as indicated — monitoring or manipulating a program’s execution. I won’t go into what application monitoring means here, but it’s the beginning of adding more observability for Wasm applications. Using Whamm for this is usual for debugging, collecting and analyzing logs and metrics as the application runs, instead of just statically.

Once you find the source of the error, so-called “manipulating execution” allows you to fix errors by changing the “dynamic behavior,” or in other words, fixing what is wrong. You can change the application state by “manipulating an application’s dynamic behavior,” as the documentation states.

Basic Test

You can run a basic test to make sure that the Whamm binary is on your path and working as expected by running the following command:

whamm --help

This is what you should see:

For reasons I don’t yet know, my initial test of Whamm functionality did not work, as shown above. But then I went through all the commands above, including reinstalling the Rust target and rebuilding or reinstalling the WebAssembly target, and reinstalling Cargo for Rust to make sure it was available in all terminals. So it was likely a Rust problem, though I’m not sure. In any case, I went through most of the commands above and eventually succeeded.

Now you’re ready to begin your Whamm journey for instrumenting, rebuilding, correcting, monitoring and debugging code. Hats off to the creator — and now, I assume, main maintainer — Elizabeth Gilbert, a doctoral candidate at Carnegie Mellon University, for this great project.

Although I would argue that this looks simple and is relatively simple to use, it’s an amazing build and represents a lot of hard work and engineering dedication. Definitely another win for the WebAssembly community, as well as for observability, debugging and the ability to update applications dynamically with Wasm.

The post Open Source Whamm: Use WebAssembly To Monitor and Fix Running Apps appeared first on The New Stack.