fix(tracing): fall back to protocol naming in ports w/o apiName (#9896)

This commit is contained in:
Pavel Feldman 2021-10-30 11:26:38 -08:00 committed by GitHub
parent b244f035bc
commit bd505ed07c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 3 deletions

View file

@ -99,7 +99,7 @@ export class Connection extends EventEmitter {
const converted = { id, guid, method, params };
// Do not include metadata in debug logs to avoid noise.
debugLogger.log('channel:command', converted);
const metadata: channels.Metadata = { stack: frames, apiName };
const metadata: channels.Metadata = { stack: frames, apiName, internal: !apiName };
this.onmessage({ ...converted, metadata });
return await new Promise((resolve, reject) => this._callbacks.set(id, { resolve, reject, stackTrace }));

View file

@ -224,6 +224,7 @@ export class DispatcherConnection {
id: `call@${id}`,
stack: validMetadata.stack,
apiName: validMetadata.apiName,
internal: validMetadata.internal,
objectId: sdkObject?.guid,
pageId: sdkObject?.attribution?.page?.guid,
frameId: sdkObject?.attribution?.frame?.guid,

View file

@ -26,6 +26,7 @@ export type CallMetadata = {
method: string;
params: any;
apiName?: string;
internal?: boolean;
stack?: StackFrame[];
log: string[];
afterSnapshot?: string;

View file

@ -33,6 +33,7 @@ export type StackFrame = {
export type Metadata = {
stack?: StackFrame[],
apiName?: string,
internal?: boolean,
};
export type Point = {

View file

@ -29,6 +29,7 @@ Metadata:
type: array?
items: StackFrame
apiName: string?
internal: boolean?
Point:

View file

@ -42,6 +42,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
scheme.Metadata = tObject({
stack: tOptional(tArray(tType('StackFrame'))),
apiName: tOptional(tString),
internal: tOptional(tBoolean),
});
scheme.Point = tObject({
x: tNumber,

View file

@ -111,9 +111,12 @@ export class TraceModel {
break;
}
case 'action': {
const include = !!event.metadata.apiName && !isTracing(event.metadata);
if (include)
const include = !isTracing(event.metadata) && (!event.metadata.internal || event.metadata.apiName);
if (include) {
if (!event.metadata.apiName)
event.metadata.apiName = event.metadata.type + '.' + event.metadata.method;
this.contextEntry!.actions.push(event);
}
break;
}
case 'event': {