+ @property
+ def uuid(self):
+ uuid_bytes = native_bt.trace_get_uuid(self._ptr)
+ if uuid_bytes is None:
+ return
+
+ return uuidp.UUID(bytes=uuid_bytes)
+
+ @property
+ def environment(self):
+ return self._trace_env_pycls(self)
+
+ def add_destruction_listener(self, listener):
+ """Add a listener to be called when the trace is destroyed."""
+ if not callable(listener):
+ raise TypeError("'listener' parameter is not callable")
+
+ handle = utils._ListenerHandle(self.addr)
+
+ fn = native_bt.bt2_trace_add_destruction_listener
+ listener_from_native = functools.partial(
+ _trace_destruction_listener_from_native, listener, handle
+ )
+
+ status, listener_id = fn(self._ptr, listener_from_native)
+ utils._handle_func_status(
+ status, "cannot add destruction listener to trace object"
+ )
+
+ handle._set_listener_id(listener_id)
+
+ return handle
+
+ def remove_destruction_listener(self, listener_handle):
+ utils._check_type(listener_handle, utils._ListenerHandle)
+
+ if listener_handle._addr != self.addr:
+ raise ValueError(
+ "This trace destruction listener does not match the trace object."
+ )
+
+ if listener_handle._listener_id is None:
+ raise ValueError("This trace destruction listener was already removed.")
+
+ status = native_bt.trace_remove_destruction_listener(
+ self._ptr, listener_handle._listener_id
+ )
+ utils._handle_func_status(status)
+ listener_handle._invalidate()
+
+
+class _Trace(_TraceConst):
+ _borrow_stream_ptr_by_id = staticmethod(native_bt.trace_borrow_stream_by_id)
+ _borrow_stream_ptr_by_index = staticmethod(native_bt.trace_borrow_stream_by_index)
+ _borrow_class_ptr = staticmethod(native_bt.trace_borrow_class)
+ _borrow_user_attributes_ptr = staticmethod(native_bt.trace_borrow_user_attributes)
+ _create_value_from_ptr_and_get_ref = staticmethod(
+ bt2_value._create_from_ptr_and_get_ref
+ )
+ _stream_pycls = property(lambda _: bt2_stream._Stream)
+ _trace_class_pycls = property(lambda _: _bt2_trace_class()._TraceClass)
+ _trace_env_pycls = property(lambda _: _TraceEnvironment)
+