Skip to content

Commit

Permalink
change instances of probabilitysampler to traceidratiobasedsampler
Browse files Browse the repository at this point in the history
  • Loading branch information
prondubuisi committed Sep 19, 2020
1 parent 4f158ad commit 0ec1674
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion sdk/Trace/Sampler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function shouldSample(
/**
* Returns the sampler name or short description with the configuration.
* This may be displayed on debug pages or in the logs.
* Example: "ProbabilitySampler{0.000100}"
* Example: "TraceIdRatioBasedSampler{0.000100}"
* @return string
*/
public function getDescription(): string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
* This implementation of the SamplerInterface records with given probability.
* Example:
* ```
* use OpenTelemetry\Trace\ProbabilitySampler;
* $sampler = new ProbabilitySampler(0.01);
* use OpenTelemetry\Trace\TraceIdRatioBasedSampler;
* $sampler = new TraceIdRatioBasedSampler(0.01);
* ```
*/
class ProbabilitySampler implements Sampler
class TraceIdRatioBasedSampler implements Sampler
{
/**
* @var float
*/
private $probability;

/**
* ProbabilitySampler constructor.
* TraceIdRatioBasedSampler constructor.
* @param float $probability Probability float value between 0.0 and 1.0.
*/
public function __construct(float $probability)
Expand Down Expand Up @@ -59,6 +59,6 @@ public function shouldSample(

public function getDescription(): string
{
return sprintf('%s{%.6f}', 'ProbabilitySampler', $this->probability);
return sprintf('%s{%.6f}', 'TraceIdRatioBasedSampler', $this->probability);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace OpenTelemetry\Tests\Sdk\Integration;

use OpenTelemetry\Sdk\Trace\Sampler\ProbabilitySampler;
use OpenTelemetry\Sdk\Trace\Sampler\TraceIdRatioBasedSampler;
use OpenTelemetry\Sdk\Trace\SamplingResult;
use OpenTelemetry\Trace as API;
use PHPUnit\Framework\TestCase;

class ProbabilitySamplerTest extends TestCase
class TraceIdRatioBasedSamplerTest extends TestCase
{
public function testNeverProbabilitySamplerDecision()
public function testNeverTraceIdRatioBasedSamplerDecision()
{
$sampler = new ProbabilitySampler(0.0);
$sampler = new TraceIdRatioBasedSampler(0.0);
$decision = $sampler->shouldSample(
null,
'4bf92f3577b34da6a3ce929d0e0e4736',
Expand All @@ -24,9 +24,9 @@ public function testNeverProbabilitySamplerDecision()
$this->assertEquals(SamplingResult::NOT_RECORD, $decision->getDecision());
}

public function testAlwaysProbabilitySamplerDecision()
public function testAlwaysTraceIdRatioBasedSamplerDecision()
{
$sampler = new ProbabilitySampler(1.0);
$sampler = new TraceIdRatioBasedSampler(1.0);
$decision = $sampler->shouldSample(
null,
'4bf92f3577b34da6a3ce929d0e0e4736',
Expand All @@ -39,7 +39,7 @@ public function testAlwaysProbabilitySamplerDecision()

public function testAlwaysOnSamplerDescription()
{
$sampler = new ProbabilitySampler(0.0001);
$this->assertEquals('ProbabilitySampler{0.000100}', $sampler->getDescription());
$sampler = new TraceIdRatioBasedSampler(0.0001);
$this->assertEquals('TraceIdRatioBasedSampler{0.000100}', $sampler->getDescription());
}
}

0 comments on commit 0ec1674

Please sign in to comment.