Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Change sampler param sentinel value from YAML parser #145

Merged
merged 2 commits into from
Jan 2, 2019
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
12 changes: 12 additions & 0 deletions src/jaegertracing/ConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ TEST(Config, testDefaultSamplingProbability)
Config().sampler().param());
}

TEST(Config, testZeroSamplingParam)
{
{
constexpr auto kConfigYAML = R"cfg(
sampler:
param: 0
)cfg";
const auto config = Config::parse(YAML::Load(kConfigYAML));
ASSERT_EQ(0, config.sampler().param());
}
}

#endif // JAEGERTRACING_WITH_YAML_CPP

} // namespace jaegertracing
4 changes: 2 additions & 2 deletions src/jaegertracing/samplers/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Config {
const auto type =
utils::yaml::findOrDefault<std::string>(configYAML, "type", "");
const auto param =
utils::yaml::findOrDefault<double>(configYAML, "param", 0);
utils::yaml::findOrDefault<double>(configYAML, "param", -1);
const auto samplingServerURL = utils::yaml::findOrDefault<std::string>(
configYAML, "samplingServerURL", "");
const auto maxOperations =
Expand All @@ -86,7 +86,7 @@ class Config {
const Clock::duration& samplingRefreshInterval =
defaultSamplingRefreshInterval())
: _type(type.empty() ? kSamplerTypeRemote : type)
, _param(param == 0 ? kDefaultSamplingProbability : param)
, _param(param == -1 ? kDefaultSamplingProbability : param)
, _samplingServerURL(samplingServerURL.empty()
? kDefaultSamplingServerURL
: samplingServerURL)
Expand Down