Skip to content

Telemetry for Rust, without the ceremony

Structured logs with one line of setup. OpenTelemetry traces, metrics and logs when you want them, without changing your code.
Cargo.toml
[dependencies]
oxtel = "0.4"
tracing = "0.1"
examples/logs.rs
fn main() -> Result<(), oxtel::Error> {
// Text on a terminal, JSON anywhere else. Keep the guard alive.
let _logs = oxtel::init()?;
// Fields are structured: in JSON, each is a key of its own.
tracing::info!(user.id = 42, plan = "team", "signed in");
// Lines inside a span carry its fields and its trace id, so every line
// about one request can be found together.
let request = tracing::info_span!("request", http.route = "/orders", order.id = 7);
let _entered = request.enter();
tracing::warn!(attempt = 2, "payment provider slow; retrying");
Ok(())
}
Standard error
{"timestamp":"2026-11-20T20:26:48.537496Z","level":"INFO","target":"oxtel","message":"log lines: standard error, as JSON; traces, metrics and logs: not exported (set OTEL_EXPORTER_OTLP_ENDPOINT to send them to a collector)"}
{"timestamp":"2026-11-20T20:26:48.537538Z","level":"INFO","target":"logs","message":"signed in","user.id":42,"plan":"team"}
{"timestamp":"2026-11-20T20:26:48.537580Z","level":"WARN","target":"logs","message":"payment provider slow; retrying","trace_id":"409c20c1faeb1cb209081fdf8cba692e","span_id":"16048a549a6a6719","http.route":"/orders","order.id":7,"attempt":2}

The first line is oxtel’s own. It says, in plain words, where each kind of telemetry goes, and here that nothing leaves the program. After it come the program’s lines. Each field is a key of its own, and lines inside a span carry its fields and its trace id, so you can find everything one request did. CI runs the example and checks it still prints these lines.

  1. Logs. oxtel::init(), as above. Text on a terminal, JSON anywhere else, and RUST_LOG chooses how much.

  2. Requests. For a web service, one layer on an axum router gives every request a span, a log line and duration metrics:

    examples/web.rs
    let app = Router::new()
    .route("/orders/{id}", get(order))
    .layer(oxtel_tower::HttpServerLayer::new());
    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await?;
    tracing::info!("listening on http://127.0.0.1:3000");
    axum::serve(listener, app)
    // On Ctrl-C, finish the requests in flight and let main return, so
    // the guard is dropped and sends what's pending. Without this,
    // Ctrl-C ends the process at once and the last few seconds of
    // telemetry are lost.
    .with_graceful_shutdown(async {
    let _ = tokio::signal::ctrl_c().await;
    })
    .await?;
  3. Send it somewhere. Point oxtel at an OpenTelemetry Collector or any backend that takes OTLP. The code doesn’t change:

    Terminal window
    OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 OTEL_SERVICE_NAME=shop cargo run

Get started goes through each step.

Your code doesn't change

Rust code already records spans, logs and metrics with tracing and metrics. oxtel turns them into log lines, OTLP for collectors and backends, and Prometheus scrapes. There’s no second API to learn, and no bridge between two.

One line per framework

A layer for axum and tower services, a wrapper for MCP servers and clients, one line for SQLite, PostgreSQL and sqlx. Each records what the OpenTelemetry conventions name, under their names.

Nothing is sent until you say so

With no settings, you get log lines and nothing else. Set OTEL_EXPORTER_OTLP_ENDPOINT and traces, metrics and logs go there, with no rebuild. A program that only wants logs can leave out every HTTP and TLS crate.

Failures are explained

When sending fails, oxtel says so at once, with where it was sending, why it failed and what to check. Then it counts quietly, and says when sending works again.

Measured against the official OpenTelemetry Rust SDK with tracing-opentelemetry, doing the same work on the same machine, in October 2026. Lower is better.

WhatoxtelOfficial stack
A span with 3 fields258 ns671 ns
A span that isn’t sampled84 ns589 ns
A counter, with attributes on each call13 ns23 ns
A counter, 8 threads on one series0.4–0.6 ns20–65 ns
CPU per span, sent over OTLP at 40,000 spans/s5.3 µs7.2 µs

In a burst, oxtel exports 1.9 times as many spans a second, with 2.5 times less CPU per span, and both stay within 1.5 MiB. The benchmarks say how each was measured and made fair, with every number and how to reproduce them.

  • An OpenTelemetry Collector decodes oxtel’s traces, metrics and logs on every change, over protobuf and JSON, and CI compares what it got with what was sent. The conformance tests list what’s checked.
  • Prometheus’s own checker, promtool, reads oxtel’s /metrics page, and the Collector’s Prometheus receiver scrapes it.
  • The names come from the conventions. OpenTelemetry’s Weaver generates them from a pinned conventions release, and CI checks they match.
  • Input from outside is fuzzed. On every change, CI fuzzes the parsers of trace context and baggage headers, configuration files, and the lists in environment variables: none may panic, and accepted trace context and baggage must come back unchanged from a round trip. Property tests check the same of the trace context, baggage and resource attribute parsers.