001package io.ebean.meta; 002 003import java.util.ArrayList; 004import java.util.List; 005 006/** 007 * A simple MetricVisitor that can collect the desired metrics into lists. 008 */ 009public class BasicMetricVisitor extends AbstractMetricVisitor implements ServerMetrics { 010 011 private final List<MetaTimedMetric> timed = new ArrayList<>(); 012 private final List<MetaQueryMetric> query = new ArrayList<>(); 013 private final List<MetaCountMetric> count = new ArrayList<>(); 014 015 /** 016 * Construct to reset and collect everything. 017 */ 018 public BasicMetricVisitor() { 019 super(true, true, true, true); 020 } 021 022 /** 023 * Construct specifying reset and what to collect. 024 */ 025 public BasicMetricVisitor(boolean reset, boolean collectTransactionMetrics, boolean collectQueryMetrics, boolean collectL2Metrics) { 026 super(reset, collectTransactionMetrics, collectQueryMetrics, collectL2Metrics); 027 } 028 029 @Override 030 public List<MetaTimedMetric> getTimedMetrics() { 031 return timed; 032 } 033 034 @Override 035 public List<MetaQueryMetric> getQueryMetrics() { 036 return query; 037 } 038 039 @Override 040 public List<MetaCountMetric> getCountMetrics() { 041 return count; 042 } 043 044 @Override 045 public void visitTimed(MetaTimedMetric metric) { 046 timed.add(metric); 047 } 048 049 @Override 050 public void visitQuery(MetaQueryMetric metric) { 051 query.add(metric); 052 } 053 054 @Override 055 public void visitCount(MetaCountMetric metric) { 056 count.add(metric); 057 } 058}