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:
emit_term
to emit events to stdout.
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
supportswasm32-unknown-unknown
, but notwasm32v1-none
.emit_web
to emit events via theconsole
API.emit_web
supports bothwasm32-unknown-unknown
andwasm32v1-none
.
You can also treat WebAssembly like any other embedded target. See Instrumenting embedded applications for more details.