Skip to content

Improve and trace connection startup performance - #22616

Open
Chris Johnstone (cjohnsto-nz) wants to merge 2 commits into
microsoft:mainfrom
cjohnsto-nz:feature/connection-startup
Open

Improve and trace connection startup performance#22616
Chris Johnstone (cjohnsto-nz) wants to merge 2 commits into
microsoft:mainfrom
cjohnsto-nz:feature/connection-startup

Conversation

@cjohnsto-nz

Copy link
Copy Markdown
Contributor

Description

This PR extracts the connection-startup and diagnostic improvements from #22614 into a focused change.

It improves startup performance and makes slow connection phases easier to diagnose by:

  • Loading saved connections and connection groups concurrently.
  • Carrying correlation IDs and timestamps from the connection dialog and Object Explorer through connection setup.
  • Adding phase-level debug traces for credential preparation, Entra token acquisition, Object Explorer initialization, and SQL Tools Service connection requests.
  • Replacing verbose Entra information logs containing account, tenant, resource, or token-expiry details with privacy-conscious timing traces.
  • Validating connection-dialog timing payloads before using them.

The traces contain timings, correlation identifiers, authentication type, and boolean state only. They do not include server names, database names, account IDs, tenant IDs, resource endpoints, or credentials.

Validation performed:

  • npm run build -- --target mssql
  • npm run test -- --target mssql --coverage=false
  • npm run package -- --target mssql --online
  • Manual VSIX installation and connection testing

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR focuses on improving connection-startup performance and diagnosability by adding correlation-aware, phase-level tracing across the connection dialog, connection manager, Object Explorer session creation, and VS Code Entra token acquisition, plus making startup loading more concurrent.

Changes:

  • Load saved connections and connection groups concurrently during connection-manager startup checks.
  • Propagate correlation IDs and timestamps from the Connection Dialog through Object Explorer session creation and key connection phases.
  • Add privacy-conscious timing traces for Entra token acquisition and Object Explorer/SQL Tools Service connection phases, with unit tests covering the new tracing/validation behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
extensions/mssql/test/unit/vscodeEntraMfaUtils.test.ts Adds unit coverage for separate silent vs interactive token-session trace phases.
extensions/mssql/test/unit/connectionManager.test.ts Adds a test ensuring connection/group reads are initiated together during startup checks.
extensions/mssql/test/unit/connectionDialogWebviewController.test.ts Adds tests for correlation logging, missing payload handling, payload sanitization, and correlation propagation to OE creation.
extensions/mssql/src/webviews/pages/ConnectionDialog/connectionDialogStateProvider.tsx Emits a click correlation payload from the webview when “Connect” is pressed.
extensions/mssql/src/sharedInterfaces/connectionDialog.ts Extends the connect reducer payload to optionally include clickId/clickTimestamp.
extensions/mssql/src/objectExplorer/objectExplorerService.ts Records click traces and emits phase-level OE timing logs correlated to a click.
extensions/mssql/src/objectExplorer/objectExplorerProvider.ts Plumbs correlation/timing parameters through provider APIs and exposes recordConnectionClick.
extensions/mssql/src/controllers/mainController.ts Generates correlation IDs for OE selection and records them for expansion tracing; plumbs correlation through session creation.
extensions/mssql/src/controllers/connectionManager.ts Adds connection-phase tracing, concurrent startup reads, and privacy-conscious Entra token timing logs.
extensions/mssql/src/connectionconfig/connectionDialogWebviewController.ts Validates/normalizes correlation payloads and traces connection form/submit/test/connect phases.
extensions/mssql/src/azure/vscodeEntraMfaUtils.ts Adds trace helpers to time and correlate account/tenant/session/token acquisition phases.

Comment thread extensions/mssql/src/controllers/connectionManager.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Suppressed comments (2)

extensions/mssql/test/unit/vscodeEntraMfaUtils.test.ts:74

  • These expectations likely won’t match the actual trace output: traceTokenPhase() prefixes messages with [ConnectionTrace] VS Code accounts ... and the "completed" messages also include durationMs=... (and potentially additional details). Using regex matchers here avoids brittle exact-string matching.
        expect(traceLogger.debug).to.have.been.calledWithMatch(
            "silent token session request started requestId=token-request",
        );
        expect(traceLogger.debug).to.have.been.calledWithMatch(
            "silent token session request completed requestId=token-request",
        );
        expect(traceLogger.debug).to.have.been.calledWithMatch(
            "interactive token session request started requestId=token-request",
        );
        expect(traceLogger.debug).to.have.been.calledWithMatch(
            "interactive token session request completed requestId=token-request",
        );

extensions/mssql/test/unit/vscodeEntraMfaUtils.test.ts:8

  • This test uses sinon-chai assertions (e.g. expect(...).to.have.been.calledWithMatch(...)) but doesn’t register the sinon-chai plugin in this file. Test order isn’t guaranteed, so this can fail when the file is run in isolation.

This issue also appears on line 63 of the same file.

import { expect } from "chai";
import * as vscode from "vscode";
import {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants