tracing-axiom 0.1.0

The tracing layer for shipping traces to Axiom
Documentation

tracing-axiom

CI crates.io docs.rs License

The tracing layer for shipping traces to Axiom.

Install

Add the following to your Cargo.toml:

[dependencies]
tracing-axiom = "0.1"

Quickstart

Expose an API token with ingest permission under AXIOM_TOKEN and initialize and shut down the exporter like this:

#[tokio::main]
async fn main() {
    tracing_axiom::init(); // or try_init() to handle errors
    say_hello();
    tracing_axiom::shutdown();
}

#[tracing::instrument]
pub fn say_hello() {
    tracing::info!("Hello, world!");
}

Note: Due to a limitation of an underlying library, events outside of a span are not recorded.

Kitchen Sink Full Configuration

Here's a full configuration:

use opentelemetry::sdk::trace;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
  let trace_config = trace::Config::default()
    .with_max_events_per_span(42);

  tracing_axiom::builder()
    .with_token("xaat-123456789")
    .with_url("https://my-axiom.example.org")
    .with_service_name("my-service")
    .with_trace_config(trace_config)
    .try_init()?;
  Ok(())
}

If you want to use other layers next to Axiom in your tracing configuration, check out the fmt example.

Under The Hood

This library uses OpenTelemetry to send data to Axiom. You can set this up yourself if you want to, but make sure to use the OTLP format with the http transport and set the endpoint to https://cloud.axiom.co/api/v1/traces. A good entrypoint is the opentelemetry-otlp crate.

Features

The following are a list of Cargo features that can be enabled or disabled:

  • default-tls (enabled by default): Provides TLS support to connect over HTTPS.
  • native-tls: Enables TLS functionality provided by native-tls.
  • rustls-tls: Enables TLS functionality provided by rustls.

License

Licensed under either of

at your option.