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

Commit fa8d376

Browse files
andremarianielloisaachier
authored andcommitted
Change sampler param sentinel value from YAML parser (#145)
* Change sampler param sentinel value Signed-off-by: andremarianiello <[email protected]> * Add unit test for param=0 Signed-off-by: andremarianiello <[email protected]>
1 parent cefa941 commit fa8d376

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/jaegertracing/ConfigTest.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ TEST(Config, testDefaultSamplingProbability)
7373
Config().sampler().param());
7474
}
7575

76+
TEST(Config, testZeroSamplingParam)
77+
{
78+
{
79+
constexpr auto kConfigYAML = R"cfg(
80+
sampler:
81+
param: 0
82+
)cfg";
83+
const auto config = Config::parse(YAML::Load(kConfigYAML));
84+
ASSERT_EQ(0, config.sampler().param());
85+
}
86+
}
87+
7688
#endif // JAEGERTRACING_WITH_YAML_CPP
7789

7890
} // namespace jaegertracing

src/jaegertracing/samplers/Config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Config {
6161
const auto type =
6262
utils::yaml::findOrDefault<std::string>(configYAML, "type", "");
6363
const auto param =
64-
utils::yaml::findOrDefault<double>(configYAML, "param", 0);
64+
utils::yaml::findOrDefault<double>(configYAML, "param", -1);
6565
const auto samplingServerURL = utils::yaml::findOrDefault<std::string>(
6666
configYAML, "samplingServerURL", "");
6767
const auto maxOperations =
@@ -86,7 +86,7 @@ class Config {
8686
const Clock::duration& samplingRefreshInterval =
8787
defaultSamplingRefreshInterval())
8888
: _type(type.empty() ? kSamplerTypeRemote : type)
89-
, _param(param == 0 ? kDefaultSamplingProbability : param)
89+
, _param(param == -1 ? kDefaultSamplingProbability : param)
9090
, _samplingServerURL(samplingServerURL.empty()
9191
? kDefaultSamplingServerURL
9292
: samplingServerURL)

0 commit comments

Comments
 (0)