import promClient from "prom-client";

const registry = new promClient.Registry();
registry.setDefaultLabels({ service: "teacher-bff" });

registry.registerMetric(
  new promClient.Counter({
    name: "teacher_bff_requests_total",
    help: "Total number of teacher-bff requests",
    labelNames: ["method", "endpoint", "status"],
  }),
);

registry.registerMetric(
  new promClient.Histogram({
    name: "teacher_bff_request_duration_seconds",
    help: "Teacher-bff request duration in seconds",
    labelNames: ["method", "endpoint"],
    buckets: [0.01, 0.05, 0.1, 0.3, 0.5, 1, 3, 5],
  }),
);

// 自动收集 Node.js 进程级指标（CPU/内存/事件循环/GC等）
promClient.collectDefaultMetrics({ register: registry });

export { registry as metricsRegistry };
