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

GraphQL response processing must happen under the execution span #3732

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changesets/fix_geal_fix_execution_span_attribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### GraphQL response processing must happen under the execution span ([PR #3732](https://github.com/apollographql/router/pull/3732))

Previously, any event in processing would be reported under the supergraph span, or any plugin span (like rhai) happening in between

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/3732
23 changes: 14 additions & 9 deletions apollo-router/src/services/execution_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use tower::ServiceExt;
use tower_service::Service;
use tracing::event;
use tracing::Instrument;
use tracing::Span;
use tracing_core::Level;

use super::new_service::ServiceFactory;
Expand Down Expand Up @@ -171,17 +172,21 @@ impl ExecutionService {
let schema = self.schema.clone();
let mut nullified_paths: Vec<Path> = vec![];

let execution_span = Span::current();

let stream = stream
.filter_map(move |response: Response| {
ready(Self::process_graphql_response(
&query,
operation_name.as_deref(),
&variables,
is_deferred,
&schema,
&mut nullified_paths,
response,
))
ready(execution_span.in_scope(|| {
Self::process_graphql_response(
&query,
operation_name.as_deref(),
&variables,
is_deferred,
&schema,
&mut nullified_paths,
response,
)
}))
})
.boxed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,24 +707,24 @@ expression: get_spans()
}
}
}
},
"apollo_router::services::execution_service::format_response": {
"name": "apollo_router::services::execution_service::format_response",
"record": {
"entries": [],
"metadata": {
"name": "format_response",
"target": "apollo_router::services::execution_service",
"level": "DEBUG",
"module_path": "apollo_router::services::execution_service",
"fields": {
"names": []
}
}
},
"children": {}
}
}
},
"apollo_router::services::execution_service::format_response": {
"name": "apollo_router::services::execution_service::format_response",
"record": {
"entries": [],
"metadata": {
"name": "format_response",
"target": "apollo_router::services::execution_service",
"level": "DEBUG",
"module_path": "apollo_router::services::execution_service",
"fields": {
"names": []
}
}
},
"children": {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,24 +422,24 @@ expression: get_spans()
"children": {}
}
}
},
"apollo_router::services::execution_service::format_response": {
"name": "apollo_router::services::execution_service::format_response",
"record": {
"entries": [],
"metadata": {
"name": "format_response",
"target": "apollo_router::services::execution_service",
"level": "DEBUG",
"module_path": "apollo_router::services::execution_service",
"fields": {
"names": []
}
}
},
"children": {}
}
}
},
"apollo_router::services::execution_service::format_response": {
"name": "apollo_router::services::execution_service::format_response",
"record": {
"entries": [],
"metadata": {
"name": "format_response",
"target": "apollo_router::services::execution_service",
"level": "DEBUG",
"module_path": "apollo_router::services::execution_service",
"fields": {
"names": []
}
}
},
"children": {}
}
}
}
Expand Down