Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Records

A record groups related fields into a named, reusable type. Event attributes can use a record name wherever they can use a scalar type.

YAML model

quent: alpha
model: records

records:
  # Reused by events on both Task and Batch.
  WorkResult:
    fields:
      success: bool
      items_processed: u64

entities:
  Task:
    events:
      started: {}
      ended:
        attributes:
          result: WorkResult
  Batch:
    events:
      started: {}
      ended:
        attributes:
          result: WorkResult

Instrumentation API

The generated API represents WorkResult as a target-language record type. Both Task and Batch accept that type when emitting ended.

// 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"), "/records.rs"));
}

use instrumentation::{Batch, Context, Noop, Records, Task, WorkResult};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let context = Context::<Records>::try_new(Noop)?;
    let mut task = context.observer::<Task>().handle();
    let mut batch = context.observer::<Batch>().handle();

    task.started()?;
    task.ended(WorkResult {
        success: true,
        items_processed: 128,
    })?;

    batch.started()?;
    batch.ended(WorkResult {
        success: true,
        items_processed: 512,
    })?;

    Ok(())
}
Key point

A named record provides one reusable structure for event attributes.

Check yourself

What type do the Task and Batch ended events expect for result?

Why declare a record instead of repeating its fields?