mirror of
https://github.com/renovatebot/renovate.git
synced 2026-11-02 10:33:39 +00:00
264f813cab
* fix(cache): instrument repository cache load and save Wrap repository cache `load()` and `save()` calls with the existing `instrument()` helper to create OpenTelemetry spans for cache lifecycle operations. This gives operators visibility into repository cache performance, especially useful with S3 backends. Refs #41760 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(cache): instrument package cache init and destroy Wrap package cache `init()` and `destroy()` with `instrument()` to create OpenTelemetry spans, matching the repository cache instrumentation from the previous commit. Covers redis, sqlite, and file backends. Refs #41760 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: document cache lifecycle tracing in OpenTelemetry guide Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Move destroy() outside init instrument span Avoids nesting the package-cache.destroy span inside package-cache.init, making them sibling spans instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Use 'verb NounClass' span naming convention Rename instrument span names from dot-notation (e.g. 'package-cache.init') to 'verb NounClass' pattern (e.g. 'init PackageCache') per reviewer feedback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { instrument } from '../../../instrumentation/index.ts';
|
|
import { CacheFactory } from './impl/cache-factory.ts';
|
|
import { RepoCacheNull } from './impl/null.ts';
|
|
import { resetCache, setCache } from './index.ts';
|
|
import type { RepoCacheConfig } from './types.ts';
|
|
|
|
/**
|
|
* Extracted to separate file in order to avoid circular module dependencies.
|
|
*/
|
|
export async function initRepoCache(config: RepoCacheConfig): Promise<void> {
|
|
resetCache();
|
|
|
|
const {
|
|
repository,
|
|
repositoryCache,
|
|
repositoryCacheType: type = 'local',
|
|
repoFingerprint,
|
|
} = config;
|
|
|
|
if (repositoryCache === 'disabled') {
|
|
setCache(new RepoCacheNull());
|
|
return;
|
|
}
|
|
|
|
if (repositoryCache === 'enabled') {
|
|
const cache = CacheFactory.get(repository!, repoFingerprint, type);
|
|
await instrument('load RepoCache', () => cache.load());
|
|
setCache(cache);
|
|
return;
|
|
}
|
|
|
|
if (repositoryCache === 'reset') {
|
|
const cache = CacheFactory.get(repository!, repoFingerprint, type);
|
|
await instrument('save RepoCache', () => cache.save());
|
|
setCache(cache);
|
|
return;
|
|
}
|
|
}
|