import { Counter, Registry, Summary } from "prom-client";

export enum BuzzerActivatedMetrics {
  CALL_REJECTED = "CallRejected",
  API_UNLOCK = "ApiUnlocked",
  DIAL_THROUGH = "DialThrough",
  RESULT_NOTIFICATION_FATE_UNKNOWN = "ResultNotificationFateUnknown",
  POLL_ATTEMPTS = "PollAttempts",
  POLL_LATENCY = "PollLatency",
  NOTIFY_LATENCY = "NotifyLatency",
  ONBOARDING_ATTEMPT = "OnboardingAttempt",
}

export const registerMetrics = (metricsRegistry: Registry) => {
  metricsRegistry.registerMetric(new Counter({
    name: BuzzerActivatedMetrics.CALL_REJECTED,
    help: "A call is rejected because the dialer / door is not registered",
    labelNames: ["From"],
  }));

  metricsRegistry.registerMetric(new Counter({
    name: BuzzerActivatedMetrics.ONBOARDING_ATTEMPT,
    help: "A non registered number attempted onboarding",
    labelNames: ["From"],
  }));

  metricsRegistry.registerMetric(new Counter({
    name: BuzzerActivatedMetrics.API_UNLOCK,
    help: "Door was unlocked with the API",
    labelNames: ["door"],
  }));

  metricsRegistry.registerMetric(new Counter({
    name: BuzzerActivatedMetrics.DIAL_THROUGH,
    help: "Dialed through to fallback numbers",
    labelNames: ["door"],
  }));

  metricsRegistry.registerMetric(new Counter({
    name: BuzzerActivatedMetrics.RESULT_NOTIFICATION_FATE_UNKNOWN,
    help: "Discord result notification may or may not have been delivered due to time constraints",
    labelNames: ["door"],
  }));

  metricsRegistry.registerMetric(new Counter({
    name: BuzzerActivatedMetrics.POLL_ATTEMPTS,
    help: "Number of times the door status was polled",
    labelNames: ["door"],
  }));

  metricsRegistry.registerMetric(new Summary({
    name: BuzzerActivatedMetrics.POLL_LATENCY,
    help: "Latency for the door status poll",
    labelNames: ["door"],
  }));

  metricsRegistry.registerMetric(new Summary({
    name: BuzzerActivatedMetrics.NOTIFY_LATENCY,
    help: "Latency for notify api calls",
  }));
}
