mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
19 lines
576 B
TypeScript
19 lines
576 B
TypeScript
import { Controller, Get, Res } from '@nestjs/common';
|
|
import type { Response } from 'express';
|
|
import { register } from 'prom-client';
|
|
|
|
import { PrismaService } from '../prisma';
|
|
|
|
@Controller()
|
|
export class MetricsController {
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
@Get('/metrics')
|
|
async index(@Res() res: Response): Promise<void> {
|
|
res.header('Content-Type', register.contentType);
|
|
const prismaMetrics = await this.prisma.$metrics.prometheus();
|
|
const appMetrics = await register.metrics();
|
|
res.send(appMetrics + prismaMetrics);
|
|
}
|
|
}
|