Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured Logging #379

Open
Michael-F-Bryan opened this issue Nov 12, 2021 · 1 comment
Open

Structured Logging #379

Michael-F-Bryan opened this issue Nov 12, 2021 · 1 comment
Labels
area - codegen The code gets generated when compiling a Rune category - enhancement New feature or request effort - easy This should be pretty simple

Comments

@Michael-F-Bryan
Copy link
Contributor

For telemetry, we'd like a Rune to tell us when certain events happen (start of proc block X, etc.) so we can pass that on information to the user.

One way we can do this is by switching from the log crate to something that supports structured logging (e.g. tracing). Then we just need to set up "well-known" messages that the runtime can look out for and translate into telemetry events (e.g. by wrapping the call in a span). Then it's just a case of wiring up a Subscriber that passes these events to _debug().

cc: @jacekpie

@Michael-F-Bryan Michael-F-Bryan added category - enhancement New feature or request area - codegen The code gets generated when compiling a Rune labels Nov 12, 2021
@Michael-F-Bryan
Copy link
Contributor Author

Michael-F-Bryan commented Nov 12, 2021

At the moment we generate a pipeline lambda like this:

let pipeline = move || {
    let _guard = hotg_runicos_base_wasm::PipelineGuard::default();
    log::debug!("Reading data from \"audio\"");
    let audio_0: Tensor<i16> = audio.generate();
    log::debug!("Executing \"fft\"");
    let fft_0: Tensor<u32> = fft.transform(audio_0.clone());
    log::debug!("Executing \"noise_filtering\"");
    let noise_filtering_0: Tensor<i8> = noise_filtering.transform(fft_0.clone());
    log::debug!("Executing \"model\"");
    let model_0: Tensor<i8> = model.transform(noise_filtering_0.clone());
    log::debug!("Executing \"most_confident\"");
    let most_confident_0: Tensor<u32> = most_confident.transform(model_0.clone());
    log::debug!("Executing \"label\"");
    let label_0: Tensor<alloc::borrow::Cow<'static, str>> =
        label.transform(most_confident_0.clone());
    log::debug!("Sending results to the \"serial\" output");
    serial.consume(label_0.clone());
};

Switching to structured logging would mean we generate this:

let pipeline = move || {
    let pipeline_span = tracing::span!(target: "pipeline").entered();

    let span = tracing::span!(target: "stage", Level::INFO, name = "audio", node_type = "capability").entered();
    let audio_0: Tensor<i16> = audio.generate();
    drop(span);

    let span = tracing::span!(target: "stage", Level::INFO, name = "fft", node_type = "proc-block").entered();
    let fft_0: Tensor<u32> = fft.transform(audio_0.clone());
    drop(span);

    let span = tracing::span!(target: "stage", Level::INFO, name = "noise_filtering", node_type = "proc-block").entered();
    let noise_filtering_0: Tensor<i8> = noise_filtering.transform(fft_0.clone());
    drop(span);

    let span = tracing::span!(target: "stage", Level::INFO, name = "model", node_type = "model").entered();
    let model_0: Tensor<i8> = model.transform(noise_filtering_0.clone());
    drop(span);

    let span = tracing::span!(target: "stage", Level::INFO, name = "most_confident", node_type = "proc-block").entered();
    let most_confident_0: Tensor<u32> = most_confident.transform(model_0.clone());
    drop(span);

    let span = tracing::span!(target: "stage", Level::INFO, name = "label", node_type = "proc-block").entered();
    let label_0: Tensor<alloc::borrow::Cow<'static, str>> = label.transform(most_confident_0.clone());
    drop(span);

    let span = tracing::span!(target: "stage", Level::INFO, name = "serial", node_type = "out").entered();
    serial.consume(label_0.clone());
    drop(span);
};

Note: We are notified whenever we enter/exit a Span, so that can be used to derive timing information.

@Michael-F-Bryan Michael-F-Bryan added the effort - easy This should be pretty simple label Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area - codegen The code gets generated when compiling a Rune category - enhancement New feature or request effort - easy This should be pretty simple
Projects
None yet
Development

No branches or pull requests

1 participant