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

Federated tracing is not included in the response even though HTTP header 'apollo-federation-include-trace': 'ftv1' is provided #432

Closed
michalkrajcovic opened this issue Feb 4, 2025 · 2 comments

Comments

@michalkrajcovic
Copy link

michalkrajcovic commented Feb 4, 2025

Version v4.4.0 commit 370 changed the federated tracing to not generate ftv1 traces by default. The result is that tracing information is never returned in the response.

FederatedTracingInstrumentation#shouldTrace checks whether ExecutionInput#getGraphQLContext map contains the entry ‘apollo-federation-include-trace with value ‘ftv1’.

That key ‘apollo-federation-include-trace with value ‘ftv1’ is not present in the GraphQLContext map even though HTTP header 'apollo-federation-include-trace': 'ftv1' is provided. The result is that federated tracing is not present in the response.

Step to reproduce:

  1. check out https://github.com/apollographql/federation-jvm-spring-example (spring-boot 3.3.0, federation-graphql-java-support 5.3.0)
  2. enable federated tracing in the product subgraph
@Bean
public GraphQlSourceBuilderCustomizer customizer(FederationSchemaFactory factory) {
 return builder -> builder.schemaFactory(factory::createGraphQLSchema).instrumentation(List.of(new FederatedTracingInstrumentation()));
}
  1. Run the product service ./gradlew :products-subgraph:bootRun
  2. Query product service
curl --location 'http://localhost:8080/graphql' \
--header 'apollo-federation-include-trace: ftv1' \
--header 'Content-Type: application/json' \
--data '{"query":"query ExampleQuery {\n    products {\n        id\n        name\n        description\n    }\n}","variables":{}}'
  1. Field extensions": { "ftv1": "..." } } is not present

The workaround is custom shouldTracePredicate:

new FederatedTracingInstrumentation(new FederatedTracingInstrumentation.Options(false, executionInput -> true))
@dariuszkuc
Copy link
Member

Hello 👋,
Federation JVM is a low level library that only relies on graphql-java and is unaware of any web frameworks (e.g. Spring). FederatedTracingInstrumentation relies on the appropriate value being set in the context - it is up to you to ensure that the values are populated from the incoming request (see README and spring-graphql example. ).

Tracing should only happen if ftv1 value is set and it should generally only be set on a small sample of transactions. Your workaround sets it always to true which means that every request would calculate the tracing information regardless whether router asks for it or not.

@dariuszkuc dariuszkuc closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2025
@michalkrajcovic
Copy link
Author

Hi @dariuszkuc

thanks for pointing me into the right direction.

Would it make sense to update the federation-jvm-spring-example to have a Spring Boot example of how to configure the federated tracing? That repo is mentioned as 'Federation JVM example integrations' in the README you just posted. Or please reference spring-graphql example in the README as well.

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

No branches or pull requests

2 participants