From ab71064b292d88ac97e7d044a0e729de17d0219e Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Thu, 26 Dec 2024 21:04:38 +0100 Subject: [PATCH] feat(telemetry): mark error field in spans w/errors --- trace-request/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trace-request/src/lib.rs b/trace-request/src/lib.rs index 2f1d099..48ddf8a 100644 --- a/trace-request/src/lib.rs +++ b/trace-request/src/lib.rs @@ -50,8 +50,10 @@ pub fn trace_request(_attr: TokenStream, input: TokenStream) -> TokenStream { let span = tracing::Span::current(); span.record("http.status", &status.as_str()); if let Err(err) = &result { + span.record("error", true); span.record("error.external", &err.external_message); span.record("error.internal", &err.internal_message); + } result @@ -62,8 +64,9 @@ pub fn trace_request(_attr: TokenStream, input: TokenStream) -> TokenStream { "http.method" = req.method().as_str(), "http.uri" = req.uri().to_string(), "http.status" = tracing::field::Empty, + "error" = tracing::field::Empty, "error.external" = tracing::field::Empty, - "error.internal" = tracing::field::Empty + "error.internal" = tracing::field::Empty, ) ).await }