dcramer / peated

https://peated.com
Apache License 2.0
59 stars 12 forks source link

feat(instrument-cache): emit cache spans from query client #172

Open bcoe opened 1 month ago

bcoe commented 1 month ago

This PR adds instrumentation of cache spans to the @tanstack/react-query client. I could not find a hook for this, so I subclassed QueryClient, we should be mindful of this contract changing over time:

Screenshot 2024-06-17 at 1 44 50 PM

Note: in implementing this, I noticed that queries seem to cache for 5 minutes, which is the default garbage collection in the cache, vs., 60 seconds configured for revalidation. I believe this might be due to revalidateIfStale defaulting to false. If this is fixed, the cache span logic also needs to be updated to reflect this.