We are using Absinthe to provide a GraphQL API. The absinthe service is using HTTP calls to resolve fields. There is a Rails application that is a source of the data.
To get a better visibility into the external calls, we would like to count in the absinthe service the number of external calls made and return it as a header. Also to log this number it at the end of the request.
What would be the best way how to approach this?
So far the idea is to start an Agent somewhere in Plug middleware for every incoming request. Then before a request to Rails during resolutions, we would increment the value.
Sorry, I didn’t read the whole post clearly and missed the whole bit where this is part of the response to an individual request. I think your agent solution works, as would probably using the process dictionary, although with the latter you’d need to be thoughtful about any intermediary processes you spawn.