2020
2121import jdk .jfr .EventType ;
2222
23- import static java .util .concurrent .TimeUnit .NANOSECONDS ;
24-
2523
2624@ AllowNonPortable
2725public class JfrEventManager implements EventManager {
@@ -101,7 +99,6 @@ public JdbcConnectionAcquisitionEvent beginJdbcConnectionAcquisitionEvent() {
10199 if ( jdbcConnectionAcquisitionEventType .isEnabled () ) {
102100 final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = new JdbcConnectionAcquisitionEvent ();
103101 jdbcConnectionAcquisitionEvent .begin ();
104- jdbcConnectionAcquisitionEvent .startedAt = System .nanoTime ();
105102 return jdbcConnectionAcquisitionEvent ;
106103 }
107104 else {
@@ -118,7 +115,6 @@ public void completeJdbcConnectionAcquisitionEvent(
118115 final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = (JdbcConnectionAcquisitionEvent ) event ;
119116 jdbcConnectionAcquisitionEvent .end ();
120117 if ( jdbcConnectionAcquisitionEvent .shouldCommit () ) {
121- jdbcConnectionAcquisitionEvent .executionTime = getExecutionTime ( jdbcConnectionAcquisitionEvent .startedAt );
122118 jdbcConnectionAcquisitionEvent .sessionIdentifier = getSessionIdentifier ( session );
123119 jdbcConnectionAcquisitionEvent .tenantIdentifier = tenantId == null ? null : session .getFactory ()
124120 .getTenantIdentifierJavaType ()
@@ -133,7 +129,6 @@ public JdbcConnectionReleaseEvent beginJdbcConnectionReleaseEvent() {
133129 if ( jdbcConnectionReleaseEventType .isEnabled () ) {
134130 final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = new JdbcConnectionReleaseEvent ();
135131 jdbcConnectionReleaseEvent .begin ();
136- jdbcConnectionReleaseEvent .startedAt = System .nanoTime ();
137132 return jdbcConnectionReleaseEvent ;
138133 }
139134 else {
@@ -150,7 +145,6 @@ public void completeJdbcConnectionReleaseEvent(
150145 final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = (JdbcConnectionReleaseEvent ) event ;
151146 jdbcConnectionReleaseEvent .end ();
152147 if ( jdbcConnectionReleaseEvent .shouldCommit () ) {
153- jdbcConnectionReleaseEvent .executionTime = getExecutionTime ( jdbcConnectionReleaseEvent .startedAt );
154148 jdbcConnectionReleaseEvent .sessionIdentifier = getSessionIdentifier ( session );
155149 jdbcConnectionReleaseEvent .tenantIdentifier = tenantId == null ? null : session .getFactory ()
156150 .getTenantIdentifierJavaType ()
@@ -165,7 +159,6 @@ public JdbcPreparedStatementCreationEvent beginJdbcPreparedStatementCreationEven
165159 if ( jdbcPreparedStatementCreationEventType .isEnabled () ) {
166160 final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = new JdbcPreparedStatementCreationEvent ();
167161 jdbcPreparedStatementCreation .begin ();
168- jdbcPreparedStatementCreation .startedAt = System .nanoTime ();
169162 return jdbcPreparedStatementCreation ;
170163 }
171164 else {
@@ -181,7 +174,6 @@ public void completeJdbcPreparedStatementCreationEvent(
181174 final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = (JdbcPreparedStatementCreationEvent ) event ;
182175 jdbcPreparedStatementCreation .end ();
183176 if ( jdbcPreparedStatementCreation .shouldCommit () ) {
184- jdbcPreparedStatementCreation .executionTime = getExecutionTime ( jdbcPreparedStatementCreation .startedAt );
185177 jdbcPreparedStatementCreation .sql = preparedStatementSql ;
186178 jdbcPreparedStatementCreation .commit ();
187179 }
@@ -193,7 +185,6 @@ public JdbcPreparedStatementExecutionEvent beginJdbcPreparedStatementExecutionEv
193185 if ( jdbcPreparedStatementExecutionEventType .isEnabled () ) {
194186 final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = new JdbcPreparedStatementExecutionEvent ();
195187 jdbcPreparedStatementExecutionEvent .begin ();
196- jdbcPreparedStatementExecutionEvent .startedAt = System .nanoTime ();
197188 return jdbcPreparedStatementExecutionEvent ;
198189 }
199190 else {
@@ -209,8 +200,6 @@ public void completeJdbcPreparedStatementExecutionEvent(
209200 final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = (JdbcPreparedStatementExecutionEvent ) event ;
210201 jdbcPreparedStatementExecutionEvent .end ();
211202 if ( jdbcPreparedStatementExecutionEvent .shouldCommit () ) {
212- jdbcPreparedStatementExecutionEvent .executionTime = getExecutionTime (
213- jdbcPreparedStatementExecutionEvent .startedAt );
214203 jdbcPreparedStatementExecutionEvent .sql = preparedStatementSql ;
215204 jdbcPreparedStatementExecutionEvent .commit ();
216205 }
@@ -222,7 +211,6 @@ public JdbcBatchExecutionEvent beginJdbcBatchExecutionEvent() {
222211 if ( jdbcBatchExecutionEventType .isEnabled () ) {
223212 final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = new JdbcBatchExecutionEvent ();
224213 jdbcBatchExecutionEvent .begin ();
225- jdbcBatchExecutionEvent .startedAt = System .nanoTime ();
226214 return jdbcBatchExecutionEvent ;
227215 }
228216 else {
@@ -238,7 +226,6 @@ public void completeJdbcBatchExecutionEvent(
238226 final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = (JdbcBatchExecutionEvent ) event ;
239227 jdbcBatchExecutionEvent .end ();
240228 if ( jdbcBatchExecutionEvent .shouldCommit () ) {
241- jdbcBatchExecutionEvent .executionTime = getExecutionTime ( jdbcBatchExecutionEvent .startedAt );
242229 jdbcBatchExecutionEvent .sql = statementSql ;
243230 jdbcBatchExecutionEvent .commit ();
244231 }
@@ -250,7 +237,6 @@ public HibernateMonitoringEvent beginCachePutEvent() {
250237 if ( cachePutEventType .isEnabled () ) {
251238 final CachePutEvent cachePutEvent = new CachePutEvent ();
252239 cachePutEvent .begin ();
253- cachePutEvent .startedAt = System .nanoTime ();
254240 return cachePutEvent ;
255241 }
256242 else {
@@ -269,7 +255,6 @@ public void completeCachePutEvent(
269255 final CachePutEvent cachePutEvent = (CachePutEvent ) event ;
270256 cachePutEvent .end ();
271257 if ( cachePutEvent .shouldCommit () ) {
272- cachePutEvent .executionTime = getExecutionTime ( cachePutEvent .startedAt );
273258 cachePutEvent .sessionIdentifier = getSessionIdentifier ( session );
274259 cachePutEvent .regionName = region .getName ();
275260 cachePutEvent .description = description .getText ();
@@ -311,7 +296,6 @@ public void completeCachePutEvent(
311296 final CachePutEvent cachePutEvent = (CachePutEvent ) event ;
312297 cachePutEvent .end ();
313298 if ( cachePutEvent .shouldCommit () ) {
314- cachePutEvent .executionTime = getExecutionTime ( cachePutEvent .startedAt );
315299 cachePutEvent .sessionIdentifier = getSessionIdentifier ( session );
316300 cachePutEvent .regionName = cachedDomainDataAccess .getRegion ().getName ();
317301 cachePutEvent .entityName = getEntityName ( persister );
@@ -335,7 +319,6 @@ public void completeCachePutEvent(
335319 final CachePutEvent cachePutEvent = (CachePutEvent ) event ;
336320 cachePutEvent .end ();
337321 if ( cachePutEvent .shouldCommit () ) {
338- cachePutEvent .executionTime = getExecutionTime ( cachePutEvent .startedAt );
339322 cachePutEvent .sessionIdentifier = getSessionIdentifier ( session );
340323 cachePutEvent .regionName = cachedDomainDataAccess .getRegion ().getName ();
341324 cachePutEvent .collectionName = persister .getNavigableRole ().getFullPath ();
@@ -351,7 +334,6 @@ public HibernateMonitoringEvent beginCacheGetEvent() {
351334 if ( cacheGetEventType .isEnabled () ) {
352335 final CacheGetEvent cacheGetEvent = new CacheGetEvent ();
353336 cacheGetEvent .begin ();
354- cacheGetEvent .startedAt = System .nanoTime ();
355337 return cacheGetEvent ;
356338 }
357339 else {
@@ -369,7 +351,6 @@ public void completeCacheGetEvent(
369351 final CacheGetEvent cacheGetEvent = (CacheGetEvent ) event ;
370352 cacheGetEvent .end ();
371353 if ( cacheGetEvent .shouldCommit () ) {
372- cacheGetEvent .executionTime = getExecutionTime ( cacheGetEvent .startedAt );
373354 cacheGetEvent .sessionIdentifier = getSessionIdentifier ( session );
374355 cacheGetEvent .regionName = region .getName ();
375356 cacheGetEvent .hit = hit ;
@@ -390,7 +371,6 @@ public void completeCacheGetEvent(
390371 final CacheGetEvent cacheGetEvent = (CacheGetEvent ) event ;
391372 cacheGetEvent .end ();
392373 if ( cacheGetEvent .shouldCommit () ) {
393- cacheGetEvent .executionTime = getExecutionTime ( cacheGetEvent .startedAt );
394374 cacheGetEvent .sessionIdentifier = getSessionIdentifier ( session );
395375 cacheGetEvent .entityName = getEntityName ( persister );
396376 cacheGetEvent .regionName = region .getName ();
@@ -412,7 +392,6 @@ public void completeCacheGetEvent(
412392 final CacheGetEvent cacheGetEvent = (CacheGetEvent ) event ;
413393 cacheGetEvent .end ();
414394 if ( cacheGetEvent .shouldCommit () ) {
415- cacheGetEvent .executionTime = getExecutionTime ( cacheGetEvent .startedAt );
416395 cacheGetEvent .sessionIdentifier = getSessionIdentifier ( session );
417396 cacheGetEvent .collectionName = persister .getNavigableRole ().getFullPath ();
418397 cacheGetEvent .regionName = region .getName ();
@@ -427,7 +406,6 @@ public FlushEvent beginFlushEvent() {
427406 if ( flushEventType .isEnabled () ) {
428407 final FlushEvent flushEvent = new FlushEvent ();
429408 flushEvent .begin ();
430- flushEvent .startedAt = System .nanoTime ();
431409 return flushEvent ;
432410 }
433411 else {
@@ -451,7 +429,6 @@ public void completeFlushEvent(
451429 final FlushEvent flushEvent = (FlushEvent ) hibernateMonitoringEvent ;
452430 flushEvent .end ();
453431 if ( flushEvent .shouldCommit () ) {
454- flushEvent .executionTime = getExecutionTime ( flushEvent .startedAt );
455432 flushEvent .sessionIdentifier = getSessionIdentifier ( event .getSession () );
456433 flushEvent .numberOfEntitiesProcessed = event .getNumberOfEntitiesProcessed ();
457434 flushEvent .numberOfCollectionsProcessed = event .getNumberOfCollectionsProcessed ();
@@ -465,7 +442,6 @@ public void completeFlushEvent(
465442 public PartialFlushEvent beginPartialFlushEvent () {
466443 if ( partialFlushEventType .isEnabled () ) {
467444 final PartialFlushEvent partialFlushEvent = new PartialFlushEvent ();
468- partialFlushEvent .startedAt = System .nanoTime ();
469445 partialFlushEvent .begin ();
470446 return partialFlushEvent ;
471447 }
@@ -482,7 +458,6 @@ public void completePartialFlushEvent(
482458 final PartialFlushEvent flushEvent = (PartialFlushEvent ) hibernateMonitoringEvent ;
483459 flushEvent .end ();
484460 if ( flushEvent .shouldCommit () ) {
485- flushEvent .executionTime = getExecutionTime ( flushEvent .startedAt );
486461 flushEvent .sessionIdentifier = getSessionIdentifier ( event .getSession () );
487462 flushEvent .numberOfEntitiesProcessed = event .getNumberOfEntitiesProcessed ();
488463 flushEvent .numberOfCollectionsProcessed = event .getNumberOfCollectionsProcessed ();
@@ -496,7 +471,6 @@ public void completePartialFlushEvent(
496471 public DirtyCalculationEvent beginDirtyCalculationEvent () {
497472 if ( dirtyCalculationEventType .isEnabled () ) {
498473 final DirtyCalculationEvent dirtyCalculationEvent = new DirtyCalculationEvent ();
499- dirtyCalculationEvent .startedAt = System .nanoTime ();
500474 dirtyCalculationEvent .begin ();
501475 return dirtyCalculationEvent ;
502476 }
@@ -516,7 +490,6 @@ public void completeDirtyCalculationEvent(
516490 final DirtyCalculationEvent dirtyCalculationEvent = (DirtyCalculationEvent ) event ;
517491 dirtyCalculationEvent .end ();
518492 if ( dirtyCalculationEvent .shouldCommit () ) {
519- dirtyCalculationEvent .executionTime = getExecutionTime ( dirtyCalculationEvent .startedAt );
520493 dirtyCalculationEvent .sessionIdentifier = getSessionIdentifier ( session );
521494 dirtyCalculationEvent .entityName = getEntityName ( persister );
522495 dirtyCalculationEvent .entityStatus = entry .getStatus ().name ();
@@ -530,7 +503,6 @@ public void completeDirtyCalculationEvent(
530503 public PrePartialFlushEvent beginPrePartialFlush () {
531504 if ( prePartialFlushEventType .isEnabled () ) {
532505 final PrePartialFlushEvent partialFlushEvent = new PrePartialFlushEvent ();
533- partialFlushEvent .startedAt = System .nanoTime ();
534506 partialFlushEvent .begin ();
535507 return partialFlushEvent ;
536508 }
@@ -547,17 +519,12 @@ public void completePrePartialFlush(
547519 final PrePartialFlushEvent prePartialFlushEvent = (PrePartialFlushEvent ) event ;
548520 prePartialFlushEvent .end ();
549521 if ( prePartialFlushEvent .shouldCommit () ) {
550- prePartialFlushEvent .executionTime = getExecutionTime ( prePartialFlushEvent .startedAt );
551522 prePartialFlushEvent .sessionIdentifier = getSessionIdentifier ( session );
552523 prePartialFlushEvent .commit ();
553524 }
554525 }
555526 }
556527
557- private long getExecutionTime (Long startTime ) {
558- return NANOSECONDS .convert ( System .nanoTime () - startTime , NANOSECONDS );
559- }
560-
561528 private String getSessionIdentifier (SharedSessionContractImplementor session ) {
562529 if ( session == null ) {
563530 return null ;
0 commit comments