https://github.com/emit-rs/emit
Developer-first diagnostics for Rust applications
https://github.com/emit-rs/emit
logging metrics observability rust tracing
Last synced: 4 months ago
JSON representation
Developer-first diagnostics for Rust applications
- Host: GitHub
- URL: https://github.com/emit-rs/emit
- Owner: emit-rs
- License: apache-2.0
- Created: 2016-03-17T00:09:31.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2025-12-05T21:26:59.000Z (7 months ago)
- Last Synced: 2025-12-07T14:41:43.899Z (7 months ago)
- Topics: logging, metrics, observability, rust, tracing
- Language: Rust
- Homepage: https://emit-rs.io
- Size: 5.04 MB
- Stars: 170
- Watchers: 3
- Forks: 4
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
emit
[](https://github.com/emit-rs/emit/actions/workflows/all.yml)
## Developer-first diagnostics for Rust applications
`emit` is a stable, complete, and capable framework for adding structured diagnostics to your Rust applications with a simple, powerful data model and an expressive syntax inspired by [Message Templates](https://messagetemplates.org). `emit`'s guiding design principle is low ceremony, low cognitive-load.
This readme covers just enough to give you an idea of what `emit` is. For a proper treatment, see:
- [the guide](https://emit-rs.io).
- [a set of task-oriented examples](https://github.com/emit-rs/emit/tree/main/examples).
- [the API docs](https://docs.rs/emit/1.17.2/emit/index.html).
## Getting started
Add `emit` to your `Cargo.toml`:
```toml
[dependencies.emit]
version = "1.17.2"
# Optional
features = ["serde"]
# Optional
[dependencies.emit_term]
version = "1.17.2"
# Optional
[dependencies.serde]
version = "1"
features = ["derive"]
```
Initialize `emit` in your `main.rs` and start peppering diagnostics throughout your application:
```rust
fn main() {
// Configure `emit` to write events to the console
let rt = emit::setup()
.emit_to(emit_term::stdout())
.init();
// Your app code goes here
{
// `emit` supports fully structured data
// See the `#[emit::as_serde]` attribute in our `greet` function below
#[derive(serde::Serialize)]
struct User<'a> {
id: u32,
name: &'a str,
}
// Annotate functions with `#[emit::span]` to produce traces
#[emit::span("Greet {user}", #[emit::as_serde] user)]
fn greet(user: &User) {
// Use `emit::info` to produce log events
emit::info!("Hello, {user: user.name}!");
}
greet(&User { id: 1, name: "Rust" });
}
// Flush any remaining events before `main` returns
rt.blocking_flush(std::time::Duration::from_secs(5));
}
```

`emit` has a capable syntax for writing events that's different from the standard `format!` trait. You can read more about it in [the guide](https://emit-rs.io/reference/templates.html).
## Tracing
`emit` can produce trace data that's compatible with OpenTelemetry and standard tracing tools, like Zipkin.

The above screenshot was generated by [this example application](https://github.com/emit-rs/emit/tree/main/examples/trace_zipkin).
See [the guide](https://emit-rs.io/producing-events/tracing.html) for details.
## Metrics
`emit` can produce metric data that's compatible with OpenTelemetry and standard metric tools, like Prometheus.

The above screenshot was generated by [this example application](https://github.com/emit-rs/emit/tree/main/examples/metric_prometheus).
See [the guide](https://emit-rs.io/producing-events/metrics.html) for details.
## Quick debugging
`emit` has a `dbg!` macro like the standard library's which you can use for quick-and-dirty debugging:
```rust
#[derive(Debug)]
pub struct User<'a> {
id: u32,
name: &'a str,
}
emit::dbg!(&User { id: 1, name: "Rust" });
```
See [the guide](https://emit-rs.io/producing-events/quick-debugging.html) for details.
## Stability
`emit` has a complete and stable API that's suitable for production environments.