Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Light Query Profiler works with [Extended Events](https://docs.microsoft.com/en-
- Sortable, resizable event columns
- Detailed event inspection with tabbed view
- Cross-platform support: Windows, Linux, and macOS
- Export and import captured events as JSON files for offline analysis and sharing

---

Expand All @@ -63,6 +64,15 @@ Light Query Profiler is available on the **Visual Studio Code Marketplace**:
- Authentication mode and credentials
5. Click **Start** to begin profiling

### Export & Import Events

Captured events can be **exported to a JSON file** for offline analysis, sharing, or archiving — and **imported back** at any time without needing an active SQL Server connection.

- Click **⬆ Export...** in the toolbar, or use **Light Query Profiler: Export Events...** from the Command Palette
- Click **⬇ Import...** in the toolbar, or use **Light Query Profiler: Import Events...** from the Command Palette

The exported JSON format is compatible between the VS Code extension and the desktop application.

---

## Requirements
Expand Down
14 changes: 14 additions & 0 deletions vscode-extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ All notable changes to the Light Query Profiler extension will be documented in
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2026-03-27

### Added
- Export profiling events to a JSON file via the toolbar **Export...** button or the `Light Query Profiler: Export Events` palette command
- Import profiling events from a JSON file via the toolbar **Import...** button or the `Light Query Profiler: Import Events` palette command
- New `EventExportImportService` responsible for serializing/deserializing events, preserving row order (`__RowIndex`) and timestamps (`__Timestamp`)
- Confirmation dialog when importing events over an existing session (replace or cancel)
- Pending-import handshake: events imported while the profiler panel is closed are automatically loaded once the panel is opened
- Host-side `capturedEvents` mirror (up to 10,000 events) used as the source of truth for exports, keeping the extension host and webview in sync

### Changed
- **Export** and **Import** toolbar buttons are enabled only when the profiler is in the `stopped` state, preventing data corruption during live or paused sessions
- `README.md` and root `README.md` updated with an "Export & Import Events" section describing usage and the JSON format

## [1.0.1] - 2026-03-24

### Changed
Expand Down
31 changes: 31 additions & 0 deletions vscode-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ A SQL Server and Azure SQL Database query profiler for Visual Studio Code, power
- Event filtering and full-text search
- Sortable, resizable event columns
- Detailed event inspection with tabbed view
- Export captured events to a JSON file for offline analysis or sharing
- Import previously exported events without needing an active SQL Server connection

## Requirements

Expand All @@ -28,6 +30,35 @@ A SQL Server and Azure SQL Database query profiler for Visual Studio Code, power
- Authentication mode and credentials
5. Click **Start** to begin profiling

## Export & Import Events

Light Query Profiler lets you save captured events to a JSON file and reload them later — no active SQL Server connection required.

### Exporting Events

1. Capture events by starting a profiling session
2. Click **⬆ Export...** in the toolbar, or run **Light Query Profiler: Export Events...** from the Command Palette (`Ctrl+Shift+P`)
3. Choose a destination and file name — the default is `ProfilerEvents_yyyyMMdd_HHmmss.json`
4. A confirmation shows the number of events exported

> **Note:** Up to 10,000 events are kept in memory per session. If more events are captured, the oldest ones are automatically removed.

### Importing Events

1. Click **⬇ Import...** in the toolbar, or run **Light Query Profiler: Import Events...** from the Command Palette
2. Select a previously exported JSON file
3. If events are already loaded, you will be asked to confirm the replacement
4. The imported events appear in the table immediately, with full search, sort, and filter support

### JSON File Format

The exported JSON is a plain array where each entry contains the event fields (EventClass, TextData, ApplicationName, Duration, CPU, Reads, Writes, etc.) plus two metadata fields:

- `__RowIndex` — preserves the original capture order
- `__Timestamp` — copy of the event start time for alternative sorting

The format is compatible with events exported from the **Light Query Profiler desktop application**.

## Authentication Modes

| Mode | Description |
Expand Down
14 changes: 13 additions & 1 deletion vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "light-query-profiler",
"displayName": "Light Query Profiler",
"description": "SQL Server and Azure SQL Database query profiler for VS Code",
"version": "1.0.1",
"version": "1.1.0",
"publisher": "brandochn",
"author": {
"name": "Hildebrando Chávez",
Expand Down Expand Up @@ -40,6 +40,18 @@
"light": "media/icon-small.svg",
"dark": "media/icon-small.svg"
}
},
{
"command": "lightQueryProfiler.exportEvents",
"title": "Export Events...",
"category": "Light Query Profiler",
"icon": "$(arrow-up)"
},
{
"command": "lightQueryProfiler.importEvents",
"title": "Import Events...",
"category": "Light Query Profiler",
"icon": "$(arrow-down)"
}
]
},
Expand Down
54 changes: 46 additions & 8 deletions vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,36 @@ export async function activate(
// The handler checks whether the provider is ready and either shows the
// panel or queues a retry once initialization completes.
let activationReady = false;
const exportEventsCommand = vscode.commands.registerCommand(
'lightQueryProfiler.exportEvents',
() => {
log.info('Export Events command executed');
if (state.profilerPanelProvider) {
void state.profilerPanelProvider.exportEvents();
} else {
void vscode.window.showErrorMessage(
'Light Query Profiler: Extension is not initialized.',
);
}
},
);
context.subscriptions.push(exportEventsCommand);

const importEventsCommand = vscode.commands.registerCommand(
'lightQueryProfiler.importEvents',
() => {
log.info('Import Events command executed');
if (state.profilerPanelProvider) {
void state.profilerPanelProvider.importEvents();
} else {
void vscode.window.showErrorMessage(
'Light Query Profiler: Extension is not initialized.',
);
}
},
);
context.subscriptions.push(importEventsCommand);

const showProfilerCommand = vscode.commands.registerCommand(
'lightQueryProfiler.showProfiler',
() => {
Expand All @@ -75,7 +105,10 @@ export async function activate(
}, 50);
// Safety: stop polling after 10 s regardless
// eslint-disable-next-line prefer-const
const deferredTimeout = setTimeout(() => clearInterval(deferredInterval), 10_000);
const deferredTimeout = setTimeout(
() => clearInterval(deferredInterval),
10_000,
);
// Register both handles so they are cancelled if the extension is
// deactivated within the 10-second initialization window.
context.subscriptions.push({
Expand Down Expand Up @@ -150,14 +183,19 @@ export async function activate(
log.info('Light Query Profiler extension activated successfully');

// Show welcome message only on first activation
const hasShownWelcomeMessage = context.globalState.get<boolean>('hasShownWelcomeMessage', false);
const hasShownWelcomeMessage = context.globalState.get<boolean>(
'hasShownWelcomeMessage',
false,
);
if (!hasShownWelcomeMessage) {
void vscode.window.showInformationMessage(
"Light Query Profiler is ready! Run 'Show SQL Profiler' command to open the profiler.",
).then(() => {
// Mark as shown after user dismisses or acknowledges the message
void context.globalState.update('hasShownWelcomeMessage', true);
});
void vscode.window
.showInformationMessage(
"Light Query Profiler is ready! Run 'Show SQL Profiler' command to open the profiler.",
)
.then(() => {
// Mark as shown after user dismisses or acknowledges the message
void context.globalState.update('hasShownWelcomeMessage', true);
});
}
} catch (error) {
activationReady = true; // Stop the deferred-panel polling
Expand Down
Loading
Loading