From 93ef013c70dda73bb0358cdad4ccd07a4d379799 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Thu, 2 Jun 2022 12:24:18 -0700 Subject: [PATCH] Copy string_view passed to ETW exporter in PropertyVariant (#1425) --- api/include/opentelemetry/trace/span_context.h | 2 +- .../etw/include/opentelemetry/exporters/etw/etw_properties.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/include/opentelemetry/trace/span_context.h b/api/include/opentelemetry/trace/span_context.h index ca13a8df60..e19bb99001 100644 --- a/api/include/opentelemetry/trace/span_context.h +++ b/api/include/opentelemetry/trace/span_context.h @@ -81,7 +81,7 @@ class SpanContext final bool IsRemote() const noexcept { return is_remote_; } - static SpanContext GetInvalid() { return SpanContext(false, false); } + static SpanContext GetInvalid() noexcept { return SpanContext(false, false); } bool IsSampled() const noexcept { return trace_flags_.IsSampled(); } diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h index 04ad86130f..3cf365c8a0 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h @@ -192,7 +192,7 @@ class PropertyValue : public PropertyVariant {} /** - * @brief Convert owning PropertyValue to non-owning common::AttributeValue + * @brief Convert non-owning common::AttributeValue to owning PropertyValue. * @return */ PropertyValue &FromAttributeValue(const common::AttributeValue &v) @@ -222,7 +222,8 @@ class PropertyValue : public PropertyVariant break; } case common::AttributeType::kTypeString: { - PropertyVariant::operator=(nostd::string_view(nostd::get(v)).data()); + PropertyVariant::operator= + (std::string{nostd::string_view(nostd::get(v)).data()}); break; }