-
Notifications
You must be signed in to change notification settings - Fork 272
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
chore: Add integration tests for Open Telemetry #276
Changes from all commits
c61e954
3be9bce
bf24d41
11b18ad
dd30f07
9efec19
113deea
a827251
c0575d0
ad9a1dc
a6b4cbe
c4e73c4
3245333
9fd9d40
d74ca96
ee70ef3
61f8ee3
a6c1f81
8f41302
c6170cc
c6a44d8
b01ea51
342568a
0a98404
abc5fa0
1208efe
bc9208d
8698f10
9aa0c52
f9b0215
c5b4266
e715d99
ca5b9ad
22e527e
0d77c2f
78516c6
7128963
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,11 +45,8 @@ pub(crate) enum PlanNode { | |
|
||
impl QueryPlan { | ||
/// Validate the entire request for variables and services used. | ||
#[tracing::instrument(name = "validation", level = "debug", skip_all)] | ||
pub fn validate_request( | ||
&self, | ||
service_registry: Arc<dyn ServiceRegistry>, | ||
) -> Result<(), Response> { | ||
#[tracing::instrument(skip_all, name = "validate", level = "debug")] | ||
pub fn validate(&self, service_registry: Arc<dyn ServiceRegistry>) -> Result<(), Response> { | ||
let mut early_errors = Vec::new(); | ||
for err in self | ||
.root | ||
|
@@ -323,14 +320,16 @@ mod fetch { | |
|
||
let query_span = tracing::info_span!("subfetch", service = service_name.as_str()); | ||
|
||
let Variables { variables, paths } = Variables::new( | ||
&self.requires, | ||
self.variable_usages.as_ref(), | ||
data, | ||
current_dir, | ||
request, | ||
schema, | ||
)?; | ||
let Variables { variables, paths } = query_span.in_scope(|| { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧶 per our ADR on telemetry, we should prefer to put this at the source instead of the caller. |
||
Variables::new( | ||
&self.requires, | ||
self.variable_usages.as_ref(), | ||
data, | ||
current_dir, | ||
request, | ||
schema, | ||
) | ||
})?; | ||
|
||
let fetcher = service_registry | ||
.get(service_name) | ||
|
@@ -343,16 +342,18 @@ mod fetch { | |
.variables(Arc::new(variables)) | ||
.build(), | ||
) | ||
.instrument(query_span) | ||
.instrument(tracing::info_span!(parent: &query_span, "subfetch_stream")) | ||
.await?; | ||
|
||
if !response.is_primary() { | ||
return Err(FetchError::SubrequestUnexpectedPatchResponse { | ||
service: service_name.to_owned(), | ||
}); | ||
} | ||
query_span.in_scope(|| { | ||
if !response.is_primary() { | ||
return Err(FetchError::SubrequestUnexpectedPatchResponse { | ||
service: service_name.to_owned(), | ||
}); | ||
} | ||
Comment on lines
+349
to
+353
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧶 I'm don't understand why this is under the query_span |
||
|
||
self.response_at_path(current_dir, paths, response) | ||
self.response_at_path(current_dir, paths, response) | ||
}) | ||
} | ||
|
||
#[instrument(level = "debug", name = "response_insert", skip_all)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ impl RouterBridgeQueryPlanner { | |
|
||
#[async_trait] | ||
impl QueryPlanner for RouterBridgeQueryPlanner { | ||
#[tracing::instrument(name = "plan", level = "debug", skip_all)] | ||
#[tracing::instrument(skip_all, name = "plan", level = "debug")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧶 File unnecessarily touch in this PR If possible I would like to keep the commits on main focus on their actual feature. If you want to re-order all the |
||
async fn get( | ||
&self, | ||
query: String, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ use serde_json::to_string_pretty; | |
use std::collections::hash_map::Entry; | ||
use std::collections::HashMap; | ||
use std::sync::{Arc, Mutex}; | ||
use test_log::test; | ||
use test_span::prelude::*; | ||
use url::Url; | ||
|
||
macro_rules! assert_federated_response { | ||
|
@@ -43,7 +43,7 @@ macro_rules! assert_federated_response { | |
}; | ||
} | ||
|
||
#[test(tokio::test)] | ||
#[tokio::test] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ Why did you remove the logger initialization for these tests? |
||
async fn basic_request() { | ||
assert_federated_response!( | ||
r#"{ topProducts { name name2:name } }"#, | ||
|
@@ -53,7 +53,7 @@ async fn basic_request() { | |
); | ||
} | ||
|
||
#[test(tokio::test)] | ||
#[tokio::test] | ||
async fn basic_composition() { | ||
assert_federated_response!( | ||
r#"{ topProducts { upc name reviews {id product { name } author { id name } } } }"#, | ||
|
@@ -65,7 +65,31 @@ async fn basic_composition() { | |
); | ||
} | ||
|
||
#[test(tokio::test)] | ||
#[test_span(tokio::test)] | ||
async fn traced_basic_request() { | ||
assert_federated_response!( | ||
r#"{ topProducts { name name2:name } }"#, | ||
hashmap! { | ||
"products".to_string()=>1, | ||
}, | ||
); | ||
insta::assert_json_snapshot!(get_spans()); | ||
} | ||
|
||
#[test_span(tokio::test)] | ||
async fn traced_basic_composition() { | ||
assert_federated_response!( | ||
r#"{ topProducts { upc name reviews {id product { name } author { id name } } } }"#, | ||
hashmap! { | ||
"products".to_string()=>2, | ||
"reviews".to_string()=>1, | ||
"accounts".to_string()=>1, | ||
}, | ||
); | ||
insta::assert_json_snapshot!(get_spans()); | ||
} | ||
|
||
#[tokio::test] | ||
async fn basic_mutation() { | ||
assert_federated_response!( | ||
r#"mutation { | ||
|
@@ -88,7 +112,7 @@ async fn basic_mutation() { | |
); | ||
} | ||
|
||
#[test(tokio::test)] | ||
#[test_span(tokio::test)] | ||
async fn variables() { | ||
assert_federated_response!( | ||
r#" | ||
|
@@ -113,7 +137,7 @@ async fn variables() { | |
); | ||
} | ||
|
||
#[test(tokio::test)] | ||
#[tokio::test] | ||
async fn missing_variables() { | ||
let request = graphql::Request::builder() | ||
.query( | ||
|
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.