code wiki / (root) / obs.nx

obs.nx

buildroot/runtime/obs.nx

4453 B133 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

obs.nx -- observability primitives (spans, structured logs). EFFICIENCY_ROADMAP ยง5.2. OpenTelemetry-style distributed tracing + structured logging. Today's observability is ad-hoc sys_write; this module lands a proper API with trace IDs, parent-child span relationships, + KV attributes. Phase A: runtime spans + log records serialised to stdout as JSON (or future Protobuf via protobuf_wire.nx). Phase B: `@trace` function attribute auto-instruments every call. Designed to match OpenTelemetry data model so future bridges to Jaeger / Honeycomb / Datadog are clean byte-copies. Invariants: OB1 Span IDs are 128-bit; collision probability at one million spans/sec for a year < 1 in 10^30. OB2 Parent-child relationships form a tree per trace_id (enforced by caller; runtime doesn't verify). OB3 Log records are structured: all fields get key+value; no printf-style interpolation (bad for aggregation).

dependencies 2 imports · 0 importers

syscalls.nx rand.nx obs.nx

imports: syscalls.nxrand.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main span_new_root rand_bytes rand_open_urandom sys_read span_new rand_bytes ↻ span_new ↻ span_close span_duration_ns

structs

34struct Span {

consts

27const LOG_TRACE: i64 = 0
28const LOG_DEBUG: i64 = 1
29const LOG_INFO: i64 = 2
30const LOG_WARN: i64 = 3
31const LOG_ERROR: i64 = 4
32const LOG_FATAL: i64 = 5

functions

46func span_new(name: *u8, name_len: i64,
called by 2: span_new_rootmain calls 1: rand_bytes
75func span_new_root(name: *u8, name_len: i64, start_ns: i64) -> *Span {
called by 1: main calls 2: rand_bytesspan_new
87func span_close(s: *Span, end_ns: i64, status: i64) -> i64 {
called by 1: main
93func span_duration_ns(s: *Span) -> i64 {
called by 1: main
101func log_write(fd: i64, level: i64,
116func main() -> i64 {