-
Notifications
You must be signed in to change notification settings - Fork 35
Opentracing? #12
Comments
I'm pretty excited about integrating with OpenTracing, but it would be an addition rather than a replacement of this format I think. The goal of Apollo Tracing is to include GraphQL-specific timing and schema information in-band, as part of a response. It isn't clear how OpenTracing could replace that. But I can imagine adding fields to the format to associate a request with a trace ID, or associate span IDs with individual resolver calls for example. |
I think there's a great opportunity for the Apollo team to suggest a standard for how to implement tracing with OpenTracing across GraphQL servers. The Go implementation that may provide a good starting point: https://github.com/neelance/graphql-go/blob/master/trace/trace.go The Go add these tags to a their
Here is what Apollo tracing defines as tags on their
I did some quick research and it seems like tracing in GraphQL is pretty fragmented:
|
The Go implementation is what I had in mind as well. It's working really well for me in production. |
So what use cases are people looking at solving with OpenTracing integration? Is it mostly about being able to propagate context to downstream operations? How do you see yourself using that context? For Engine, one of the feature ideas we've talked about is the ability to associate a |
It's exactly why I use tracing for, my GraphQL API is only one component of my global project and I'd like to be able to follow the trace from the very beginning to the end, across all the services/components. |
@martijnwalraven while I agree the output will be different I think the underlying data structures and instrumentation could be shared as @loganvolkers proposed. I would speculate you can store everything in opentracing's data structures that is required for Apollo tracing JSON. Before the final response body is sent across the wire the JSON trace data could be assembled from the opentracing trace tree. Naively ObjectType feels like the best place to instrument the trace capture but I'm fairly new to graphene. So there might be a better place to conduct instrumentation. ResolveInfo or something else that's passed to the resolvers would benefit from having these additional fields as a minimum;
There's some other fields I think ResolveInfo could benefit having which would help query optimisation but I'll not conflate that in this issue. Ideally what I would want from it is all performance metrics and annotations that are available. The aim would be to answer questions like;
I've instrumented some tracing using Jaegar, custom middleware, and opentracing in a spike I've done with Star Wars data. It's not where I want it to be but this screenshot which uses a Star Wars schema illustrates the minimum I would want to see. Ideally I wouldn't need custom middleware to create these spans. |
@martijnwalraven In my team, we have many services and we use a GraphQL server (the Go implementation mentioned by @tonyghita and @loganvolkers) in front of them as an API Gateway pattern. The GraphQL server is a very thin layer that contains (almost) no logic at all. Each resolver is fetching data from one or more other services using gRPC. In this setup, it is common to have GraphQL requests, which fetch data from multiple services, databases, Redis instances, Elasticsearch etc. We have also been able to identify poor performance where some sub-requests were executed sequentially instead of in parallel. Things like parallelism and concurrency are immediately visible on the trace graph. And finally, tracing solutions like Jaeger help you visualise service dependencies in your system. If every single service in your system implements OpenTracing, you can easily plot a dependency graph and see which service depends on which other service. Or which service (if any) uses a particular resolver. I truly believe that OpenTracing is the 2nd most important feature in a GraphQL server (after being able to serve GraphQL). |
Hello, I am also interested in this and have created a test project to see what is possible. Note this does require some unreleased context extensions changes which have been merged to master but not yet released so I am patching apollo-server-core right now. The results look promising so far This is the query:
With a 1 second delay on resolving people and 200 millisecond delay for each name - Contrived I know but easy to test what I am after. The traces might look a bit weird because the person resolvers (last 6 spans) are not nested inside the people span. So resolution of people appears to take 1 second when it actually takes 1.2. Resolution Sequence:
I plan to integrate tracing into knex next and see how that goes. I also found this project |
I would also give https://github.com/census-instrumentation a look too. With the Go API it is at least a little more idiomatic and does a good job abstracting the underlying tracers away. |
Any updates on this issue? |
Filed an issue relating to opentelemetry here now that the project has been merged: apollographql/apollo-tooling#1889 |
Would you be open to adopting the OpenTracing standard? It's a vendor-neutral open standard for distributed tracing (kind of like GraphQL is to APIs).
There is a wealth of distributed tracing tooling that also implements the standard. Adopting OpenTracing would make it easier to integrate with this other tooling.
The text was updated successfully, but these errors were encountered: