mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-01 03:52:15 +00:00
Exception safe from destructor
Signed-off-by: Frank Chen <frank.chen021@outlook.com>
This commit is contained in:
parent
92f7ca3616
commit
cf1081eada
@ -102,7 +102,7 @@ SpanHolder::SpanHolder(std::string_view _operation_name)
|
||||
}
|
||||
}
|
||||
|
||||
void SpanHolder::finish()
|
||||
void SpanHolder::finish() noexcept
|
||||
{
|
||||
if (!this->isTraceEnabled())
|
||||
return;
|
||||
@ -294,14 +294,29 @@ TracingContextHolder::~TracingContextHolder()
|
||||
{
|
||||
if (this->root_span.isTraceEnabled())
|
||||
{
|
||||
auto shared_span_log = current_thread_trace_context.span_log.lock();
|
||||
if (shared_span_log)
|
||||
try
|
||||
{
|
||||
this->root_span.addAttribute("clickhouse.thread_id", getThreadId());
|
||||
this->root_span.finish_time_us
|
||||
= std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
auto shared_span_log = current_thread_trace_context.span_log.lock();
|
||||
if (shared_span_log)
|
||||
{
|
||||
try
|
||||
{
|
||||
this->root_span.addAttribute("clickhouse.thread_id", getThreadId());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
/// Ignore any exceptions
|
||||
}
|
||||
|
||||
shared_span_log->add(OpenTelemetrySpanLogElement(this->root_span));
|
||||
this->root_span.finish_time_us
|
||||
= std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
|
||||
shared_span_log->add(OpenTelemetrySpanLogElement(this->root_span));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__FUNCTION__);
|
||||
}
|
||||
|
||||
this->root_span.trace_id = UUID();
|
||||
|
@ -152,7 +152,7 @@ struct SpanHolder : public Span
|
||||
|
||||
/// Finish a span explicitly if needed.
|
||||
/// It's safe to call it multiple times
|
||||
void finish();
|
||||
void finish() noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user