ResourceSpan

Struct ResourceSpan 

Source
pub struct ResourceSpan {
Show 13 fields pub name: String, pub trace_context: TraceContext, pub parent_span_id: Option<SpanId>, pub start_time_unix_us: u64, pub end_time_unix_us: u64, pub status: SpanStatus, pub lease_ids: Vec<u128>, pub ops: Vec<(OpKey, u64)>, pub bytes_read: u64, pub bytes_written: u64, pub lease_cost_byte_secs: u64, pub lease_acquire_wait_us: u64, pub attributes: Vec<(String, String)>,
}
Expand description

A resource-attributed span carrying grafOS-specific metadata.

Populated automatically by lease API instrumentation hooks and the #[grafos::instrument] proc macro. Exported to OTel collectors via the otlp exporter (requires otlp feature).

Fields§

§name: String

Human-readable name for this span (usually the function name).

§trace_context: TraceContext

Trace context (trace_id + span_id + flags).

§parent_span_id: Option<SpanId>

Parent span ID (if this span has a parent in the same service).

§start_time_unix_us: u64

Start time as Unix microseconds.

§end_time_unix_us: u64

End time as Unix microseconds.

§status: SpanStatus

Completion status.

§lease_ids: Vec<u128>

Lease IDs touched during this span.

§ops: Vec<(OpKey, u64)>

Operation counts by (resource_type, op_type).

§bytes_read: u64

Total bytes read across all lease operations in this span.

§bytes_written: u64

Total bytes written across all lease operations in this span.

§lease_cost_byte_secs: u64

Sum of (leased_bytes * seconds_held) for all leases in this span.

§lease_acquire_wait_us: u64

Time spent waiting for lease acquisition, in microseconds.

§attributes: Vec<(String, String)>

User-defined key-value attributes.

Implementations§

Source§

impl ResourceSpan

Source

pub fn new(name: &str, trace_context: TraceContext) -> Self

Create a new span with the given name and trace context.

Source

pub fn duration_us(&self) -> u64

Duration in microseconds.

Source

pub fn record_op( &mut self, resource_type: ResourceType, op_type: OpType, count: u64, )

Record an operation.

Source

pub fn op_count(&self, resource_type: ResourceType, op_type: OpType) -> u64

Get the operation count for a specific (resource_type, op_type) pair.

Source

pub fn add_lease_id(&mut self, lease_id: u128)

Add a lease ID to the span’s lease list.

Source

pub fn set_attribute(&mut self, key: &str, value: &str)

Add a user-defined attribute.

Source

pub fn trace_id(&self) -> TraceId

Convenience: trace ID from the context.

Source

pub fn span_id(&self) -> SpanId

Convenience: span ID from the context.

Trait Implementations§

Source§

impl Clone for ResourceSpan

Source§

fn clone(&self) -> ResourceSpan

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResourceSpan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.