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

Commit

Permalink
Change sampler param sentinel value from YAML parser (#145)
Browse files Browse the repository at this point in the history
* Change sampler param sentinel value

Signed-off-by: andremarianiello <andremarianiello@users.noreply.github.com>

* Add unit test for param=0

Signed-off-by: andremarianiello <andremarianiello@users.noreply.github.com>
  • Loading branch information
andremarianiello authored and isaachier committed Jan 2, 2019
1 parent cefa941 commit fa8d376
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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

0 comments on commit fa8d376

Please sign in to comment.