Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce response logging. #1818

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,20 @@ async fn run_server(addr: SocketAddr) -> anyhow::Result<()> {
Ok::<_, hyper::Error>(hyper::service::service_fn(move |req| {
let uuid = uuid::Uuid::new_v4();
let span = tracing::span!(tracing::Level::INFO, "request", ?uuid);
// Only log the webhook responses at INFO level to avoid flooding the
// logs with huge responses. Other responses are at DEBUG.
let log_info_response = matches!(req.uri().path(), "/github-hook" | "/zulip-hook");
serve_req(req, ctx.clone(), agenda.clone())
.map(move |mut resp| {
if let Ok(resp) = &mut resp {
resp.headers_mut()
.insert("X-Request-Id", uuid.to_string().parse().unwrap());
}
log::info!("response = {:?}", resp);
if log_info_response {
log::info!("response = {resp:?}");
} else {
log::debug!("response = {resp:?}");
}
resp
})
.instrument(span)
Expand Down
Loading