class SamplerFactory
Hierarchy
- class \OpenTelemetry\SDK\Trace\SamplerFactory
Expanded class hierarchy of SamplerFactory
1 file declares its use of SamplerFactory
- SdkAutoloader.php in vendor/
open-telemetry/ sdk/ SdkAutoloader.php
File
-
vendor/
open-telemetry/ sdk/ Trace/ SamplerFactory.php, line 16
Namespace
OpenTelemetry\SDK\TraceView source
class SamplerFactory {
private const TRACEIDRATIO_PREFIX = 'traceidratio';
public function create() : SamplerInterface {
$name = Configuration::getString(Env::OTEL_TRACES_SAMPLER);
if (str_contains($name, self::TRACEIDRATIO_PREFIX)) {
$arg = Configuration::getRatio(Env::OTEL_TRACES_SAMPLER_ARG);
switch ($name) {
case Values::VALUE_TRACE_ID_RATIO:
return new TraceIdRatioBasedSampler($arg);
case Values::VALUE_PARENT_BASED_TRACE_ID_RATIO:
return new ParentBased(new TraceIdRatioBasedSampler($arg));
}
}
return match ($name) { Values::VALUE_ALWAYS_ON => new AlwaysOnSampler(),
Values::VALUE_ALWAYS_OFF => new AlwaysOffSampler(),
Values::VALUE_PARENT_BASED_ALWAYS_ON => new ParentBased(new AlwaysOnSampler()),
Values::VALUE_PARENT_BASED_ALWAYS_OFF => new ParentBased(new AlwaysOffSampler()),
default => throw new InvalidArgumentException(sprintf('Unknown sampler: %s', $name)),
};
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
SamplerFactory::create | public | function | |
SamplerFactory::TRACEIDRATIO_PREFIX | private | constant |