diff --git a/crates/mongodb-connector/src/mongo_connector.rs b/crates/mongodb-connector/src/mongo_connector.rs index 957c6378..79460304 100644 --- a/crates/mongodb-connector/src/mongo_connector.rs +++ b/crates/mongodb-connector/src/mongo_connector.rs @@ -17,6 +17,7 @@ use ndc_sdk::{ QueryResponse, SchemaResponse, }, }; +use tracing::instrument; use crate::{ api_type_conversions::{ @@ -29,10 +30,12 @@ use crate::{capabilities::mongo_capabilities_response, mutation::handle_mutation #[derive(Clone, Default)] pub struct MongoConnector; +#[allow(clippy::blocks_in_conditions)] #[async_trait] impl ConnectorSetup for MongoConnector { type Connector = MongoConnector; + #[instrument(err, skip_all)] async fn parse_configuration( &self, configuration_dir: impl AsRef + Send, @@ -44,6 +47,10 @@ impl ConnectorSetup for MongoConnector { } /// Reads database connection URI from environment variable + #[instrument(err, skip_all)] + // `instrument` automatically emits traces when this function returns. + // - `err` limits logging to `Err` results, at log level `error` + // - `skip_all` omits arguments from the trace async fn try_init_state( &self, configuration: &Configuration, @@ -54,11 +61,13 @@ impl ConnectorSetup for MongoConnector { } } +#[allow(clippy::blocks_in_conditions)] #[async_trait] impl Connector for MongoConnector { type Configuration = Configuration; type State = MongoConfig; + #[instrument(err, skip_all)] fn fetch_metrics( _configuration: &Self::Configuration, _state: &Self::State, @@ -66,6 +75,7 @@ impl Connector for MongoConnector { Ok(()) } + #[instrument(err, skip_all)] async fn health_check( _configuration: &Self::Configuration, state: &Self::State, @@ -83,6 +93,7 @@ impl Connector for MongoConnector { mongo_capabilities_response().into() } + #[instrument(err, skip_all)] async fn get_schema( configuration: &Self::Configuration, ) -> Result, SchemaError> { @@ -90,6 +101,7 @@ impl Connector for MongoConnector { Ok(response.into()) } + #[instrument(err, skip_all)] async fn query_explain( configuration: &Self::Configuration, state: &Self::State, @@ -109,6 +121,7 @@ impl Connector for MongoConnector { Ok(v2_to_v3_explain_response(response).into()) } + #[instrument(err, skip_all)] async fn mutation_explain( _configuration: &Self::Configuration, _state: &Self::State, @@ -119,6 +132,7 @@ impl Connector for MongoConnector { )) } + #[instrument(err, skip_all)] async fn mutation( _configuration: &Self::Configuration, state: &Self::State, @@ -127,6 +141,7 @@ impl Connector for MongoConnector { handle_mutation_request(state, request).await } + #[instrument(err, skip_all)] async fn query( configuration: &Self::Configuration, state: &Self::State,