Skip to main content

Crate veilid_tracing_wasm

Crate veilid_tracing_wasm 

Source
Expand description

§wasm-tracing

Leverages tracing to profile wasm performance via console.

§Usage

For the simplest out of the box set-up, you can simply set veilid_tracing_wasm 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();

    veilid_tracing_wasm::set_as_global_default();

    Ok(())
}

§Features

FeatureFunction
mark-with-rayon-thread-indexLogs the rayon worker thread’s index within its current pool.

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.

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.