vector/internal_telemetry/allocations/allocator/
tracer.rs

1use super::token::AllocationGroupId;
2
3/// Traces allocations and deallocations.
4pub trait Tracer {
5    /// Traces an allocation.
6    ///
7    /// All allocations/deallocations that occur within the call to `Tracer::trace_allocation` are ignored, so
8    /// implementors can allocate/deallocate without risk of reentrancy bugs. It does mean, however, that the
9    /// allocations/deallocations that occur will be effectively lost, so implementors should ensure that the only data
10    /// they deallocate in the tracer is data that was similarly allocated, and vice versa.
11    ///
12    /// The object size is from the original layout excluding the group ID size.
13    fn trace_allocation(&self, object_size: usize, group_id: AllocationGroupId);
14
15    /// Traces a deallocation.
16    ///
17    /// `source_group_id` contains the group ID where the given allocation originated from, while `current_group_id` is
18    /// the current group ID, and as such, these values may differ depending on how values have had their ownership
19    /// transferred.
20    ///
21    /// All allocations/deallocations that occur within the call to `Tracer::trace_deallocation` are ignored, so
22    /// implementors can allocate/deallocate without risk of reentrancy bugs. It does mean, however, that the
23    /// allocations/deallocations that occur will be effectively lost, so implementors should ensure that the only data
24    /// they deallocate in the tracer is data that was similarly allocated, and vice versa.
25    ///
26    /// The object size is from the original layout excluding the group ID size.
27    fn trace_deallocation(&self, object_size: usize, source_group_id: AllocationGroupId);
28}