nx_obs.nx
buildroot/runtime/nx_obs.nx
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
imports: nx_syscalls.nxnx_rand.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 46 | struct Span |
consts
| 31 | const LOG_MAGIC_1000000000: i64 = 1000000000 |
| 32 | const LOG_MAGIC_1000100000: i64 = 1000100000 |
| 33 | const LOG_MAGIC_1000200000: i64 = 1000200000 |
| 34 | const LOG_MAGIC_100000: i64 = 100000 |
| 35 | const LOG_MAGIC_1000500000: i64 = 1000500000 |
| 36 | const LOG_MAGIC_500000: i64 = 500000 |
| 39 | const LOG_TRACE: i64 = 0 |
| 40 | const LOG_DEBUG: i64 = 1 |
| 41 | const LOG_INFO: i64 = 2 |
| 42 | const LOG_WARN: i64 = 3 |
| 43 | const LOG_ERROR: i64 = 4 |
| 44 | const LOG_FATAL: i64 = 5 |
functions
| 58 | func span_new(name: *u8, name_len: i64, |
| 87 | func span_new_root(name: *u8, name_len: i64, start_ns: i64) -> *Span |
| 99 | func span_close(s: *Span, end_ns: i64, status: i64) -> i64 called by 1: main |
| 105 | func span_duration_ns(s: *Span) -> i64 called by 1: main |
| 113 | func log_write(fd: i64, level: i64, |
| 128 | func main() -> i64 |