Skip to content

Commit c851de7

Browse files
cloneableblackbeam
authored andcommitted
Record errors from routines in tracing spans
Updates blackbeam#223
1 parent 043d81a commit c851de7

File tree

6 files changed

+43
-6
lines changed

6 files changed

+43
-6
lines changed

src/conn/routines/exec.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ impl Routine<()> for ExecRoutine<'_> {
104104
};
105105

106106
#[cfg(feature = "tracing")]
107-
let fut = fut.instrument(span);
107+
let fut = async {
108+
fut.await.or_else(|e| {
109+
tracing::error!(error = %e);
110+
Err(e)
111+
})
112+
}
113+
.instrument(span);
108114

109115
fut.boxed()
110116
}

src/conn/routines/next_set.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ where
3636
};
3737

3838
#[cfg(feature = "tracing")]
39-
let fut = fut.instrument(span);
39+
let fut = async {
40+
fut.await.or_else(|e| {
41+
tracing::error!(error = %e);
42+
Err(e)
43+
})
44+
}
45+
.instrument(span);
4046

4147
fut.boxed()
4248
}

src/conn/routines/ping.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ impl Routine<()> for PingRoutine {
2424
};
2525

2626
#[cfg(feature = "tracing")]
27-
let fut = fut.instrument(span);
27+
let fut = async {
28+
fut.await.or_else(|e| {
29+
tracing::error!(error = %e);
30+
Err(e)
31+
})
32+
}
33+
.instrument(span);
2834

2935
fut.boxed()
3036
}

src/conn/routines/prepare.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ impl Routine<Arc<StmtInner>> for PrepareRoutine {
4848

4949
let packet = conn.read_packet().await?;
5050
let mut inner_stmt = StmtInner::from_payload(&*packet, conn.id(), self.query.clone())?;
51+
5152
#[cfg(feature = "tracing")]
5253
Span::current().record("mysql_async.statement.id", inner_stmt.id());
5354

@@ -65,7 +66,13 @@ impl Routine<Arc<StmtInner>> for PrepareRoutine {
6566
};
6667

6768
#[cfg(feature = "tracing")]
68-
let fut = fut.instrument(span);
69+
let fut = async {
70+
fut.await.or_else(|e| {
71+
tracing::error!(error = %e);
72+
Err(e)
73+
})
74+
}
75+
.instrument(span);
6976

7077
fut.boxed()
7178
}

src/conn/routines/query.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ impl<L: TracingLevel> Routine<()> for QueryRoutine<'_, L> {
5454
};
5555

5656
#[cfg(feature = "tracing")]
57-
let fut = fut.instrument(span);
57+
let fut = async {
58+
fut.await.or_else(|e| {
59+
tracing::error!(error = %e);
60+
Err(e)
61+
})
62+
}
63+
.instrument(span);
5864

5965
fut.boxed()
6066
}

src/conn/routines/reset.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ impl Routine<()> for ResetRoutine {
2525
};
2626

2727
#[cfg(feature = "tracing")]
28-
let fut = fut.instrument(span);
28+
let fut = async {
29+
fut.await.or_else(|e| {
30+
tracing::error!(error = %e);
31+
Err(e)
32+
})
33+
}
34+
.instrument(span);
2935

3036
fut.boxed()
3137
}

0 commit comments

Comments
 (0)