Build services Browse docs
On this page 4 sections
Build services
Observability
Counters, latency buckets, and per-route costs with zero instrumentation. What system.* measures, what the ledger records, and how a percentile is estimated.
Every server measures itself: request counts, average latency, active workers, per-route costs, with zero instrumentation code from you. This page covers system.*, /_ledger and rate budgets. It also covers how to read a percentile: the value is estimated inside the bucket that holds its rank, and it is not a single-request measurement.
Counters, not magic
system.* calls read live runtime counters. Every value is measured. Responses are split by class at the send path: system.http_requests_ok() counts responses below 400, and system.http_requests_error() counts responses at or above 400 (runtime/builtins.c:546-554). A route reads them like any other counter:
route GET "/metrics" {
val total = system.http_requests_total()
val latency = system.latency_avg_us()
val workers = system.active_workers()
return ok { metrics: { http_requests_total: total, latency_avg_us: latency, active_workers: workers } }
}
Real run after three requests, canned and labeled:
curl http://127.0.0.1:8080/metrics
{"metrics":{"http_requests_total":3,"latency_avg_us":358,"active_workers":8}}
Percentiles are estimates
The histogram counts latencies in 1000 buckets of 100 µs up to 100 ms, then 20 buckets of doubling width (runtime/performance.h:164-171). The state is two arrays of 1020 slots: a count and a sum of the microseconds each bucket received. The estimate anchors on that bucket’s mean and spreads by rank, as mean + width * (rank - half) / count, clamped to the bucket edges (runtime/performance.h:225-267). A bucket holding one request answers that request. A uniform spread inside a bucket answers within one rank step of the value at that rank. The rules:
system.latency_p50_us(),latency_p95_us()andlatency_p99_us()read the same histogram.- The rank is the request count times 500, 950 or 990 per mille, rounded up.
- The estimate never leaves its bucket: below the low edge it answers the low edge, above the high edge it answers the high edge.
- Only the final bucket has no upper edge of its own. It starts near 14.6 h and answers the recorded max.
- Every counter reads
0before the first request. - The mean shares the request log’s approximate clock basis (RDTSC cycles on a 2.5 GHz basis — approximate on other clocks).
| Call | Returns | Source |
|---|---|---|
system.uptime() |
int seconds since process start |
monotonic clock |
system.pid() |
int process id |
OS |
system.active_workers() |
int workers configured at startup (0 outside servers) |
server startup |
system.http_requests_total() |
int completed requests |
request counter |
system.http_requests_ok() |
int responses below 400 |
counted at the send path |
system.http_requests_error() |
int responses at or above 400 |
counted at the send path |
system.latency_avg_us() |
int mean latency, microseconds |
RDTSC cycles, same basis as the request log |
system.latency_p50_us() |
int median estimate, microseconds |
100 µs histogram, bucket mean spread by rank |
system.latency_p95_us() |
int 95th-percentile estimate |
same histogram and rule |
system.latency_p99_us() |
int 99th-percentile estimate |
same histogram; the final bucket answers the recorded max |
The ledger
The ledger is a table of what each route costs per request. Every server records it automatically, with no annotations. Two endpoints return it:
| Endpoint | Returns |
|---|---|
/_ledger |
a live table (loopback only) |
/_ledger/data |
the same data as JSON |
Columns: requests, mean ms, p50/p95/p99 µs, DB share, energy, source. The JSON also carries per-route arena_overflow and arena_max_bytes (how much memory the route’s requests needed), plus top-level energy_source and energy_note. The table holds at most 64 routes.
There is no built-in /metrics endpoint: the one above is a route you write. The runtime also serves a /_pulse dashboard with its JSON feed at /_pulse/data, which reports request counts and cycle totals.
The per-route percentiles use the same estimate rule over 64 log2 buckets of handler cycles, one bucket per power of two (runtime/ledger.c:103-149). The final ledger bucket answers its own recorded mean. The process-wide final bucket answers the recorded max instead. Milliseconds and percentiles share the request log’s approximate clock basis. The energy column reads joules per request (estimated route share) where a power sensor exists, and a labeled CPU proxy in cycles where it does not. The proxy is never converted to joules.
Budgets in one board
Rate budgets (limit/burst on the route, enforced per source IP by the admission gate) and telemetry belong together: the budget decides which requests run, the counters record what they cost. One board, both halves — snippet, counters, ledger columns, and the two gate scenarios from blog_api.orb:
route GET "/health" limit 20 / s burst 20 {
return ok 200 """{"status":"UP"}"""
}
route GET "/gate-burst" limit 5 / s burst 5 {
return ok 200 """{"status":"burst-ok"}"""
}
| Call | Returns | Source |
|---|---|---|
system.uptime() |
int seconds since process start | monotonic clock |
system.pid() |
int process id | OS |
system.active_workers() |
int workers at startup (0 outside servers) | server startup |
system.http_requests_total() |
int completed requests | request counter |
system.http_requests_ok() |
int responses below 400 | counted at the send path |
system.http_requests_error() |
int responses at or above 400 | counted at the send path |
system.latency_avg_us() |
int mean latency, microseconds | RDTSC cycles, 2.5 GHz basis |
system.latency_p50_us() |
int median estimate, microseconds | 100 us histogram, bucket mean spread by rank |
system.latency_p95_us() |
int 95th-percentile estimate | same histogram and rule |
system.latency_p99_us() |
int 99th-percentile estimate | same histogram; final bucket answers the recorded max |
Ledger columns
requests, mean ms, p50/p95/p99 us, DB share, energy, source
Every value is measured on orbit 0.1.0 from
feature/0.1.0-stability at 31591e66
(2026-11-08). A percentile is estimated inside the bucket that holds its rank.
Each bucket keeps a count and a sum, so the estimate anchors on the bucket's
recorded mean and spreads by rank, clamped to the bucket edges. A bucket holding
one request answers that request. The last bucket answers the recorded max for
these counters, and its own mean for the per-route ledger. Process-wide
system.latency_p*_us reads 1000 buckets of 100 us plus
20 doubling buckets from 100 ms. The per-route ledger reads 64 log2 buckets of
handler cycles. No percentile is a single-request measurement.
20/s — window 1000 ms, burst 20
Outcome
200 sustained, no drops
5/s — window 1000 ms, burst 5
Outcome
429s past burst, always trips
The full annotation contract — units (ms/s/sec/min, default window 1000 ms, burst defaults to rate), the 32-annotated-route cap with admission_route_limit_drops, compiler rejection of non-positive rates — lives on the routes page. What the ledger cannot tell you, 0.1.0 cannot do yet — see limits.
What next
The command reference lists every command, its flags, and the 0/1/2 exit matrix.