2
0

🔊 Add prisma metrics to prometheus endpoint (#1420)

This commit is contained in:
Baptiste Arnaud
2024-04-06 15:08:57 +02:00
committed by GitHub
parent d96f384e02
commit 6e0388c501
9 changed files with 92 additions and 75 deletions

View File

@ -4,6 +4,7 @@ import { whatsAppRuntime } from './runtimes/whatsapp'
import { prometheus } from '@hono/prometheus'
import { sentry } from '@hono/sentry'
import { env } from '@typebot.io/env'
import prisma from '@typebot.io/lib/prisma'
const app = new Hono()
@ -12,16 +13,21 @@ app.use(
sentry({
environment: env.NODE_ENV,
dsn: env.NEXT_PUBLIC_SENTRY_DSN,
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA + '-chat-api',
})
)
const { printMetrics, registerMetrics } = prometheus()
app.use('*', registerMetrics)
app.get('/metrics', printMetrics)
app.get('/metrics', async (c) => {
const honoMetrics = await (await printMetrics(c)).text()
const prismaMetrics = await prisma.$metrics.prometheus()
return c.text(`${honoMetrics}\n\n${prismaMetrics}`, 200)
})
app.get('/ping', (c) => c.json({ status: 'ok' }, 200))
app.route('/', webRuntime)
app.route('/', whatsAppRuntime)
export default {