Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Issue #171: why error_sample_rates only use for errors #215

Merged
merged 5 commits into from Jul 3, 2017

Conversation

ArturMoczulski
Copy link
Contributor

This add exception_samples_rates config which allows to set sampling rates for exceptions based on exception class.

@ArturMoczulski
Copy link
Contributor Author

This is ready for review

README.md Outdated
@@ -404,6 +404,13 @@ Default: `'production'`
Default: empty array, meaning all errors are reported.
</dd>

<dt>exception_sample_rates
</dt>
<dd>Associative array mapping exception classes to sample rates. Sample rates are ratio out of 1, e.g. 0 is "never report", 1 is "always report", and 0.1 is "report 10% of the time". Sampling is done on a per-exception basis. It also respects class inheritance meaning if Exception is at 1.0 then ExceptionSublcass is also at 1.0, unless explicitly configured otherwise. If ExceptionSubclass is set to 0.5, but Exception is at 1.0 then Exception and all its' subclasses run at 1.0, except for ExceptionSubclass and its' subclasses which run at 0.5. Names of exception classes should NOT be followed with additional `\` for global namespace, i.e. Rollbar\SampleException and NOT \Rollbar\SampleException.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"should NOT be follow with additional" -> "should NOT be prefixed with additional"

src/Config.php Outdated
public function exceptionSampleRate(\Exception $toLog)
{
$sampleRate = 1.0;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if $this->exception_sample_rates is empty which will be often because that is the default, we should not go through the work of gathering the class hierarchy for this exception, we should just return 1.0 early.

Copy link
Contributor

@rokob rokob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments

rokob added 2 commits July 3, 2017 16:07
If there is no configured exception_sample_rates, then there is no reason to do any work to check for the rate for a particular exception, so return early in this case the default value of 1.0 which means don't sample.
@rokob rokob merged commit 14b3cd9 into rollbar:master Jul 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants