#2981 - ENH: Add profile-line-number-mode with options none | all | auto ... to control adding line numbers to profile locations

This commit is contained in:
rob
2023-02-22 23:02:42 +13:00
parent 34dc4375da
commit 2e0dba3741
16 changed files with 85 additions and 26 deletions
@@ -17,15 +17,32 @@ public interface ProfileLocation {
}
/**
* Create and return a new ProfileLocation with a given lineNumber and label.
* Create and return a new ProfileLocation with line number.
*/
static ProfileLocation create(int lineNumber, String label) {
return XServiceProvider.profileLocationFactory().create(lineNumber, label);
static ProfileLocation createWithLine() {
return XServiceProvider.profileLocationFactory().createWithLine();
}
/**
* Create and return a new ProfileLocation with a given lineNumber and label.
*/
static ProfileLocation create(String label) {
return XServiceProvider.profileLocationFactory().create(label);
}
/**
* Deprecated in favor of {@link #create(String)}.
*/
@Deprecated
static ProfileLocation create(int lineNumber, String label) {
return create(label);
}
/**
* Deprecated for removal - not used.
* Create and return a new ProfileLocation with a given location.
*/
@Deprecated
static ProfileLocation createAt(String location) {
return XServiceProvider.profileLocationFactory().createAt(location);
}
@@ -12,6 +12,11 @@ public interface SpiProfileLocationFactory {
*/
ProfileLocation create();
/**
* Create a profile location with line numbering.
*/
ProfileLocation createWithLine();
/**
* Create with a given label - used only with {@code @Transaction}.
*
@@ -19,16 +24,6 @@ public interface SpiProfileLocationFactory {
*/
ProfileLocation create(String label);
/**
* Create a profile location with a line number.
*
* @param lineNumber always 0
* @param label the label for the transaction
*/
default ProfileLocation create(int lineNumber, String label) {
return create(label);
}
/**
* Create a known location.
*/
@@ -1 +1 @@
ebean-version: 142
ebean-version: 143
@@ -12,12 +12,14 @@ class DProfileLocation implements ProfileLocation {
private static final String UNKNOWN = "unknown";
private final boolean withLine;
private String fullLocation;
private String location;
private String label;
private int traceCount;
DProfileLocation() {
DProfileLocation(boolean withLine) {
this.withLine = withLine;
}
@Override
@@ -37,7 +39,7 @@ class DProfileLocation implements ProfileLocation {
return false;
}
final String loc = create();
final String location = UtilLocation.loc(loc);
final String location = UtilLocation.loc(loc, withLine);
this.label = UtilLocation.label(location);
this.location = location;
this.fullLocation = loc;
@@ -11,7 +11,12 @@ public final class DProfileLocationFactory implements SpiProfileLocationFactory
@Override
public ProfileLocation create() {
return new DProfileLocation();
return new DProfileLocation(false);
}
@Override
public ProfileLocation createWithLine() {
return new DProfileLocation(true);
}
@Override
@@ -16,6 +16,7 @@ final class DTimedProfileLocation extends DProfileLocation implements TimedProfi
private String reportName;
DTimedProfileLocation(String label, TimedMetric timedMetric) {
super(false);
this.label = label;
this.timedMetric = timedMetric;
this.overrideMetricName = "".equals(label);
@@ -1 +1 @@
ebean-version: 142
ebean-version: 143
+1 -1
View File
@@ -107,7 +107,7 @@
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.ebean.tile:enhancement:13.12.0</tile>
<tile>io.ebean.tile:enhancement:13.13.1</tile>
</tiles>
</configuration>
</plugin>
@@ -9,9 +9,21 @@ public class QContactTest {
@Test
public void test_oneToManyMap() {
findThem();
findThem(ZonedDateTime.now());
}
void findThem() {
new QContact()
.others.fetch()
.zoneDateTime.before(ZonedDateTime.now())
.findList();
}
void findThem(ZonedDateTime dateTime) {
new QContact()
.others.fetch()
.zoneDateTime.before(dateTime)
.findList();
}
}
@@ -368,6 +368,17 @@ public class QCustomerTest {
.findList();
}
@Test
public void testTwoDiffQueryTypes_expect_NoLineNumbers() {
new QCustomer()
.id.isIn(34L)
.findList();
new QContact()
.email.isNull()
.findList();
}
@Test
public void testQueryBoolean() {
@@ -1,6 +1,8 @@
ebean.ddl.generate=true
ebean.ddl.run=true
ebean.ddl.initSql=init-db.sql
ebean.dumpMetricsOnShutdown=true
ebean.dumpMetricsOptions=sql,hash,loc
datasource.default=h2
+3 -1
View File
@@ -1,5 +1,7 @@
entity-packages: org.example.domain
querybean-packages: org.example.domain,org.querytest
debug: 0
synthetic: false
synthetic: true
entity-field-access: true
profile-line-number-mode: auto
@@ -10,10 +10,12 @@ class ProfileLocationTest {
private static final ProfileLocation loc = ProfileLocation.create(12, "foo");
private static final ProfileLocation locB = ProfileLocation.create();
private static final ProfileLocation loc2 = ProfileLocation.create();
private static final ProfileLocation locWithLine = ProfileLocation.createWithLine();
private boolean doIt() {
locB.obtain(); // simulate a location moving by line number only
return loc.obtain();
boolean result = loc.obtain();
locWithLine.obtain();
return result;
}
@Test
@@ -29,6 +31,16 @@ class ProfileLocationTest {
assertThat(locB.label()).isEqualTo("ProfileLocationTest.doIt");
}
@Test
void test_obtainWithLine() {
doIt();
// same hash even when the line number has changed
assertThat(locWithLine.fullLocation()).isEqualTo("org.tests.profile.ProfileLocationTest.doIt(ProfileLocationTest.java:17)");
assertThat(locWithLine.location()).isEqualTo("org.tests.profile.ProfileLocationTest.doIt:17");
assertThat(locWithLine.label()).isEqualTo("ProfileLocationTest.doIt:17");
}
@Test
void test_add() {
loc.add(100);
@@ -1 +1 @@
ebean-version: 142
ebean-version: 143
+2 -2
View File
@@ -50,8 +50,8 @@
<ebean-migration.version>13.7.0</ebean-migration.version>
<ebean-test-containers.version>6.3</ebean-test-containers.version>
<ebean-datasource.version>8.5</ebean-datasource.version>
<ebean-agent.version>13.13.0</ebean-agent.version>
<ebean-maven-plugin.version>13.13.0</ebean-maven-plugin.version>
<ebean-agent.version>13.13.1</ebean-agent.version>
<ebean-maven-plugin.version>13.13.1</ebean-maven-plugin.version>
<surefire.useModulePath>false</surefire.useModulePath>
</properties>
@@ -1 +1 @@
ebean-version: 142
ebean-version: 143