mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-17 22:56:28 +00:00
#1345 - Refactor io.ebean.meta.MetaInfoManager API (query execution metrics). Breaking change for people collecting query execution metrics.
This commit is contained in:
1 parent
eda6350d89
commit
85bfe3d03e
79 files changed
+928
-466
No files matched your search
@@ -1,6 +1,10 @@
|
||||
package io.ebeaninternal.server.persist;
|
||||
|
||||
import io.ebean.meta.MetricType;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.metric.MetricFactory;
|
||||
import io.ebeaninternal.metric.TimedMetricMap;
|
||||
import io.ebeaninternal.server.core.PersistRequestCallableSql;
|
||||
import io.ebeaninternal.server.core.PersistRequestOrmUpdate;
|
||||
import io.ebeaninternal.server.core.PersistRequestUpdateSql;
|
||||
@@ -24,15 +28,48 @@ final class DefaultPersistExecute implements PersistExecute {
|
||||
*/
|
||||
private final int defaultBatchSize;
|
||||
|
||||
private final TimedMetricMap ormUpdateMetric;
|
||||
|
||||
private final TimedMetricMap sqlUpdateMetric;
|
||||
|
||||
private final TimedMetricMap sqlCallMetric;
|
||||
|
||||
/**
|
||||
* Construct this DmlPersistExecute.
|
||||
*/
|
||||
DefaultPersistExecute(Binder binder, int defaultBatchSize) {
|
||||
|
||||
this.exeOrmUpdate = new ExeOrmUpdate(binder);
|
||||
this.exeUpdateSql = new ExeUpdateSql(binder);
|
||||
this.exeCallableSql = new ExeCallableSql(binder);
|
||||
this.defaultBatchSize = defaultBatchSize;
|
||||
this.ormUpdateMetric = MetricFactory.get().createTimedMetricMap(MetricType.SQL, "orm.update.");
|
||||
this.sqlUpdateMetric = MetricFactory.get().createTimedMetricMap(MetricType.SQL, "sql.update.");
|
||||
this.sqlCallMetric = MetricFactory.get().createTimedMetricMap(MetricType.SQL, "sql.call.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMetrics(MetricVisitor visitor) {
|
||||
ormUpdateMetric.visit(visitor);
|
||||
sqlUpdateMetric.visit(visitor);
|
||||
sqlCallMetric.visit(visitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectOrmUpdate(String label, long startNanos, int rowCount) {
|
||||
long exeMicros = (System.nanoTime() - startNanos) / 1000L;
|
||||
ormUpdateMetric.add(label, exeMicros, rowCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectSqlUpdate(String label, long startNanos, int rowCount) {
|
||||
long exeMicros = (System.nanoTime() - startNanos) / 1000L;
|
||||
sqlUpdateMetric.add(label, exeMicros, rowCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectSqlCall(String label, long startNanos, int rowCount) {
|
||||
long exeMicros = (System.nanoTime() - startNanos) / 1000L;
|
||||
sqlCallMetric.add(label, exeMicros, rowCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.ebean.bean.BeanCollection.ModifyListenMode;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.bean.PersistenceContext;
|
||||
import io.ebean.event.BeanPersistController;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.api.SpiUpdate;
|
||||
@@ -79,6 +80,11 @@ public final class DefaultPersister implements Persister {
|
||||
this.persistExecute = new DefaultPersistExecute(binder, server.getServerConfig().getPersistBatchSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMetrics(MetricVisitor visitor) {
|
||||
persistExecute.visitMetrics(visitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the CallableSql.
|
||||
*/
|
||||
|
||||
@@ -60,6 +60,7 @@ class ExeCallableSql {
|
||||
|
||||
private CallableStatement bindStmt(PersistRequestCallableSql request, boolean batchThisRequest) throws SQLException {
|
||||
|
||||
request.startBind(batchThisRequest);
|
||||
SpiCallableSql callableSql = request.getCallableSql();
|
||||
SpiTransaction t = request.getTransaction();
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ class ExeOrmUpdate {
|
||||
|
||||
private PreparedStatement bindStmt(PersistRequestOrmUpdate request, boolean batchThisRequest) throws SQLException {
|
||||
|
||||
request.startBind(batchThisRequest);
|
||||
SpiUpdate<?> ormUpdate = request.getOrmUpdate();
|
||||
SpiTransaction t = request.getTransaction();
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ class ExeUpdateSql {
|
||||
|
||||
private PreparedStatement bindStmt(PersistRequestUpdateSql request, boolean batchThisRequest) throws SQLException {
|
||||
|
||||
request.startBind(batchThisRequest);
|
||||
SpiSqlUpdate updateSql = request.getUpdateSql();
|
||||
SpiTransaction t = request.getTransaction();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.ebeaninternal.server.persist;
|
||||
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.server.core.PersistRequestCallableSql;
|
||||
import io.ebeaninternal.server.core.PersistRequestOrmUpdate;
|
||||
@@ -34,4 +35,23 @@ public interface PersistExecute {
|
||||
*/
|
||||
int executeSqlUpdate(PersistRequestUpdateSql request);
|
||||
|
||||
/**
|
||||
* Collect execution metrics for sql update.
|
||||
*/
|
||||
void collectOrmUpdate(String label, long startNanos, int rowCount);
|
||||
|
||||
/**
|
||||
* Collect execution metrics for sql update.
|
||||
*/
|
||||
void collectSqlUpdate(String label, long startNanos, int rowCount);
|
||||
|
||||
/**
|
||||
* Collect execution metrics for sql callable.
|
||||
*/
|
||||
void collectSqlCall(String label, long startNanos, int rowCount);
|
||||
|
||||
/**
|
||||
* Visit the metrics.
|
||||
*/
|
||||
void visitMetrics(MetricVisitor visitor);
|
||||
}
|
||||
Reference in new issue
Block a user