HHH-18109 Remove executionTime from JFR events

This commit is contained in:
Philippe Marschall 2024-05-14 10:36:21 +02:00 committed by Christian Beikov
parent 5cdcb2c582
commit 86d40a4f87
25 changed files with 20 additions and 106 deletions

View File

@ -40,9 +40,6 @@ public class CacheGetEvent extends Event implements HibernateMonitoringEvent {
@Label( "Region Name" ) @Label( "Region Name" )
public String regionName; public String regionName;
@Label( "Cache Get Execution Time" )
public long executionTime;
@Label("Cache Hit") @Label("Cache Hit")
public boolean hit; public boolean hit;
@ -51,6 +48,4 @@ public class CacheGetEvent extends Event implements HibernateMonitoringEvent {
return NAME ; return NAME ;
} }
public transient long startedAt;
} }

View File

@ -40,9 +40,6 @@ public class CachePutEvent extends Event implements HibernateMonitoringEvent {
@Label( "Used Natural Id" ) @Label( "Used Natural Id" )
public boolean isNaturalId; public boolean isNaturalId;
@Label( "Cache Put Execution Time" )
public long executionTime;
@Label( "Description" ) @Label( "Description" )
public String description; public String description;
@ -54,6 +51,4 @@ public class CachePutEvent extends Event implements HibernateMonitoringEvent {
return NAME ; return NAME ;
} }
public transient long startedAt;
} }

View File

@ -28,9 +28,6 @@ public class DirtyCalculationEvent extends Event implements HibernateMonitoringE
@Label("Session Identifier") @Label("Session Identifier")
public String sessionIdentifier; public String sessionIdentifier;
@Label("PartialFlushEvent time")
public long executionTime;
@Label("Entity Name") @Label("Entity Name")
public String entityName; public String entityName;
@ -45,5 +42,4 @@ public class DirtyCalculationEvent extends Event implements HibernateMonitoringE
return NAME; return NAME;
} }
public transient long startedAt;
} }

View File

@ -34,9 +34,6 @@ public class FlushEvent extends Event implements HibernateMonitoringEvent {
@Label("Number Of Processed Collections") @Label("Number Of Processed Collections")
public int numberOfCollectionsProcessed; public int numberOfCollectionsProcessed;
@Label("Flush time")
public long executionTime;
@Label("Auto Flush") @Label("Auto Flush")
public boolean isAutoFlush; public boolean isAutoFlush;
@ -45,6 +42,4 @@ public class FlushEvent extends Event implements HibernateMonitoringEvent {
return NAME; return NAME;
} }
public transient long startedAt;
} }

View File

@ -28,15 +28,9 @@ public class JdbcBatchExecutionEvent extends Event implements HibernateMonitorin
@Label("PreparedStatement SQL") @Label("PreparedStatement SQL")
public String sql; public String sql;
@Label("Batch Execution time")
public long executionTime;
@Override @Override
public String toString() { public String toString() {
return NAME; return NAME;
} }
public transient long startedAt;
} }

View File

@ -31,13 +31,9 @@ public class JdbcConnectionAcquisitionEvent extends Event implements HibernateMo
@Label("Tenant Identifier") @Label("Tenant Identifier")
public String tenantIdentifier; public String tenantIdentifier;
@Label("Connection Acquisition Time")
public long executionTime;
@Override @Override
public String toString() { public String toString() {
return NAME; return NAME;
} }
public transient long startedAt;
} }

View File

@ -31,14 +31,9 @@ public class JdbcConnectionReleaseEvent extends Event implements HibernateMonito
@Label("Tenant Identifier") @Label("Tenant Identifier")
public String tenantIdentifier; public String tenantIdentifier;
@Label("Connection Release Time")
public long executionTime;
@Override @Override
public String toString() { public String toString() {
return NAME; return NAME;
} }
public transient long startedAt;
} }

View File

@ -28,14 +28,9 @@ public class JdbcPreparedStatementCreationEvent extends Event implements Hiberna
@Label("PreparedStatement SQL") @Label("PreparedStatement SQL")
public String sql; public String sql;
@Label("PreparedStatement Creation Time")
public long executionTime;
@Override @Override
public String toString() { public String toString() {
return NAME; return NAME;
} }
public transient long startedAt;
} }

View File

@ -28,14 +28,9 @@ public class JdbcPreparedStatementExecutionEvent extends Event implements Hibern
@Label( "PreparedStatement SQL" ) @Label( "PreparedStatement SQL" )
public String sql; public String sql;
@Label( "PreparedStatement Execution Time" )
public long executionTime;
@Override @Override
public String toString() { public String toString() {
return NAME ; return NAME ;
} }
public transient long startedAt;
} }

View File

@ -20,8 +20,6 @@ import org.hibernate.stat.internal.StatsHelper;
import jdk.jfr.EventType; import jdk.jfr.EventType;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
@AllowNonPortable @AllowNonPortable
public class JfrEventManager implements EventManager { public class JfrEventManager implements EventManager {
@ -101,7 +99,6 @@ public class JfrEventManager implements EventManager {
if ( jdbcConnectionAcquisitionEventType.isEnabled() ) { if ( jdbcConnectionAcquisitionEventType.isEnabled() ) {
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = new JdbcConnectionAcquisitionEvent(); final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = new JdbcConnectionAcquisitionEvent();
jdbcConnectionAcquisitionEvent.begin(); jdbcConnectionAcquisitionEvent.begin();
jdbcConnectionAcquisitionEvent.startedAt = System.nanoTime();
return jdbcConnectionAcquisitionEvent; return jdbcConnectionAcquisitionEvent;
} }
else { else {
@ -118,7 +115,6 @@ public class JfrEventManager implements EventManager {
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = (JdbcConnectionAcquisitionEvent) event; final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = (JdbcConnectionAcquisitionEvent) event;
jdbcConnectionAcquisitionEvent.end(); jdbcConnectionAcquisitionEvent.end();
if ( jdbcConnectionAcquisitionEvent.shouldCommit() ) { if ( jdbcConnectionAcquisitionEvent.shouldCommit() ) {
jdbcConnectionAcquisitionEvent.executionTime = getExecutionTime( jdbcConnectionAcquisitionEvent.startedAt );
jdbcConnectionAcquisitionEvent.sessionIdentifier = getSessionIdentifier( session ); jdbcConnectionAcquisitionEvent.sessionIdentifier = getSessionIdentifier( session );
jdbcConnectionAcquisitionEvent.tenantIdentifier = tenantId == null ? null : session.getFactory() jdbcConnectionAcquisitionEvent.tenantIdentifier = tenantId == null ? null : session.getFactory()
.getTenantIdentifierJavaType() .getTenantIdentifierJavaType()
@ -133,7 +129,6 @@ public class JfrEventManager implements EventManager {
if ( jdbcConnectionReleaseEventType.isEnabled() ) { if ( jdbcConnectionReleaseEventType.isEnabled() ) {
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = new JdbcConnectionReleaseEvent(); final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = new JdbcConnectionReleaseEvent();
jdbcConnectionReleaseEvent.begin(); jdbcConnectionReleaseEvent.begin();
jdbcConnectionReleaseEvent.startedAt = System.nanoTime();
return jdbcConnectionReleaseEvent; return jdbcConnectionReleaseEvent;
} }
else { else {
@ -150,7 +145,6 @@ public class JfrEventManager implements EventManager {
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = (JdbcConnectionReleaseEvent) event; final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = (JdbcConnectionReleaseEvent) event;
jdbcConnectionReleaseEvent.end(); jdbcConnectionReleaseEvent.end();
if ( jdbcConnectionReleaseEvent.shouldCommit() ) { if ( jdbcConnectionReleaseEvent.shouldCommit() ) {
jdbcConnectionReleaseEvent.executionTime = getExecutionTime( jdbcConnectionReleaseEvent.startedAt );
jdbcConnectionReleaseEvent.sessionIdentifier = getSessionIdentifier( session ); jdbcConnectionReleaseEvent.sessionIdentifier = getSessionIdentifier( session );
jdbcConnectionReleaseEvent.tenantIdentifier = tenantId == null ? null : session.getFactory() jdbcConnectionReleaseEvent.tenantIdentifier = tenantId == null ? null : session.getFactory()
.getTenantIdentifierJavaType() .getTenantIdentifierJavaType()
@ -165,7 +159,6 @@ public class JfrEventManager implements EventManager {
if ( jdbcPreparedStatementCreationEventType.isEnabled() ) { if ( jdbcPreparedStatementCreationEventType.isEnabled() ) {
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = new JdbcPreparedStatementCreationEvent(); final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = new JdbcPreparedStatementCreationEvent();
jdbcPreparedStatementCreation.begin(); jdbcPreparedStatementCreation.begin();
jdbcPreparedStatementCreation.startedAt = System.nanoTime();
return jdbcPreparedStatementCreation; return jdbcPreparedStatementCreation;
} }
else { else {
@ -181,7 +174,6 @@ public class JfrEventManager implements EventManager {
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = (JdbcPreparedStatementCreationEvent) event; final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = (JdbcPreparedStatementCreationEvent) event;
jdbcPreparedStatementCreation.end(); jdbcPreparedStatementCreation.end();
if ( jdbcPreparedStatementCreation.shouldCommit() ) { if ( jdbcPreparedStatementCreation.shouldCommit() ) {
jdbcPreparedStatementCreation.executionTime = getExecutionTime( jdbcPreparedStatementCreation.startedAt );
jdbcPreparedStatementCreation.sql = preparedStatementSql; jdbcPreparedStatementCreation.sql = preparedStatementSql;
jdbcPreparedStatementCreation.commit(); jdbcPreparedStatementCreation.commit();
} }
@ -193,7 +185,6 @@ public class JfrEventManager implements EventManager {
if ( jdbcPreparedStatementExecutionEventType.isEnabled() ) { if ( jdbcPreparedStatementExecutionEventType.isEnabled() ) {
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = new JdbcPreparedStatementExecutionEvent(); final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = new JdbcPreparedStatementExecutionEvent();
jdbcPreparedStatementExecutionEvent.begin(); jdbcPreparedStatementExecutionEvent.begin();
jdbcPreparedStatementExecutionEvent.startedAt = System.nanoTime();
return jdbcPreparedStatementExecutionEvent; return jdbcPreparedStatementExecutionEvent;
} }
else { else {
@ -209,8 +200,6 @@ public class JfrEventManager implements EventManager {
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = (JdbcPreparedStatementExecutionEvent) event; final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = (JdbcPreparedStatementExecutionEvent) event;
jdbcPreparedStatementExecutionEvent.end(); jdbcPreparedStatementExecutionEvent.end();
if ( jdbcPreparedStatementExecutionEvent.shouldCommit() ) { if ( jdbcPreparedStatementExecutionEvent.shouldCommit() ) {
jdbcPreparedStatementExecutionEvent.executionTime = getExecutionTime(
jdbcPreparedStatementExecutionEvent.startedAt );
jdbcPreparedStatementExecutionEvent.sql = preparedStatementSql; jdbcPreparedStatementExecutionEvent.sql = preparedStatementSql;
jdbcPreparedStatementExecutionEvent.commit(); jdbcPreparedStatementExecutionEvent.commit();
} }
@ -222,7 +211,6 @@ public class JfrEventManager implements EventManager {
if ( jdbcBatchExecutionEventType.isEnabled() ) { if ( jdbcBatchExecutionEventType.isEnabled() ) {
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = new JdbcBatchExecutionEvent(); final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = new JdbcBatchExecutionEvent();
jdbcBatchExecutionEvent.begin(); jdbcBatchExecutionEvent.begin();
jdbcBatchExecutionEvent.startedAt = System.nanoTime();
return jdbcBatchExecutionEvent; return jdbcBatchExecutionEvent;
} }
else { else {
@ -238,7 +226,6 @@ public class JfrEventManager implements EventManager {
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = (JdbcBatchExecutionEvent) event; final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = (JdbcBatchExecutionEvent) event;
jdbcBatchExecutionEvent.end(); jdbcBatchExecutionEvent.end();
if ( jdbcBatchExecutionEvent.shouldCommit() ) { if ( jdbcBatchExecutionEvent.shouldCommit() ) {
jdbcBatchExecutionEvent.executionTime = getExecutionTime( jdbcBatchExecutionEvent.startedAt );
jdbcBatchExecutionEvent.sql = statementSql; jdbcBatchExecutionEvent.sql = statementSql;
jdbcBatchExecutionEvent.commit(); jdbcBatchExecutionEvent.commit();
} }
@ -250,7 +237,6 @@ public class JfrEventManager implements EventManager {
if ( cachePutEventType.isEnabled() ) { if ( cachePutEventType.isEnabled() ) {
final CachePutEvent cachePutEvent = new CachePutEvent(); final CachePutEvent cachePutEvent = new CachePutEvent();
cachePutEvent.begin(); cachePutEvent.begin();
cachePutEvent.startedAt = System.nanoTime();
return cachePutEvent; return cachePutEvent;
} }
else { else {
@ -269,7 +255,6 @@ public class JfrEventManager implements EventManager {
final CachePutEvent cachePutEvent = (CachePutEvent) event; final CachePutEvent cachePutEvent = (CachePutEvent) event;
cachePutEvent.end(); cachePutEvent.end();
if ( cachePutEvent.shouldCommit() ) { if ( cachePutEvent.shouldCommit() ) {
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
cachePutEvent.sessionIdentifier = getSessionIdentifier( session ); cachePutEvent.sessionIdentifier = getSessionIdentifier( session );
cachePutEvent.regionName = region.getName(); cachePutEvent.regionName = region.getName();
cachePutEvent.description = description.getText(); cachePutEvent.description = description.getText();
@ -311,7 +296,6 @@ public class JfrEventManager implements EventManager {
final CachePutEvent cachePutEvent = (CachePutEvent) event; final CachePutEvent cachePutEvent = (CachePutEvent) event;
cachePutEvent.end(); cachePutEvent.end();
if ( cachePutEvent.shouldCommit() ) { if ( cachePutEvent.shouldCommit() ) {
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
cachePutEvent.sessionIdentifier = getSessionIdentifier( session ); cachePutEvent.sessionIdentifier = getSessionIdentifier( session );
cachePutEvent.regionName = cachedDomainDataAccess.getRegion().getName(); cachePutEvent.regionName = cachedDomainDataAccess.getRegion().getName();
cachePutEvent.entityName = getEntityName( persister ); cachePutEvent.entityName = getEntityName( persister );
@ -335,7 +319,6 @@ public class JfrEventManager implements EventManager {
final CachePutEvent cachePutEvent = (CachePutEvent) event; final CachePutEvent cachePutEvent = (CachePutEvent) event;
cachePutEvent.end(); cachePutEvent.end();
if ( cachePutEvent.shouldCommit() ) { if ( cachePutEvent.shouldCommit() ) {
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
cachePutEvent.sessionIdentifier = getSessionIdentifier( session ); cachePutEvent.sessionIdentifier = getSessionIdentifier( session );
cachePutEvent.regionName = cachedDomainDataAccess.getRegion().getName(); cachePutEvent.regionName = cachedDomainDataAccess.getRegion().getName();
cachePutEvent.collectionName = persister.getNavigableRole().getFullPath(); cachePutEvent.collectionName = persister.getNavigableRole().getFullPath();
@ -351,7 +334,6 @@ public class JfrEventManager implements EventManager {
if ( cacheGetEventType.isEnabled() ) { if ( cacheGetEventType.isEnabled() ) {
final CacheGetEvent cacheGetEvent = new CacheGetEvent(); final CacheGetEvent cacheGetEvent = new CacheGetEvent();
cacheGetEvent.begin(); cacheGetEvent.begin();
cacheGetEvent.startedAt = System.nanoTime();
return cacheGetEvent; return cacheGetEvent;
} }
else { else {
@ -369,7 +351,6 @@ public class JfrEventManager implements EventManager {
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event; final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
cacheGetEvent.end(); cacheGetEvent.end();
if ( cacheGetEvent.shouldCommit() ) { if ( cacheGetEvent.shouldCommit() ) {
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
cacheGetEvent.sessionIdentifier = getSessionIdentifier( session ); cacheGetEvent.sessionIdentifier = getSessionIdentifier( session );
cacheGetEvent.regionName = region.getName(); cacheGetEvent.regionName = region.getName();
cacheGetEvent.hit = hit; cacheGetEvent.hit = hit;
@ -390,7 +371,6 @@ public class JfrEventManager implements EventManager {
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event; final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
cacheGetEvent.end(); cacheGetEvent.end();
if ( cacheGetEvent.shouldCommit() ) { if ( cacheGetEvent.shouldCommit() ) {
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
cacheGetEvent.sessionIdentifier = getSessionIdentifier( session ); cacheGetEvent.sessionIdentifier = getSessionIdentifier( session );
cacheGetEvent.entityName = getEntityName( persister ); cacheGetEvent.entityName = getEntityName( persister );
cacheGetEvent.regionName = region.getName(); cacheGetEvent.regionName = region.getName();
@ -412,7 +392,6 @@ public class JfrEventManager implements EventManager {
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event; final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
cacheGetEvent.end(); cacheGetEvent.end();
if ( cacheGetEvent.shouldCommit() ) { if ( cacheGetEvent.shouldCommit() ) {
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
cacheGetEvent.sessionIdentifier = getSessionIdentifier( session ); cacheGetEvent.sessionIdentifier = getSessionIdentifier( session );
cacheGetEvent.collectionName = persister.getNavigableRole().getFullPath(); cacheGetEvent.collectionName = persister.getNavigableRole().getFullPath();
cacheGetEvent.regionName = region.getName(); cacheGetEvent.regionName = region.getName();
@ -427,7 +406,6 @@ public class JfrEventManager implements EventManager {
if ( flushEventType.isEnabled() ) { if ( flushEventType.isEnabled() ) {
final FlushEvent flushEvent = new FlushEvent(); final FlushEvent flushEvent = new FlushEvent();
flushEvent.begin(); flushEvent.begin();
flushEvent.startedAt = System.nanoTime();
return flushEvent; return flushEvent;
} }
else { else {
@ -451,7 +429,6 @@ public class JfrEventManager implements EventManager {
final FlushEvent flushEvent = (FlushEvent) hibernateMonitoringEvent; final FlushEvent flushEvent = (FlushEvent) hibernateMonitoringEvent;
flushEvent.end(); flushEvent.end();
if ( flushEvent.shouldCommit() ) { if ( flushEvent.shouldCommit() ) {
flushEvent.executionTime = getExecutionTime( flushEvent.startedAt );
flushEvent.sessionIdentifier = getSessionIdentifier( event.getSession() ); flushEvent.sessionIdentifier = getSessionIdentifier( event.getSession() );
flushEvent.numberOfEntitiesProcessed = event.getNumberOfEntitiesProcessed(); flushEvent.numberOfEntitiesProcessed = event.getNumberOfEntitiesProcessed();
flushEvent.numberOfCollectionsProcessed = event.getNumberOfCollectionsProcessed(); flushEvent.numberOfCollectionsProcessed = event.getNumberOfCollectionsProcessed();
@ -465,7 +442,6 @@ public class JfrEventManager implements EventManager {
public PartialFlushEvent beginPartialFlushEvent() { public PartialFlushEvent beginPartialFlushEvent() {
if ( partialFlushEventType.isEnabled() ) { if ( partialFlushEventType.isEnabled() ) {
final PartialFlushEvent partialFlushEvent = new PartialFlushEvent(); final PartialFlushEvent partialFlushEvent = new PartialFlushEvent();
partialFlushEvent.startedAt = System.nanoTime();
partialFlushEvent.begin(); partialFlushEvent.begin();
return partialFlushEvent; return partialFlushEvent;
} }
@ -482,7 +458,6 @@ public class JfrEventManager implements EventManager {
final PartialFlushEvent flushEvent = (PartialFlushEvent) hibernateMonitoringEvent; final PartialFlushEvent flushEvent = (PartialFlushEvent) hibernateMonitoringEvent;
flushEvent.end(); flushEvent.end();
if ( flushEvent.shouldCommit() ) { if ( flushEvent.shouldCommit() ) {
flushEvent.executionTime = getExecutionTime( flushEvent.startedAt );
flushEvent.sessionIdentifier = getSessionIdentifier( event.getSession() ); flushEvent.sessionIdentifier = getSessionIdentifier( event.getSession() );
flushEvent.numberOfEntitiesProcessed = event.getNumberOfEntitiesProcessed(); flushEvent.numberOfEntitiesProcessed = event.getNumberOfEntitiesProcessed();
flushEvent.numberOfCollectionsProcessed = event.getNumberOfCollectionsProcessed(); flushEvent.numberOfCollectionsProcessed = event.getNumberOfCollectionsProcessed();
@ -496,7 +471,6 @@ public class JfrEventManager implements EventManager {
public DirtyCalculationEvent beginDirtyCalculationEvent() { public DirtyCalculationEvent beginDirtyCalculationEvent() {
if ( dirtyCalculationEventType.isEnabled() ) { if ( dirtyCalculationEventType.isEnabled() ) {
final DirtyCalculationEvent dirtyCalculationEvent = new DirtyCalculationEvent(); final DirtyCalculationEvent dirtyCalculationEvent = new DirtyCalculationEvent();
dirtyCalculationEvent.startedAt = System.nanoTime();
dirtyCalculationEvent.begin(); dirtyCalculationEvent.begin();
return dirtyCalculationEvent; return dirtyCalculationEvent;
} }
@ -516,7 +490,6 @@ public class JfrEventManager implements EventManager {
final DirtyCalculationEvent dirtyCalculationEvent = (DirtyCalculationEvent) event; final DirtyCalculationEvent dirtyCalculationEvent = (DirtyCalculationEvent) event;
dirtyCalculationEvent.end(); dirtyCalculationEvent.end();
if ( dirtyCalculationEvent.shouldCommit() ) { if ( dirtyCalculationEvent.shouldCommit() ) {
dirtyCalculationEvent.executionTime = getExecutionTime( dirtyCalculationEvent.startedAt );
dirtyCalculationEvent.sessionIdentifier = getSessionIdentifier( session ); dirtyCalculationEvent.sessionIdentifier = getSessionIdentifier( session );
dirtyCalculationEvent.entityName = getEntityName( persister ); dirtyCalculationEvent.entityName = getEntityName( persister );
dirtyCalculationEvent.entityStatus = entry.getStatus().name(); dirtyCalculationEvent.entityStatus = entry.getStatus().name();
@ -530,7 +503,6 @@ public class JfrEventManager implements EventManager {
public PrePartialFlushEvent beginPrePartialFlush() { public PrePartialFlushEvent beginPrePartialFlush() {
if ( prePartialFlushEventType.isEnabled() ) { if ( prePartialFlushEventType.isEnabled() ) {
final PrePartialFlushEvent partialFlushEvent = new PrePartialFlushEvent(); final PrePartialFlushEvent partialFlushEvent = new PrePartialFlushEvent();
partialFlushEvent.startedAt = System.nanoTime();
partialFlushEvent.begin(); partialFlushEvent.begin();
return partialFlushEvent; return partialFlushEvent;
} }
@ -547,17 +519,12 @@ public class JfrEventManager implements EventManager {
final PrePartialFlushEvent prePartialFlushEvent = (PrePartialFlushEvent) event; final PrePartialFlushEvent prePartialFlushEvent = (PrePartialFlushEvent) event;
prePartialFlushEvent.end(); prePartialFlushEvent.end();
if ( prePartialFlushEvent.shouldCommit() ) { if ( prePartialFlushEvent.shouldCommit() ) {
prePartialFlushEvent.executionTime = getExecutionTime( prePartialFlushEvent.startedAt );
prePartialFlushEvent.sessionIdentifier = getSessionIdentifier( session ); prePartialFlushEvent.sessionIdentifier = getSessionIdentifier( session );
prePartialFlushEvent.commit(); prePartialFlushEvent.commit();
} }
} }
} }
private long getExecutionTime(Long startTime) {
return NANOSECONDS.convert( System.nanoTime() - startTime, NANOSECONDS );
}
private String getSessionIdentifier(SharedSessionContractImplementor session) { private String getSessionIdentifier(SharedSessionContractImplementor session) {
if ( session == null ) { if ( session == null ) {
return null; return null;

View File

@ -34,9 +34,6 @@ public class PartialFlushEvent extends Event implements HibernateMonitoringEvent
@Label( "Number Of Processed Collections" ) @Label( "Number Of Processed Collections" )
public int numberOfCollectionsProcessed; public int numberOfCollectionsProcessed;
@Label( "PartialFlushEvent time" )
public long executionTime;
@Label( "Auto Flush" ) @Label( "Auto Flush" )
public boolean isAutoFlush; public boolean isAutoFlush;
@ -45,6 +42,4 @@ public class PartialFlushEvent extends Event implements HibernateMonitoringEvent
return NAME ; return NAME ;
} }
public transient long startedAt;
} }

View File

@ -28,13 +28,9 @@ public class PrePartialFlushEvent extends Event implements HibernateMonitoringEv
@Label("Session Identifier") @Label("Session Identifier")
public String sessionIdentifier; public String sessionIdentifier;
@Label("PrePartialFlushEvent time")
public long executionTime;
@Override @Override
public String toString() { public String toString() {
return NAME; return NAME;
} }
public transient long startedAt;
} }

View File

@ -62,7 +62,7 @@ public class DirtyCalculationEventTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( DirtyCalculationEvent.NAME ); .isEqualTo( DirtyCalculationEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( sessionId ); .isEqualTo( sessionId );
assertThat( event.getString( "entityName" ) ) assertThat( event.getString( "entityName" ) )

View File

@ -58,14 +58,14 @@ public class JdbcBatchExecutionEventTests {
RecordedEvent jdbcBatchExecutionEvent = events.get( 0 ); RecordedEvent jdbcBatchExecutionEvent = events.get( 0 );
assertThat( jdbcBatchExecutionEvent.getEventType().getName() ) assertThat( jdbcBatchExecutionEvent.getEventType().getName() )
.isEqualTo( JdbcBatchExecutionEvent.NAME ); .isEqualTo( JdbcBatchExecutionEvent.NAME );
assertThat( jdbcBatchExecutionEvent.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( jdbcBatchExecutionEvent.getDuration() ).isPositive();
assertThat( jdbcBatchExecutionEvent.getString( "sql" ).toLowerCase( Locale.ROOT ) ) assertThat( jdbcBatchExecutionEvent.getString( "sql" ).toLowerCase( Locale.ROOT ) )
.contains( "insert into " ); .contains( "insert into " );
jdbcBatchExecutionEvent = events.get( 1 ); jdbcBatchExecutionEvent = events.get( 1 );
assertThat( jdbcBatchExecutionEvent.getEventType().getName() ) assertThat( jdbcBatchExecutionEvent.getEventType().getName() )
.isEqualTo( JdbcBatchExecutionEvent.NAME ); .isEqualTo( JdbcBatchExecutionEvent.NAME );
assertThat( jdbcBatchExecutionEvent.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( jdbcBatchExecutionEvent.getDuration() ).isPositive();
assertThat( jdbcBatchExecutionEvent.getString( "sql" ).toLowerCase( Locale.ROOT ) ) assertThat( jdbcBatchExecutionEvent.getString( "sql" ).toLowerCase( Locale.ROOT ) )
.contains( "insert into " ); .contains( "insert into " );
} }

View File

@ -47,14 +47,14 @@ public class JdbcPreparedStatementEventTests {
RecordedEvent preparedStatementCreationEvent = events.get( 0 ); RecordedEvent preparedStatementCreationEvent = events.get( 0 );
assertThat( preparedStatementCreationEvent.getEventType().getName() ) assertThat( preparedStatementCreationEvent.getEventType().getName() )
.isEqualTo( JdbcPreparedStatementCreationEvent.NAME ); .isEqualTo( JdbcPreparedStatementCreationEvent.NAME );
assertThat( preparedStatementCreationEvent.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( preparedStatementCreationEvent.getDuration() ).isPositive();
assertThat( preparedStatementCreationEvent.getString( "sql" ).toLowerCase( Locale.ROOT ) ) assertThat( preparedStatementCreationEvent.getString( "sql" ).toLowerCase( Locale.ROOT ) )
.contains( "select " ); .contains( "select " );
RecordedEvent preparedStatementExecutionEvent = events.get( 1 ); RecordedEvent preparedStatementExecutionEvent = events.get( 1 );
assertThat( preparedStatementExecutionEvent.getEventType().getName() ) assertThat( preparedStatementExecutionEvent.getEventType().getName() )
.isEqualTo( JdbcPreparedStatementExecutionEvent.NAME ); .isEqualTo( JdbcPreparedStatementExecutionEvent.NAME );
assertThat( preparedStatementExecutionEvent.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( preparedStatementExecutionEvent.getDuration() ).isPositive();
assertThat( preparedStatementExecutionEvent.getString( "sql" ) ) assertThat( preparedStatementExecutionEvent.getString( "sql" ) )
.isEqualTo( preparedStatementCreationEvent.getString( "sql" ) ); .isEqualTo( preparedStatementCreationEvent.getString( "sql" ) );
} }

View File

@ -68,7 +68,7 @@ public class CacheGetEventTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CacheGetEvent.NAME ); .isEqualTo( CacheGetEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ) assertThat( event.getString( "entityName" ) )

View File

@ -64,7 +64,7 @@ public class EntityInsertCachePutEventTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CachePutEvent.NAME ); .isEqualTo( CachePutEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ).isEqualTo( TestEntity.class.getName() ); assertThat( event.getString( "entityName" ) ).isEqualTo( TestEntity.class.getName() );
@ -91,7 +91,7 @@ public class EntityInsertCachePutEventTests {
event = events.get( 0 ); event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CachePutEvent.NAME ); .isEqualTo( CachePutEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ).isEqualTo( AnotherTestEntity.class.getName() ); assertThat( event.getString( "entityName" ) ).isEqualTo( AnotherTestEntity.class.getName() );

View File

@ -77,7 +77,7 @@ public class EntityUpdateCachePutEventTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CachePutEvent.NAME ); .isEqualTo( CachePutEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ).isEqualTo( TestEntity.class.getName() ); assertThat( event.getString( "entityName" ) ).isEqualTo( TestEntity.class.getName() );
@ -107,7 +107,7 @@ public class EntityUpdateCachePutEventTests {
event = events.get( 0 ); event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CachePutEvent.NAME ); .isEqualTo( CachePutEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ).isEqualTo( AnotherTestEntity.class.getName() ); assertThat( event.getString( "entityName" ) ).isEqualTo( AnotherTestEntity.class.getName() );

View File

@ -71,7 +71,7 @@ public class NaturalIdGetCacheTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CacheGetEvent.NAME ); .isEqualTo( CacheGetEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ) assertThat( event.getString( "entityName" ) )
@ -83,7 +83,7 @@ public class NaturalIdGetCacheTests {
event = events.get( 1 ); event = events.get( 1 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CacheGetEvent.NAME ); .isEqualTo( CacheGetEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ) assertThat( event.getString( "entityName" ) )

View File

@ -61,7 +61,7 @@ public class NaturalIdPutCacheTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CachePutEvent.NAME ); .isEqualTo( CachePutEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ).isEqualTo( TestEntity.class.getName() ); assertThat( event.getString( "entityName" ) ).isEqualTo( TestEntity.class.getName() );
@ -73,7 +73,7 @@ public class NaturalIdPutCacheTests {
event = events.get( 1 ); event = events.get( 1 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CachePutEvent.NAME ); .isEqualTo( CachePutEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getString( "entityName" ) ).isEqualTo( TestEntity.class.getName() ); assertThat( event.getString( "entityName" ) ).isEqualTo( TestEntity.class.getName() );

View File

@ -75,7 +75,7 @@ public class QueryCachePutEventTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( CachePutEvent.NAME ); .isEqualTo( CachePutEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getBoolean( "cacheChanged" ) ).isTrue(); assertThat( event.getBoolean( "cacheChanged" ) ).isTrue();

View File

@ -50,7 +50,7 @@ public class AutoFlushTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( FlushEvent.NAME ); .isEqualTo( FlushEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getInt( "numberOfEntitiesProcessed" ) ) assertThat( event.getInt( "numberOfEntitiesProcessed" ) )
@ -69,7 +69,7 @@ public class AutoFlushTests {
event = events.get( 0 ); event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( PartialFlushEvent.NAME ); .isEqualTo( PartialFlushEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getInt( "numberOfEntitiesProcessed" ) ) assertThat( event.getInt( "numberOfEntitiesProcessed" ) )

View File

@ -48,7 +48,7 @@ public class ExplicitFlushTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( FlushEvent.NAME ); .isEqualTo( FlushEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( session.getSessionIdentifier().toString() ); .isEqualTo( session.getSessionIdentifier().toString() );
assertThat( event.getInt( "numberOfEntitiesProcessed" ) ) assertThat( event.getInt( "numberOfEntitiesProcessed" ) )

View File

@ -52,7 +52,7 @@ public class FlushTests {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( FlushEvent.NAME ); .isEqualTo( FlushEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( sessionId ); .isEqualTo( sessionId );
assertThat( event.getInt( "numberOfEntitiesProcessed" ) ) assertThat( event.getInt( "numberOfEntitiesProcessed" ) )

View File

@ -65,7 +65,7 @@ public class PrePartialFlushTest {
RecordedEvent event = events.get( 0 ); RecordedEvent event = events.get( 0 );
assertThat( event.getEventType().getName() ) assertThat( event.getEventType().getName() )
.isEqualTo( PrePartialFlushEvent.NAME ); .isEqualTo( PrePartialFlushEvent.NAME );
assertThat( event.getLong( "executionTime" ) ).isGreaterThan( 0 ); assertThat( event.getDuration() ).isPositive();
assertThat( event.getString( "sessionIdentifier" ) ) assertThat( event.getString( "sessionIdentifier" ) )
.isEqualTo( sessionId ); .isEqualTo( sessionId );
} }