How can we keep track of all the transactions performed in the entire supergraph for one request?

Hello,

I would like to know if there is a known way of keeping track of a transaction across a graph (monolith or supergraph - from the gateway to the database)?
I can be useful for auditing or debugging purpose to keep an historic of the transaction. (data sent, response given, subgrap used, database transaction… All would be referenced with the same Transaction ID)

I was thinking of something like creating a middleware on the gateway that will create a UUID and send it down to the subgraphs and send the data to my logging server (such as graphana) at every level(very bad for performance)
Or gathering the data from the subgraph somehow and once the response comes back to the gateway, i send the information at once.
The bad thing would be the performance that will be reduced.

Any other idea or existing solution?

Best regards

Hey Cyril,

We have a UUID that is standard and generated at the edge so that we can get a full view. That’s then forwarded along all requests between router, subgraphs, other services, etc. There is definitely a cost factor here, but alternatively we have a low rate sampling on something like DataDog APM which usually gives us a good pool of traces there as well.

Similarly, we also have other metrics for example operation X, we keep track of latency of all subgraphs resolving operation X. This also has a high cost factor because of cardinality, but the cost outweighs the visibility the platform (router) gives to the entire organization without coordinating with something like a UUID that everyone has to report/log properly.

2 Likes

I agree with @Serey_Morm here. What you are describing is what is known as a trace id in OpenTelemetry: Traces | OpenTelemetry

Router supports OpenTelemetry and adding that value for you if it is not already defined: Router Telemetry - Apollo GraphQL Docs

Then using other tools like the coprocessor, you can additional log other things like the query plan or operation size/cost for a given trace id: External Coprocessing - Apollo GraphQL Docs