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

use trace ids from the client #297

Closed
Geal opened this issue Jan 3, 2022 · 2 comments · Fixed by #782
Closed

use trace ids from the client #297

Geal opened this issue Jan 3, 2022 · 2 comments · Fixed by #782
Assignees

Comments

@Geal
Copy link
Contributor

Geal commented Jan 3, 2022

trace ids propagation works for spans generated in the router propagated to the subgraphs, but spans generated by the client are not used as parent of the router's root span.
Since there's some potential for abuse (clients using invalid spans or sampling values on open servers), this should be an option, deactivated by default.

Once we make a decision on this, supporting it is easy:

diff --git a/apollo-router/src/warp_http_server_factory.rs b/apollo-router/src/warp_http_server_factory.rs
index c797f97..7c18d0a 100644                                                                             
--- a/apollo-router/src/warp_http_server_factory.rs                                                       
+++ b/apollo-router/src/warp_http_server_factory.rs                                                       
@@ -286,14 +286,14 @@ where                                                                               
     PreparedQuery: graphql::PreparedQuery + 'static,                                                     
 {                                                                                                        
     // retrieve and reuse the potential trace id from the caller                                         
-    opentelemetry::global::get_text_map_propagator(|injector| {                                          
-        injector.extract_with_context(&Span::current().context(), &HeaderMapCarrier(&header_map));       
+    let parent_context = opentelemetry::global::get_text_map_propagator(|injector| {                     
+        injector.extract_with_context(&Span::current().context(), &HeaderMapCarrier(&header_map))        
     });                                                                                                  
                                                                                                          
     async move {                                                                                         
-        let response_stream = stream_request(router, request)                                            
-            .instrument(tracing::info_span!("graphql_request"))                                          
-            .await;                                                                                      
+        let span = tracing::info_span!("graphql_request");                                               
+        span.set_parent(parent_context);                                                                 
+        let response_stream = stream_request(router, request).instrument(span).await;                    

This should also add a test for this behavior, following up on #276 .

@abernix
Copy link
Member

abernix commented Mar 24, 2022

In theory this works, but needs to be tested.

@Geal Geal assigned Geal and BrynCooke and unassigned Geal Apr 5, 2022
@BrynCooke BrynCooke linked a pull request Apr 5, 2022 that will close this issue
@BrynCooke
Copy link
Contributor

I think this mostly is fixed with #782

Relevant information from Otel Spec

In particular we now fulfill this requirements:

If there is a valid parent trace ID, use it. Otherwise generate a new trace ID (note: this must be done before calling ShouldSample, because it expects a valid trace ID as input).

TLDR the decision to sample is not made by the client unless ParentBased sampling is enabled.

@BrynCooke BrynCooke modified the milestone: v0.1.0-preview.4 Apr 20, 2022
tinnou pushed a commit to Netflix-Skunkworks/router that referenced this issue Oct 16, 2023
CentOS 8 is EOL, but CentOS 7 is LTS until June 30, 2024. Closes apollographql#297
(which is failing CI due to broken support in v8).
lennyburdette added a commit that referenced this issue Dec 20, 2023
feat: carry interfaces into connector (inner) supergraph
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 a pull request may close this issue.

3 participants