6 releases (breaking)

0.6.1 Mar 19, 2024
0.5.0 Nov 30, 2023
0.4.0 Jun 19, 2023
0.3.0 Aug 29, 2022
0.1.0 Aug 26, 2022

#196 in Debugging

Download history 17/week @ 2023-12-22 28/week @ 2023-12-29 6/week @ 2024-01-05 23/week @ 2024-01-12 66/week @ 2024-01-19 53/week @ 2024-01-26 73/week @ 2024-02-02 98/week @ 2024-02-09 72/week @ 2024-02-16 98/week @ 2024-02-23 23/week @ 2024-03-01 3/week @ 2024-03-08 156/week @ 2024-03-15 27/week @ 2024-03-22 67/week @ 2024-03-29 27/week @ 2024-04-05

277 downloads per month

MIT/Apache

28KB
390 lines

tracing-axiom: The official Rust tracing layer for Axiom tracing-axiom: The official Rust tracing layer for Axiom

docs.rs build crates.io License

Axiom unlocks observability at any scale.

  • Ingest with ease, store without limits: Axiom’s next-generation datastore enables ingesting petabytes of data with ultimate efficiency. Ship logs from Kubernetes, AWS, Azure, Google Cloud, DigitalOcean, Nomad, and others.
  • Query everything, all the time: Whether DevOps, SecOps, or EverythingOps, query all your data no matter its age. No provisioning, no moving data from cold/archive to “hot”, and no worrying about slow queries. All your data, all. the. time.
  • Powerful dashboards, for continuous observability: Build dashboards to collect related queries and present information that’s quick and easy to digest for you and your team. Dashboards can be kept private or shared with others, and are the perfect way to bring together data from different sources

For more information check out the official documentation.

Usage

Add the following to your Cargo.toml:

[dependencies]
tracing-axiom = "0.5"

Create a dataset in Axiom and export the name as AXIOM_DATASET. Then create an API token with ingest permission into that dataset in the Axiom settings and export it as AXIOM_TOKEN.

Now you can set up tracing in one line like this:

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    tracing_axiom::init()?;
    say_hello();

    // Ensure that the tracing provider is shutdown correctly
    opentelemetry::global::shutdown_tracer_provider();

    Ok(())
}

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

For further examples, head over to the examples directory.

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

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.

FAQ & Troubleshooting

How do I log traces to the console in addition to Axiom?

You can use this library to get a tracing-subscriber::layer and combine it with other layers, for example one that prints traces to the console. You can see how this works in the fmt example.

My test function hangs indefinitely

This can happen when you use #[tokio::test] as that defaults to a single-threaded executor, but the opentelemetry crate requires a multi-thread executor.

License

Licensed under either of

at your option.

Dependencies

~11–26MB
~407K SLoC