Skip to content

Commit

Permalink
Add logging for normalization
Browse files Browse the repository at this point in the history
Reviewed By: gordyf

Differential Revision: D62901540

fbshipit-source-id: 96e1a2fe340098ae9800606a9af41ce1b614aef2
  • Loading branch information
tyao1 authored and facebook-github-bot committed Sep 18, 2024
1 parent da733d3 commit ba0b469
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ describe('logging', () => {
{
name: 'queryresource.fetch',
resourceID: 200000,
profilerContext: expect.objectContaining({}),
profilerContext: {},
},
{
name: 'suspense.query',
Expand All @@ -964,6 +964,12 @@ describe('logging', () => {
name: 'execute.next.start',
executeId: 100001,
},
{
name: 'execute.normalize.start',
},
{
name: 'execute.normalize.end',
},
{
name: 'execute.next.end',
executeId: 100001,
Expand All @@ -979,7 +985,7 @@ describe('logging', () => {
{
name: 'queryresource.retain',
resourceID: 200000,
profilerContext: expect.objectContaining({}),
profilerContext: {},
},
]);
});
Expand Down Expand Up @@ -1148,6 +1154,12 @@ describe('logging', () => {
name: 'execute.next.start',
executeId: 100002,
},
{
name: 'execute.normalize.start',
},
{
name: 'execute.normalize.end',
},
{
name: 'execute.next.end',
executeId: 100002,
Expand Down
9 changes: 8 additions & 1 deletion packages/relay-runtime/store/OperationExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ class Executor<TMutation: MutationParameters> {
_processResponses(
responses: $ReadOnlyArray<GraphQLResponseWithData>,
): $ReadOnlyArray<RelayResponsePayload> {
this._log({
name: 'execute.normalize.start',
operation: this._operation,
});
if (this._optimisticUpdates !== null) {
this._optimisticUpdates.forEach(update => {
this._getPublishQueueAndSaveActor().revertUpdate(update);
Expand Down Expand Up @@ -801,7 +805,10 @@ class Executor<TMutation: MutationParameters> {
relayPayload,
this._updater,
);

this._log({
name: 'execute.normalize.end',
operation: this._operation,
});
return relayPayload;
});
}
Expand Down
12 changes: 12 additions & 0 deletions packages/relay-runtime/store/RelayStoreTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,16 @@ export type ExecuteCompleteLogEvent = {
+executeId: number,
};
export type ExecuteNormalizeStart = {
+name: 'execute.normalize.start',
+operation: OperationDescriptor,
};
export type ExecuteNormalizeEnd = {
+name: 'execute.normalize.end',
+operation: OperationDescriptor,
};
export type StoreDataCheckerStartEvent = {
+name: 'store.datachecker.start',
+selector: NormalizationSelector,
Expand Down Expand Up @@ -801,6 +811,8 @@ export type LogEvent =
| ExecuteAsyncModuleLogEvent
| ExecuteErrorLogEvent
| ExecuteCompleteLogEvent
| ExecuteNormalizeStart
| ExecuteNormalizeEnd
| StoreDataCheckerStartEvent
| StoreDataCheckerEndEvent
| StorePublishLogEvent
Expand Down

0 comments on commit ba0b469

Please sign in to comment.