Skip to content

Commit

Permalink
[protocolv2] Add invalid-request tag to logs (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
masad-frost committed Jun 20, 2024
1 parent 8d640b2 commit 334056e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion logging/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type Logger = {
[key in LoggingLevel]: (msg: string, metadata?: MessageMetadata) => void;
};

export type Tags = 'invariant-violation';
export type Tags = 'invariant-violation' | 'invalid-request';

const cleanedLogFn = (log: LogFn) => {
return (msg: string, metadata?: MessageMetadata) => {
Expand Down
14 changes: 13 additions & 1 deletion router/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
validationErrors: [
...Value.Errors(InputErrResultSchema, msg.payload),
],
tags: ['invalid-request'],
});
}

Expand All @@ -311,6 +312,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
...loggingMetadata,
clientId: this.transport.clientId,
transportMessage: msg,
tags: ['invalid-request'],
});

onServerAbort(
Expand Down Expand Up @@ -341,6 +343,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
clientId: this.transport.clientId,
transportMessage: msg,
validationErrors,
tags: ['invalid-request'],
});

onServerAbort(
Expand Down Expand Up @@ -579,7 +582,10 @@ class RiverServer<Services extends AnyServiceSchemaMap>
`got request for invalid procedure type ${
(procedure as AnyProcedure).type
} at ${serviceName}.${procedureName}`,
loggingMetadata,
{
...loggingMetadata,
tags: ['invariant-violation'],
},
);

return;
Expand Down Expand Up @@ -651,6 +657,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
...session.loggingMetadata,
clientId: this.transport.clientId,
transportMessage: initMessage,
tags: ['invalid-request'],
});

this.abortStream(
Expand All @@ -671,6 +678,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
...session.loggingMetadata,
clientId: this.transport.clientId,
transportMessage: initMessage,
tags: ['invalid-request'],
});

this.abortStream(
Expand All @@ -691,6 +699,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
...session.loggingMetadata,
clientId: this.transport.clientId,
transportMessage: initMessage,
tags: ['invalid-request'],
});

this.abortStream(
Expand All @@ -711,6 +720,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
...session.loggingMetadata,
clientId: this.transport.clientId,
transportMessage: initMessage,
tags: ['invalid-request'],
});

this.abortStream(
Expand All @@ -732,6 +742,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
...session.loggingMetadata,
clientId: this.transport.clientId,
transportMessage: initMessage,
tags: ['invalid-request'],
});

this.abortStream(
Expand All @@ -754,6 +765,7 @@ class RiverServer<Services extends AnyServiceSchemaMap>
...session.loggingMetadata,
clientId: this.transport.clientId,
transportMessage: initMessage,
tags: ['invalid-request'],
});

this.abortStream(
Expand Down

0 comments on commit 334056e

Please sign in to comment.