Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

feat: add a new counter for new bookmarks by source

Mohamed Bassemf42cb3561b83
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts
index b664b06f..e9fe3600 100644
--- a/packages/trpc/routers/bookmarks.ts
+++ b/packages/trpc/routers/bookmarks.ts
@@ -28,6 +28,7 @@ import {
} from "@karakeep/shared-server";
import { SUPPORTED_BOOKMARK_ASSET_TYPES } from "@karakeep/shared/assetdb";
import serverConfig from "@karakeep/shared/config";
+import { bookmarkCreationCounter } from "../stats";
import { InferenceClientFactory } from "@karakeep/shared/inference";
import { buildSummaryPrompt } from "@karakeep/shared/prompts.server";
import { EnqueueOptions } from "@karakeep/shared/queueing";
@@ -313,6 +314,8 @@ export const bookmarksAppRouter = router({
},
);
+ bookmarkCreationCounter.labels(input.source ?? "unknown").inc();
+
const forceLowPriority = await shouldUseLowPriorityQueues(ctx);
const shouldUseLowPriority =
input.crawlPriority === "low" || forceLowPriority;
diff --git a/packages/trpc/stats.ts b/packages/trpc/stats.ts
index af47d4a6..5ee49a43 100644
--- a/packages/trpc/stats.ts
+++ b/packages/trpc/stats.ts
@@ -107,6 +107,13 @@ const totalBookmarksGauge = new Gauge({
},
});
+// Bookmark creation metrics
+const bookmarkCreationCounter = new Counter({
+ name: "karakeep_bookmark_creations_total",
+ help: "Total number of bookmarks created",
+ labelNames: ["source"],
+});
+
// Api metrics
const apiRequestsTotalCounter = new Counter({
name: "karakeep_trpc_requests_total",
@@ -134,6 +141,7 @@ register.registerMetric(queuePendingJobsGauge);
register.registerMetric(totalUsersGauge);
register.registerMetric(totalAssetSizeGauge);
register.registerMetric(totalBookmarksGauge);
+register.registerMetric(bookmarkCreationCounter);
register.registerMetric(apiRequestsTotalCounter);
register.registerMetric(apiErrorsTotalCounter);
register.registerMetric(apiRequestDurationSummary);
@@ -143,6 +151,7 @@ export {
totalUsersGauge,
totalAssetSizeGauge,
totalBookmarksGauge,
+ bookmarkCreationCounter,
apiRequestsTotalCounter,
apiErrorsTotalCounter,
apiRequestDurationSummary,