Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query metrics and spans #74

Merged
merged 5 commits into from
Nov 16, 2023
Merged

Conversation

danieljharvey
Copy link
Collaborator

@danieljharvey danieljharvey commented Nov 15, 2023

What

In order to run the benchmarks we rely on a bunch of metrics existing, such as connection acquisition time and query time. This adds these, as well as instrumenting OTel spans in this area too.

Screenshot 2023-11-15 at 15 28 18

How

Match ndc-postgres as much as possible.

@@ -155,39 +156,7 @@ impl connector::Connector for SQLServer {
state: &Self::State,
query_request: models::QueryRequest,
) -> Result<JsonResponse<models::QueryResponse>, connector::QueryError> {
tracing::info!("{}", serde_json::to_string(&query_request).unwrap());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to src/query.rs

@@ -1,58 +0,0 @@
//! Metrics setup and update for our connector.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Superceded by metrics.rs in query-engine

///
/// This function implements the [query endpoint](https://hasura.github.io/ndc-spec/specification/queries/index.html)
/// from the NDC specification.
pub async fn query(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Split this up into plan_query and execute_query so it's easier to time / instrument both.

Ok(response)
}

async fn execute_query(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Make execute_query it's own function so it's easier to instrument / time.

@@ -21,35 +24,57 @@ pub async fn mssql_execute(
&plan.variables,
);

let acquisition_timer = metrics.time_connection_acquisition_wait();
let connection_result = mssql_pool
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Acquire one connection and use it throughout rather than passing the pool around.

@danieljharvey danieljharvey force-pushed the djh/NDAT-1031/add-metrics branch from 5866d79 to 07614ce Compare November 15, 2023 15:33
@@ -0,0 +1,12 @@
apiVersion: 1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Everything in /metrics is taken from ndc-postgres and postgres -> sqlserver.

@danieljharvey danieljharvey force-pushed the djh/NDAT-1031/add-metrics branch from 965a7c5 to c12eef1 Compare November 15, 2023 15:47
@danieljharvey danieljharvey requested a review from soupi November 15, 2023 15:47
@danieljharvey danieljharvey mentioned this pull request Nov 15, 2023
@danieljharvey danieljharvey added this pull request to the merge queue Nov 16, 2023
Merged via the queue into main with commit fea9824 Nov 16, 2023
6 checks passed
@danieljharvey danieljharvey deleted the djh/NDAT-1031/add-metrics branch November 16, 2023 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants