add metrics to api

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-05-24 10:17:51 +02:00
parent 3cd35082de
commit 06367b504c
3 changed files with 35 additions and 0 deletions

View File

@@ -24,6 +24,7 @@
"@openpanel/trpc": "workspace:*",
"@trpc/server": "^10.45.1",
"fastify": "^4.25.2",
"fastify-metrics": "^11.0.0",
"ico-to-png": "^0.2.1",
"pino": "^8.17.2",
"pino-pretty": "^10.3.1",

View File

@@ -4,6 +4,7 @@ import cors from '@fastify/cors';
import type { FastifyTRPCPluginOptions } from '@trpc/server/adapters/fastify';
import { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';
import Fastify from 'fastify';
import metricsPlugin from 'fastify-metrics';
import type { IServiceClient } from '@openpanel/db';
import { redisPub } from '@openpanel/redis';
@@ -33,6 +34,8 @@ const startServer = async () => {
maxParamLength: 15_000,
});
await fastify.register(metricsPlugin, { endpoint: '/metrics' });
fastify.register(cors, {
origin: '*',
credentials: true,