🔊 Add prisma metrics to prometheus endpoint (#1420)
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user