@@ -504,19 +504,19 @@ private void connectionPoolCreated(final ConnectionPoolListener connectionPoolLi
504
504
* Send both current and deprecated events in order to preserve backwards compatibility.
505
505
* Must not throw {@link Exception}s.
506
506
*
507
- * @return A {@link TimePoint} after executing {@link ConnectionPoolListener#connectionCreated(ConnectionCreatedEvent)},
508
- * {@link ConnectionPoolListener#connectionCreated(ConnectionCreatedEvent)}.
509
- * This order is required by
507
+ * @return A {@link TimePoint} before executing {@link ConnectionPoolListener#connectionCreated(ConnectionCreatedEvent)}
508
+ * and logging the event. This order is required by
510
509
* <a href="https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#events">CMAP</a>
511
510
* and {@link ConnectionReadyEvent#getElapsedTime(TimeUnit)}.
512
511
*/
513
512
private TimePoint connectionCreated (final ConnectionPoolListener connectionPoolListener , final ConnectionId connectionId ) {
513
+ TimePoint openStart = TimePoint .now ();
514
514
logEventMessage ("Connection created" ,
515
515
"Connection created: address={}:{}, driver-generated ID={}" ,
516
516
connectionId .getLocalValue ());
517
517
518
518
connectionPoolListener .connectionCreated (new ConnectionCreatedEvent (connectionId ));
519
- return TimePoint . now () ;
519
+ return openStart ;
520
520
}
521
521
522
522
/**
@@ -562,16 +562,18 @@ private void connectionCheckedOut(
562
562
}
563
563
564
564
/**
565
- * @return A {@link TimePoint} after executing {@link ConnectionPoolListener#connectionCheckOutStarted(ConnectionCheckOutStartedEvent)}.
565
+ * @return A {@link TimePoint} before executing
566
+ * {@link ConnectionPoolListener#connectionCheckOutStarted(ConnectionCheckOutStartedEvent)} and logging the event.
566
567
* This order is required by
567
568
* <a href="https://github.com/mongodb/specifications/blob/master/source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst#events">CMAP</a>
568
569
* and {@link ConnectionCheckedOutEvent#getElapsedTime(TimeUnit)}, {@link ConnectionCheckOutFailedEvent#getElapsedTime(TimeUnit)}.
569
570
*/
570
571
private TimePoint connectionCheckoutStarted (final OperationContext operationContext ) {
572
+ TimePoint checkoutStart = TimePoint .now ();
571
573
logEventMessage ("Connection checkout started" , "Checkout started for connection to {}:{}" );
572
574
573
575
connectionPoolListener .connectionCheckOutStarted (new ConnectionCheckOutStartedEvent (serverId , operationContext .getId ()));
574
- return TimePoint . now () ;
576
+ return checkoutStart ;
575
577
}
576
578
577
579
/**
0 commit comments