Skip to content

make repo garbage collection async #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion demo-site-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$schema": "./schemas/v2/index.json",
"settings": {
"autoDeleteStaleRepos": true,
"reindexInterval": 86400000, // 24 hours
"resyncInterval": 86400000 // 24 hours
},
Expand Down
3 changes: 2 additions & 1 deletion grafana.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ prometheus.scrape "local_app" {
]

metrics_path = "/metrics"
scrape_interval = "10s"
scrape_timeout = "500ms"
scrape_interval = "500ms"

job_name = sys.env("GRAFANA_ENVIRONMENT")

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { Settings } from "./types.js";
*/
export const DEFAULT_SETTINGS: Settings = {
maxFileSize: 2 * 1024 * 1024, // 2MB in bytes
autoDeleteStaleRepos: true,
reindexIntervalMs: 1000 * 60 * 60, // 1 hour
resyncConnectionPollingIntervalMs: 1000,
reindexRepoPollingIntervalMs: 1000,
indexConcurrencyMultiple: 3,
configSyncConcurrencyMultiple: 3,
gcConcurrencyMultiple: 1,
gcGracePeriodMs: 10 * 1000, // 10 seconds
}
60 changes: 51 additions & 9 deletions packages/backend/src/promClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ export class PromClient {
private app: express.Application;
public activeRepoIndexingJobs: Gauge<string>;
public repoIndexingDuration: Histogram<string>;
public repoIndexingErrors: Counter<string>;
public repoIndexingFails: Counter<string>;
public repoIndexingSuccesses: Counter<string>;
public repoIndexingErrorTotal: Counter<string>;
public repoIndexingFailTotal: Counter<string>;
public repoIndexingSuccessTotal: Counter<string>;

public activeRepoGarbageCollectionJobs: Gauge<string>;
public repoGarbageCollectionDuration: Histogram<string>;
public repoGarbageCollectionErrorTotal: Counter<string>;
public repoGarbageCollectionFailTotal: Counter<string>;
public repoGarbageCollectionSuccessTotal: Counter<string>;

public readonly PORT = 3060;

constructor() {
Expand All @@ -28,26 +35,61 @@ export class PromClient {
});
this.registry.registerMetric(this.repoIndexingDuration);

this.repoIndexingErrors = new Counter({
this.repoIndexingErrorTotal = new Counter({
name: 'repo_indexing_errors',
help: 'The number of repo indexing errors',
labelNames: ['repo'],
});
this.registry.registerMetric(this.repoIndexingErrors);
this.registry.registerMetric(this.repoIndexingErrorTotal);

this.repoIndexingFails = new Counter({
this.repoIndexingFailTotal = new Counter({
name: 'repo_indexing_fails',
help: 'The number of repo indexing fails',
labelNames: ['repo'],
});
this.registry.registerMetric(this.repoIndexingFails);
this.registry.registerMetric(this.repoIndexingFailTotal);

this.repoIndexingSuccesses = new Counter({
this.repoIndexingSuccessTotal = new Counter({
name: 'repo_indexing_successes',
help: 'The number of repo indexing successes',
labelNames: ['repo'],
});
this.registry.registerMetric(this.repoIndexingSuccesses);
this.registry.registerMetric(this.repoIndexingSuccessTotal);

this.activeRepoGarbageCollectionJobs = new Gauge({
name: 'active_repo_garbage_collection_jobs',
help: 'The number of repo garbage collection jobs in progress',
labelNames: ['repo'],
});
this.registry.registerMetric(this.activeRepoGarbageCollectionJobs);

this.repoGarbageCollectionDuration = new Histogram({
name: 'repo_garbage_collection_duration',
help: 'The duration of repo garbage collection jobs',
labelNames: ['repo'],
});
this.registry.registerMetric(this.repoGarbageCollectionDuration);

this.repoGarbageCollectionErrorTotal = new Counter({
name: 'repo_garbage_collection_errors',
help: 'The number of repo garbage collection errors',
labelNames: ['repo'],
});
this.registry.registerMetric(this.repoGarbageCollectionErrorTotal);

this.repoGarbageCollectionFailTotal = new Counter({
name: 'repo_garbage_collection_fails',
help: 'The number of repo garbage collection fails',
labelNames: ['repo'],
});
this.registry.registerMetric(this.repoGarbageCollectionFailTotal);

this.repoGarbageCollectionSuccessTotal = new Counter({
name: 'repo_garbage_collection_successes',
help: 'The number of repo garbage collection successes',
labelNames: ['repo'],
});
this.registry.registerMetric(this.repoGarbageCollectionSuccessTotal);

client.collectDefaultMetrics({
register: this.registry,
Expand Down
Loading