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

@@ -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,