feat(telemetry): mark error field in spans w/errors
Some checks failed
ci/woodpecker/push/ci Pipeline failed

This commit is contained in:
Daniel Lundin 2024-12-26 21:04:38 +01:00
parent 86db3cb3a0
commit ab71064b29
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI

View file

@ -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
}