Skip to content

Commit

Permalink
Don't use the debug representation of request IDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Feb 9, 2024
1 parent ac32f7c commit db2e620
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,14 @@ pub fn preflight(root: &Path) -> anyhow::Result<()> {
}

fn make_request_span(request: &axum::extract::Request) -> tracing::span::Span {
let request_id = &request.headers()["x-request-id"];
let request_id = String::from_utf8_lossy(request.headers()["x-request-id"].as_bytes());
tracing::span!(
tracing::Level::DEBUG,
"request",
method = tracing::field::display(request.method()),
uri = tracing::field::display(request.uri()),
version = tracing::field::debug(request.version()),
request_id = tracing::field::debug(request_id)
request_id = tracing::field::display(request_id)
)
}

Expand Down
5 changes: 4 additions & 1 deletion tests/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,10 @@ async fn request_id_is_logged() {

let storage = storage.lock();
let span = storage.scan_spans().single(&name(eq("request")));
assert!(span.value("request_id").unwrap().is_debug(&"foobar123"));
assert!(span
.value("request_id")
.unwrap()
.is_debug(&tracing::field::display("foobar123")));
span.scan_events()
.single(&message(eq("started processing request")));
span.scan_events()
Expand Down

0 comments on commit db2e620

Please sign in to comment.