diff --git a/tracing/tracing.cc b/tracing/tracing.cc index 86a717f974..0fa2d1c6f3 100644 --- a/tracing/tracing.cc +++ b/tracing/tracing.cc @@ -206,8 +206,9 @@ void tracing::set_trace_probability(double p) { } one_session_records::one_session_records() - : backend_state_ptr(tracing::get_local_tracing_instance().allocate_backend_session_state()) - , budget_ptr(tracing::get_local_tracing_instance().get_cached_records_ptr()) {} + : _local_tracing_ptr(tracing::get_local_tracing_instance().shared_from_this()) + , backend_state_ptr(_local_tracing_ptr->allocate_backend_session_state()) + , budget_ptr(_local_tracing_ptr->get_cached_records_ptr()) {} std::ostream& operator<<(std::ostream& os, const span_id& id) { return os << id.get_id(); diff --git a/tracing/tracing.hh b/tracing/tracing.hh index 39a6166339..c62f0c0a15 100644 --- a/tracing/tracing.hh +++ b/tracing/tracing.hh @@ -240,6 +240,8 @@ public: }; class one_session_records { +private: + shared_ptr _local_tracing_ptr; public: utils::UUID session_id; session_record session_rec; @@ -665,7 +667,7 @@ private: void one_session_records::set_pending_for_write() { _is_pending_for_write = true; - budget_ptr = tracing::get_local_tracing_instance().get_pending_records_ptr(); + budget_ptr = _local_tracing_ptr->get_pending_records_ptr(); } void one_session_records::data_consumed() { @@ -674,7 +676,7 @@ void one_session_records::data_consumed() { } _is_pending_for_write = false; - budget_ptr = tracing::get_local_tracing_instance().get_cached_records_ptr(); + budget_ptr = _local_tracing_ptr->get_cached_records_ptr(); } inline span_id span_id::make_span_id() {