Skip to main content

Crate sideways_otel

Crate sideways_otel 

Source
Expand description

§Sideways OTel 🦀

Observability from the side - because crabs walk sideways, and so should your telemetry.

A production-ready telemetry library for Rust services that provides vendor-neutral OpenTelemetry tracing, metrics, and logs, exported via OTLP to any compatible backend (a local Collector, Honeycomb, or anything else that speaks OTLP).

§Features

  • Easy one-line initialization for traces, metrics, and logs
  • Graceful degradation when the OTLP endpoint is unavailable
  • Environment-based configuration using standard OTEL_* variables
  • Health check filtering to reduce noise
  • Native OpenTelemetry metrics API - no vendor-specific macros required
  • W3C Trace Context + Baggage propagation installed by default, matching the OTEL_PROPAGATORS spec default

§Quick Start

use sideways_otel::prelude::*;
use sideways_otel::{init_telemetry, TelemetryConfig};

fn main() {
    let config = TelemetryConfig::from_env();
    let telemetry = init_telemetry(&config);

    tracing::info!("Application started");

    let requests = counter("requests.handled");
    requests.add(1, &[KeyValue::new("status", "success")]);

    telemetry.shutdown();
}

Modules§

metrics
prelude
propagation
resource
span
Helpers for enriching the current tracing span with OpenTelemetry attributes and events, without needing to reach for tracing_opentelemetry directly.
tracing

Macros§

build_otlp_exporter
Build an OTLP exporter for a given signal (traces/metrics/logs), honoring crate::OtlpProtocol: gRPC (via tonic, with header/TLS support) or HTTP/protobuf (via reqwest, with plain string headers). $builder_ctor is an expression like opentelemetry_otlp::SpanExporter::builder().

Structs§

Telemetry
Telemetry components that need to be kept alive for the duration of the application and flushed/shutdown on exit.
TelemetryConfig
Configuration for telemetry initialization.
TelemetryConfigBuilder
Builder for TelemetryConfig.

Enums§

OtlpProtocol
Which OTLP wire protocol to export over.
PropagatorKind
A W3C-standard context propagation format. Corresponds to the values accepted by the standard OTEL_PROPAGATORS environment variable, though only tracecontext and baggage are currently supported here - the spec also defines b3, b3multi, jaeger, xray, and ottrace, each of which needs its own crate (opentelemetry-zipkin, etc.). Add support for those as real use cases show up rather than pre-building the full matrix.
TelemetryError

Functions§

init_telemetry
Initialize telemetry and install the resulting layer as the global tracing subscriber. A convenience wrapper around init_telemetry_layer for the common case where the application doesn’t need to add any tracing layers of its own - if it does, call init_telemetry_layer directly instead.
init_telemetry_layer
Initialize telemetry with the given configuration, without installing a global tracing subscriber.