Open
Description
In order to record span data (which allows us to write out the service name in the log, and also allows us to determine if certain errors are crits), we store them in an Arc<Mutex<HashMap<_, _>>
. This has the downside of causing us to need to manage the lock, check if it's poisoned, etc. We are also using an unwrap here:
lighthouse/common/logging/src/tracing_logging_layer.rs
Lines 426 to 434 in bde0f1e
I believe we can use tracing
's built in Extension
system to manage this data for us, something like this:
let mut extensions = span.extensions_mut();
let span_data = SpanData {
name: attrs.metadata().name().to_string(),
fields: visitor.fields,
};
extensions.insert(span_data);
This would allow us to remove the Mutex
and the unwrap
.