import { Controller, Get, Inject, Res } from '@nestjs/common';
import { ApiExcludeController } from '@nestjs/swagger';
import { Response } from 'express';
import { TELEMETRY_METRICS_SERVICE, ITelemetryMetricsService } from '../../../domain/ports/telemetry-metrics.service.interface';

@ApiExcludeController()
@Controller('metrics')
export class MetricsController {
  constructor(@Inject(TELEMETRY_METRICS_SERVICE) private readonly metricsService: ITelemetryMetricsService) {}

  @Get()
  async getMetrics(@Res() res: Response) {
    const metrics = await this.metricsService.getMetrics();
    res.set('Content-Type', this.metricsService.getContentType());
    res.send(metrics);
  }
}
