E588 Add DD_TAGS colon edge case test (#248) · DataDog/dd-opentracing-cpp@515c445 · GitHub
[go: up one dir, main page]

Skip to content

Commit 515c445

Browse files
jybpdgoffredo
andauthored
Add DD_TAGS colon edge case test (#248)
* Add colon edge case * teach catch2 how to print a pair of strings * the first key/value separator is skipped, but no subsequent ones * flat is better than nested Co-authored-by: David Goffredo <david.goffredo@datadoghq.com>
1 parent 6462aea commit 515c445

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/tracer_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ std::map<std::string, std::string> keyvalues(std::string text, char itemsep, cha
6868
keyfound = false;
6969
continue;
7070
}
71-
if (ch == itemsep) {
71+
if (ch == itemsep && !keyfound) {
7272
keyfound = true;
7373
continue;
7474
}

test/tracer_options_test.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ std::ostream &operator<<(std::ostream &stream,
2121
} // namespace opentracing
2222
} // namespace datadog
2323

24+
namespace std {
25+
26+
std::ostream &operator<<(std::ostream &stream,
27+
const std::pair<const std::string, std::string> &key_value) {
28+
return stream << key_value.first << "" << key_value.second;
29+
}
30+
31+
} // namespace std
32+
2433
void requireTracerOptionsResultsMatch(const ot::expected<TracerOptions, std::string> &lhs,
2534
const ot::expected<TracerOptions, std::string> &rhs) {
2635
// One is an error, the other not.
@@ -78,7 +87,7 @@ TEST_CASE("tracer options from environment variables") {
7887
{"DD_TRACE_REPORT_HOSTNAME", "true"},
7988
{"DD_TRACE_ANALYTICS_ENABLED", "true"},
8089
{"DD_TRACE_ANALYTICS_SAMPLE_RATE", "0.5"},
81-
{"DD_TAGS", "host:my-host-name,region:us-east-1,datacenter:us,partition:5"},
90+
{"DD_TAGS", "host:my-host-name,region:us-east-1,datacenter:us,a.b_c:a:b,partition:5"},
8291
{"DD_TRACE_RATE_LIMIT", "200"},
8392
{"DD_TRACE_SAMPLE_RATE", "0.7"}},
8493
TracerOptions{
@@ -101,6 +110,7 @@ TEST_CASE("tracer options from environment variables") {
101110
{"host", "my-host-name"},
102111
{"region", "us-east-1"},
103112
{"datacenter", "us"},
113+
{"a.b_c", "a:b"},
104114
{"partition", "5"},
105115
}, // tags
106116
"test-version v0.0.1", // version

0 commit comments

Comments
 (0)
0