Mojo struct
Trace
struct Trace[level: TraceLevel, *, category: TraceCategory = TraceCategory(4), target: Optional[StringSlice[StaticConstantOrigin]] = 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): 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,
Movable,
UnknownDestructibility
Aliases
__copyinit__is_trivial
alias __copyinit__is_trivial = False
__del__is_trivial
alias __del__is_trivial = False
__moveinit__is_trivial
alias __moveinit__is_trivial = False
Methods
__init__
__init__(out self, *, var _name_value: Variant[String, StringSlice[StaticConstantOrigin]], detail: String = "", parent_id: Int = 0, task_id: OptionalReg[Int] = None, color: Optional[Color] = None)
Creates a Mojo trace with the given name.
Args:
- _name_value (
Variant): 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 that is appended to name. - color (
Optional): Color of the trace span when visualized.
__init__(out self, var name: String, detail: String = "", parent_id: 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 of the trace span when visualized. - task_id (
OptionalReg): Int that is appended to name.
__init__(out self, name: StringSlice[StaticConstantOrigin], detail: String = "", parent_id: Int = 0, color: Optional[Color] = None, *, task_id: OptionalReg[Int] = None)
Creates a Mojo trace with the given static string name.
Args:
- name (
StringSlice): 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 of the trace span when visualized. - task_id (
OptionalReg): Int that is appended to name.
__init__(out self, name: StringLiteral[value], detail: String = "", parent_id: 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 of the trace span when visualized. - task_id (
OptionalReg): Int that is appended to name.
__enter__
__enter__(mut self)
Enters the trace context.
This begins recording of the trace event.
Raises:
If the operation fails.
__exit__
__exit__(self)
Exits the trace context.
This finishes recording of the trace event.
Raises:
If the operation fails.
mark
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
name(self) -> String
Returns the name of the trace.
Returns:
String: The name of the trace as a String.
start
start(mut self)
Start recording trace event.
This begins recording of the trace event, similar to enter.
Raises:
If the operation fails.
end
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!