diff --git a/src/helpers/cache.ts b/src/helpers/cache.ts index 961e87e9..92d08eb1 100644 --- a/src/helpers/cache.ts +++ b/src/helpers/cache.ts @@ -1,6 +1,5 @@ import redis from '../redis'; import { get, set } from '../aws'; -import { cacheActivitesCount } from '../metrics'; export const VP_KEY_PREFIX = 'vp'; @@ -16,7 +15,6 @@ export async function cachedVp>( toCache = true ) { if (!toCache || !redis) { - cacheActivitesCount.inc({ type: 'vp', status: 'skip' }); return { result: await callback(), cache: false }; } @@ -26,15 +24,12 @@ export async function cachedVp>( cache.vp = parseFloat(cache.vp); cache.vp_by_strategy = JSON.parse(cache.vp_by_strategy); - cacheActivitesCount.inc({ type: 'vp', status: 'hit' }); return { result: cache as Awaited, cache: true }; } const result = await callback(); - let cacheHitStatus = 'unqualified'; if (result.vp_state === 'final') { - cacheHitStatus = 'miss'; const multi = redis.multi(); multi.hSet(`${VP_KEY_PREFIX}:${key}`, 'vp', result.vp); multi.hSet(`${VP_KEY_PREFIX}:${key}`, 'vp_by_strategy', JSON.stringify(result.vp_by_strategy)); @@ -42,26 +37,22 @@ export async function cachedVp>( multi.exec(); } - cacheActivitesCount.inc({ type: 'vp', status: cacheHitStatus }); return { result, cache: false }; } export async function cachedScores(key: string, callback: () => Type, toCache = false) { if (!toCache || !!process.env.AWS_REGION) { - cacheActivitesCount.inc({ type: 'scores', status: 'skip' }); return { scores: await callback(), cache: false }; } const cache = await get(key); if (cache) { - cacheActivitesCount.inc({ type: 'scores', status: 'hit' }); return { scores: cache as Awaited, cache: true }; } const scores = await callback(); set(key, scores); - cacheActivitesCount.inc({ type: 'scores', status: 'miss' }); return { scores, cache: false }; } diff --git a/src/metrics.ts b/src/metrics.ts index 36ff3ef9..10b0d90d 100644 --- a/src/metrics.ts +++ b/src/metrics.ts @@ -30,9 +30,3 @@ export const requestDeduplicatorSize = new client.Gauge({ name: 'request_deduplicator_size', help: 'Total number of items in the deduplicator queue' }); - -export const cacheActivitesCount = new client.Gauge({ - name: 'cache_activites_count', - help: 'Number of requests to the cache layer', - labelNames: ['type', 'status'] -});