A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix(import): register improt metrics to the prom registry
Mohamed Basseme48bae7ce754
diff --git a/apps/workers/metrics.ts b/apps/workers/metrics.tsindex 3dc4d2c0..c16c7bd4 100644--- a/apps/workers/metrics.ts+++ b/apps/workers/metrics.ts@@ -1,7 +1,7 @@import { prometheus } from "@hono/prometheus";import { Counter, Registry } from "prom-client";-const registry = new Registry();+export const registry = new Registry();export const { printMetrics } = prometheus({registry: registry,diff --git a/apps/workers/workers/importWorker.ts b/apps/workers/workers/importWorker.tsindex c5ec3700..654de9e5 100644--- a/apps/workers/workers/importWorker.ts+++ b/apps/workers/workers/importWorker.ts@@ -23,38 +23,46 @@ import { LinkCrawlerQueue, OpenAIQueue } from "@karakeep/shared-server";import logger, { throttledLogger } from "@karakeep/shared/logger";import { BookmarkTypes } from "@karakeep/shared/types/bookmarks";+import { registry } from "../metrics";+// Prometheus metricsconst importStagingProcessedCounter = new Counter({name: "import_staging_processed_total",help: "Total number of staged items processed",labelNames: ["result"],+ registers: [registry],});const importStagingStaleResetCounter = new Counter({name: "import_staging_stale_reset_total",help: "Total number of stale processing items reset to pending",+ registers: [registry],});const importStagingInFlightGauge = new Gauge({name: "import_staging_in_flight",help: "Current number of in-flight items (processing + recently completed)",+ registers: [registry],});const importSessionsGauge = new Gauge({name: "import_sessions_active",help: "Number of active import sessions by status",labelNames: ["status"],+ registers: [registry],});const importStagingPendingGauge = new Gauge({name: "import_staging_pending_total",help: "Total number of pending items in staging table",+ registers: [registry],});const importBatchDurationHistogram = new Histogram({name: "import_batch_duration_seconds",help: "Time taken to process a batch of staged items",buckets: [0.1, 0.5, 1, 2, 5, 10, 30],+ registers: [registry],});const backpressureLogger = throttledLogger(60_000);