-
Notifications
You must be signed in to change notification settings - Fork 1k
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
graphql: metrics for validation and parsing phases #3760
Conversation
92d5c46
to
841e8e0
Compare
Seems there are build issues. |
I'm trying to add This way it's all in one place. |
841e8e0
to
b2cd397
Compare
Tests are not passing. |
graph/src/data/query/result.rs
Outdated
@@ -45,12 +46,14 @@ pub type Data = Object; | |||
/// A collection of query results that is serialized as a single result. | |||
pub struct QueryResults { | |||
results: Vec<Arc<QueryResult>>, | |||
pub validation_time: Option<Duration>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not great that this field had to be added. Could perhaps the GraphQlRunner have access to the GraphQLServiceMetrics
and register the metric immediately after taking the measurement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created GraphQLMetrics
that is passed to GraphQlRunner
and is responsible for all metrics related to GraphQL:
query_execution_time
query_parsing_time
query_validation_time
query_result_size
query_result_max
81dc87a
to
e525140
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor!
graph/src/components/graphql.rs
Outdated
pub trait GraphQLMetrics: Send + Sync + 'static { | ||
fn observe_query_execution(&self, duration: Duration, results: &QueryResults) -> (); | ||
fn observe_query_parsing(&self, duration: Duration, results: &QueryResults) -> (); | ||
fn observe_query_validation(&self, duration: Duration, id: &DeploymentHash) -> (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -> ()
can be omitted.
pub trait GraphQLMetrics: Send + Sync + 'static { | |
fn observe_query_execution(&self, duration: Duration, results: &QueryResults) -> (); | |
fn observe_query_parsing(&self, duration: Duration, results: &QueryResults) -> (); | |
fn observe_query_validation(&self, duration: Duration, id: &DeploymentHash) -> (); | |
pub trait GraphQLMetrics: Send + Sync + 'static { | |
fn observe_query_execution(&self, duration: Duration, results: &QueryResults); | |
fn observe_query_parsing(&self, duration: Duration, results: &QueryResults); | |
fn observe_query_validation(&self, duration: Duration, id: &DeploymentHash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, did
server/index-node/src/service.rs
Outdated
@@ -120,7 +120,7 @@ where | |||
let validated = ValidatedRequest::new(body, &req_parts.headers)?; | |||
let query = validated.query; | |||
|
|||
let query = match PreparedQuery::new(&self.logger, schema, None, query, None, 100) { | |||
let query = match PreparedQuery::new(&self.logger, schema, None, query, None, 100, None) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to use a fake metrics collector like there is for tests, than have this be an option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@kamilkisiela this just needs to be rebased. |
cf91af7
to
a90028a
Compare
@leoyvens rebased |
New Prometheus metrics
query_parsing_time
query_validation_time
Closes #3752