Ebean collects metrics for transactions, queries and cache hits. These metrics are then available to collect and report.

Dumping metrics

The fast way to see what metrics are collected is to have them dumped when the server is shutdown via dumpMetricsOnShutdown (typically after running all the tests).

Example application-test.yaml

  dumpMetricsOnShutdown: true
  dumpMetricsOptions: loc,sql,hash
    platform: h2 # h2, postgres, mysql, oracle, sqlserver, sqlite
    ddlMode: dropCreate # none | dropCreate | migrations | create
    dbName: my_app

Example output

Below is small example output with options of loc,sql,hash.

  • loc - include profile location
  • hash - include the hash of the sql query
  • sql - include the sql for queries
-- Dumping metrics for db --
txn.main                                        count:10       total:117459   mean:11745    max:32894

-- ORM queries --
query:CustomerFinder.findByName                 count:1        total:4089     mean:4089     max:4089

sql:select, from customer t0 where lower( like ? escape'|'

query:ProductFinder.findMapBySku                count:1        total:2364     mean:2364     max:2364

sql:select, t0.sku,, t0.version, t0.when_created, t0.when_modified from product t0



We can obtain the metrics via MetaInfoManager. When we call collectMetrics() the non-empty metrics are returned and the metric counters are reset.

// Collect the metrics
ServerMetrics serverMetrics = database.getMetaInfoManager().collectMetrics();

// Transactions, L2 cache, SQL updates and queries
List<MetaTimedMetric> timedMetrics : serverMetrics.getTimedMetrics()

// ORM queries
List<MetaOrmQueryMetric> ormQueryMetrics = serverMetrics.getOrmQueryMetrics();

// DTO queries
List<MetaQueryMetric> dtoQueryMetrics = serverMetrics.getDtoQueryMetrics();

Edit Page