THIS IS A PERSONAL PROJECT. IT IS STILL IN DEVELOPMENT. USE ON YOUR OWN RISK.
An exporter exports trace, metric and log data in the OTLP format.
| protocol | trace | metric | log | | ---------------- | -------- | -------- | -------- | | grpc(tonic) | ✓ | ☐ | ☐ | | grpc(grpcio)[^1] | ✓ | ☐ | ☐ | | http/protobuf | ✓ | ☐ | ☐ | | http/json | blocking | ☐ | ☐ |
| dep | std | provided ca | client key | | ------- | -------- | ----------- | ---------- | | tonic | not test | not test | not test | | grpcio | not test | not test | not test | | reqwest | not test | not test | not test |
grpc
, we can use install_simple
simply. It uses future_executors
.```rust use opentelemetryapi::{trace::Tracer, global, KeyValue}; use opentelemetrysdk::Resource;
pub async fn main() { let tracer = match otlpexporter::newpipeline() .trace() .withenv() .withtracerconfig( opentelemetrysdk::trace::config().withresource(Resource::new(vec![KeyValue::new( opentelemetrysemanticconventions::resource::SERVICENAME, "otlp-exporter-example", )])), ) .install_simple() { Ok(tracer) => tracer, Err(e) => { println!("error: {e}"); return; } };
tracer.in_span("otlp-exporter trace example", |_cx| {});
global::shutdown_tracer_provider();
} ```
http/protocol
and http/json
, it depends on reqwest
which depends on tokio
. So, we must use install_batch
with Tokio
.```rust use opentelemetryapi::{trace::Tracer, global, KeyValue}; use opentelemetrysdk::{runtime::Tokio, Resource};
pub async fn main() { let tracer = match otlpexporter::newpipeline() .trace() .withenv() .withtracerconfig( opentelemetrysdk::trace::config().withresource(Resource::new(vec![KeyValue::new( opentelemetrysemanticconventions::resource::SERVICENAME, "otlp-exporter-example", )])), ) .install_batch(Tokio) { Ok(tracer) => tracer, Err(e) => { println!("error: {e}"); return; } };
tracer.in_span("otlp-exporter trace example", |_cx| {});
global::shutdown_tracer_provider();
} ```