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

change instances of probabilitysampler to traceidratiobasedsampler #179

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}