import { Injectable } from '@nestjs/common'; @Injectable() export class MetricsService { private readonly counters = new Map(); increment(name: string, by = 1): void { this.counters.set(name, (this.counters.get(name) ?? 0) + by); } snapshot(): Record { return Object.fromEntries(this.counters.entries()); } }