mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
use strum instead
This commit is contained in:
parent
792300d220
commit
9364d44ce2
3 changed files with 27 additions and 12 deletions
|
|
@ -18,6 +18,7 @@ use opentelemetry_sdk::{
|
|||
metrics::{new_view, Aggregation, Instrument, SdkMeterProvider, Stream},
|
||||
Resource,
|
||||
};
|
||||
use strum::AsRefStr;
|
||||
use tokio::time::Instant;
|
||||
use tracing_flame::{FlameLayer, FlushGuard};
|
||||
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Layer, Registry};
|
||||
|
|
@ -41,7 +42,7 @@ impl Drop for Guard {
|
|||
}
|
||||
|
||||
/// Type to record cache performance in a tracing span field.
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, AsRefStr)]
|
||||
pub(crate) enum FoundIn {
|
||||
/// Found in cache
|
||||
Cache,
|
||||
|
|
@ -55,20 +56,10 @@ pub(crate) enum FoundIn {
|
|||
}
|
||||
|
||||
impl FoundIn {
|
||||
/// Returns a stringified representation of the current value
|
||||
fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
FoundIn::Cache => "Cache",
|
||||
FoundIn::Database => "Database",
|
||||
FoundIn::Remote => "Remote",
|
||||
FoundIn::Nothing => "Nothing",
|
||||
}
|
||||
}
|
||||
|
||||
/// Record the current value to the current [`tracing::Span`]
|
||||
// TODO: use tracing::Value instead if it ever becomes accessible
|
||||
pub(crate) fn record(self, field: &str) {
|
||||
tracing::Span::current().record(field, self.as_str());
|
||||
tracing::Span::current().record(field, self.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue