For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo struct
Trace
struct Trace[level: TraceLevel, *, category: TraceCategory = TraceCategory.MAX, target: Optional[StringSlice[ImmStaticOrigin]] = None]
An object representing a specific trace.
This struct provides functionality for creating and managing trace events for profiling and debugging purposes.
Parametersβ
- βlevel (
TraceLevel): The trace level to use. - βcategory (
TraceCategory): The trace category to use (defaults to TraceCategory.MAX). - βtarget (
Optional[StringSlice[ImmStaticOrigin]]): Optional target information to include in the trace.
Fieldsβ
- βint_payload (
OptionalReg[Int]): Optional integer payload, typically used for task IDs that are appended to trace names. - βdetail (
String): Additional details about the trace event, included when detailed tracing is enabled. - βevent_id (
Int): Unique identifier for the trace event, assigned when the trace begins. - βparent_id (
Int): Identifier of the parent trace event, used for creating hierarchical trace relationships. - βcolor (
Optional[Color]): Color of the trace span in NSight Systems viewer, only used for NVTX markers.
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable
Methodsβ
__init__β
def __init__(out self, *, var _name_value: Variant[String, StringSlice[ImmStaticOrigin]], detail: String = "", parent_id: Int = Int(0), task_id: OptionalReg[Int] = None, color: Optional[Color] = None)
Creates a Mojo trace with the given name.
Args:
- β_name_value (
Variant[String, StringSlice[ImmStaticOrigin]]): The name that is used to identify this Mojo trace. - βdetail (
String): Details of the trace entry. - βparent_id (
Int): Parent to associate the trace with. Trace name will be appended to parent name. 0 (default) indicates no parent. - βtask_id (
OptionalReg[Int]): Int that is appended to name. - βcolor (
Optional[Color]): Color of the trace span when visualized.
def __init__(out self, var name: String, detail: String = "", parent_id: Int = Int(0), color: Optional[Color] = None, *, task_id: OptionalReg[Int] = None)
Creates a Mojo trace with the given string name.
Args:
- βname (
String): The name that is used to identify this Mojo trace. - βdetail (
String): Details of the trace entry. - βparent_id (
Int): Parent to associate the trace with. Trace name will be appended to parent name. 0 (default) indicates no parent. - βcolor (
Optional[Color]): Color of the trace span when visualized. - βtask_id (
OptionalReg[Int]): Int that is appended to name.
def __init__(out self, name: StringSlice[ImmStaticOrigin], detail: String = "", parent_id: Int = Int(0), color: Optional[Color] = None, *, task_id: OptionalReg[Int] = None)
Creates a Mojo trace with the given static string name.
Args:
- βname (
StringSlice[ImmStaticOrigin]): The name that is used to identify this Mojo trace. - βdetail (
String): Details of the trace entry. - βparent_id (
Int): Parent to associate the trace with. Trace name will be appended to parent name. 0 (default) indicates no parent. - βcolor (
Optional[Color]): Color of the trace span when visualized. - βtask_id (
OptionalReg[Int]): Int that is appended to name.
def __init__(out self, name: StringLiteral, detail: String = "", parent_id: Int = Int(0), color: Optional[Color] = None, *, task_id: OptionalReg[Int] = None)
Creates a Mojo trace with the given string literal name.
Args:
- βname (
StringLiteral): The name that is used to identify this Mojo trace. - βdetail (
String): Details of the trace entry. - βparent_id (
Int): Parent to associate the trace with. Trace name will be appended to parent name. 0 (default) indicates no parent. - βcolor (
Optional[Color]): Color of the trace span when visualized. - βtask_id (
OptionalReg[Int]): Int that is appended to name.
__enter__β
def __enter__(mut self)
Enters the trace context.
This begins recording of the trace event.
Raises:
If the operation fails.
__exit__β
def __exit__(self)
Exits the trace context.
This finishes recording of the trace event.
markβ
def mark(self)
Marks the tracer with the info at the specific point of time.
This creates a point event in the trace timeline rather than a range.
Raises:
If the operation fails.
nameβ
def name(self) -> String
Returns the name of the trace.
Returns:
String: The name of the trace as a String.
startβ
def start(mut self)
Start recording trace event.
This begins recording of the trace event, similar to enter.
Raises:
If the operation fails.
endβ
def end(mut self)
End recording trace event.
This finishes recording of the trace event, similar to exit.
Raises:
If the operation fails.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!