Skip to content

Instantly share code, notes, and snippets.

@nkgokul
Created December 24, 2019 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkgokul/452ddb5d2905dd0f92f9084c7090a134 to your computer and use it in GitHub Desktop.
Save nkgokul/452ddb5d2905dd0f92f9084c7090a134 to your computer and use it in GitHub Desktop.
Sentry Fractional Logging
const percentateOfErrorsToLog = 30;
const percentateOfErrorsToLogFraction = percentateOfErrorsToLog/100;
const threshold = 1 - percentateOfErrorsToLogFraction;
try {
someErrorCasuingFunction();
}
catch(error) {
if(Math.random() >= threshold) {
Sentry.captureException(error);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment