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 }; const converted = { id, guid, method, params };
// Do not include metadata in debug logs to avoid noise. // Do not include metadata in debug logs to avoid noise.
debugLogger.log('channel:command', converted); 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 }); this.onmessage({ ...converted, metadata });
return await new Promise((resolve, reject) => this._callbacks.set(id, { resolve, reject, stackTrace })); 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}`, id: `call@${id}`,
stack: validMetadata.stack, stack: validMetadata.stack,
apiName: validMetadata.apiName, apiName: validMetadata.apiName,
internal: validMetadata.internal,
objectId: sdkObject?.guid, objectId: sdkObject?.guid,
pageId: sdkObject?.attribution?.page?.guid, pageId: sdkObject?.attribution?.page?.guid,
frameId: sdkObject?.attribution?.frame?.guid, frameId: sdkObject?.attribution?.frame?.guid,

View file

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

View file

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

View file

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

View file

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

View file

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