diff --git a/api/include/opentelemetry/baggage/baggage.h b/api/include/opentelemetry/baggage/baggage.h index 259fd7f3b6..eb5e4dcc7c 100644 --- a/api/include/opentelemetry/baggage/baggage.h +++ b/api/include/opentelemetry/baggage/baggage.h @@ -25,11 +25,12 @@ class Baggage static constexpr char kMembersSeparator = ','; static constexpr char kMetadataSeparator = ';'; - Baggage() : kv_properties_(new opentelemetry::common::KeyValueProperties()) {} - Baggage(size_t size) : kv_properties_(new opentelemetry::common::KeyValueProperties(size)){}; + Baggage() noexcept : kv_properties_(new opentelemetry::common::KeyValueProperties()) {} + Baggage(size_t size) noexcept + : kv_properties_(new opentelemetry::common::KeyValueProperties(size)){}; template - Baggage(const T &keys_and_values) + Baggage(const T &keys_and_values) noexcept : kv_properties_(new opentelemetry::common::KeyValueProperties(keys_and_values)) {} @@ -42,7 +43,7 @@ class Baggage /* Get value for key in the baggage @returns true if key is found, false otherwise */ - bool GetValue(nostd::string_view key, std::string &value) const + bool GetValue(nostd::string_view key, std::string &value) const noexcept { return kv_properties_->GetValue(key, value); } @@ -50,7 +51,8 @@ class Baggage /* Returns shared_ptr of new baggage object which contains new key-value pair. If key or value is invalid, copy of current baggage is returned */ - nostd::shared_ptr Set(const nostd::string_view &key, const nostd::string_view &value) + nostd::shared_ptr Set(const nostd::string_view &key, + const nostd::string_view &value) noexcept { nostd::shared_ptr baggage(new Baggage(kv_properties_->Size() + 1)); @@ -89,7 +91,7 @@ class Baggage // if key does not exist, copy of current baggage is returned. // Validity of key is not checked as invalid keys should never be populated in baggage in the // first place. - nostd::shared_ptr Delete(nostd::string_view key) + nostd::shared_ptr Delete(nostd::string_view key) noexcept { // keeping size of baggage same as key might not be found in it nostd::shared_ptr baggage(new Baggage(kv_properties_->Size())); @@ -103,7 +105,7 @@ class Baggage } // Returns shared_ptr of baggage after extracting key-value pairs from header - static nostd::shared_ptr FromHeader(nostd::string_view header) + static nostd::shared_ptr FromHeader(nostd::string_view header) noexcept { if (header.size() > kMaxSize) { @@ -158,7 +160,7 @@ class Baggage } // Creates string from baggage object. - std::string ToHeader() const + std::string ToHeader() const noexcept { std::string header_s; bool first = true; diff --git a/api/include/opentelemetry/baggage/baggage_context.h b/api/include/opentelemetry/baggage/baggage_context.h index b2b61703f8..9a92bac77f 100644 --- a/api/include/opentelemetry/baggage/baggage_context.h +++ b/api/include/opentelemetry/baggage/baggage_context.h @@ -16,7 +16,7 @@ namespace baggage static const std::string kBaggageHeader = "baggage"; inline nostd::shared_ptr GetBaggage( - const opentelemetry::context::Context &context) + const opentelemetry::context::Context &context) noexcept { context::ContextValue context_value = context.GetValue(kBaggageHeader); if (nostd::holds_alternative>(context_value)) @@ -28,8 +28,9 @@ inline nostd::shared_ptr GetBaggage( return empty_baggage; } -inline context::Context SetBaggage(opentelemetry::context::Context &context, - nostd::shared_ptr baggage) +inline context::Context SetBaggage( + opentelemetry::context::Context &context, + nostd::shared_ptr baggage) noexcept { return context.SetValue(kBaggageHeader, baggage); } diff --git a/api/include/opentelemetry/common/kv_properties.h b/api/include/opentelemetry/common/kv_properties.h index 799fd293c7..7ac747a733 100644 --- a/api/include/opentelemetry/common/kv_properties.h +++ b/api/include/opentelemetry/common/kv_properties.h @@ -33,7 +33,7 @@ class KeyValueStringTokenizer public: KeyValueStringTokenizer( nostd::string_view str, - const KeyValueStringTokenizerOptions &opts = KeyValueStringTokenizerOptions()) + const KeyValueStringTokenizerOptions &opts = KeyValueStringTokenizerOptions()) noexcept : str_(str), opts_(opts), index_(0) {} @@ -48,7 +48,7 @@ class KeyValueStringTokenizer // @param key : key in kv pair // @param key : value in kv pair // @returns true if next kv pair was found, false otherwise. - bool next(bool &valid_kv, nostd::string_view &key, nostd::string_view &value) + bool next(bool &valid_kv, nostd::string_view &key, nostd::string_view &value) noexcept { valid_kv = true; while (index_ < str_.size()) @@ -170,13 +170,13 @@ class KeyValueProperties } // Gets the key associated with this entry. - nostd::string_view GetKey() const { return key_.get(); } + nostd::string_view GetKey() const noexcept { return key_.get(); } // Gets the value associated with this entry. - nostd::string_view GetValue() const { return value_.get(); } + nostd::string_view GetValue() const noexcept { return value_.get(); } // Sets the value for this entry. This overrides the previous value. - void SetValue(nostd::string_view value) { value_ = CopyStringToPointer(value); } + void SetValue(nostd::string_view value) noexcept { value_ = CopyStringToPointer(value); } private: // Store key and value as raw char pointers to avoid using std::string. @@ -206,15 +206,15 @@ class KeyValueProperties public: // Create Key-value list of given size // @param size : Size of list. - KeyValueProperties(size_t size) + KeyValueProperties(size_t size) noexcept : num_entries_(0), max_num_entries_(size), entries_(new Entry[size]) {} // Create Empty Key-Value list - KeyValueProperties() : num_entries_(0), max_num_entries_(0), entries_(nullptr) {} + KeyValueProperties() noexcept : num_entries_(0), max_num_entries_(0), entries_(nullptr) {} template ::value>::type> - KeyValueProperties(const T &keys_and_values) + KeyValueProperties(const T &keys_and_values) noexcept : num_entries_(0), max_num_entries_(keys_and_values.size()), entries_(new Entry[max_num_entries_]) @@ -227,7 +227,7 @@ class KeyValueProperties } // Adds new kv pair into kv properties - void AddEntry(nostd::string_view key, nostd::string_view value) + void AddEntry(nostd::string_view key, nostd::string_view value) noexcept { if (num_entries_ < max_num_entries_) { @@ -238,7 +238,7 @@ class KeyValueProperties // Returns all kv pair entries bool GetAllEntries( - nostd::function_ref callback) const + nostd::function_ref callback) const noexcept { for (size_t i = 0; i < num_entries_; i++) { @@ -252,7 +252,7 @@ class KeyValueProperties } // Return value for key if exists, return false otherwise - bool GetValue(nostd::string_view key, std::string &value) const + bool GetValue(nostd::string_view key, std::string &value) const noexcept { for (size_t i = 0; i < num_entries_; i++) { diff --git a/api/include/opentelemetry/common/string_util.h b/api/include/opentelemetry/common/string_util.h index 00f80db992..ffee86c96b 100644 --- a/api/include/opentelemetry/common/string_util.h +++ b/api/include/opentelemetry/common/string_util.h @@ -26,7 +26,7 @@ namespace common class StringUtil { public: - static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) + static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept { while (str[static_cast(left)] == ' ' && left <= right) { @@ -39,7 +39,7 @@ class StringUtil return str.substr(left, 1 + right - left); } - static nostd::string_view Trim(nostd::string_view str) + static nostd::string_view Trim(nostd::string_view str) noexcept { if (str.empty()) { diff --git a/api/include/opentelemetry/context/context.h b/api/include/opentelemetry/context/context.h index 50cfde3c4f..923b396c7f 100644 --- a/api/include/opentelemetry/context/context.h +++ b/api/include/opentelemetry/context/context.h @@ -24,14 +24,14 @@ class Context // Creates a context object from a map of keys and identifiers, this will // hold a shared_ptr to the head of the DataList linked list template - Context(const T &keys_and_values) + Context(const T &keys_and_values) noexcept { head_ = nostd::shared_ptr{new DataList(keys_and_values)}; } // Creates a context object from a key and value, this will // hold a shared_ptr to the head of the DataList linked list - Context(nostd::string_view key, ContextValue value) + Context(nostd::string_view key, ContextValue value) noexcept { head_ = nostd::shared_ptr{new DataList(key, value)}; } diff --git a/api/include/opentelemetry/context/runtime_context.h b/api/include/opentelemetry/context/runtime_context.h index 74fa2151ea..167a928f10 100644 --- a/api/include/opentelemetry/context/runtime_context.h +++ b/api/include/opentelemetry/context/runtime_context.h @@ -173,7 +173,7 @@ class RuntimeContext } }; -inline Token::~Token() +inline Token::~Token() noexcept { context::RuntimeContext::Detach(*this); } diff --git a/api/include/opentelemetry/trace/context.h b/api/include/opentelemetry/trace/context.h index 165f1540b9..963c187177 100644 --- a/api/include/opentelemetry/trace/context.h +++ b/api/include/opentelemetry/trace/context.h @@ -12,7 +12,7 @@ namespace trace { // Get Span from explicit context -inline nostd::shared_ptr GetSpan(const opentelemetry::context::Context &context) +inline nostd::shared_ptr GetSpan(const opentelemetry::context::Context &context) noexcept { context::ContextValue span = context.GetValue(kSpanKey); if (nostd::holds_alternative>(span)) @@ -24,7 +24,7 @@ inline nostd::shared_ptr GetSpan(const opentelemetry::context::Context &co // Set Span into explicit context inline context::Context SetSpan(opentelemetry::context::Context &context, - nostd::shared_ptr span) + nostd::shared_ptr span) noexcept { return context.SetValue(kSpanKey, span); } diff --git a/api/include/opentelemetry/trace/default_span.h b/api/include/opentelemetry/trace/default_span.h index 6755704291..fadd92386f 100644 --- a/api/include/opentelemetry/trace/default_span.h +++ b/api/include/opentelemetry/trace/default_span.h @@ -50,13 +50,13 @@ class DefaultSpan : public Span void End(const EndSpanOptions & /* options */ = {}) noexcept {} - nostd::string_view ToString() { return "DefaultSpan"; } + nostd::string_view ToString() const noexcept { return "DefaultSpan"; } - DefaultSpan(SpanContext span_context) : span_context_(span_context) {} + DefaultSpan(SpanContext span_context) noexcept : span_context_(span_context) {} // movable and copiable - DefaultSpan(DefaultSpan &&spn) : span_context_(spn.GetContext()) {} - DefaultSpan(const DefaultSpan &spn) : span_context_(spn.GetContext()) {} + DefaultSpan(DefaultSpan &&spn) noexcept : span_context_(spn.GetContext()) {} + DefaultSpan(const DefaultSpan &spn) noexcept : span_context_(spn.GetContext()) {} private: SpanContext span_context_; diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index 1257ebd279..e7784c4be6 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -100,14 +100,15 @@ class NoopTracer final : public Tracer, public std::enable_shared_from_this( new opentelemetry::trace::NoopTracer)} {} - nostd::shared_ptr GetTracer(nostd::string_view library_name, - nostd::string_view library_version, - nostd::string_view schema_url) override + nostd::shared_ptr GetTracer( + nostd::string_view library_name, + nostd::string_view library_version, + nostd::string_view schema_url) noexcept override { return tracer_; } diff --git a/api/include/opentelemetry/trace/span_context.h b/api/include/opentelemetry/trace/span_context.h index 569a3c1e71..ca13a8df60 100644 --- a/api/include/opentelemetry/trace/span_context.h +++ b/api/include/opentelemetry/trace/span_context.h @@ -26,7 +26,7 @@ class SpanContext final * sampled * @param is_remote true if this context was propagated from a remote parent. */ - SpanContext(bool sampled_flag, bool is_remote) + SpanContext(bool sampled_flag, bool is_remote) noexcept : trace_id_(), span_id_(), trace_flags_(opentelemetry::trace::TraceFlags((uint8_t)sampled_flag)), diff --git a/api/include/opentelemetry/trace/trace_state.h b/api/include/opentelemetry/trace/trace_state.h index 1dc0457356..0343637cfa 100644 --- a/api/include/opentelemetry/trace/trace_state.h +++ b/api/include/opentelemetry/trace/trace_state.h @@ -53,7 +53,7 @@ class TraceState * the W3C Trace Context specification https://www.w3.org/TR/trace-context/ * @return TraceState A new TraceState instance or DEFAULT */ - static nostd::shared_ptr FromHeader(nostd::string_view header) + static nostd::shared_ptr FromHeader(nostd::string_view header) noexcept { common::KeyValueStringTokenizer kv_str_tokenizer(header); @@ -89,7 +89,7 @@ class TraceState /** * Creates a w3c tracestate header from TraceState object */ - std::string ToHeader() + std::string ToHeader() const noexcept { std::string header_s; bool first = true; @@ -135,7 +135,8 @@ class TraceState * * If the existing object has maximum list members, it's copy is returned. */ - nostd::shared_ptr Set(const nostd::string_view &key, const nostd::string_view &value) + nostd::shared_ptr Set(const nostd::string_view &key, + const nostd::string_view &value) noexcept { auto curr_size = kv_properties_->Size(); if (!IsValidKey(key) || !IsValidValue(value)) @@ -168,7 +169,7 @@ class TraceState * @returns empty TraceState object if key is invalid * @returns copy of original TraceState object if key is not present (??) */ - nostd::shared_ptr Delete(const nostd::string_view &key) + nostd::shared_ptr Delete(const nostd::string_view &key) noexcept { if (!IsValidKey(key)) { diff --git a/api/include/opentelemetry/trace/tracer_provider.h b/api/include/opentelemetry/trace/tracer_provider.h index 540a2f6b24..2dae74ce14 100644 --- a/api/include/opentelemetry/trace/tracer_provider.h +++ b/api/include/opentelemetry/trace/tracer_provider.h @@ -25,7 +25,7 @@ class TracerProvider */ virtual nostd::shared_ptr GetTracer(nostd::string_view library_name, nostd::string_view library_version = "", - nostd::string_view schema_url = "") = 0; + nostd::string_view schema_url = "") noexcept = 0; }; } // namespace trace OPENTELEMETRY_END_NAMESPACE diff --git a/api/test/trace/provider_test.cc b/api/test/trace/provider_test.cc index 3c4bd1e74e..9e5a7aad1d 100644 --- a/api/test/trace/provider_test.cc +++ b/api/test/trace/provider_test.cc @@ -16,7 +16,7 @@ class TestProvider : public TracerProvider { nostd::shared_ptr GetTracer(nostd::string_view library_name, nostd::string_view library_version, - nostd::string_view schema_url) override + nostd::string_view schema_url) noexcept override { return nostd::shared_ptr(nullptr); } diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index 82bd6d726c..5db31a7a75 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -980,7 +980,7 @@ class TracerProvider : public opentelemetry::trace::TracerProvider nostd::shared_ptr GetTracer( nostd::string_view name, nostd::string_view args = "", - nostd::string_view schema_url = "") override + nostd::string_view schema_url = "") noexcept override { UNREFERENCED_PARAMETER(args); UNREFERENCED_PARAMETER(schema_url);