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

Commit

Permalink
Added support for setting tracer tags via the configuration (#284)
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Stadler <[email protected]>

Co-authored-by: Yuri Shkuro <[email protected]>
  • Loading branch information
tobiasstadler and yurishkuro authored Sep 13, 2021
1 parent 6a20fed commit 703028f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/jaegertracing/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,21 @@ class Config {
const auto baggageRestrictionsNode = configYAML["baggage_restrictions"];
const auto baggageRestrictions =
baggage::RestrictionsConfig::parse(baggageRestrictionsNode);

std::vector<Tag> tags;
const auto node = configYAML["tags"];
for(YAML::const_iterator it = node.begin(); it != node.end(); ++it) {
tags.emplace_back(it->first.as<std::string>(), it->second.as<std::string>());
}

return Config(disabled,
traceId128Bit,
sampler,
reporter,
headers,
baggageRestrictions,
serviceName,
std::vector<Tag>(),
tags,
propagationFormat);
}

Expand Down
15 changes: 15 additions & 0 deletions src/jaegertracing/ConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ propagation_format: w3c
}
}

TEST(Config, testTags)
{
{
constexpr auto kConfigYAML = R"cfg(
tags:
foo: bar
)cfg";
const auto config = Config::parse(YAML::Load(kConfigYAML));

std::vector<Tag> expectedTags;
expectedTags.emplace_back("foo", std::string("bar"));
ASSERT_EQ(expectedTags, config.tags());
}
}

#endif // JAEGERTRACING_WITH_YAML_CPP

TEST(Config, testFromEnv)
Expand Down

0 comments on commit 703028f

Please sign in to comment.