Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,9 @@ const connectWithOptions = (
inflightConnection = (async () => {
const deviceAuthAbortController = new AbortController();

let cancelled = false;
let started = false;
let succeeded = false;
try {
if (
getCurrentConnectionStatus(getState(), connectionInfo.id) ===
Expand Down Expand Up @@ -1639,6 +1642,17 @@ const connectWithOptions = (
);
}

started = true;
log.info(
mongoLogId(1_001_000_005),
'Compass Connection Attempt Started',
'Connection attempt started',
{
clusterName: connectionInfo.atlasMetadata?.clusterName,
connectionId: connectionInfo.id,
}
);
Comment on lines +1639 to +1647
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@syn-zhu On line 1583, there is log 1_001_000_004 that carries the same info, is there a significance to this logs position over that one?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to my response to your next comment: Our purpose for introducing these logs was to facilitate connection latency tracking with Sentry. Given that, I wanted to reduce the surface area to connection attempts that would actually be meaningful.


const connectionAttempt = createConnectionAttempt({
logger: log.unbound,
proxyOptions: proxyPreferenceToProxyOptions(
Expand All @@ -1659,6 +1673,16 @@ const connectWithOptions = (
// This is how connection attempt indicates that the connection was
// aborted
if (!dataService || connectionAttempt.isClosed()) {
cancelled = true;
log.info(
mongoLogId(1_001_000_007),
'Compass Connection Attempt Cancelled',
'Connection attempt cancelled',
{
clusterName: connectionInfo.atlasMetadata?.clusterName,
connectionId: connectionInfo.id,
}
);
dispatch({
type: ActionTypes.ConnectionAttemptCancelled,
connectionId: connectionInfo.id,
Expand Down Expand Up @@ -1825,6 +1849,7 @@ const connectWithOptions = (
connectionInfo
);

succeeded = true;
log.info(
mongoLogId(1_001_000_006),
'Compass Connection Attempt Succeeded',
Expand Down Expand Up @@ -1870,6 +1895,18 @@ const connectWithOptions = (
);
}
} catch (err) {
if (started && !succeeded && !cancelled) {
log.info(
mongoLogId(1_001_000_008),
'Compass Connection Attempt Failed',
'Connection attempt failed',
{
clusterName: connectionInfo.atlasMetadata?.clusterName,
connectionId: connectionInfo.id,
error: (err as Error).message,
}
);
}
dispatch(connectionAttemptError(connectionInfo, err));
} finally {
deviceAuthAbortController.abort();
Expand Down
Loading