-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4dbf2f
commit 368a6e6
Showing
3 changed files
with
42 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
import type { LRUCache } from 'lru-cache'; | ||
import { metrics } from '@hive/service-common'; | ||
|
||
export const cacheHits = new metrics.Counter({ | ||
name: 'tokens_cache_hits', | ||
help: 'Number of cache hits', | ||
const tokenReads = new metrics.Counter({ | ||
name: 'tokens_reads', | ||
help: 'Number of token reads', | ||
labelNames: ['status'], | ||
}); | ||
|
||
export const cacheMisses = new metrics.Counter({ | ||
name: 'tokens_cache_misses', | ||
help: 'Number of cache misses', | ||
const cacheReads = new metrics.Counter({ | ||
name: 'tokens_cache_reads', | ||
help: 'Number of cache reads', | ||
labelNames: ['status'], | ||
}); | ||
|
||
export const cacheInvalidations = new metrics.Counter({ | ||
name: 'tokens_cache_invalidations', | ||
help: 'Number of cache invalidations', | ||
const cacheFills = new metrics.Counter({ | ||
name: 'tokens_cache_fills', | ||
help: 'Number of cache fills', | ||
labelNames: ['source'], | ||
}); | ||
|
||
export function recordCacheRead(status: NonNullable<LRUCache.Status<unknown>['fetch']>) { | ||
cacheReads.inc({ status }); | ||
} | ||
|
||
export function recordCacheFill(source: 'db' | 'redis-fresh' | 'redis-stale') { | ||
cacheFills.inc({ source }); | ||
} | ||
|
||
export function recordTokenRead(status: 200 | 500 | 404) { | ||
tokenReads.inc({ status }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters