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

Added support for setting tracer tags via the configuration #284

Merged
merged 2 commits into from
Sep 13, 2021
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
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