исправить: закрыть ревью сквозной корреляции
This commit is contained in:
@@ -63,24 +63,13 @@ impl Stage {
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn db_span(self, operation: DbOperation) -> Option<Span> {
|
||||
if self != Self::DbQuery {
|
||||
return None;
|
||||
}
|
||||
let span = self.span();
|
||||
span.record("db.operation", operation.as_str());
|
||||
Some(span)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn observe_db_query<T, E>(
|
||||
operation: DbOperation,
|
||||
future: impl Future<Output = Result<T, E>>,
|
||||
) -> Result<T, E> {
|
||||
let span = Stage::DbQuery
|
||||
.db_span(operation)
|
||||
.expect("database operation requires db.query stage");
|
||||
let span = operation.span();
|
||||
let result = future.instrument(span.clone()).await;
|
||||
match &result {
|
||||
Ok(_) => StageOutcome::Success.record(&span),
|
||||
@@ -182,6 +171,12 @@ pub enum DbOperation {
|
||||
}
|
||||
|
||||
impl DbOperation {
|
||||
pub fn span(self) -> Span {
|
||||
let span = Stage::DbQuery.span();
|
||||
span.record("db.operation", self.as_str());
|
||||
span
|
||||
}
|
||||
|
||||
pub const fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
Self::MachineAccessRead => "machine_access.read",
|
||||
|
||||
Reference in New Issue
Block a user