Crates.io | ts_opentelemetry_stdout |
lib.rs | ts_opentelemetry_stdout |
version | 0.1.0-beta.1 |
source | src |
created_at | 2023-06-13 17:39:39.207283 |
updated_at | 2023-06-13 17:39:39.207283 |
description | A fork of an OpenTelemetry exporter for stdout |
homepage | https://github.com/ThetaSinner/opentelemetry-rust |
repository | https://github.com/ThetaSinner/opentelemetry-rust |
max_upload_size | |
id | 889313 |
size | 85,040 |
Exporters for applications instrumented with OpenTelemetry
.
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.60+
Export telemetry signals to stdout.
use opentelemetry_api::{
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..
OpenTelemetry is built against the latest stable release. The minimum supported version is 1.60. 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.