Skip to content

Commit

Permalink
HPCC-33298 Code review 1
Browse files Browse the repository at this point in the history
- Uses streq instead of strcmp
- Gets iproptree double directly
- Various format changes

Signed-off-by: Rodrigo Pastrana <rodrigo.pastrana@lexisnexisrisk.com>
  • Loading branch information
rpastrana committed Jan 29, 2025
1 parent c56a09b commit 34965d1
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions system/jlib/jtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1368,19 +1368,17 @@ static std::unique_ptr<opentelemetry::sdk::trace::Sampler> createSampler(IProper
const char * samplerType = samplerTree->queryProp("@type");
if (!isEmptyString(samplerType))
{
const char * samplerArgument = samplerTree->queryProp("@argument");
if (strcmp("AlwaysOff", samplerType)==0)
if (streq(samplerType, "AlwaysOff"))
{
sampler.reset(new opentelemetry::sdk::trace::AlwaysOffSampler());
}
else if (strcmp("AlwaysOn", samplerType)==0)
else if (streq(samplerType, "AlwaysOn"))
{
sampler.reset(new opentelemetry::sdk::trace::AlwaysOnSampler());
}
else if (strcmp("Ratio", samplerType)==0)
else if (streq(samplerType,"Ratio"))
{
size_t pos;
double ratio = std::stod(samplerArgument, &pos);
double ratio = samplerTree->getPropReal("@argument");
if (ratio < 0 || ratio > 1)
{
OERRLOG("JTrace invalid ratio sampler configuration. Ratio must be LE 1.0 or GE 0.0");
Expand All @@ -1397,16 +1395,15 @@ static std::unique_ptr<opentelemetry::sdk::trace::Sampler> createSampler(IProper

if (sampler && samplerTree->getPropBool("@parentBased", true))
{
return std::unique_ptr<opentelemetry::sdk::trace::ParentBasedSampler>(new opentelemetry::sdk::trace::ParentBasedSampler( std::move(sampler)));
return std::unique_ptr<opentelemetry::sdk::trace::ParentBasedSampler>(new opentelemetry::sdk::trace::ParentBasedSampler(std::move(sampler)));
}
}
}

if (!sampler)
{
WARNLOG("JTrace: Default Sampler 'Always ON' set");
sampler = std::unique_ptr<opentelemetry::sdk::trace::AlwaysOnSampler>
(new opentelemetry::sdk::trace::AlwaysOnSampler);
sampler.reset(new opentelemetry::sdk::trace::AlwaysOnSampler());
WARNLOG("JTrace sampler set to 'Always ON' by default!");
}

return sampler;
Expand Down Expand Up @@ -1466,8 +1463,7 @@ void CTraceManager::initTracerProviderAndGlobalInternals(const IPropertyTree * t

if (!sampler)
{
sampler = std::unique_ptr<opentelemetry::sdk::trace::AlwaysOnSampler>
(new opentelemetry::sdk::trace::AlwaysOnSampler);
sampler = std::unique_ptr<opentelemetry::sdk::trace::AlwaysOnSampler>(new opentelemetry::sdk::trace::AlwaysOnSampler);
}

if (enableDefaultLogExporter)
Expand Down

0 comments on commit 34965d1

Please sign in to comment.