Skip to content

Commit

Permalink
Merge pull request #19 from hasura:add-internal-visibility-tag
Browse files Browse the repository at this point in the history
add internal.visibility tag to spans
  • Loading branch information
BenoitRanque committed Apr 29, 2024
2 parents ece8fb0 + 8e89940 commit f1629f7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.8]

- Make spans visible to cloud console users (tag spans with `internal.visibility = 'user'`)

## [0.2.7]

- Fix a bug introduced in 0.2.6 that would cause responses including a single quote to be serialized as invalid JSON strings
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ members = [
]
resolver = "2"

package.version = "0.2.7"
package.version = "0.2.8"
package.edition = "2021"
10 changes: 8 additions & 2 deletions crates/common/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ pub async fn execute_query(
.query(parameters)
.body(statement.to_owned())
.send()
.instrument(tracing::info_span!("Execute HTTP request"))
.instrument(tracing::info_span!(
"Execute HTTP request",
internal.visibility = "user"
))
.await?;

if response.error_for_status_ref().is_err() {
Expand All @@ -36,7 +39,10 @@ pub async fn execute_query(

let response = response
.bytes()
.instrument(tracing::info_span!("Read HTTP response"))
.instrument(tracing::info_span!(
"Read HTTP response",
internal.visibility = "user"
))
.await?;

Ok(response)
Expand Down
27 changes: 15 additions & 12 deletions crates/ndc-clickhouse/src/connector/handler/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@ pub async fn query(
}

let (statement_string, parameters) =
tracing::info_span!("Build SQL Query").in_scope(|| -> Result<_, QueryError> {
let statement = QueryBuilder::new(&request, configuration).build()?;
tracing::info_span!("Build SQL Query", internal.visibility = "user").in_scope(
|| -> Result<_, QueryError> {
let statement = QueryBuilder::new(&request, configuration).build()?;

#[cfg(debug_assertions)]
{
// this block only present in debug builds, to avoid leaking sensitive information
let unsafe_statement_string = statement.to_unsafe_sql_string();
#[cfg(debug_assertions)]
{
// this block only present in debug builds, to avoid leaking sensitive information
let unsafe_statement_string = statement.to_unsafe_sql_string();

tracing::event!(Level::DEBUG, "Generated SQL" = unsafe_statement_string);
}
tracing::event!(Level::DEBUG, "Generated SQL" = unsafe_statement_string);
}

let (statement, parameters) = statement.into_parameterized_statement();
let (statement, parameters) = statement.into_parameterized_statement();

let statement_string = statement.to_parameterized_sql_string();
let statement_string = statement.to_parameterized_sql_string();

Ok((statement_string, parameters))
})?;
Ok((statement_string, parameters))
},
)?;

let client = state
.client(configuration)
Expand All @@ -51,6 +53,7 @@ pub async fn query(
db.system = "clickhouse",
db.user = configuration.connection.username,
db.statement = statement_string,
internal.visibility = "user",
);

let rowsets = execute_query(
Expand Down

0 comments on commit f1629f7

Please sign in to comment.