crabka-telemetry 0.3.0

Generic OTLP distributed-tracing pipeline for Crabka services
Documentation

Generic OTLP distributed-tracing pipeline for Crabka services.

The consuming service always installs a tracing_subscriber fmt layer (stdout, gated by the usual RUST_LOG EnvFilter). When OTLP export is configured via the environment, a second tracing-opentelemetry layer is attached that converts tracing spans into OpenTelemetry spans and batch-exports them over OTLP to a collector (gRPC :4317 or HTTP/protobuf :4318).

Enabling

OTLP is off by default — a service with no OTLP environment behaves byte-for-byte as before. It turns on when any endpoint is set (CRABKA_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_ENDPOINT) or CRABKA_OTLP_ENABLED=true, and is force-disabled by OTEL_SDK_DISABLED=true.

Resolve OTLP settings without touching the environment

use crabka_telemetry::{OtlpConfig, OtlpProtocol};

let cfg = OtlpConfig::from_env(
    |key| (key == "CRABKA_OTLP_ENABLED").then(|| "true".to_string()),
    "broker-1",
    "0.1.0",
    "crabka-broker",
).unwrap();

assert_eq!(cfg.protocol, OtlpProtocol::Grpc);
assert_eq!(cfg.endpoint, "http://localhost:4317");