In a traditional REST API, it is common to add percentile response time monitoring on the URL level. In graphql, things are slightly different. All requests go via one endpoint, /graphql. Placing a percentile on the HTTP URL would not give us any useful information. So how do we identify slow resolvers and bottlenecks?
One method is to add request tracing to your resolvers/datafetchers, dataloaders and fields. This tracing will record important information such as the execution time. This data can then be used to identify slow revolvers that need tuned.
Although, beware If a resolver throws an exception, its child resolvers will not execute - therefore you may have slightly misleading metrics / missing data for that period of time (until parent resolver is not throwing exceptions).
We can enable the TracingInstrumentation bean by setting the graphql.servlet.tracingEnabled: true.
This will record the execution time of our resolvers/field methods. This data will be placed into the graphql response object and visible via graphql playground.
Beware in production, I have seen this add considerable latency to response times in high-throughput APIs. You might want to have a play about first... or do some sampling.
In the next video I introduce a multi-threaded safe correlation_id log :)
See you in the next video!
Cheers!
Philip
GraphQL Instrumentation: https://www.graphql-java.com/document...
Spring Boot GraphQL Java: https://github.com/graphql-java-kicks...
Good article on graphql paypal instrumentation: / graphql-instrumenting-your-api-and-unlocki...
Apollo tracing: https://github.com/apollographql/apol...
Auf dieser Seite können Sie das Online-Video Spring Boot GraphQL Tutorial #25 - Request Tracing mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Philip Starritt 11 Oktober 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 3,563 Mal angesehen und es wurde von 33 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!