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 args carry 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: BaseModel

Single 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: BaseModel

Human‑readable event record for reports.

This is a convenient representation used by s6.utils.profiler export 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