001package io.ebean.meta; 002 003import java.util.List; 004 005/** 006 * Provides access to the meta data in Database such as query execution statistics. 007 */ 008public interface MetaInfoManager { 009 010 /** 011 * Return the metrics for the database instance. 012 * <p> 013 * This will reset the metrics (reset counters back to zero etc) and 014 * will only return the non-empty metrics. 015 * </p> 016 */ 017 ServerMetrics collectMetrics(); 018 019 /** 020 * Collect the metrics in raw JSON form. 021 * <pre>{@code 022 * 023 * String metricsJson = database.getMetaInfoManager() 024 * .collectMetricsAsJson() 025 * .json(); 026 * 027 * }</pre> 028 */ 029 ServerMetricsAsJson collectMetricsAsJson(); 030 031 /** 032 * Return the metrics as a list of MetricData. 033 */ 034 List<MetricData> collectMetricsAsData(); 035 036 /** 037 * Visit the metrics resetting and collecting/reporting as desired. 038 */ 039 void visitMetrics(MetricVisitor visitor); 040 041 /** 042 * Run a visit collecting all the metrics and returning BasicMetricVisitor 043 * which holds all the metrics in simple lists. 044 */ 045 BasicMetricVisitor visitBasic(); 046 047 /** 048 * Just reset all the metrics. Maybe only useful for testing purposes. 049 */ 050 void resetAllMetrics(); 051 052 /** 053 * Initiate query plan collection by turning on "bind capture" on matching query plans. 054 * <p> 055 * Also refer to DatabaseConfig collectQueryPlans that needs to be set to true 056 * and collectQueryPlanThresholdMicros which is a global defaults that can also 057 * initiate query plan capture. 058 * 059 * @return The query plans that have had bind capture turned on by this request. 060 */ 061 List<MetaQueryPlan> queryPlanInit(QueryPlanInit initRequest); 062 063 /** 064 * Collect query plans in the foreground. 065 */ 066 List<MetaQueryPlan> queryPlanCollectNow(QueryPlanRequest request); 067 068 069}