mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
tracing: make the session state modifying methods and tracing::trace(...) noexcept
Make state session creation, stop_forground() and tracing::trace(...) methods noexcept. Most of them have already been implemented the way that they won't throw but this patch makes it official... Signed-off-by: Vlad Zolotarov <vladz@scylladb.com>
This commit is contained in:
@@ -93,7 +93,7 @@ trace_state::~trace_state() {
|
||||
trace_state_logger.trace("{}: destructing", session_id());
|
||||
}
|
||||
|
||||
void trace_state::stop_foreground_and_write() {
|
||||
void trace_state::stop_foreground_and_write() noexcept {
|
||||
// Do nothing if state hasn't been initiated
|
||||
if (is_in_state(state::inactive)) {
|
||||
return;
|
||||
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
* @note The tracing session's "duration" is the time it was in the "foreground"
|
||||
* state.
|
||||
*/
|
||||
void stop_foreground_and_write();
|
||||
void stop_foreground_and_write() noexcept;
|
||||
|
||||
const utils::UUID& session_id() const {
|
||||
return _records->session_id;
|
||||
@@ -390,14 +390,34 @@ private:
|
||||
*/
|
||||
void build_parameters_map();
|
||||
|
||||
/**
|
||||
* The actual trace message storing method.
|
||||
*
|
||||
* @note This method is allowed to throw.
|
||||
* @param msg the trace message to store
|
||||
*/
|
||||
void trace_internal(sstring msg);
|
||||
|
||||
/**
|
||||
* Add a single trace entry - a special case for a simple string.
|
||||
*
|
||||
* @param msg trace message
|
||||
*/
|
||||
void trace(sstring msg);
|
||||
void trace(const char* msg) {
|
||||
trace(sstring(msg));
|
||||
void trace(sstring msg) noexcept {
|
||||
try {
|
||||
trace_internal(std::move(msg));
|
||||
} catch (...) {
|
||||
// Bump up an error counter and ignore
|
||||
++_local_tracing_ptr->stats.trace_errors;
|
||||
}
|
||||
}
|
||||
void trace(const char* msg) noexcept {
|
||||
try {
|
||||
trace_internal(sstring(msg));
|
||||
} catch (...) {
|
||||
// Bump up an error counter and ignore
|
||||
++_local_tracing_ptr->stats.trace_errors;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,13 +436,13 @@ private:
|
||||
* @param a positional parameters
|
||||
*/
|
||||
template <typename... A>
|
||||
void trace(const char* fmt, A&&... a);
|
||||
void trace(const char* fmt, A&&... a) noexcept;
|
||||
|
||||
template <typename... A>
|
||||
friend void begin(const trace_state_ptr& p, A&&... a);
|
||||
|
||||
template <typename... A>
|
||||
friend void trace(const trace_state_ptr& p, A&&... a);
|
||||
friend void trace(const trace_state_ptr& p, A&&... a) noexcept;
|
||||
|
||||
friend void set_page_size(const trace_state_ptr& p, int32_t val);
|
||||
friend void set_batchlog_endpoints(const trace_state_ptr& p, const std::unordered_set<gms::inet_address>& val);
|
||||
@@ -434,7 +454,7 @@ private:
|
||||
friend void add_table_name(const trace_state_ptr& p, const sstring& ks_name, const sstring& cf_name);
|
||||
};
|
||||
|
||||
inline void trace_state::trace(sstring message) {
|
||||
inline void trace_state::trace_internal(sstring message) {
|
||||
if (is_in_state(state::inactive)) {
|
||||
throw std::logic_error("trying to use a trace() before begin() for \"" + message + "\" tracepoint");
|
||||
}
|
||||
@@ -480,9 +500,9 @@ inline void trace_state::trace(sstring message) {
|
||||
}
|
||||
|
||||
template <typename... A>
|
||||
void trace_state::trace(const char* fmt, A&&... a) {
|
||||
void trace_state::trace(const char* fmt, A&&... a) noexcept {
|
||||
try {
|
||||
trace(seastar::format(fmt, std::forward<A>(a)...));
|
||||
trace_internal(seastar::format(fmt, std::forward<A>(a)...));
|
||||
} catch (...) {
|
||||
// Bump up an error counter and ignore
|
||||
++_local_tracing_ptr->stats.trace_errors;
|
||||
@@ -589,7 +609,7 @@ inline void begin(const trace_state_ptr& p, A&&... a) {
|
||||
* @param a trace message format string with optional parameters
|
||||
*/
|
||||
template <typename... A>
|
||||
inline void trace(const trace_state_ptr& p, A&&... a) {
|
||||
inline void trace(const trace_state_ptr& p, A&&... a) noexcept {
|
||||
if (p) {
|
||||
p->trace(std::forward<A>(a)...);
|
||||
}
|
||||
@@ -610,7 +630,7 @@ inline std::experimental::optional<trace_info> make_trace_info(const trace_state
|
||||
return std::experimental::nullopt;
|
||||
}
|
||||
|
||||
inline void stop_foreground(const trace_state_ptr& state) {
|
||||
inline void stop_foreground(const trace_state_ptr& state) noexcept {
|
||||
if (state) {
|
||||
state->stop_foreground_and_write();
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ future<> tracing::start_tracing() {
|
||||
});
|
||||
}
|
||||
|
||||
trace_state_ptr tracing::create_session(trace_type type, trace_state_props_set props) {
|
||||
trace_state_ptr tracing::create_session(trace_type type, trace_state_props_set props) noexcept {
|
||||
if (!started()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ trace_state_ptr tracing::create_session(trace_type type, trace_state_props_set p
|
||||
}
|
||||
}
|
||||
|
||||
trace_state_ptr tracing::create_session(const trace_info& secondary_session_info) {
|
||||
trace_state_ptr tracing::create_session(const trace_info& secondary_session_info) noexcept {
|
||||
if (!started()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ public:
|
||||
*
|
||||
* @return tracing state handle
|
||||
*/
|
||||
trace_state_ptr create_session(trace_type type, trace_state_props_set props);
|
||||
trace_state_ptr create_session(trace_type type, trace_state_props_set props) noexcept;
|
||||
|
||||
/**
|
||||
* Create a new secondary tracing session.
|
||||
@@ -479,7 +479,7 @@ public:
|
||||
*
|
||||
* @return tracing state handle
|
||||
*/
|
||||
trace_state_ptr create_session(const trace_info& secondary_session_info);
|
||||
trace_state_ptr create_session(const trace_info& secondary_session_info) noexcept;
|
||||
|
||||
void write_maybe() {
|
||||
if (_pending_for_write_records_count >= write_event_records_threshold || _pending_for_write_records_bulk.size() >= write_event_sessions_threshold) {
|
||||
|
||||
Reference in New Issue
Block a user