mirror of
https://github.com/p-stream/backend.git
synced 2026-04-20 11:52:04 +00:00
24 lines
No EOL
789 B
TypeScript
24 lines
No EOL
789 B
TypeScript
import { getRegistry } from '../../utils/metrics';
|
|
import { scopedLogger } from '../../utils/logger';
|
|
|
|
const log = scopedLogger('metrics-monthly-endpoint');
|
|
|
|
export default defineEventHandler(async event => {
|
|
try {
|
|
// Get the monthly registry
|
|
const monthlyRegistry = getRegistry('monthly');
|
|
|
|
const metrics = await monthlyRegistry.metrics();
|
|
event.node.res.setHeader('Content-Type', monthlyRegistry.contentType);
|
|
return metrics;
|
|
} catch (error) {
|
|
log.error('Error in monthly metrics endpoint:', {
|
|
evt: 'metrics_error',
|
|
error: error instanceof Error ? error.message : String(error),
|
|
});
|
|
throw createError({
|
|
statusCode: 500,
|
|
message: error instanceof Error ? error.message : 'Failed to collect monthly metrics',
|
|
});
|
|
}
|
|
});
|