obs.nx
buildroot/runtime/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: syscalls.nxrand.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 34 | struct Span { |
consts
| 27 | const LOG_TRACE: i64 = 0 |
| 28 | const LOG_DEBUG: i64 = 1 |
| 29 | const LOG_INFO: i64 = 2 |
| 30 | const LOG_WARN: i64 = 3 |
| 31 | const LOG_ERROR: i64 = 4 |
| 32 | const LOG_FATAL: i64 = 5 |
functions
| 46 | func span_new(name: *u8, name_len: i64, |
| 75 | func span_new_root(name: *u8, name_len: i64, start_ns: i64) -> *Span { |
| 87 | func span_close(s: *Span, end_ns: i64, status: i64) -> i64 {
called by 1: main |
| 93 | func span_duration_ns(s: *Span) -> i64 {
called by 1: main |
| 101 | func log_write(fd: i64, level: i64, |
| 116 | func main() -> i64 { |