#tracing #service #performance #send

tracing-actions-otlp

tracing-actions extension that sends action traces to an opentelemetry server

5 unstable releases

0.3.1 Jun 23, 2023
0.3.0 Jun 23, 2023
0.2.0 Jun 21, 2023
0.1.2 Jun 13, 2023
0.1.0 May 9, 2023

#364 in Profiling

Download history 77/week @ 2023-12-17 21/week @ 2023-12-31 17/week @ 2024-01-07 28/week @ 2024-01-14 29/week @ 2024-01-21 37/week @ 2024-01-28 86/week @ 2024-02-04 14/week @ 2024-02-11 84/week @ 2024-02-18 42/week @ 2024-02-25 45/week @ 2024-03-03 45/week @ 2024-03-10 65/week @ 2024-03-17 1/week @ 2024-03-24 88/week @ 2024-03-31

204 downloads per month

Apache-2.0

79KB
1.5K SLoC

tracing-actions-otlp

An extension for tracing-actions that consumes action traces and vends them to an opentelemetry traces server.

tracing-actions is under development and some material details may change. Every effort will be made to ensure that breaking changes fail at compile time rather than runtime, so you know what rules change when.

How this relates to opentelemetry_otlp

In short, it doesn't.

tracing-actions is less general than tracing-subscriber and opentelemetry_otlp. It tracks the latest upstreams - pr's are welcome and promptly addressed. Your service will not be pinned to an old version of tonic.


lib.rs:

A bridge between Rust tracing and opentelemetry traces.

tracing-actions-otlp is a tracing-actions sink for sending traces in opentelemetry trace format to a listening server. That server might be an opentelemetry collector on your NAS, or a service like Honeycomb or Lightstep.

Your batches are built up on your heap from ActionSpans and then sent. There's not a background timer in here to flush your pipeline. If you need to make sure traces are not sitting in a batch for too long you can call drain_batch:

fn periodic_job(otlp_sink: &tracing_actions_otlp::OtlpActionTraceSink) {
    otlp_sink.drain_batch();
}

Examples

Lightstep

use tracing_actions;
use tracing_actions_otlp;

// First, we set up our trace sink.
let batch_size = 1024;
let secure = true;
let otlp_sink = tracing_actions_otlp::OtlpActionTraceSink::new(
    "https://ingest.lightstep.com:443",
    tracing_actions_otlp::header_interceptor(vec![
        ("lightstep-access-token", std::env::var("token").unwrap_or_else(|_| "none".to_string())),
    ]),
    batch_size,
    secure,
    tracing_actions_otlp::OtlpAttributes {
        service_name: "docs-rs example".to_string(),
        other_attributes: None,
    }
).expect("should be able to make otlp sink");


// Next, we configure a subscriber (just like any usage of `tracing-actions`)
let level = "debug".parse().unwrap();
let k_logging_subscriber = tracing_actions::ActionTraceSubscriber::new(
    level,
    otlp_sink,
    tracing_actions::span_constructor::LazySpanCache::default(),
);

// Finally, we install the subscriber.
tracing::subscriber::set_global_default(k_logging_subscriber)
    .expect("I should be able to set the global trace subscriber");

// Now the rest of your application will emit ActionSpans as opentelemetry spans to Lightstep.

Dependencies

~16–29MB
~504K SLoC