feat(server): /metrics endpoint + HTTP request metrics#35
Open
Zorlin wants to merge 1 commit into
Open
Conversation
Concurrent PXE imaging can starve Dragonfly's HTTP serving pipeline, but there
was no visibility into it (no /metrics, only TraceLayer logs). Add a Prometheus
/metrics endpoint plus a request middleware that records, per bounded endpoint
label: in-flight gauge, request counter (method/status), and latency histogram.
Endpoint labels are a coarse classification of the path (classify), not the raw
path — /boot/{mac} is high-cardinality; collapsing to "boot"/"image"/"os_image"/
etc. keeps the histogram meaningful under a boot storm. Uses metrics +
metrics-exporter-prometheus (axum-prometheus was avoided: it dragged tower 0.5 +
tower-http 0.6 alongside the workspace's 0.4/0.5). The recorder handle is cached
in a OnceLock so /metrics needs no AppState change.
Wire: install the recorder at server start (run), register GET /metrics, and
apply the middleware as the outermost router layer.
Tests: classify truth-table + cardinality bound, and an end-to-end test driving
a request through the instrumented router and scraping /metrics for the
counter/histogram/labels. Full dragonfly-server suite green (193).
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Prometheus
/metricsendpoint + an HTTP request middleware so the servingpipeline — the surface that starves under concurrent PXE imaging — can be
scraped and bisected. Today there is zero visibility (no
/metrics; onlyTraceLayerINFO logs).Surface
GET /metrics(text/plain; version=0.0.4) exposes, per bounded endpointlabel:
http_requests_in_flight(gauge)http_requests_total(counter: method, status)http_request_duration_seconds(histogram)Endpoint labels are a coarse
classify()of the path — not the raw path(
/boot/{mac}is high-cardinality).boot/image/os_image/boot_debian_asset/pxelinux_config/ipxe_artifact/api/infra. Thiskeeps the latency histogram meaningful under a boot storm and lets us see which
serve surface saturates (the iPXE-script per-boot store read vs the big OS image
vs JIT QCOW2 conversion).
How
metrics+metrics-exporter-prometheus(avoidedaxum-prometheus— itdragged
tower 0.5+tower-http 0.6alongside the workspace's0.4/0.5).run); handle cached in aOnceLockso/metricsneeds noAppStatechange./metricsregistered as apublic route (no auth extraction — like the
/bootPXE endpoints).Tests
classifytruth-table + a cardinality-bound property test (1000 distinct MACs→ one
bootlabel)./metrics,assert 200 +
text/plain+ the counter/histogram/labels present.dragonfly-serversuite green (193).Why
First piece of the repeatable PXE-starvation harness — a Jetpack playbook repro
instrumented on controller / server / client. This is the server plane. Next:
jetpack controller telemetry + the repro/collect playbooks in
infra.🤖 Generated with Claude Code