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

Commit 703028f

Browse files
Added support for setting tracer tags via the configuration (#284)
Signed-off-by: Tobias Stadler <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
1 parent 6a20fed commit 703028f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/jaegertracing/Config.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,21 @@ class Config {
6868
const auto baggageRestrictionsNode = configYAML["baggage_restrictions"];
6969
const auto baggageRestrictions =
7070
baggage::RestrictionsConfig::parse(baggageRestrictionsNode);
71+
72+
std::vector<Tag> tags;
73+
const auto node = configYAML["tags"];
74+
for(YAML::const_iterator it = node.begin(); it != node.end(); ++it) {
75+
tags.emplace_back(it->first.as<std::string>(), it->second.as<std::string>());
76+
}
77+
7178
return Config(disabled,
7279
traceId128Bit,
7380
sampler,
7481
reporter,
7582
headers,
7683
baggageRestrictions,
7784
serviceName,
78-
std::vector<Tag>(),
85+
tags,
7986
propagationFormat);
8087
}
8188

src/jaegertracing/ConfigTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ propagation_format: w3c
107107
}
108108
}
109109

110+
TEST(Config, testTags)
111+
{
112+
{
113+
constexpr auto kConfigYAML = R"cfg(
114+
tags:
115+
foo: bar
116+
)cfg";
117+
const auto config = Config::parse(YAML::Load(kConfigYAML));
118+
119+
std::vector<Tag> expectedTags;
120+
expectedTags.emplace_back("foo", std::string("bar"));
121+
ASSERT_EQ(expectedTags, config.tags());
122+
}
123+
}
124+
110125
#endif // JAEGERTRACING_WITH_YAML_CPP
111126

112127
TEST(Config, testFromEnv)

0 commit comments

Comments
 (0)