nx_http_metrics.nx
buildroot/runtime/nx_http_metrics.nx
about
nx_http_metrics.nx -- Prometheus-text /metrics endpoint emitter.
Closes the observability triad: health (liveness) + ready
(readiness) + metrics (instrumentation). Companion to
nx_http_health.nx.
Per cardinal feedback-no-third-party-trust-native-or-nothing:
substrate's own metrics emitter following the Prometheus
exposition format (text/plain v0.0.4 per
prometheus.io/docs/instrumenting/exposition_formats/). No
Prometheus SDK; no OpenTelemetry SDK; no statsd. Substrate
produces the wire bytes; any Prometheus / Grafana / Mimir / Loki
consumer can scrape.
Per cardinal feedback-defensive-at-boundaries-trusting-internally:
metric NAMES are validated (ASCII alnum + underscore per spec);
metric VALUES are i64 (Q10 fixed-point friendly; substrate has
no FP). Float values would need nx_q10_to_fp_text (queued).
Metric format (Prometheus exposition v0.0.4):
# HELP <name> <human-text>
# TYPE <name> {counter|gauge|histogram|summary}
<name> <value>
<name>{label="value"} <value>
Substrate emits:
- counter monotonically-increasing i64
- gauge arbitrary i64 (may go up or down)
- (histogram + summary queued)
nx_capability_claims:
needs: [sealed_enum, bounded_buffer]
provides: [prometheus_text_metric_emit, metrics_observability]
safety: [no_unchecked_deref, no_floating_point, no_syscall,
bounded_iteration, bit_equal_reproducible,
target_agnostic, metric_name_validated]
verdict: [sealed_enum_5_state]
license: ORIGINAL
kind: racing_crew_specialist
dependencies 0 imports · 3 importers
imports: none
imported by: nx_audit_server_routed.nxnx_http_metrics_test.nxnx_wiki_routes.nx
structs
| none |
consts
| 45 | const NXM_OK: i64 = 0 |
| 46 | const NXM_OOM_BUFFER: i64 = 1 |
| 47 | const NXM_BAD_METRIC_NAME: i64 = 2 |
| 48 | const NXM_BAD_TYPE: i64 = 3 |
| 49 | const NXM_BAD_ARG: i64 = 4 |
| 50 | const NXM_VERDICT_N: i64 = 5 |
| 69 | const NXM_TYPE_COUNTER: i64 = 0 |
| 70 | const NXM_TYPE_GAUGE: i64 = 1 |
| 71 | const NXM_TYPE_HISTOGRAM: i64 = 2 |
| 72 | const NXM_TYPE_SUMMARY: i64 = 3 |
| 73 | const NXM_TYPE_N: i64 = 4 |
functions
| 52 | func nxm_verdict_is_valid(v: i64) -> i64 called by 1: main |
| 58 | func nxm_verdict_name(v: i64) -> *u8 |
| 75 | func nxm_type_is_valid(t: i64) -> i64 |
| 81 | func nxm_type_name(t: i64) -> *u8 |
| 89 | func nxm_type_name_len(t: i64) -> i64 |
| 104 | func nxm_is_name_start(b: i64) -> i64 |
| 111 | func nxm_is_name_cont(b: i64) -> i64 |
| 117 | func nxm_validate_name(name: *u8, name_n: i64) -> i64 |
| 131 | func nxm_put(out: *u8, off: *i64, cap: i64, b: i64) -> i64 |
| 138 | func nxm_put_cstr(out: *u8, off: *i64, cap: i64, s: *u8) -> i64 |
| 148 | func nxm_put_bytes(out: *u8, off: *i64, cap: i64, src: *u8, n: i64) -> i64 |
| 159 | func nxm_put_dec(out: *u8, off: *i64, cap: i64, |
| 194 | func nx_http_metrics_emit_one( |
| 277 | func nx_http_metrics_emit_response( |