The tracing layer for shipping traces to Axiom.
Add the following to your Cargo.toml
:
toml
[dependencies]
tracing-axiom = "0.3"
Expose an API token with ingest permission under AXIOM_TOKEN
and initialize
the exporter like this:
```rust
async fn main() { let guard = tracingaxiom::init(); // or tryinit() to handle errors sayhello(); }
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.
Here's a full configuration:
```rust use opentelemetry::sdk::trace;
async fn main() -> Result<(), Box
let guard = tracingaxiom::builder() .withtoken("xaat-123456789") .withurl("https://my-axiom.example.org") .withservicename("my-service") .withtraceconfig(traceconfig) .tryinit()?; Ok(()) } ```
If you want to use other layers next to Axiom in your tracing configuration, check out the fmt example.
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.
The following are a list of Cargo features that can be enabled or disabled:
native-tls
.rustls
.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.
init
, try_init
and layer
all return a Guard
, which will shutdown the
tracer provider on drop.
Logs won't be sent to Axiom if the Guard
is dropped prematurely.
If you have a function that sets up observability, return the Guard
up to the
main func to prevent it from being dropped.
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.
Licensed under either of
at your option.