Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions docs/MONITORING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ Suggested schedule: every 1–5 minutes. Alert on consecutive failures (e.g. 2).

## Protect the route from amplification

`createStorePingCheck` performs a real write plus a read on every call — that is
the point, a connectivity ping would lie. It also means each request to the
public route costs one storage write against a metered backend. Hosts SHOULD put
rate limiting (or a short response cache, a few seconds) in front of the route,
or expose the store ping only on a route scraped by trusted monitors. This
package deliberately owns no rate limiter.
`createStorePingCheck` performs a real write plus a read for each probe
execution — that is the point, a connectivity ping would lie. It also means
requests to the public route can cost storage writes against a metered backend.
Hosts SHOULD put rate limiting (or a short response cache, a few seconds) in
front of the route, or expose the store ping only on a route scraped by trusted
monitors. This package deliberately owns no rate limiter.

Construct `createStorePingCheck` once at the composition root and reuse that
Comment thread
FlyOverCoderKY marked this conversation as resolved.
Resolved
check for every request. Concurrent calls to one check share the same in-flight
round trip and its reported latency. By default, each constructed check receives
its own probe record id, so replicas using the same health collection do not
overwrite one another. A verified row is conditionally removed after the round
trip. Pass an explicit `id` when a host needs a stable key, and keep that id
distinct among simultaneously running replicas. Earlier releases used `ping` as
the default; pass `id: "ping"` to retain that key intentionally.

`degraded` still returns HTTP 200 with `ok: true`. If you want to page on
degraded storage/logging, add a JSON assertion on `$.status` or a log monitor
Expand Down
12 changes: 10 additions & 2 deletions packages/health/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ logged through the injected `Logger` only, never placed in the public body. A
check must settle, though: `runHealthChecks` imposes no deadline of its own, so
bound your own I/O the way `createStorePingCheck` bounds its `timeoutMs`.

`createStorePingCheck` writes and reads on every call, so a host serving it on a
public route SHOULD rate limit or briefly cache that route — see
`createStorePingCheck` performs a write-and-read round trip for each probe
execution, so a host serving it on a public route SHOULD rate limit or briefly
cache that route — see
[`docs/MONITORING.md`](https://github.com/pegma-dev/health/blob/main/docs/MONITORING.md).
Construct the check once at the composition root and reuse it for every health
request. Concurrent callers share one execution and its `latencyMs`. The default
record id is unique to that check instance, which keeps replicas from sharing a
probe row, and a verified row is conditionally removed after the round trip.
Pass an explicit `id` when the host needs a stable key; keep that id distinct
among simultaneously running replicas. Earlier releases used `ping` as the
default, so pass `id: "ping"` to retain that key intentionally.
Loading
Loading