Send OpenTelemetry traces over OTLP (#87)
ipx had no spans, only log lines, so there was no way to see where a
slow scan, download or request spent its time. With
OTEL_EXPORTER_OTLP_ENDPOINT set, the daemon now exports traces over
OTLP/HTTP (Tempo on Tower): a scan, each feed in it, the feed fetch and
site icon lookup, downloads, torrents, reaps, and web requests. Log lines
inside a span ride along as its events.
Only the daemon exports: the healthcheck runs ipx status every 30s and
would bury everything else. The web event stream and the log view's
polling get no span, for the same reason. The exporter shares ipx's
reqwest 0.13, so no second HTTP stack comes in.
The stderr log now prefixes lines inside a span with it, as
tracing-subscriber's fmt layer does (scan{only=None force=false}: ...).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
17
src/web.rs
17
src/web.rs
@@ -1938,8 +1938,23 @@ async fn access_log(req: Request, next: Next) -> Response {
|
||||
let path = req.uri().path().to_owned();
|
||||
let method = req.method().clone();
|
||||
let quiet = path.starts_with("/api/logs");
|
||||
// No trace for the event stream either: an open page asks for it again and again, and Tempo
|
||||
// would fill with nothing else.
|
||||
let span = if quiet || path == "/api/events" {
|
||||
tracing::Span::none()
|
||||
} else {
|
||||
tracing::info_span!(
|
||||
target: "ipx::http",
|
||||
"http",
|
||||
otel.name = %format!("{method} {path}"),
|
||||
http.request.method = %method,
|
||||
url.path = %path,
|
||||
http.response.status_code = tracing::field::Empty,
|
||||
)
|
||||
};
|
||||
let started = std::time::Instant::now();
|
||||
let resp = next.run(req).await;
|
||||
let resp = tracing::Instrument::instrument(next.run(req), span.clone()).await;
|
||||
span.record("http.response.status_code", resp.status().as_u16());
|
||||
if !quiet {
|
||||
let ms = started.elapsed().as_millis();
|
||||
let status = resp.status().as_u16();
|
||||
|
||||
Reference in New Issue
Block a user