s6.schema.trace¶
Chrome Trace schema used by Sense Core profiling.
Defines lightweight Pydantic models that mirror the Chrome Trace Event
format so we can serialize profiler spans to a browserâinspectable trace
(about://tracing). The TraceEvent model matches the wire format,
while ReadableEvent is a friendlier record used when exporting
humanâreadable metrics.
Key concepts¶
Events use microsecond timestamps and have a phase:
'B'(begin) or'E'(end).Optional
argscarry arbitrary metadata for viewers and analysis.
- class s6.schema.trace.TraceEvent(*, name: str, cat: str = 'profiling', ph: Literal['B', 'E'], ts: ConstrainedFloatValue, pid: ConstrainedIntValue = 0, tid: ConstrainedIntValue = 0, args: Dict[str, Any] | None = None)
Bases:
BaseModelSingle Chrome Trace event record.
This model mirrors the Chrome Trace Event schema and is suitable for direct JSON emission to viewers compatible with the trace event profiling tool.
- name
Event name shown in trace viewers.
- Type:
str
- cat
Category string used to group or filter events. Defaults to
"profiling".- Type:
str
- ph
Phase code:
"B"for begin,"E"for end.- Type:
{âBâ, âEâ}
- ts
Timestamp in microseconds since program start (nonânegative).
- Type:
float
- pid
Process identifier (nonânegative).
- Type:
int
- tid
Thread identifier (nonânegative).
- Type:
int
- args
Optional metadata for viewers and downstream tooling.
- Type:
dict[str, Any] | None
Notes
See the Chrome trace event documentation for full schema details.
- name: str
- cat: str
- ph: Literal['B', 'E']
- ts: float
- pid: int
- tid: int
- args: Dict[str, Any] | None
- class Config
Bases:
object- extra = 'ignore'
- allow_population_by_field_name = True
- validate_all = True
- class s6.schema.trace.ReadableEvent(*, event_name: str, event_type: Literal['begin', 'end'], relative_time_ms: ConstrainedFloatValue, depth: ConstrainedIntValue | None = None, metadata: Dict[str, Any] = None, full_path: str)
Bases:
BaseModelHumanâreadable event record for reports.
This is a convenient representation used by
s6.utils.profilerexport helpers to produce tabular summaries and logs. Times are relative to process start in milliseconds and the phase is expanded to{"begin", "end"}.- event_name
Name of the event span.
- Type:
str
- event_type
Humanâreadable phase.
- Type:
{âbeginâ, âendâ}
- relative_time_ms
Time since program start, in milliseconds (nonânegative).
- Type:
float
- depth
Optional nesting depth for hierarchical spans.
- Type:
int | None
- metadata
Additional metadata excluding depth.
- Type:
dict[str, Any]
- full_path
Slashâseparated scope path, e.g.
"stage/inner".- Type:
str
- event_name: str
- event_type: Literal['begin', 'end']
- relative_time_ms: float
- depth: int | None
- metadata: Dict[str, Any]
- full_path: str
- class Config
Bases:
object- extra = 'ignore'
- allow_population_by_field_name = True
- validate_all = True