prop/rust/prop_grid_rs/src/telemetry.rs
Graham McIntire d7d865d566
chore(rust): drop OpenTelemetry stack to speed up cold builds
Removes the OTLP span exporter (tracing-opentelemetry, opentelemetry,
opentelemetry_sdk, opentelemetry-otlp) and its transitive tonic/prost/
h2 tree — 56 crates off the build graph, ~3-5 min off a cold build on
the forgejo runner.

The fmt layer (JSON to stdout via tracing-subscriber) is unchanged;
structured logs still reach the Loki collector through kubectl logs,
and /metrics on :9100 still serves Prometheus. Traces were a nice-to-
have that nothing on call was actually reading.

telemetry::init keeps its signature (service_name + TelemetryGuard)
so re-adding OTLP later is a single-module change. k8s manifests drop
the now-unused OTEL_EXPORTER_OTLP_ENDPOINT env var.
2026-04-24 09:11:43 -05:00

38 lines
1.4 KiB
Rust

//! Tracing init for the Rust workers.
//!
//! Both bin targets (`worker`, `hrrr_point_worker`) call `init(svc)` at
//! startup to install a JSON-to-stdout `tracing` subscriber so kubectl
//! logs keep working.
//!
//! OTLP span export was removed in 2026-04 — the opentelemetry stack
//! pulled ~80 transitive crates and added ~3-5 min to cold builds on
//! the forgejo runner, and the cluster's trace consumption was
//! negligible compared to structured logs + /metrics. Re-add via
//! `tracing-opentelemetry` only if Tempo becomes load-bearing.
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
/// Opaque handle the caller holds until shutdown. No-op today; kept
/// so re-adding OTLP later doesn't require churn at every call site.
pub struct TelemetryGuard;
impl TelemetryGuard {
/// Flush/drop hook. Currently a no-op; the fmt layer flushes each
/// line as it's written.
pub fn shutdown(self) {}
}
/// Initialize tracing for a binary. `service_name` is accepted for API
/// compatibility with the previous OTLP-capable init and is currently
/// unused in the fmt-only path.
pub fn init(_service_name: &'static str) -> TelemetryGuard {
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
let fmt_layer = tracing_subscriber::fmt::layer().json();
tracing_subscriber::registry()
.with(env_filter)
.with(fmt_layer)
.init();
TelemetryGuard
}