Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Instrumenting WebAssembly

You can use emit in WebAssembly applications.

When WebAssembly support requires bindings to JavaScript APIs, crates will use a web Cargo feature that enables them.

If you're targeting WASI via the wasm32-wasip1 or wasm32-wasip2 targets, you shouldn't need to do anything special to make emit work, but not all emitters support WASI yet. The following emitters are compatible with WASI:

If you're targeting NodeJS or the web via the wasm32-unknown-unknown target, you can use emit's default enabled web Cargo feature, and any emitters that support a web Cargo feature of their own. That includes:

  • emit_otlp to emit events to an OpenTelemetry-compatible service. Note that in the browser you may need to configure CORS. See the docs for more details. emit_otlp supports wasm32-unknown-unknown, but not wasm32v1-none.
  • emit_web to emit events via the console API. emit_web supports both wasm32-unknown-unknown and wasm32v1-none.

You can also treat WebAssembly like any other embedded target. See Instrumenting embedded applications for more details.