Skip to content

Commit

Permalink
[1.x] Allow concern usage for 3rd parties (#118)
Browse files Browse the repository at this point in the history
* Allow recorder inheritance

* Recorder inheritance - only update Concerns
  • Loading branch information
danwall authored Dec 4, 2023
1 parent 9ab920b commit 6d27eed
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Recorders/Concerns/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait Groups
*/
protected function group(string $value): string
{
foreach ($this->config->get('pulse.recorders.'.self::class.'.groups') as $pattern => $replacement) {
foreach ($this->config->get('pulse.recorders.'.static::class.'.groups') as $pattern => $replacement) {
$group = preg_replace($pattern, $replacement, $value, count: $count);

if ($count > 0 && $group !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Recorders/Concerns/Ignores.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait Ignores
protected function shouldIgnore(string $value): bool
{
// @phpstan-ignore argument.templateType, argument.templateType
return collect($this->config->get('pulse.recorders.'.self::class.'.ignore'))
return collect($this->config->get('pulse.recorders.'.static::class.'.ignore'))
->contains(fn (string $pattern) => preg_match($pattern, $value));
}
}
4 changes: 2 additions & 2 deletions src/Recorders/Concerns/Sampling.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait Sampling
protected function shouldSample(): bool
{
return Lottery::odds(
$this->config->get('pulse.recorders.'.self::class.'.sample_rate')
$this->config->get('pulse.recorders.'.static::class.'.sample_rate')
)->choose();
}

Expand All @@ -23,6 +23,6 @@ protected function shouldSampleDeterministically(string $seed): bool
{
$value = hexdec(md5($seed)) / pow(16, 32); // Scale to 0-1

return $value <= $this->config->get('pulse.recorders.'.self::class.'.sample_rate');
return $value <= $this->config->get('pulse.recorders.'.static::class.'.sample_rate');
}
}
2 changes: 1 addition & 1 deletion src/Recorders/Concerns/Thresholds.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ trait Thresholds
*/
protected function underThreshold(int|float $duration): bool
{
return $duration < $this->config->get('pulse.recorders.'.self::class.'.threshold');
return $duration < $this->config->get('pulse.recorders.'.static::class.'.threshold');
}
}

0 comments on commit 6d27eed

Please sign in to comment.