feat(observability): RuntimeAddOns trait with a Prometheus add-on#192
Open
mfw78 wants to merge 1 commit into
Open
feat(observability): RuntimeAddOns trait with a Prometheus add-on#192mfw78 wants to merge 1 commit into
mfw78 wants to merge 1 commit into
Conversation
Move the Prometheus install out of the launch path and into a PrometheusAddOn behind a RuntimeAddOns trait. install reads the resolved metrics config from AddOnsContext and preserves the recorder-versus-listener behaviour: an HTTP listener when enabled, the recorder alone otherwise so metric call sites stay live. The launcher takes the add-on list as a parameter, so the composition root chooses the set and an embedder omits or replaces it. AddOnsContext and the AddOnHandle guard slot leave room for a future control-surface add-on.
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.
Summary
Closes #91.
Adds a
RuntimeAddOnstrait and moves the Prometheus install logic behind it, so an embedder can now choose which add-ons run instead of the runtime hard-coding Prometheus.This is part of the epic #79 train and merges in stack order: this PR targets
feat/m0-component-builders, which itself targets the chain-log PR.Changes
crates/nexum-runtime/src/addons.rswithRuntimeAddOns(a singleinstall(&self, ctx: &AddOnsContext<'_>) -> anyhow::Result<AddOnHandle>method),AddOnsContext<'a>(carries the resolved&MetricsSection),AddOnHandle(a name plus an optional guard slot reserved for a future add-on's shutdown handle), andPrometheusAddOn.PrometheusAddOn::installunchanged in behaviour: the enabled path callswith_http_listener(addr).install()and logs, the disabled path callsinstall_recorder()into a discarded sink.bootstrap::runnow takes anadd_ons: &[&dyn RuntimeAddOns]parameter, installs each add-on before engine boot in the order given, and holds the returned handles until shutdown.nexum-cli's launch path and theembed.rsexample, to pass[&PrometheusAddOn]. The example comment notes that an embedder can pass&[]to omit add-ons entirely or a different list to replace Prometheus.nexum-runtime::lib.Test plan
cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features --no-fail-fast(all green, including the supervisor e2e suite)embed.rsexample buildsNotes for reviewer
The issue text specified the trait and the move but did not specify how an embedder would omit or replace the add-on. I realised that by threading the add-on list into
bootstrap::runas a parameter chosen at the composition root, rather than hard-coding a default set insiderun. This adds one parameter torunand touches its two callers; there is no behaviour change for the shipped binary, since both callers still pass[&PrometheusAddOn].AddOnHandle's guard field is public and currently unused byPrometheusAddOn(which manages its own listener task and returns an empty guard). It is the documented seam for a future control-surface add-on to stash a listener or shutdown handle; that add-on is not part of this change.One known gap: the crate's e2e coverage (
shepherd-cow-host) boots viaSupervisor::boot_singleand never callsbootstrap::run, so no automated test currently exercises the add-ons install path end to end. This is a pre-existing gap in that suite, not something introduced here.AI Assistance: Claude Code (Opus 4.8 implementation and adversarial review, Sonnet 5 PR authoring) used for the full change.