ドキュメンテーション / モニタリング
モニタリング
Ebean はトランザクション、クエリ、およびキャッシュヒットのメトリクスを収集します。これらのメトリクスは収集してレポートするために使用できます。
メトリクスのダンプ
収集されたメトリクスの内容を迅速に確認するには、dumpMetricsOnShutdown
でサーバーのシャットダウン時にダンプします(通常はすべてのテストを実行した後)。
application-test.yaml
の例
ebean:
dumpMetricsOnShutdown: true
dumpMetricsOptions: loc,sql,hash
test:
platform: h2 # h2, postgres, mysql, oracle, sqlserver, sqlite
ddlMode: dropCreate # none | dropCreate | migrations | create
dbName: my_app
出力例
以下に loc,sql,hash
オプションを指定した小さな出力例を示します。
- loc - プロファイルの場所を含める
- hash - SQL クエリのハッシュを含める
- sql - クエリの SQL を含める
-- 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
hash:8c314fa1f6dbecfcdd449ccd021c8980
loc:CustomerFinder.findByName(CustomerFinder.kt:17)
sql:select t0.id, t0.name from customer t0 where lower(t0.name) like ? escape'|'
query:ProductFinder.findMapBySku count:1 total:2364 mean:2364 max:2364
hash:aeda919cc69bea1026543d5307276eeb
loc:ProductFinder.findMapBySku(ProductFinder.kt:12)
sql:select t0.id, t0.sku, t0.name, t0.version, t0.when_created, t0.when_modified from product t0
...
メトリクス
MetaInfoManager を使用してメトリクスを取得できます。 collectMetrics() を呼び出すと、空でないメトリクスが返され、メトリックカウンターがリセットされます。
// 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();