Resource capacities
A resource can expose measured capacities. occupancy describes a quantity
held over the usage span, such as bytes of memory held while a task runs.
YAML model
quent: alpha
model: resource_capacity
entities:
Memory:
resource:
bytes:
kind: occupancy
events:
created: {}
fsms:
Task:
states:
running:
initial: true
attributes:
memory: { uses: Memory }
to: [completed]
completed: {}
Declaring the bytes capacity generates a MemoryUsage record with a bytes
field.
Instrumentation API
The task’s reference to Memory carries the quantity it claims.
// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
#[allow(unused)]
mod instrumentation {
include!(concat!(env!("OUT_DIR"), "/resource_capacity.rs"));
}
use instrumentation::{Context, Memory, MemoryUsage, Noop, ResourceCapacity, Task};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let context = Context::<ResourceCapacity>::try_new(Noop)?;
let mut memory = context.observer::<Memory>().handle();
memory.created()?;
let _task = context
.observer::<Task>()
.handle()
.running(memory.as_entity_ref_with(MemoryUsage { bytes: 512_000_000 }))
.completed();
Ok(())
}
Key point
A capacity resource records the quantity of a resource used by an entity.