Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions crates/factor-outbound-mqtt/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ impl v3::HostConnectionWithStore for crate::MqttFactorData {
}

#[instrument(name = "spin_outbound_mqtt.publish", skip(accessor, connection, payload), err(level = Level::INFO),
fields(otel.kind = "producer", otel.name = format!("{} publish", topic), messaging.operation = "publish",
messaging.system = "mqtt"))]
fields(
otel.kind = "producer",
messaging.operation = "publish",
messaging.system = "mqtt",
messaging.destination.name = topic,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved topic here (per otel semantic conventions)

))]
async fn publish<T: Send>(
accessor: &Accessor<T, Self>,
connection: Resource<v3::Connection>,
Expand Down Expand Up @@ -218,8 +222,12 @@ impl v2::HostConnection for InstanceState {
/// current trace context into the payload yourself.
/// https://w3c.github.io/trace-context-mqtt/#mqtt-v3-recommendation.
#[instrument(name = "spin_outbound_mqtt.publish", skip(self, connection, payload), err(level = Level::INFO),
fields(otel.kind = "producer", otel.name = format!("{} publish", topic), messaging.operation = "publish",
messaging.system = "mqtt"))]
fields(
otel.kind = "producer",
messaging.operation = "publish",
messaging.system = "mqtt",
messaging.destination.name = topic,
))]
async fn publish(
&mut self,
connection: Resource<v2::Connection>,
Expand Down
9 changes: 6 additions & 3 deletions crates/factor-outbound-mysql/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,16 @@ impl<C: Client> v3::HostConnectionWithStore for MysqlFactorData<C> {
impl<C: Client> v2::Host for InstanceState<C> {}

impl<C: Client> v2::HostConnection for InstanceState<C> {
#[instrument(name = "spin_outbound_mysql.open", skip(self, address), err(level = Level::INFO), fields(otel.kind = "client", db.system = "mysql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
#[instrument(name = "spin_outbound_mysql.open", skip(self, address), err(level = Level::INFO),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: shouldn't we use skip_all instead of skip(self, address)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds fine but I don't really want to audit all arguments in this PR.

fields(otel.kind = "client", db.system = "mysql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
async fn open(&mut self, address: String) -> Result<Resource<v2::Connection>, v2::Error> {
let mut state = self.0.lock().await;
state.otel.reparent_tracing_span();
state.open_connection(&address).await.map(Resource::new_own)
}

#[instrument(name = "spin_outbound_mysql.execute", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "mysql", otel.name = statement))]
#[instrument(name = "spin_outbound_mysql.execute", skip(self, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "mysql"))]
async fn execute(
&mut self,
connection: Resource<v2::Connection>,
Expand All @@ -184,7 +186,8 @@ impl<C: Client> v2::HostConnection for InstanceState<C> {
.map_err(track_db_error_on_span)
}

#[instrument(name = "spin_outbound_mysql.query", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "mysql", otel.name = statement))]
#[instrument(name = "spin_outbound_mysql.query", skip(self, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "mysql"))]
async fn query(
Comment thread
lann marked this conversation as resolved.
&mut self,
connection: Resource<v2::Connection>,
Expand Down
36 changes: 24 additions & 12 deletions crates/factor-outbound-pg/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ fn v3_params_to_v4(params: Vec<v3::ParameterValue>) -> Vec<v4::ParameterValue> {
}

impl<CF: ClientFactory> v3::HostConnection for InstanceState<CF> {
#[instrument(name = "spin_outbound_pg.open", skip(self, address), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
#[instrument(name = "spin_outbound_pg.open", skip(self, address), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
async fn open(&mut self, address: String) -> Result<Resource<v3::Connection>, v3::Error> {
spin_factor_outbound_networking::record_address_fields(&address);

Expand All @@ -97,7 +98,8 @@ impl<CF: ClientFactory> v3::HostConnection for InstanceState<CF> {
.map_err(v3::Error::from)
}

#[instrument(name = "spin_outbound_pg.execute", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
#[instrument(name = "spin_outbound_pg.execute", skip(self, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql"))]
async fn execute(
&mut self,
connection: Resource<v3::Connection>,
Expand All @@ -113,7 +115,8 @@ impl<CF: ClientFactory> v3::HostConnection for InstanceState<CF> {
.map_err(track_db_error_on_span_v3)
}

#[instrument(name = "spin_outbound_pg.query", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
#[instrument(name = "spin_outbound_pg.query", skip(self, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql"))]
async fn query(
&mut self,
connection: Resource<v3::Connection>,
Expand Down Expand Up @@ -190,7 +193,8 @@ impl<CF: ClientFactory> v4::HostConnectionBuilder for InstanceState<CF> {
}

impl<CF: ClientFactory> v4::HostConnection for InstanceState<CF> {
#[instrument(name = "spin_outbound_pg.open", skip(self, address), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
#[instrument(name = "spin_outbound_pg.open", skip(self, address), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
async fn open(&mut self, address: String) -> Result<Resource<v4::Connection>, v4::Error> {
spin_factor_outbound_networking::record_address_fields(&address);

Expand All @@ -201,7 +205,8 @@ impl<CF: ClientFactory> v4::HostConnection for InstanceState<CF> {
self.open_connection(&address, None).await
}

#[instrument(name = "spin_outbound_pg.execute", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
#[instrument(name = "spin_outbound_pg.execute", skip(self, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql"))]
async fn execute(
&mut self,
connection: Resource<v4::Connection>,
Expand All @@ -215,7 +220,8 @@ impl<CF: ClientFactory> v4::HostConnection for InstanceState<CF> {
.map_err(track_db_error_on_span_v4)
}

#[instrument(name = "spin_outbound_pg.query", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
#[instrument(name = "spin_outbound_pg.query", skip(self, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql"))]
async fn query(
&mut self,
connection: Resource<v4::Connection>,
Expand All @@ -238,7 +244,8 @@ impl<CF: ClientFactory> v4::HostConnection for InstanceState<CF> {
impl<CF: ClientFactory> spin_world::spin::postgres4_2_0::postgres::HostConnectionWithStore
for crate::PgFactorData<CF>
{
#[instrument(name = "spin_outbound_pg.open_async", skip(accessor, address), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
#[instrument(name = "spin_outbound_pg.open_async", skip(accessor, address), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
async fn open_async<T>(
accessor: &Accessor<T, Self>,
address: String,
Expand All @@ -251,7 +258,8 @@ impl<CF: ClientFactory> spin_world::spin::postgres4_2_0::postgres::HostConnectio
Self::open_connection_async(accessor, &address, None).await
}

#[instrument(name = "spin_outbound_pg.execute", skip(accessor, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
#[instrument(name = "spin_outbound_pg.execute", skip(accessor, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql"))]
async fn execute_async<T>(
accessor: &Accessor<T, Self>,
connection: Resource<v4::Connection>,
Expand All @@ -270,7 +278,8 @@ impl<CF: ClientFactory> spin_world::spin::postgres4_2_0::postgres::HostConnectio
}

#[allow(clippy::type_complexity)] // blame bindgen, clippy, blame bindgen
#[instrument(name = "spin_outbound_pg.query_async", skip(accessor, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
#[instrument(name = "spin_outbound_pg.query_async", skip(accessor, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql"))]
async fn query_async<T>(
accessor: &Accessor<T, Self>,
connection: Resource<v4::Connection>,
Expand Down Expand Up @@ -446,7 +455,8 @@ macro_rules! delegate {
impl<CF: ClientFactory> v2::Host for InstanceState<CF> {}

impl<CF: ClientFactory> v2::HostConnection for InstanceState<CF> {
#[instrument(name = "spin_outbound_pg.open", skip(self, address), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
#[instrument(name = "spin_outbound_pg.open", skip(self, address), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql", db.address = Empty, server.port = Empty, db.namespace = Empty))]
async fn open(&mut self, address: String) -> Result<Resource<v2::Connection>, v2::Error> {
self.otel.reparent_tracing_span();
spin_factor_outbound_networking::record_address_fields(&address);
Expand All @@ -460,7 +470,8 @@ impl<CF: ClientFactory> v2::HostConnection for InstanceState<CF> {
.map_err(v2::Error::from)
}

#[instrument(name = "spin_outbound_pg.execute", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
#[instrument(name = "spin_outbound_pg.execute", skip(self, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql"))]
async fn execute(
&mut self,
connection: Resource<v2::Connection>,
Expand All @@ -480,7 +491,8 @@ impl<CF: ClientFactory> v2::HostConnection for InstanceState<CF> {
.map_err(track_db_error_on_span_v2)
}

#[instrument(name = "spin_outbound_pg.query", skip(self, connection, params), err(level = Level::INFO), fields(otel.kind = "client", db.system = "postgresql", otel.name = statement))]
#[instrument(name = "spin_outbound_pg.query", skip(self, connection, params), err(level = Level::INFO),
fields(otel.kind = "client", db.system = "postgresql"))]
async fn query(
&mut self,
connection: Resource<v2::Connection>,
Expand Down
Loading
Loading