rollbar / rollbar.js

Error tracking and logging from Javascript to Rollbar
https://docs.rollbar.com/docs/javascript
MIT License
566 stars 212 forks source link

Configure Message Truncation in JS Library #1095

Open jdnarvaez opened 1 year ago

jdnarvaez commented 1 year ago

It seems this topic has been brought up a couple of times and an issue comment seems to indicate that the truncation length is configurable

Where do we configure the truncation length? Our messages are getting truncated and suffixed with ... and they are pretty short messages. It would be useful if we could change this behavior. Thanks.

waltjones commented 1 year ago

Truncation isn't configurable. Even though function truncate(payload, jsonBackup, maxSize) in PR #630 linked above accepts a maxSize argument, it is never called with that argument and always uses the default 500K maxSize.

The current algorithm successively truncates strings to shorter lengths until the total payload is under maxSize. A good improvement would be to allow customizing the truncation strategies to prioritize the parts of the payload expected to be the most problematic and/or the most optional.

I'll keep this open and tag as an enhancement.

Note: It's possible to do custom truncation in a transform function. https://docs.rollbar.com/docs/javascript#transforming-the-payload

This runs before truncation and if the payload has been reduced to maxSize, the built-in truncation will be skipped.