@@ -12,6 +12,8 @@ use tokio_postgres::{
12
12
types:: { ToSql , Type } ,
13
13
Client , NoTls , Row , Socket ,
14
14
} ;
15
+ use tracing:: instrument;
16
+ use tracing:: Level ;
15
17
16
18
pub struct OutboundPgComponent {
17
19
pub resolver : spin_expressions:: SharedPreparedResolver ,
@@ -110,6 +112,7 @@ impl v2::Host for OutboundPg {}
110
112
111
113
#[ async_trait]
112
114
impl v2:: HostConnection for OutboundPg {
115
+ #[ instrument( name = "spin_outbound_pg.open_connection" , skip( self ) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "postgresql" ) ) ]
113
116
async fn open ( & mut self , address : String ) -> Result < Result < Resource < Connection > , v2:: Error > > {
114
117
if !self . is_address_allowed ( & address) {
115
118
return Ok ( Err ( v2:: Error :: ConnectionFailed ( format ! (
@@ -119,6 +122,7 @@ impl v2::HostConnection for OutboundPg {
119
122
Ok ( self . open_connection ( & address) . await )
120
123
}
121
124
125
+ #[ instrument( name = "spin_outbound_pg.execute" , skip( self , connection) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "postgresql" , otel. name = statement) ) ]
122
126
async fn execute (
123
127
& mut self ,
124
128
connection : Resource < Connection > ,
@@ -144,6 +148,7 @@ impl v2::HostConnection for OutboundPg {
144
148
. await )
145
149
}
146
150
151
+ #[ instrument( name = "spin_outbound_pg.query" , skip( self , connection) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "postgresql" , otel. name = statement) ) ]
147
152
async fn query (
148
153
& mut self ,
149
154
connection : Resource < Connection > ,
0 commit comments