Skip to content

Commit 9f95d7c

Browse files
committed
feat(outbound-pg): Trace outbound-pg host component
Signed-off-by: Caleb Schoepp <[email protected]>
1 parent 576d9de commit 9f95d7c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crates/outbound-pg/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use tokio_postgres::{
1212
types::{ToSql, Type},
1313
Client, NoTls, Row, Socket,
1414
};
15+
use tracing::instrument;
16+
use tracing::Level;
1517

1618
pub struct OutboundPgComponent {
1719
pub resolver: spin_expressions::SharedPreparedResolver,
@@ -110,6 +112,7 @@ impl v2::Host for OutboundPg {}
110112

111113
#[async_trait]
112114
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"))]
113116
async fn open(&mut self, address: String) -> Result<Result<Resource<Connection>, v2::Error>> {
114117
if !self.is_address_allowed(&address) {
115118
return Ok(Err(v2::Error::ConnectionFailed(format!(
@@ -119,6 +122,7 @@ impl v2::HostConnection for OutboundPg {
119122
Ok(self.open_connection(&address).await)
120123
}
121124

125+
#[instrument(name = "spin_outbound_pg.execute", skip(self, connection), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
122126
async fn execute(
123127
&mut self,
124128
connection: Resource<Connection>,
@@ -144,6 +148,7 @@ impl v2::HostConnection for OutboundPg {
144148
.await)
145149
}
146150

151+
#[instrument(name = "spin_outbound_pg.query", skip(self, connection), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
147152
async fn query(
148153
&mut self,
149154
connection: Resource<Connection>,

0 commit comments

Comments
 (0)