fix(rps): count cache-served requests toward current RPS

RecordRequest() only ran inside proxyTheRequest, but cache hits return from handleCaching before reaching it. As a result the dashboard's current RPS read 0 whenever traffic was served from cache (e.g. a repeated query at 100% hit rate). Record the request on the cache-hit branch too; misses and proxied/GET requests still record in proxyTheRequest, so there is no double counting.

Verified: 100% cache-hit load now reports ~16-20k req/s instead of a flat 0.
This commit is contained in:
2026-06-21 02:48:35 +01:00
parent 01d1de1f0b
commit 5bbe986656
+7
View File
@@ -357,6 +357,13 @@ func handleCaching(c *fiber.Ctx, parsedResult *parseGraphQLQueryResult, userID,
// Try to get from cache
if cachedResponse := libpack_cache.CacheLookup(calculatedQueryHash); cachedResponse != nil {
// Count cache-served requests toward RPS too. Cache hits return here
// without reaching proxyTheRequest (where misses/proxied requests are
// recorded), so without this the dashboard's current RPS reads 0
// whenever traffic is served from cache.
if rpsTracker := GetRPSTracker(); rpsTracker != nil {
rpsTracker.RecordRequest()
}
cfg.Monitoring.Increment(libpack_monitoring.MetricsCacheHit, nil)
c.Set("X-Cache-Hit", "true")
c.Set("Content-Type", "application/json")