001package org.avaje.metric; 002 003/** 004 * Standard JVM metrics built in that we often register. 005 * <p> 006 * Typically we want the standard JVM metrics and either Logback or Log4J metrics 007 * and this provides a relatively easy way to register those. 008 * </p> 009 * <pre>{@code 010 * 011 * MetricManager.jvmMetrics() 012 * .withReportAlways() 013 * .registerStandardJvmMetrics() 014 * .registerLogbackMetrics(); 015 * 016 * }</pre> 017 */ 018public interface JvmMetrics { 019 020 /** 021 * Set to only report when the metrics change. This is the default and means 022 * that metrics that don't change are not reported. 023 */ 024 JvmMetrics withReportChangesOnly(); 025 026 /** 027 * Set to report the metrics irrespective of whether the metric has changed. 028 * <p> 029 * For metrics that generally don't change like max memory or don't change as 030 * frequently these metrics will be reported every time. 031 * </p> 032 */ 033 JvmMetrics withReportAlways(); 034 035 /** 036 * Register all the standard JVM metrics - memory, threads, gc, os load and process memory. 037 */ 038 JvmMetrics registerStandardJvmMetrics(); 039 040 /** 041 * Register a metric for OS load. 042 */ 043 JvmMetrics registerJvmOsLoadMetric(); 044 045 /** 046 * Register metrics for GC activity. 047 */ 048 JvmMetrics registerJvmGCMetrics(); 049 050 /** 051 * Register metrics for the total number of threads allocated. 052 */ 053 JvmMetrics registerJvmThreadMetrics(); 054 055 /** 056 * Register metrics for heap and non-heap memory. 057 */ 058 JvmMetrics registerJvmMemoryMetrics(); 059 060 /** 061 * Register metrics for VMRSS process memory (if supported on the platform). 062 */ 063 JvmMetrics registerJvmProcessMemoryMetrics(); 064 065 /** 066 * Set the names of the metrics for logging errors and warnings. 067 * <p> 068 * When not set these default to app.log.error and app.log.warn respectively. 069 * </p> 070 */ 071 JvmMetrics withLogMetricName(String errorMetricName, String warnMetricName); 072 073 /** 074 * Register metrics for Logback error and warning messages. 075 */ 076 JvmMetrics registerLogbackMetrics(); 077 078 /** 079 * Register metrics for Log4J error and warning messages. 080 */ 081 JvmMetrics registerLog4JMetrics(); 082 083}