27 releases

0.11.0-alpha.6 Jun 28, 2024
0.10.0 Jul 4, 2016
0.3.2 Mar 24, 2016
0.1.0 Aug 8, 2015

#50 in Debugging

Download history 54/week @ 2024-03-30 24/week @ 2024-04-06 4/week @ 2024-04-13 4/week @ 2024-04-20 3/week @ 2024-04-27 16/week @ 2024-05-04 10/week @ 2024-05-11 2/week @ 2024-05-18 1/week @ 2024-05-25 138/week @ 2024-06-01 344/week @ 2024-06-08 79/week @ 2024-06-15 96/week @ 2024-06-22 25/week @ 2024-06-29 67/week @ 2024-07-06

308 downloads per month
Used in 7 crates

MIT/Apache

305KB
6K SLoC

emit

all

Current docs

Developer-first diagnostics

emit is a framework for manually instrumenting Rust applications with an expressive syntax inspired by Message Templates.

emit represents all diagnostics as events; a combination of timestamp or timespan, template, and properties. Traditional log records, spans in a distributed trace, and metric samples are all represented as events. Having a unified model of all these signals means you can always capture your diagnostics in one way or another.

[dependencies.emit]
version = "0.11.0-alpha.6"

[dependencies.emit_term]
version = "0.11.0-alpha.6"
use std::time::Duration;

fn main() {
    let rt = emit::setup()
        .emit_to(emit_term::stdout())
        .init();

    greet("Rust");

    rt.blocking_flush(Duration::from_secs(5));
}

#[emit::span("Greet {user}")]
fn greet(user: &str) {
    emit::info!("Hello, {user}!");
}

The output of running the above program

Current status

This is alpha-level software. It implements a complete framework but has almost no tests and needs a lot more documentation.

Getting started

See the examples directory and emit documentation to get started with emit.

Where can I send my diagnostics?

Diagnostics produced by emit are sent to an emitter. This repository currently implements the following emitters:

  • emit_term for writing human-readable output to the console.
  • emit_file for writing JSON or another machine-readable format to rolling files.
  • emit_otlp for sending diagnostics to an OpenTelemetry compatible collector.
  • emit_opentelemetry for integrating emit into an application using the OpenTelemetry SDK for its diagnostics.

Dependencies

~0.6–1.3MB
~30K SLoC