@@ -2,7 +2,7 @@ use futures_core::future::BoxFuture;
2
2
use futures_util:: FutureExt ;
3
3
use mysql_common:: constants:: Command ;
4
4
#[ cfg( feature = "tracing" ) ]
5
- use tracing:: { field, info_span, Instrument , Level } ;
5
+ use tracing:: { field, info_span, span_enabled , trace_span , Instrument , Level } ;
6
6
7
7
use crate :: { Conn , TextProtocol } ;
8
8
@@ -12,24 +12,35 @@ use super::Routine;
12
12
#[ derive( Debug , Copy , Clone ) ]
13
13
pub struct QueryRoutine < ' a > {
14
14
data : & ' a [ u8 ] ,
15
+ #[ cfg_attr( not( feature = "tracing" ) , allow( dead_code) ) ]
16
+ internal : bool ,
15
17
}
16
18
17
19
impl < ' a > QueryRoutine < ' a > {
18
- pub fn new ( data : & ' a [ u8 ] ) -> Self {
19
- Self { data }
20
+ pub fn new ( data : & ' a [ u8 ] , internal : bool ) -> Self {
21
+ Self { data, internal }
20
22
}
21
23
}
22
24
23
25
impl Routine < ( ) > for QueryRoutine < ' _ > {
24
26
fn call < ' a > ( & ' a mut self , conn : & ' a mut Conn ) -> BoxFuture < ' a , crate :: Result < ( ) > > {
25
27
#[ cfg( feature = "tracing" ) ]
26
- let span = info_span ! (
27
- "mysql_async::query" ,
28
- mysql_async. connection. id = conn. id( ) ,
29
- mysql_async. query. sql = field:: Empty
30
- ) ;
28
+ let span = if self . internal {
29
+ trace_span ! (
30
+ "mysql_async::query" ,
31
+ mysql_async. connection. id = conn. id( ) ,
32
+ mysql_async. query. sql = field:: Empty
33
+ )
34
+ } else {
35
+ info_span ! (
36
+ "mysql_async::query" ,
37
+ mysql_async. connection. id = conn. id( ) ,
38
+ mysql_async. query. sql = field:: Empty
39
+ )
40
+ } ;
41
+
31
42
#[ cfg( feature = "tracing" ) ]
32
- if tracing :: span_enabled!( Level :: DEBUG ) {
43
+ if span_enabled ! ( Level :: DEBUG ) {
33
44
// The statement may contain sensitive data. Restrict to DEBUG.
34
45
span. record (
35
46
"mysql_async.query.sql" ,
0 commit comments