#1183 - ENH: Add support for transaction profiling

This commit is contained in:
rob bygrave
2017-10-25 01:07:00 +13:00
parent 093f82a87f
commit 7ebef51859
46 changed files with 1063 additions and 68 deletions
@@ -0,0 +1,34 @@
package io.ebeaninternal.server.transaction;
import io.ebean.config.ProfilingConfig;
import org.junit.Test;
import static org.junit.Assert.*;
public class DefaultProfileHandlerTest {
@Test
public void createProfileStream() throws Exception {
DefaultProfileHandler handler = new DefaultProfileHandler(new ProfilingConfig());
assertNotNull(handler.createProfileStream(12));
assertNull(handler.createProfileStream(0));
}
@Test
public void createProfileStream_when_specificIncludeIds() throws Exception {
ProfilingConfig config = new ProfilingConfig();
config.setIncludeProfileIds(new int[]{100,101});
DefaultProfileHandler handler = new DefaultProfileHandler(config);
assertNotNull(handler.createProfileStream(100));
assertNotNull(handler.createProfileStream(101));
assertNull(handler.createProfileStream(0));
assertNull(handler.createProfileStream(12));
}
}
@@ -11,12 +11,12 @@ import java.util.ArrayList;
import java.util.List;
/**
* Helper that can collect the SQL that is logged via SLF4J.
* Helper that can collectTransactionProfile the SQL that is logged via SLF4J.
* <p>
* Used {@link #start()} and {@link #stop()} to collect the logged messages that contain the
* Used {@link #start()} and {@link #stop()} to collectTransactionProfile the logged messages that contain the
* executed SQL statements.
* <p>
* Internally this uses a Logback Appender to collect messages for org.avaje.ebean.SQL.
* Internally this uses a Logback Appender to collectTransactionProfile messages for org.avaje.ebean.SQL.
*/
public class LoggedSqlCollector {
@@ -33,7 +33,7 @@ public class TestPersistenceContextScopeUsingOrders extends BaseTestCase {
assertTrue(!orders.isEmpty());
// collect the customer instances
// collectTransactionProfile the customer instances
List<Customer> customers = new ArrayList<>();
Set<Integer> identities = new HashSet<>();