Skip to content

Commit 63001cb

Browse files
authored
Merge pull request #27 from lightstep/jmacd/c_string_support
Support C strings
2 parents db0e752 + 988d229 commit 63001cb

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/c++11/lightstep/value.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef mapbox::util::variant<bool,
2323
uint64_t,
2424
std::string,
2525
std::nullptr_t,
26+
const char*,
2627
mapbox::util::recursive_wrapper<Values>,
2728
mapbox::util::recursive_wrapper<Dictionary>> variant_type;
2829

@@ -33,6 +34,9 @@ class Value : public variant_type {
3334

3435
template <typename T>
3536
Value(T&& t) : variant_type(t) { }
37+
38+
template <int N>
39+
Value(const char (&cstr)[N]) : variant_type(std::string(cstr)) { }
3640
};
3741

3842
} // namespace lighstep

src/c++11/util.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ struct KeyValueVisitor {
8282

8383
void operator()(bool b) const { kv->set_bool_value(b); }
8484

85+
void operator()(const char* s) const { kv->set_string_value(s); }
86+
8587
void operator()(const std::string &s) const { kv->set_string_value(s); }
8688

8789
// More-or-less unsupported types:

test/c++11/flushproto_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ int main() {
6969
auto recorder = tracer.impl()->recorder();
7070

7171
auto span = lightstep::Tracer::Global().StartSpan("span/parent");
72+
const char *v = "value";
73+
span.SetTag("test1", v);
74+
span.SetTag("test2", "value");
7275
span.SetBaggageItem("test", "baggage");
7376
auto parent = span.context();
7477
span.Finish();

0 commit comments

Comments
 (0)