14 breaking releases

0.15.0 Feb 25, 2024
0.14.0 Nov 6, 2023
0.13.0 Jul 30, 2023
0.12.0 Mar 26, 2023
0.3.0 Nov 10, 2020

#45 in Debugging

Download history 232800/week @ 2023-12-04 208359/week @ 2023-12-11 190173/week @ 2023-12-18 61222/week @ 2023-12-25 151399/week @ 2024-01-01 201803/week @ 2024-01-08 211677/week @ 2024-01-15 227828/week @ 2024-01-22 236624/week @ 2024-01-29 239513/week @ 2024-02-05 250530/week @ 2024-02-12 223006/week @ 2024-02-19 271583/week @ 2024-02-26 259746/week @ 2024-03-04 266406/week @ 2024-03-11 266752/week @ 2024-03-18

1,071,652 downloads per month
Used in 190 crates (75 directly)

Apache-2.0

1MB
21K SLoC

OpenTelemetry — An observability framework for cloud-native software.

OpenTelemetry Collector Rust Exporter

OTLP integration for applications instrumented with OpenTelemetry.

Crates.io: opentelemetry-otlp Documentation LICENSE GitHub Actions CI Slack

Overview

OpenTelemetry is a collection of tools, APIs, and SDKs used to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior.

This crate provides an exporter for sending trace and metric data in the OTLP format to the OpenTelemetry collector. The OpenTelemetry Collector offers a vendor-agnostic implementation on how to receive, process, and export telemetry data. In addition, it removes the need to run, operate, and maintain multiple agents/collectors in order to support open-source telemetry data formats (e.g. Jaeger, Prometheus, etc.) sending to multiple open-source or commercial back-ends.

Quickstart

First make sure you have a running version of the opentelemetry collector you want to send data to:

$ docker run -p 4317:4317 otel/opentelemetry-collector-dev:latest

Then install a new pipeline with the recommended defaults to start exporting telemetry:

use opentelemetry::trace::Tracer;

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
    // use tonic as grpc layer here.
    let tracer = opentelemetry_otlp::new_pipeline()
      .tracing()
      .with_exporter(opentelemetry_otlp::new_exporter().tonic())
      .install_simple()?;

    tracer.in_span("doing_work", |cx| {
        // Traced app logic here...
    });

    Ok(())
}

Performance

For optimal performance, a batch exporter is recommended as the simple exporter will export each span synchronously on drop. You can enable the rt-tokio, rt-tokio-current-thread or rt-async-std features and specify a runtime on the pipeline builder to have a batch exporter configured for you automatically.

[dependencies]
opentelemetry_sdk = { version = "*", features = ["async-std"] }
opentelemetry-otlp = { version = "*", features = ["grpc-tonic"] }
let tracer = opentelemetry_otlp::new_pipeline()
    .install_batch(opentelemetry_sdk::runtime::AsyncStd)?;

Kitchen Sink Full Configuration

Example showing how to override all configuration options.

Generally there are two parts of configuration. One is metrics config or tracing config. Users can config it via OtlpTracePipeline or OtlpMetricPipeline. The other is exporting configuration. Users can set those configurations using OtlpExporterPipeline based on the choice of exporters.

Dependencies

~1–16MB
~203K SLoC