Skip to content

Commit 4158d86

Browse files
authored
Merge pull request #2439 from calebschoepp/trace-db-host-components
Trace db host components
2 parents 40496e3 + 8f25a68 commit 4158d86

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

crates/outbound-mysql/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use spin_world::v2::mysql::{self as v2, Connection};
88
use spin_world::v2::rdbms_types as v2_types;
99
use spin_world::v2::rdbms_types::{Column, DbDataType, DbValue, ParameterValue};
1010
use std::sync::Arc;
11+
use tracing::{instrument, Level};
1112
use url::Url;
1213

1314
/// A simple implementation to support outbound mysql connection
@@ -85,6 +86,7 @@ impl v2::Host for OutboundMysql {}
8586

8687
#[async_trait]
8788
impl v2::HostConnection for OutboundMysql {
89+
#[instrument(name = "spin_outbound_mysql.open_connection", skip(self), err(level = Level::INFO), fields(otel.kind = "client", db.system = "mysql"))]
8890
async fn open(&mut self, address: String) -> Result<Result<Resource<Connection>, v2::Error>> {
8991
if !self.is_address_allowed(&address) {
9092
return Ok(Err(v2::Error::ConnectionFailed(format!(
@@ -94,6 +96,7 @@ impl v2::HostConnection for OutboundMysql {
9496
Ok(self.open_connection(&address).await)
9597
}
9698

99+
#[instrument(name = "spin_outbound_mysql.execute", skip(self, connection), err(level = Level::INFO), fields(otel.kind = "client", db.system = "mysql", otel.name = statement))]
97100
async fn execute(
98101
&mut self,
99102
connection: Resource<Connection>,
@@ -115,6 +118,7 @@ impl v2::HostConnection for OutboundMysql {
115118
.await)
116119
}
117120

121+
#[instrument(name = "spin_outbound_mysql.query", skip(self, connection), err(level = Level::INFO), fields(otel.kind = "client", db.system = "mysql", otel.name = statement))]
118122
async fn query(
119123
&mut self,
120124
connection: Resource<Connection>,

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)