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

Support for federated tracing #14

Closed
lennyburdette opened this issue Aug 1, 2019 · 2 comments
Closed

Support for federated tracing #14

lennyburdette opened this issue Aug 1, 2019 · 2 comments
Labels

Comments

@lennyburdette
Copy link
Contributor

Tracing works differently in a federated system than it does for a standard GraphQL server. It's officially documented here.

Question 1: do you think this library should include support for generating the trace proto and attaching it to the response? It could be a separately library, but I think it makes sense to include all federation concerns in one place.

Question 2: is anyone working on this?

The node.js implementation is here:

There's some unfinished ruby work for standard single-server traces (that are sent directly to Apollo's traces ingress endpoint instead of attached to the response to the gateway) here.

@rylanc
Copy link
Contributor

rylanc commented Aug 1, 2019

Hi @lennyburdette!

  1. I haven't given much thought to tracing yet (our gateway isn't live in production quite yet). From my understanding of federated tracing, it seems pretty specific to federation. So, it would make sense for the Ruby implementation to live in this repo.

  2. To my knowledge, no one has attempted to implement this in Ruby. Are you feeling up to the task? 🙂 I'm happy to chip in, but I don't know how much time I can dedicate to it for the next few weeks.

@lennyburdette
Copy link
Contributor Author

👋 Rylan!

Definitely agree that federated tracing is just different enough from standard tracing that it belongs here.

I'll have several hours on a plane with a laptop over the weekend so I'll get something started!

lennyburdette pushed a commit to lennyburdette/apollo-federation-ruby that referenced this issue Aug 6, 2019
Federated GraphQL services should include timing and error
information as a Base64-encoded protocol buffer message in
the `"extensions.ftv1"` field. The gateway requests traces
by adding a special header to the GraphQL request, and combines
traces from all federated services into a single trace.

This change includes a Tracer that uses the graphql-ruby
[tracing API][t] to record field timings and info and store it
on the execution context. It also includes methods on the
`ApolloFederation::Tracing` module to pluck the info from the
context, convert it to an encoded string, and attach it to the
query result's extensions.

I used the Apollo Server typescript code as reference:
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/federatedExtension.ts
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/treeBuilder.ts

As well as an unfinished fork of apollo-tracing-ruby:
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/tracer.rb
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/trace_tree.rb

Federated tracing documentation: https://www.apollographql.com/docs/apollo-server/federation/metrics/

Addresses Gusto#14

[t]:https://graphql-ruby.org/queries/tracing.html
lennyburdette pushed a commit to lennyburdette/apollo-federation-ruby that referenced this issue Aug 6, 2019
Federated GraphQL services should include timing and error
information as a Base64-encoded protocol buffer message in
the `"extensions.ftv1"` field. The gateway requests traces
by adding a special header to the GraphQL request, and combines
traces from all federated services into a single trace.

This change includes a Tracer that uses the graphql-ruby
[tracing API][t] to record field timings and info and store it
on the execution context. It also includes methods on the
`ApolloFederation::Tracing` module to pluck the info from the
context, convert it to an encoded string, and attach it to the
query result's extensions.

I used the Apollo Server typescript code as reference:
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/federatedExtension.ts
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/treeBuilder.ts

As well as an unfinished fork of apollo-tracing-ruby:
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/tracer.rb
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/trace_tree.rb

Federated tracing documentation: https://www.apollographql.com/docs/apollo-server/federation/metrics/

Addresses Gusto#14

[t]:https://graphql-ruby.org/queries/tracing.html
lennyburdette pushed a commit to lennyburdette/apollo-federation-ruby that referenced this issue Sep 7, 2019
Federated GraphQL services should include timing and error
information as a Base64-encoded protocol buffer message in
the `"extensions.ftv1"` field. The gateway requests traces
by adding a special header to the GraphQL request, and combines
traces from all federated services into a single trace.

This change includes a Tracer that uses the graphql-ruby
[tracing API][t] to record field timings and info and store it
on the execution context. It also includes methods on the
`ApolloFederation::Tracing` module to pluck the info from the
context, convert it to an encoded string, and attach it to the
query result's extensions.

I used the Apollo Server typescript code as reference:
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/federatedExtension.ts
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/treeBuilder.ts

As well as an unfinished fork of apollo-tracing-ruby:
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/tracer.rb
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/trace_tree.rb

Federated tracing documentation: https://www.apollographql.com/docs/apollo-server/federation/metrics/

Addresses Gusto#14

[t]:https://graphql-ruby.org/queries/tracing.html
lennyburdette pushed a commit to lennyburdette/apollo-federation-ruby that referenced this issue Sep 10, 2019
Federated GraphQL services should include timing and error
information as a Base64-encoded protocol buffer message in
the `"extensions.ftv1"` field. The gateway requests traces
by adding a special header to the GraphQL request, and combines
traces from all federated services into a single trace.

This change includes a Tracer that uses the graphql-ruby
[tracing API][t] to record field timings and info and store it
on the execution context. It also includes methods on the
`ApolloFederation::Tracing` module to pluck the info from the
context, convert it to an encoded string, and attach it to the
query result's extensions.

I used the Apollo Server typescript code as reference:
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/federatedExtension.ts
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/treeBuilder.ts

As well as an unfinished fork of apollo-tracing-ruby:
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/tracer.rb
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/trace_tree.rb

Federated tracing documentation: https://www.apollographql.com/docs/apollo-server/federation/metrics/

Addresses Gusto#14

[t]:https://graphql-ruby.org/queries/tracing.html
noaelad pushed a commit that referenced this issue Sep 10, 2019
* feat: add support for federated tracing

Federated GraphQL services should include timing and error
information as a Base64-encoded protocol buffer message in
the `"extensions.ftv1"` field. The gateway requests traces
by adding a special header to the GraphQL request, and combines
traces from all federated services into a single trace.

This change includes a Tracer that uses the graphql-ruby
[tracing API][t] to record field timings and info and store it
on the execution context. It also includes methods on the
`ApolloFederation::Tracing` module to pluck the info from the
context, convert it to an encoded string, and attach it to the
query result's extensions.

I used the Apollo Server typescript code as reference:
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/federatedExtension.ts
* https://github.com/apollographql/apollo-server/blob/master/packages/apollo-engine-reporting/src/treeBuilder.ts

As well as an unfinished fork of apollo-tracing-ruby:
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/tracer.rb
* https://github.com/salsify/apollo-tracing-ruby/blob/feature/new-apollo-api/lib/apollo_tracing/trace_tree.rb

Federated tracing documentation: https://www.apollographql.com/docs/apollo-server/federation/metrics/

Addresses #14

[t]:https://graphql-ruby.org/queries/tracing.html

* chore: code review

* `module_function` vs repetitive `self.`
* fix a call to `result.to_h` in `.attach_trace_to_result`

* FIXUP: add comments explaining the tracer execution order and add a test to cover lazy fields

will squash later
@noaelad noaelad closed this as completed Sep 10, 2019
grxy pushed a commit that referenced this issue Sep 10, 2019
# [0.4.0](v0.3.2...v0.4.0) (2019-09-10)

### Features

* add support for federated tracing ([#16](#16)) ([57ecc5b](57ecc5b)), closes [#14](#14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants