ENH: Add ProfileLocation - Part 2 - performance metrics for transactions with label and profileLocation

This commit is contained in:
Rob Bygrave committed 2018-01-22 14:54:27 +13:00
1 parent 4e33027fdf
commit 51d2e4c600
37 files changed
+779 -33

No files matched your search

@@ -55,6 +55,11 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
*/
protected final String id;
/**
* The user defined label to group execution statistics.
*/
protected String label;
/**
* Flag to indicate if this was an explicitly created Transaction.
*/
@@ -176,6 +181,8 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
protected ProfileLocation profileLocation;
protected final long startNanos;
/**
* Create without ProfileStream option (no profiling).
*/
@@ -196,6 +203,7 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
this.manager = manager;
this.connection = connection;
this.persistenceContext = new DefaultPersistenceContext();
this.startNanos = System.nanoTime();
if (manager == null) {
this.skipCacheAfterWrite = true;
@@ -216,6 +224,16 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
}
}
@Override
public void setLabel(String label) {
this.label = label;
}
@Override
public String getLabel() {
return label;
}
@Override
public long profileOffset() {
return (profileStream == null) ? 0 : profileStream.offset();
@@ -980,8 +998,17 @@ public class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
}
private void profileEnd() {
if (profileStream != null) {
profileStream.end(manager);
if (manager != null) {
long exeMicros = (System.nanoTime() - startNanos) / 1000L;
if (profileLocation != null) {
profileLocation.add(exeMicros);
} else if (label != null) {
manager.collectMetricNamed(exeMicros, label);
}
manager.collectMetric(exeMicros);
if (profileStream != null) {
profileStream.end(manager);
}
}
}