working proto
Signed-off-by: René <snooz@posteo.de>
This commit is contained in:
parent
6ea17a5d82
commit
edd4379078
|
|
@ -51,6 +51,14 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
|
|||
await this._startCollectingStacks(traceName);
|
||||
}
|
||||
|
||||
async group(name: string, options: { location?: string } = {}) {
|
||||
await this._channel.tracingGroup({ name, options });
|
||||
}
|
||||
|
||||
async groupEnd() {
|
||||
await this._channel.tracingGroupEnd();
|
||||
}
|
||||
|
||||
private async _startCollectingStacks(traceName: string) {
|
||||
if (!this._isTracing) {
|
||||
this._isTracing = true;
|
||||
|
|
|
|||
|
|
@ -2280,6 +2280,9 @@ scheme.DialogAcceptParams = tObject({
|
|||
scheme.DialogAcceptResult = tOptional(tObject({}));
|
||||
scheme.DialogDismissParams = tOptional(tObject({}));
|
||||
scheme.DialogDismissResult = tOptional(tObject({}));
|
||||
scheme.TracingGroupOptions = tObject({
|
||||
location: tString,
|
||||
});
|
||||
scheme.TracingInitializer = tOptional(tObject({}));
|
||||
scheme.TracingTracingStartParams = tObject({
|
||||
name: tOptional(tString),
|
||||
|
|
@ -2295,6 +2298,13 @@ scheme.TracingTracingStartChunkParams = tObject({
|
|||
scheme.TracingTracingStartChunkResult = tObject({
|
||||
traceName: tString,
|
||||
});
|
||||
scheme.TracingTracingGroupParams = tObject({
|
||||
name: tString,
|
||||
options: tType('TracingGroupOptions'),
|
||||
});
|
||||
scheme.TracingTracingGroupResult = tOptional(tObject({}));
|
||||
scheme.TracingTracingGroupEndParams = tOptional(tObject({}));
|
||||
scheme.TracingTracingGroupEndResult = tOptional(tObject({}));
|
||||
scheme.TracingTracingStopChunkParams = tObject({
|
||||
mode: tEnum(['archive', 'discard', 'entries']),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -33,14 +33,28 @@ export class TracingDispatcher extends Dispatcher<Tracing, channels.TracingChann
|
|||
super(scope, tracing, 'Tracing', {});
|
||||
}
|
||||
|
||||
// async start(options: TracerOptions) {
|
||||
async tracingStart(params: channels.TracingTracingStartParams): Promise<channels.TracingTracingStartResult> {
|
||||
await this._object.start(params);
|
||||
}
|
||||
|
||||
// async startChunk(options: { name?: string, title?: string } = {}): Promise<{ traceName: string }> {
|
||||
async tracingStartChunk(params: channels.TracingTracingStartChunkParams): Promise<channels.TracingTracingStartChunkResult> {
|
||||
return await this._object.startChunk(params);
|
||||
}
|
||||
|
||||
|
||||
// async group(name: string, options: { location?: string } = {}): Promise<void> {
|
||||
async tracingGroup(params: channels.TracingTracingGroupParams): Promise<channels.TracingTracingGroupResult> {
|
||||
const { name, options } = params;
|
||||
await this._object.group(name, options);
|
||||
}
|
||||
|
||||
// async groupEnd(): Promise<void> {
|
||||
async tracingGroupEnd(params: channels.TracingTracingGroupEndParams): Promise<channels.TracingTracingGroupEndResult> {
|
||||
await this._object.groupEnd();
|
||||
}
|
||||
|
||||
async tracingStopChunk(params: channels.TracingTracingStopChunkParams): Promise<channels.TracingTracingStopChunkResult> {
|
||||
const { artifact, entries } = await this._object.stopChunk(params);
|
||||
return { artifact: artifact ? ArtifactDispatcher.from(this, artifact) : undefined, entries };
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
|
|||
private _allResources = new Set<string>();
|
||||
private _contextCreatedEvent: trace.ContextCreatedTraceEvent;
|
||||
private _pendingHarEntries = new Set<har.Entry>();
|
||||
private _groupStack: string[] = [];
|
||||
private _groupId = 0;
|
||||
|
||||
constructor(context: BrowserContext | APIRequestContext, tracesDir: string | undefined) {
|
||||
super(context, 'tracing');
|
||||
|
|
@ -194,6 +196,34 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
|
|||
return { traceName: this._state.traceName };
|
||||
}
|
||||
|
||||
async group(name: string, options: { location?: string } = {}): Promise<void> {
|
||||
const location = options.location?.split(':', 2);
|
||||
const file = location?.[0], line = location?.[1];
|
||||
const event: trace.BeforeActionTraceEvent = {
|
||||
type: 'before',
|
||||
callId: `group-${this._groupId++}`,
|
||||
startTime: monotonicTime(),
|
||||
apiName: name,
|
||||
class: 'Tracing',
|
||||
method: 'group',
|
||||
params: { },
|
||||
stack: [{ file: file || '', line: line ? parseInt(line, 10) : 0, column: 0 }],
|
||||
};
|
||||
this._groupStack.push(event.callId);
|
||||
this._appendTraceEvent(event);
|
||||
}
|
||||
|
||||
async groupEnd(): Promise<void> {
|
||||
const callId = this._groupStack.pop();
|
||||
assert(callId, 'Cannot end group that has not started');
|
||||
const event: trace.AfterActionTraceEvent = {
|
||||
type: 'after',
|
||||
callId,
|
||||
endTime: monotonicTime(),
|
||||
};
|
||||
this._appendTraceEvent(event);
|
||||
}
|
||||
|
||||
private _startScreencast() {
|
||||
if (!(this._context instanceof BrowserContext))
|
||||
return;
|
||||
|
|
@ -357,6 +387,8 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
|
|||
const event = createBeforeActionTraceEvent(metadata);
|
||||
if (!event)
|
||||
return Promise.resolve();
|
||||
if (event.parentId === undefined && this._groupStack.length)
|
||||
event.parentId = this._groupStack[this._groupStack.length - 1];
|
||||
sdkObject.attribution.page?.temporarilyDisableTracingScreencastThrottling();
|
||||
event.beforeSnapshot = `before@${metadata.id}`;
|
||||
this._state?.callIds.add(metadata.id);
|
||||
|
|
|
|||
|
|
@ -4077,6 +4077,10 @@ export type DialogDismissResult = void;
|
|||
export interface DialogEvents {
|
||||
}
|
||||
|
||||
export type TracingGroupOptions = {
|
||||
location: string,
|
||||
};
|
||||
|
||||
// ----------- Tracing -----------
|
||||
export type TracingInitializer = {};
|
||||
export interface TracingEventTarget {
|
||||
|
|
@ -4085,6 +4089,8 @@ export interface TracingChannel extends TracingEventTarget, Channel {
|
|||
_type_Tracing: boolean;
|
||||
tracingStart(params: TracingTracingStartParams, metadata?: CallMetadata): Promise<TracingTracingStartResult>;
|
||||
tracingStartChunk(params: TracingTracingStartChunkParams, metadata?: CallMetadata): Promise<TracingTracingStartChunkResult>;
|
||||
tracingGroup(params: TracingTracingGroupParams, metadata?: CallMetadata): Promise<TracingTracingGroupResult>;
|
||||
tracingGroupEnd(params?: TracingTracingGroupEndParams, metadata?: CallMetadata): Promise<TracingTracingGroupEndResult>;
|
||||
tracingStopChunk(params: TracingTracingStopChunkParams, metadata?: CallMetadata): Promise<TracingTracingStopChunkResult>;
|
||||
tracingStop(params?: TracingTracingStopParams, metadata?: CallMetadata): Promise<TracingTracingStopResult>;
|
||||
}
|
||||
|
|
@ -4112,6 +4118,17 @@ export type TracingTracingStartChunkOptions = {
|
|||
export type TracingTracingStartChunkResult = {
|
||||
traceName: string,
|
||||
};
|
||||
export type TracingTracingGroupParams = {
|
||||
name: string,
|
||||
options: TracingGroupOptions,
|
||||
};
|
||||
export type TracingTracingGroupOptions = {
|
||||
|
||||
};
|
||||
export type TracingTracingGroupResult = void;
|
||||
export type TracingTracingGroupEndParams = {};
|
||||
export type TracingTracingGroupEndOptions = {};
|
||||
export type TracingTracingGroupEndResult = void;
|
||||
export type TracingTracingStopChunkParams = {
|
||||
mode: 'archive' | 'discard' | 'entries',
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3177,6 +3177,11 @@ Dialog:
|
|||
dismiss:
|
||||
|
||||
|
||||
TracingGroupOptions:
|
||||
type: object
|
||||
properties:
|
||||
location: string
|
||||
|
||||
Tracing:
|
||||
type: interface
|
||||
|
||||
|
|
@ -3196,6 +3201,13 @@ Tracing:
|
|||
returns:
|
||||
traceName: string
|
||||
|
||||
tracingGroup:
|
||||
parameters:
|
||||
name: string
|
||||
options: TracingGroupOptions
|
||||
|
||||
tracingGroupEnd:
|
||||
|
||||
tracingStopChunk:
|
||||
parameters:
|
||||
mode:
|
||||
|
|
|
|||
Loading…
Reference in a new issue