Skip to content
Snippets Groups Projects
Commit ae56d8c0 authored by julian.baeume's avatar julian.baeume :pick:
Browse files

unify name prefix of metrics exposed using promclient

Change the prefix to reflect the "new" name of the service. May be this even should be configurable at some point.

This is a breaking change.
parent ba11d966
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ import { viteManifestToDeps } from './util.js' ...@@ -26,7 +26,7 @@ import { viteManifestToDeps } from './util.js'
const swaggerDocument = yaml.load(fs.readFileSync('./src/swagger.yaml', 'utf8')) const swaggerDocument = yaml.load(fs.readFileSync('./src/swagger.yaml', 'utf8'))
const startUpTimeGauge = new promClient.Gauge({ const startUpTimeGauge = new promClient.Gauge({
name: 'manifest_service_startup_time', name: 'core_ui_middleware_startup_time',
help: 'Time to warm up cache' help: 'Time to warm up cache'
}) })
......
...@@ -24,13 +24,24 @@ async function fetchData (path, baseUrl, appendix) { ...@@ -24,13 +24,24 @@ async function fetchData (path, baseUrl, appendix) {
} }
const fileCounter = new promClient.Counter({ const fileCounter = new promClient.Counter({
name: 'manifest_service_file_cache_fetches', name: 'core_ui_middleware_file_cache_fetches',
help: 'Number of fetched files' help: 'Number of fetched files'
}) })
const fileErrorCounter = new promClient.Counter({ const fileErrorCounter = new promClient.Counter({
name: 'manifest_service_file_cache_fetch_errors', name: 'core_ui_middleware_file_cache_fetch_errors',
help: 'Number of errors while fetching files' help: 'Number of errors while fetching files'
}) })
const pullThroughRequestCounter = new promClient.Counter({
name: 'core_ui_middleware_file_cache_pull_through_request_count',
help: 'Number of files requested after warmup (not referenced in manifest)'
})
const pullThroughCacheCounter = new promClient.Counter({
name: 'core_ui_middleware_file_cache_pull_through_cache_size',
help: 'Number of files added after warmup (not referenced in manifest)'
})
class FileCache { class FileCache {
constructor () { constructor () {
this._cache = {} this._cache = {}
...@@ -47,6 +58,8 @@ class FileCache { ...@@ -47,6 +58,8 @@ class FileCache {
this._isCaching = true this._isCaching = true
logger.debug('beginning to warm up cache') logger.debug('beginning to warm up cache')
pullThroughCacheCounter.reset()
pullThroughRequestCounter.reset()
const cache = Object.fromEntries(await (async function () { const cache = Object.fromEntries(await (async function () {
const files = Object.keys(deps) const files = Object.keys(deps)
const chunkSize = 50 const chunkSize = 50
...@@ -91,10 +104,12 @@ class FileCache { ...@@ -91,10 +104,12 @@ class FileCache {
async fetchAndStore (path) { async fetchAndStore (path) {
if (config.urls.length === 0) await config.load() if (config.urls.length === 0) await config.load()
pullThroughRequestCounter.inc()
const [[key, value]] = const [[key, value]] =
(await Promise.allSettled(config.urls.map(baseUrl => fetchData(path, baseUrl)))) (await Promise.allSettled(config.urls.map(baseUrl => fetchData(path, baseUrl))))
.filter(r => r.status === 'fulfilled').map(r => r.value) .filter(r => r.status === 'fulfilled').map(r => r.value)
this._cache[key.slice(1)] = value this._cache[key.slice(1)] = value
pullThroughCacheCounter.inc()
return value return value
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment