3 releases (breaking)

new 0.3.0 Feb 25, 2024
0.2.0 Nov 6, 2023
0.1.0 Jul 29, 2023

#210 in Debugging

Download history 24404/week @ 2023-11-04 27022/week @ 2023-11-11 23741/week @ 2023-11-18 22072/week @ 2023-11-25 56331/week @ 2023-12-02 39878/week @ 2023-12-09 34335/week @ 2023-12-16 9522/week @ 2023-12-23 28755/week @ 2023-12-30 40683/week @ 2024-01-06 44306/week @ 2024-01-13 39939/week @ 2024-01-20 33614/week @ 2024-01-27 40854/week @ 2024-02-03 42494/week @ 2024-02-10 35577/week @ 2024-02-17

157,750 downloads per month
Used in 19 crates (17 directly)

Apache-2.0

1MB
18K SLoC

OpenTelemetry — An observability framework for cloud-native software.

OpenTelemetry Stdout

Exporters for applications instrumented with OpenTelemetry.

Crates.io: opentelemetry-stdout 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 exporters that export to stdout or any implementation of std::io::Write.

Compiler support: requires rustc 1.64+

Quickstart

Export telemetry signals to stdout.

use opentelemetry::{
    metrics::MeterProvider as _,
    trace::{Span, Tracer, TracerProvider as _},
    Context, KeyValue,
};
use opentelemetry_sdk::{
    metrics::{MeterProvider, PeriodicReader},
    runtime,
    trace::{BatchSpanProcessor, TracerProvider},
};

fn init_trace() -> TracerProvider {
    let exporter = opentelemetry_stdout::SpanExporter::default();
    let processor = BatchSpanProcessor::builder(exporter, runtime::Tokio).build();
    TracerProvider::builder()
        .with_span_processor(processor)
        .build()
}

fn init_metrics() -> MeterProvider {
    let exporter = opentelemetry_stdout::MetricsExporter::default();
    let reader = PeriodicReader::builder(exporter, runtime::Tokio).build();
    MeterProvider::builder().with_reader(reader).build()
}

let tracer_provider = init_trace();
let meter_provider = init_metrics();

Recorded traces and metrics will now be sent to stdout:

{"resourceMetrics":{"resource":{"attributes":[{"key":"service.name","value":{"str..
{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stri..

Supported Rust Versions

OpenTelemetry is built against the latest stable release. The minimum supported version is 1.64. The current OpenTelemetry version is not guaranteed to build on Rust versions earlier than the minimum supported version.

The current stable Rust compiler and the three most recent minor versions before it will always be supported. For example, if the current stable compiler version is 1.49, the minimum supported version will not be increased past 1.46, three minor versions prior. Increasing the minimum supported compiler version is not considered a semver breaking change as long as doing so complies with this policy.

Dependencies

~2.5–4MB
~74K SLoC