mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-15 13:55:20 +00:00
Add prometheus metric for pending repo indexing jobs
This commit is contained in:
parent
c841894c0a
commit
51186fe87d
2 changed files with 14 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ export class PromClient {
|
||||||
private registry: Registry;
|
private registry: Registry;
|
||||||
private app: express.Application;
|
private app: express.Application;
|
||||||
public activeRepoIndexingJobs: Gauge<string>;
|
public activeRepoIndexingJobs: Gauge<string>;
|
||||||
|
public pendingRepoIndexingJobs: Gauge<string>;
|
||||||
public repoIndexingReattemptsTotal: Counter<string>;
|
public repoIndexingReattemptsTotal: Counter<string>;
|
||||||
public repoIndexingFailTotal: Counter<string>;
|
public repoIndexingFailTotal: Counter<string>;
|
||||||
public repoIndexingSuccessTotal: Counter<string>;
|
public repoIndexingSuccessTotal: Counter<string>;
|
||||||
|
|
@ -26,6 +27,13 @@ export class PromClient {
|
||||||
});
|
});
|
||||||
this.registry.registerMetric(this.activeRepoIndexingJobs);
|
this.registry.registerMetric(this.activeRepoIndexingJobs);
|
||||||
|
|
||||||
|
this.pendingRepoIndexingJobs = new Gauge({
|
||||||
|
name: 'pending_repo_indexing_jobs',
|
||||||
|
help: 'The number of repo indexing jobs waiting in queue',
|
||||||
|
labelNames: ['repo'],
|
||||||
|
});
|
||||||
|
this.registry.registerMetric(this.pendingRepoIndexingJobs);
|
||||||
|
|
||||||
this.repoIndexingReattemptsTotal = new Counter({
|
this.repoIndexingReattemptsTotal = new Counter({
|
||||||
name: 'repo_indexing_reattempts',
|
name: 'repo_indexing_reattempts',
|
||||||
help: 'The number of repo indexing reattempts',
|
help: 'The number of repo indexing reattempts',
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,11 @@ export class RepoManager implements IRepoManager {
|
||||||
}
|
}
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
// Increment pending jobs counter for each repo added
|
||||||
|
orgRepos.forEach(repo => {
|
||||||
|
this.promClient.pendingRepoIndexingJobs.inc({ repo: repo.id.toString() });
|
||||||
|
});
|
||||||
|
|
||||||
this.logger.info(`Added ${orgRepos.length} jobs to indexQueue for org ${orgId} with priority ${priority}`);
|
this.logger.info(`Added ${orgRepos.length} jobs to indexQueue for org ${orgId} with priority ${priority}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,6 +272,7 @@ export class RepoManager implements IRepoManager {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.promClient.activeRepoIndexingJobs.inc();
|
this.promClient.activeRepoIndexingJobs.inc();
|
||||||
|
this.promClient.pendingRepoIndexingJobs.dec({ repo: repo.id.toString() });
|
||||||
|
|
||||||
let indexDuration_s: number | undefined;
|
let indexDuration_s: number | undefined;
|
||||||
let fetchDuration_s: number | undefined;
|
let fetchDuration_s: number | undefined;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue