Class JvmMetricsCollector

java.lang.Object
org.mockserver.metrics.JvmMetricsCollector
All Implemented Interfaces:
io.prometheus.metrics.model.registry.MultiCollector

public class JvmMetricsCollector extends Object implements io.prometheus.metrics.model.registry.MultiCollector
Exposes JVM runtime metrics (heap / non-heap memory, threads, GC) as Prometheus gauges so the dashboard Metrics view and Grafana can chart MockServer's process health. Registered once alongside BuildInfoCollector when metrics are enabled.

Reads only JDK java.lang.management MX beans — no extra dependency — and is read-only/allocation-light, so scraping it has negligible overhead. Values are sampled fresh on each collect() (i.e. each scrape).

  • Constructor Details

    • JvmMetricsCollector

      public JvmMetricsCollector()
  • Method Details

    • collect

      public io.prometheus.metrics.model.snapshots.MetricSnapshots collect()
      Specified by:
      collect in interface io.prometheus.metrics.model.registry.MultiCollector
    • getPrometheusNames

      public List<String> getPrometheusNames()
      Specified by:
      getPrometheusNames in interface io.prometheus.metrics.model.registry.MultiCollector