Crate tracing_axiom
source ·Expand description
Send traces to Axiom with a single line.
§Example
In a project that uses Tokio and
tracing run cargo add tracing-axiom
and
configure it like this:
use tracing_subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt as _, Registry};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let axiom_layer = tracing_axiom::default("doctests")?; // Set AXIOM_DATASET and AXIOM_TOKEN in your env!
Registry::default().with(axiom_layer).init();
say_hello();
Ok(())
}
#[tracing::instrument]
pub fn say_hello() {
tracing::info!("Hello, world!");
}
The example above gets the Axiom API token from the AXIOM_TOKEN
env and
the dataset name from AXIOM_DATASET
. For more advanced configuration, see builder()
.
Structs§
- Builder for creating a tracing tracer, a layer or a subscriber that sends traces to Axiom via the
OpenTelemetry
protocol. The API token is read from theAXIOM_TOKEN
environment variable. The dataset name is read from theAXIOM_DATASET
environment variable. The URL defaults to Axiom Cloud whose URL ishttps://cloud.axiom.co
but can be overridden by setting theAXIOM_URL
environment variable for testing purposes
Enums§
- The error type for this crate.
Functions§
- Create a new
Builder
with no defaults set. - Create a new
Builder
and set the configuratuin from the environment. - Creates a default
OpenTelemetryLayer
with aTracer
that sends traces to Axiom.