Crate wasm_tracing

Source
Expand description

§wasm-tracing

Leverages tracing to proilfe wasm performance via console.

§Usage

For the simplest out of the box set-up, you can simply set wasm_tracing as your default tracing Subscriber in wasm_bindgen(start)

We have this declared in our ./src/lib.rs

use console_error_panic_hook;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn start() -> Result<(), JsValue> {
    // print pretty errors in wasm https://github.com/rustwasm/console_error_panic_hook
    // This is not needed for tracing_wasm to work, but it is a common tool for getting proper error line numbers for panics.
    console_error_panic_hook::set_once();

    wasm_tracing::set_as_global_default();

    Ok(())
}

Modules§

prelude
Re-exports of common types

Structs§

WasmLayer
Implements tracing_subscriber::layer::Layer which uses wasm_bindgen for marking and measuring via window.performance and window.console
WasmLayerConfig
Configuration parameters for the WasmLayer.

Enums§

ConsoleConfig
Determines how the web console should behave

Functions§

set_as_global_default
Set the global default recorder with tracing::subscriber::set_global_default. Panics if the WasmLayer cannot be constructed.
set_as_global_default_with_config
Given a WasmLayerConfig, set WASM to be the default layer for a Registry.
try_set_as_global_default
Set WASM to be the default layer for a Registry via tracing::subscriber::set_global_default.