added StackTrace filtering to core
Signed-off-by: René <snooz@posteo.de>
This commit is contained in:
parent
2177a0a443
commit
472602475f
|
|
@ -18,8 +18,7 @@ import type * as api from '../../types/types';
|
||||||
import type * as channels from '@protocol/channels';
|
import type * as channels from '@protocol/channels';
|
||||||
import { Artifact } from './artifact';
|
import { Artifact } from './artifact';
|
||||||
import { ChannelOwner } from './channelOwner';
|
import { ChannelOwner } from './channelOwner';
|
||||||
import { captureRawStack } from '../utils';
|
import { captureRawStack, filteredStackTrace } from '../utils';
|
||||||
import { filteredStackTrace } from 'playwright/lib/util';
|
|
||||||
|
|
||||||
export class Tracing extends ChannelOwner<channels.TracingChannel> implements api.Tracing {
|
export class Tracing extends ChannelOwner<channels.TracingChannel> implements api.Tracing {
|
||||||
private _includeSources = false;
|
private _includeSources = false;
|
||||||
|
|
|
||||||
|
|
@ -33,24 +33,19 @@ export class TracingDispatcher extends Dispatcher<Tracing, channels.TracingChann
|
||||||
super(scope, tracing, 'Tracing', {});
|
super(scope, tracing, 'Tracing', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
// async start(options: TracerOptions) {
|
|
||||||
async tracingStart(params: channels.TracingTracingStartParams): Promise<channels.TracingTracingStartResult> {
|
async tracingStart(params: channels.TracingTracingStartParams): Promise<channels.TracingTracingStartResult> {
|
||||||
await this._object.start(params);
|
await this._object.start(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// async startChunk(options: { name?: string, title?: string } = {}): Promise<{ traceName: string }> {
|
|
||||||
async tracingStartChunk(params: channels.TracingTracingStartChunkParams): Promise<channels.TracingTracingStartChunkResult> {
|
async tracingStartChunk(params: channels.TracingTracingStartChunkParams): Promise<channels.TracingTracingStartChunkResult> {
|
||||||
return await this._object.startChunk(params);
|
return await this._object.startChunk(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// async group(name: string, options: { location?: string } = {}): Promise<void> {
|
|
||||||
async tracingGroup(params: channels.TracingTracingGroupParams): Promise<channels.TracingTracingGroupResult> {
|
async tracingGroup(params: channels.TracingTracingGroupParams): Promise<channels.TracingTracingGroupResult> {
|
||||||
const { name, options } = params;
|
const { name, options } = params;
|
||||||
await this._object.group(name, options);
|
await this._object.group(name, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// async groupEnd(): Promise<void> {
|
|
||||||
async tracingGroupEnd(params: channels.TracingTracingGroupEndParams): Promise<channels.TracingTracingGroupEndResult> {
|
async tracingGroupEnd(params: channels.TracingTracingGroupEndParams): Promise<channels.TracingTracingGroupEndResult> {
|
||||||
await this._object.groupEnd();
|
await this._object.groupEnd();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,25 @@ export function captureRawStack(): RawStack {
|
||||||
return stack.split('\n');
|
return stack.split('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function filterStackFile(file: string) {
|
||||||
|
if (!process.env.PWDEBUGIMPL && file.startsWith(CORE_DIR))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function filteredStackTrace(rawStack: RawStack): StackFrame[] {
|
||||||
|
const frames: StackFrame[] = [];
|
||||||
|
for (const line of rawStack) {
|
||||||
|
const frame = parseStackTraceLine(line);
|
||||||
|
if (!frame || !frame.file)
|
||||||
|
continue;
|
||||||
|
if (!filterStackFile(frame.file))
|
||||||
|
continue;
|
||||||
|
frames.push(frame);
|
||||||
|
}
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
|
||||||
export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: string } {
|
export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: string } {
|
||||||
const stack = captureRawStack();
|
const stack = captureRawStack();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue