You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Entire app is crashing with Log entry with size 300.0K exceeds maximum size of 256.0K error. This is happening for exemple with prisma when some errors are catched after huge failed SQL queries.
Describe the solution you'd like
Add a default error message truncation and an maxEntrySize param. E.g. with winston
Describe alternatives you've considered
Truncating error message in NestJs logger class extension:
import{Injectable}from'@nestjs/common';import{Logger}from'nestjs-pino';
@Injectable()exportclassLoggerServiceextendsLogger{error(message: any, ...context: any[]): void{super.error(this.limitErrorMessageTo256KB(message));}// log, warn, etc../** * Temporary fix for the following issue: * @see https://github.com/metcoder95/cloud-pine/issues/34 * * Google Cloud Platform doesn't accept more than 256KB for Logging Message * see: https://cloud.google.com/logging/quotas */privatelimitErrorMessageTo256KB(error: unknown){if(!(errorinstanceofError)){returnerror;}constMAX_BYTES=50_000;// Set the limit to 50KBconstencoder=newTextEncoder();constmessageBytes=encoder.encode(error.message);conststackBytes=encoder.encode(error.stack);if(messageBytes.length+stackBytes.length<=MAX_BYTES){returnerror;}else{constdecoder=newTextDecoder();consttruncatedErrorMessage=decoder.decode(messageBytes.slice(0,MAX_BYTES))+'...';error.message=truncatedErrorMessage;error.stack=undefined;returnerror;}}}
Way to reproduce
importPinofrom('pino')constlogger=Pino({transport: {target: 'cloud-pine',options: {cloudLoggingOptions: {skipInit: true,sync: true,}}}})functiongenerateLargeJSON(sizeInBytes){constcharacters='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';constdataSize=sizeInBytes-2;// Account for braces '{}' in JSON// Generate random string data for the given sizeletdata='';while(data.length<dataSize){constrandomIndex=Math.floor(Math.random()*characters.length);data+=characters[randomIndex];}// Convert the data string into a JSON objectconstjsonObject={ data };returnJSON.stringify(jsonObject);}// Generate a JSON object of size ~260 KB (260,000 bytes)constjsonSizeInBytes=260*1024;// 260 KB in bytesconstlargeJSON=generateLargeJSON(jsonSizeInBytes);logger.error(JSON.stringify(largeJSON))
The text was updated successfully, but these errors were encountered:
I think that should be doable, so far we have two things here, we can start by extending the options also to allow configure split2 with the args maxLength and skipOverflow so the behaviour is customizable.
The second one is that the current implementation is quite basic, and does not implement backpressure, which can be implemented as further enhancement.
Let's start simple, and just allow configure split2 implementation. Would you like to submit a PR for it? 🙂
Is your feature request related to a problem? Please describe.
Entire app is crashing with
Log entry with size 300.0K exceeds maximum size of 256.0K
error. This is happening for exemple withprisma
when some errors are catched after huge failed SQL queries.Describe the solution you'd like
Add a default error message truncation and an
maxEntrySize
param. E.g. with winstonDescribe alternatives you've considered
Truncating error message in NestJs logger class extension:
Way to reproduce
The text was updated successfully, but these errors were encountered: