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
GitHub Issue #171: why error_sample_rates only use for errors #215
Conversation
…eparate function as well
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. |
There was a problem hiding this comment.
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; | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments
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.
This add
exception_samples_rates
config which allows to set sampling rates for exceptions based on exception class.