🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat: send prisma stats to sentry (#2655)
Max Deichmann31a496880de7
diff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex d58677b7cb..21680a0a5d 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -3,7 +3,7 @@generator client {provider = "prisma-client-js"- previewFeatures = ["tracing", "views", "relationJoins"]+ previewFeatures = ["tracing", "views", "relationJoins", "metrics"]}datasource db {diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.tsindex b42e4cb3e0..bc05609c32 100644--- a/web/src/pages/api/public/ingestion.ts+++ b/web/src/pages/api/public/ingestion.ts@@ -84,6 +84,8 @@ export default async function handler(parsedSchema.success ? parsedSchema.data.batch.length : 0,);+ await gaugePrismaStats();+if (!parsedSchema.success) {console.log("Invalid request data", parsedSchema.error);return res.status(400).json({@@ -294,6 +296,7 @@ const handleSingleEvent = async (const { output, ...rest } = restEvent;restEvent = rest;}+console.log(`handling single event ${event.id} of type ${event.type}: ${JSON.stringify({ body: restEvent })}`,);@@ -549,3 +552,15 @@ export const sendToWorkerIfEnvironmentConfigured = async (console.error("Error sending events to worker", error);}};++const gaugePrismaStats = async () => {+ // execute with a 50% probability+ if (Math.random() > 0.5) {+ return;+ }+ const metrics = await prisma.$metrics.json();++ metrics.gauges.forEach((gauge) => {+ Sentry.metrics.gauge(gauge.key, gauge.value, gauge.labels);+ });+};