Skip to main content

completion_parent_span

Macro completion_parent_span 

Source
macro_rules! completion_parent_span {
    (
        target: $target:literal,
        parent: $parent:expr,
        name: $name:literal,
        operation: $operation:expr,
        system_instructions: $system:expr
        $(, $($extra:tt)*)?
    ) => { ... };
    (
        target: $target:literal,
        name: $name:literal,
        operation: $operation:expr,
        system_instructions: $system:expr
        $(, $($extra:tt)*)?
    ) => { ... };
}
Expand description

Declares a completion-parent span with the marker and all required fields. Defaults to the current span as parent. An optional parent: <expr> between target and name accepts any parent supported by tracing::info_span!, including None.

Records the supplied operation and system instructions. Provider and model fields are populated on adoption. Extra fields must not duplicate the marker or required fields: recording a duplicate name updates only its first field. Use Empty or Option::<&str>::None for unset values without a direct tracing dependency.

use rig_core::telemetry::completion_parent_span;

let span = completion_parent_span!(
    target: "my_runtime",
    name: "chat",
    operation: "chat",
    system_instructions: Option::<&str>::None,
    gen_ai.agent.name = "assistant",
);