mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-28 06:31:58 +00:00
Enable tracing (#274203)
* Enable tracing So that we can upload traces instead of just videos. * feedback
This commit is contained in:
parent
144fdf16ca
commit
bc5f6481a5
@ -98,11 +98,11 @@ export class Application {
|
||||
}
|
||||
}
|
||||
|
||||
async startTracing(name: string): Promise<void> {
|
||||
async startTracing(name?: string): Promise<void> {
|
||||
await this._code?.startTracing(name);
|
||||
}
|
||||
|
||||
async stopTracing(name: string, persist: boolean): Promise<void> {
|
||||
async stopTracing(name?: string, persist: boolean = false): Promise<void> {
|
||||
await this._code?.stopTracing(name, persist);
|
||||
}
|
||||
|
||||
|
||||
@ -143,11 +143,11 @@ export class Code {
|
||||
return !(this.quality === Quality.Stable && this.version.major === 1 && this.version.minor < 101);
|
||||
}
|
||||
|
||||
async startTracing(name: string): Promise<void> {
|
||||
async startTracing(name?: string): Promise<void> {
|
||||
return await this.driver.startTracing(name);
|
||||
}
|
||||
|
||||
async stopTracing(name: string, persist: boolean): Promise<void> {
|
||||
async stopTracing(name?: string, persist: boolean = false): Promise<void> {
|
||||
return await this.driver.stopTracing(name, persist);
|
||||
}
|
||||
|
||||
|
||||
@ -51,19 +51,19 @@ export class PlaywrightDriver {
|
||||
return this.page;
|
||||
}
|
||||
|
||||
async startTracing(name: string): Promise<void> {
|
||||
async startTracing(name?: string): Promise<void> {
|
||||
if (!this.options.tracing) {
|
||||
return; // tracing disabled
|
||||
}
|
||||
|
||||
try {
|
||||
await measureAndLog(() => this.context.tracing.startChunk({ title: name }), `startTracing for ${name}`, this.options.logger);
|
||||
await measureAndLog(() => this.context.tracing.startChunk({ title: name }), `startTracing${name ? ` for ${name}` : ''}`, this.options.logger);
|
||||
} catch (error) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
async stopTracing(name: string, persist: boolean): Promise<void> {
|
||||
async stopTracing(name?: string, persist: boolean = false): Promise<void> {
|
||||
if (!this.options.tracing) {
|
||||
return; // tracing disabled
|
||||
}
|
||||
@ -71,10 +71,11 @@ export class PlaywrightDriver {
|
||||
try {
|
||||
let persistPath: string | undefined = undefined;
|
||||
if (persist) {
|
||||
persistPath = join(this.options.logsPath, `playwright-trace-${PlaywrightDriver.traceCounter++}-${name.replace(/\s+/g, '-')}.zip`);
|
||||
const nameSuffix = name ? `-${name.replace(/\s+/g, '-')}` : '';
|
||||
persistPath = join(this.options.logsPath, `playwright-trace-${PlaywrightDriver.traceCounter++}${nameSuffix}.zip`);
|
||||
}
|
||||
|
||||
await measureAndLog(() => this.context.tracing.stopChunk({ path: persistPath }), `stopTracing for ${name}`, this.options.logger);
|
||||
await measureAndLog(() => this.context.tracing.stopChunk({ path: persistPath }), `stopTracing${name ? ` for ${name}` : ''}`, this.options.logger);
|
||||
|
||||
// To ensure we have a screenshot at the end where
|
||||
// it failed, also trigger one explicitly. Tracing
|
||||
@ -168,9 +169,10 @@ export class PlaywrightDriver {
|
||||
return await this._cdpSession.send('Runtime.getProperties', parameters);
|
||||
}
|
||||
|
||||
private async takeScreenshot(name: string): Promise<void> {
|
||||
private async takeScreenshot(name?: string): Promise<void> {
|
||||
try {
|
||||
const persistPath = join(this.options.logsPath, `playwright-screenshot-${PlaywrightDriver.screenShotCounter++}-${name.replace(/\s+/g, '-')}.png`);
|
||||
const nameSuffix = name ? `-${name.replace(/\s+/g, '-')}` : '';
|
||||
const persistPath = join(this.options.logsPath, `playwright-screenshot-${PlaywrightDriver.screenShotCounter++}${nameSuffix}.png`);
|
||||
|
||||
await measureAndLog(() => this.page.screenshot({ path: persistPath, type: 'png' }), 'takeScreenshot', this.options.logger);
|
||||
} catch (error) {
|
||||
|
||||
@ -260,7 +260,7 @@ export async function getApplication({ recordVideo }: { recordVideo?: boolean }
|
||||
verbose: opts.verbose,
|
||||
remote: opts.remote,
|
||||
web: opts.web,
|
||||
tracing: opts.tracing,
|
||||
tracing: true,
|
||||
headless: opts.headless,
|
||||
browser: opts.browser,
|
||||
extraArgs: (opts.electronArgs || '').split(' ').map(arg => arg.trim()).filter(arg => !!arg),
|
||||
|
||||
@ -24,6 +24,7 @@ export async function getServer(appService: ApplicationService): Promise<Server>
|
||||
},
|
||||
async ({ recordVideo }) => {
|
||||
const app = await appService.getOrCreateApplication({ recordVideo });
|
||||
await app.startTracing();
|
||||
return {
|
||||
content: [{
|
||||
type: 'text' as const,
|
||||
|
||||
@ -37,6 +37,7 @@ export function applyCoreTools(server: McpServer, appService: ApplicationService
|
||||
'Stop the VS Code application',
|
||||
async () => {
|
||||
const app = await appService.getOrCreateApplication();
|
||||
await app.stopTracing(undefined, true);
|
||||
await app.stop();
|
||||
return {
|
||||
content: [{
|
||||
|
||||
@ -19,7 +19,6 @@ export const opts = minimist(args, {
|
||||
'remote',
|
||||
'web',
|
||||
'headless',
|
||||
'tracing',
|
||||
'video',
|
||||
'autostart'
|
||||
],
|
||||
@ -31,7 +30,6 @@ export const opts = minimist(args, {
|
||||
remote?: boolean;
|
||||
headless?: boolean;
|
||||
web?: boolean;
|
||||
tracing?: boolean;
|
||||
build?: string;
|
||||
'stable-build'?: string;
|
||||
browser?: 'chromium' | 'webkit' | 'firefox' | 'chromium-msedge' | 'chromium-chrome' | undefined;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user