Skip to content

Add health_details: server and stream details in the readiness probes (#144) - #155

Merged
bpacholek merged 1 commit into
mainfrom
fix-144-health-details
Sep 27, 2026
Merged

bpacholek merged 1 commit into
mainfrom
fix-144-health-details

Conversation

@bpacholek

Copy link
Copy Markdown
Contributor

Summary

Closes #144.

To learn which nats-server a NUTS instance is connected to, or what its stream's limits and state are, an operator had to query NATS separately. Some behaviour now depends on the server version; for example, a restore keeps or replaces the creation time depending on the server (#137). Seeing it from NUTS helps triage.

Changes

  • New directive health_details [bool], off by default. With it, ready_path and health_path add:
    • nats_server: version, name, cluster, domain.
    • stream_info: subjects, storage, replicas, message and byte counts, first and last sequence, consumers, max_msgs, max_bytes, max_age_seconds, max_consumers, creation time.
  • No extra request. The stream details come from the stream-info read the probe already makes.
  • Degraded probes. nats_server is left out while disconnected, and stream_info when the stream cannot be read. The status fields and codes are unchanged.
  • Why off by default. Probe paths are often public, and the details name servers, clusters and limits. The README says so and suggests restricting the paths with Caddy matchers.
  • Left out on purpose. A Prometheus nats_server_info metric (mentioned in the issue) would need its own design: several handlers share process-wide metrics, and a server label goes stale after a reconnect.
  • Plumbing. Parsed in caddyfile.go (no argument means true). Documented in the README (listing, probes section with an example), CONFIGURATION, the website and the CHANGELOG. A new /details route in Caddyfile.test, and a "the response should not contain" step.

Tests

  • TestHandler_HealthDetails, against an embedded server with JetStream domain hub, cluster name east, a stream with limits and one durable consumer:
    • every field of both objects;
    • no details without the directive;
    • a stream that cannot be read gives 503 with the server and no stream;
    • a disconnected handler gives 503 without a server.
  • Directive. Caddyfile rows: the full config, an explicit true, and a non-boolean value that is rejected.
  • Functional. The scenario "Readiness details are opt-in", comparing /details/readyz with /events/readyz; 34/34. The full suite passes under -race; lint is clean.
  • Mutation.
    • gremlins: caddyfile.go 41/0, serve.go 220/0.
    • 22 hand mutants, all killed: each of the 18 fields, both branches, and both Caddyfile assignments.
  • Example stack. /details/readyz reports nats-server 2.15.0 and the example's memory stream (max_msgs 10000, max_age_seconds 3600, max_consumers 10000). /events/readyz is unchanged.

🤖 Generated with Claude Code

…#144)

To learn which nats-server a NUTS instance is connected to, or what its
stream's limits and state are, an operator had to query NATS separately.
Some behaviour now depends on the server version (a restore keeps or
replaces the stream's creation time depending on the server), so seeing
it from NUTS helps triage.

health_details adds nats_server (version, name, cluster, domain) and
stream_info (subjects, storage, replicas, message and byte counts, first
and last sequence, consumers, limits, creation time) to the readiness
probes' JSON. The stream details come from the read the probe already
makes, so there is no extra request. nats_server is left out while
disconnected, and stream_info when the stream cannot be read. Off by
default: probe paths are often public, and the details name servers,
clusters and limits.

Closes #144

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@bpacholek
bpacholek merged commit f6cc5da into main Sep 27, 2026
5 checks passed
@bpacholek
bpacholek deleted the fix-144-health-details branch September 27, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose the NATS server version and stream details in the readiness output, behind an opt-in

1 participant