ADR: Observability, the Admin tab
Status: roughed in 2026-09-01, the evening it was asked for. A polish pass
is planned for the Thursday build day; this records the shape and the
reasoning so the rough-in is a decision, not an accident.
In plain words
The site has a public Admin tab that shows its own condition: the health checks with how long each took, and what Azure reports about the running container. A third card lists recent server errors, kept in memory and cleared on each deploy.
What that is worth: a developer sees a slow check or a restart without opening the Azure portal, and the organization can show that the site reads its own state but can change nothing (Reader scope).
Context
The site could report its version but not its condition. The ask, verbatim:
health checks and errors, viewable from the website like an admin tab,
reaching through Azure.
Decision
An Admin tab in the header, a real screen with three cards that fetch and
fail independently:
- Application health. Hand-rolled probes behind /healthz (liveness),
/readyz (readiness), and /api/health (structured JSON: overall status,
each probe, uptime, version, commit). The container healthcheck now hits
/healthz. The framework health-check library is the planned upgrade; the
hand-rolled version shipped the same evening it was asked for.
- Azure's view of the container. The container group runs as a
user-assigned identity, that identity now holds Reader on its own
resource group, and the API trades the identity for a management-plane
token and reads its own container group: group state, container state,
restart count, and the image Azure believes it is running. Cached 60
seconds. Anywhere the identity endpoint does not exist, local dev
included, the card degrades to app-level health and says so.
- Recent server errors. Middleware records unhandled exceptions and 5xx
responses into a fixed 50-entry in-memory buffer served at /api/errors.
No stack traces are exposed. The buffer resets on every deploy and the
screen says that plainly.
The tab is public, no login. On this site the observability is the
exhibit, the same reasoning that serves the Bicep file from a menu. A real
product gates this behind authentication and ships errors to a persistent
sink; both are documented here and deliberately not built, the same
pattern as the undeployed production design.
Consequences
- The client id and resource path baked in as defaults are identifiers,
not secrets; a token for them can only be minted from inside the
container itself.
- Reader scope means the site can see itself but change nothing.
- The error buffer is honest about its limits, which is the demo working
as intended: the limits are part of the story.
Addendum, 2026-09-02: second pass, shipped as 1.0.0.17
After the first pass, Steve said he liked a screen where the health checks
are easy to see. The second pass makes the screen say more without
saying it louder.
- Every health check reports its duration. Each probe is timed with a
stopwatch and the Admin tab prints the milliseconds beside the check in
the muted style, so a slow disk or a slow lookup is visible before it
turns into a failure. The readiness endpoint uses the same probes and is
unchanged.
- Azure's card lists the container's recent events. The management
read already returned the container's instance view; the card now shows
its last three events, newest first, with the name, how many times it
happened, when it last happened, and the message trimmed to a line. A
restart story (pulled, started, killed, started again) reads from the
tab without opening the portal. Unavailable degrades exactly as before.
- The sweep. Five comments in Program.cs carried a double-encoded em
dash, and one of them a mangled "resume", from an encoding-blind edit on
the first day; they are plain ASCII now, changed byte by byte with
everything else in the file untouched.
The samples below are read from this build's source each time the page is
served (ADR: Live code samples). The timed checks
(api/TheYard.Api/Features/Health/HealthEndpoints.cs):
private static async Task<HealthCheckEntry[]> RunChecksAsync(HostPaths paths, Backends backends, CancellationToken cancellation, bool readinessOnly = false)
{
async Task<HealthCheckEntry> Check(string name, Func<CancellationToken, Task<bool>> probe, string detail, bool gatesReadiness = true)
{
if (readinessOnly && !gatesReadiness)
{
return new HealthCheckEntry(name, "pass", "not asked", 0, gatesReadiness);
}
var clock = Stopwatch.StartNew();
try { return new HealthCheckEntry(name, await probe(cancellation) ? "pass" : "fail", detail, clock.ElapsedMilliseconds, gatesReadiness); }
catch (Exception ex) { return new HealthCheckEntry(name, "fail", ex.GetType().Name, clock.ElapsedMilliseconds, gatesReadiness); }
}
var checks = new List<HealthCheckEntry>
{
await Check("dataset file", _ => Task.FromResult(File.Exists(paths.DataPath)), "data/vehicles.json present"),
await Check("docs", _ => Task.FromResult(File.Exists(Path.Combine(paths.RepoRoot, "docs", "hosting", "HOSTING.md"))), "served documents findable"),
await Check("photo manifest", _ => Task.FromResult(File.Exists(paths.ManifestPath)), "image manifest present"),
await Check("catalogue", _ => Task.FromResult(backends.Default.CatalogueLoaded), "the default store's catalogue is loaded"),
};
foreach (var backend in backends.All)
{
checks.Add(await Check(
ReferenceEquals(backend, backends.Default) ? "database" : $"database ({backend.Key})",
backend.Probe,
backend.Database.Ready
? $"the seed catalogue is in the store ({backend.Name})"
: $"{backend.Name} is unavailable, serving the catalogue from files; "
+ "the reason is in the log",
gatesReadiness: false));
}
return checks.ToArray();
}
Live from api/TheYard.Api/Features/Health/HealthEndpoints.cs, region health-checks, read from this build at 99df7a8.
The events, read from the same management response (the observability
types moved to
api/TheYard.Api/Shared/Observability/Observability.cs
in ADR: The staff review):
if (civ.TryGetProperty("events", out var evs) && evs.ValueKind == JsonValueKind.Array)
{
events = evs.EnumerateArray()
.Select(e => new
{
name = e.TryGetProperty("name", out var n) ? n.GetString() ?? "" : "",
count = e.TryGetProperty("count", out var c) && c.TryGetInt32(out int ci) ? ci : 1,
last_at = e.TryGetProperty("lastTimestamp", out var lt) ? lt.GetString() ?? "" : "",
message = Trim(e.TryGetProperty("message", out var msg) ? msg.GetString() ?? "" : "", 140),
})
.OrderByDescending(e => e.last_at, StringComparer.Ordinal)
.Take(3)
.Cast<object>()
.ToList();
}
Live from api/TheYard.Api/Shared/Observability/Observability.cs, region azure-events, read from this build at 99df7a8.
The proof is one API test that every check carries a non-negative
duration and two end-to-end checks that the Admin tab prints it, on a
laptop and on a phone, in
api/TheYard.Tests/AdminEndpointTests.cs,
tests/e2e/admin.spec.ts
and tests/e2e/mobile.spec.ts.
The events list is proven by the live site, since only the container on
Azure can ask about itself.
Where it sits
Everything this record built lives in the host Api and the front end: the probes in Endpoints/HealthEndpoints.cs, the ErrorRingBuffer and the AzureSelf reader in Observability.cs, and the cards under src/components/admin. Each card fetches and fails on its own, so one broken reading never blanks the tab. No port was needed because the container reads its own memory and its own Azure resource, and the price is an error buffer that empties on every deploy. Errors that must survive a roll are the reason to choose differently, and that is the job ILogStore, an Application port, now does for logs that outlive the container.
The look, from the live site

The health card, from the fetch to the rows
(src/components/admin/HealthCard/HealthCard.tsx, a chunk of its own since the workbench):
<article className={`${styles.card} op-glass`} data-testid="health-card">
<h2 className={styles.cardTitle}>Application health</h2>
<Range of="keptWarm" />
{health === null ? (
<CardState state="loading" />
) : health === 'failed' ? (
failed('the health report')
) : (
<>
<p className={styles.statusRow}>
<span className={pill(health.status === 'healthy')}>{health.status}</span>
<span className={styles.muted}>
v{health.version} · {health.commit} · up {formatUptime(health.uptime_seconds)}
</span>
</p>
<ul className={styles.checkList}>
{health.checks.map((check) => (
<li key={check.name} className={styles.healthRow}>
<span className={pill(check.status === 'pass')}>{check.status}</span>
<span>{check.name}</span>
<span className={styles.muted}>{check.detail}</span>
<span className={styles.duration} data-testid="check-duration">
{check.duration_ms} ms
</span>
</li>
))}
</ul>
{/* The keep-warm loop's last pass (ADR: Kept awake). */}
<p className={styles.muted} data-testid="kept-warm">
{keptWarmLine(health.kept_warm)}
</p>
</>
)}
</article>
Live from src/components/admin/HealthCard/HealthCard.tsx, region health-card, read from this build at 99df7a8.
Addendum, 2026-10-07 (1.0.3.89): ready means the catalogue is in
The process listens before its catalogue loads (ADR: The ports learn to wait, the addendum on listening first), so /readyz gained one check that gates it, catalogue, which passes once the default store's hundred thousand vehicles are in memory. /healthz still answers the moment the process is up. /api/health shows the new check beside the others, and since it is an API read it waits for the load like every other, so the Admin tab sees the check pass; it is /readyz that says 503 while a fresh container loads. The deploy waits on /readyz before it reads the filters, and a blue-green swap will wait on the same thing.
Addendum, 2026-10-29: the error ring has its own file, and the Azure read takes a token
Two changes, both forced by a rung rather than chosen for this record's own reasons.
Observability.cs was 294 lines, four inside the three-hundred cap, and the cancellation rung
needed three parameters in it. A split made under the pressure of an unrelated change is made by
the alphabet instead of by job, so it was made first and by job: ErrorEntry, StackFrames and
ErrorRingBuffer are now
api/TheYard.Api/Shared/Observability/ErrorRing.cs,
which changes when what is recorded about a failure changes. Observability.cs keeps its name,
the health probe's outcome, the site asking Azure about itself, and an index of its parts. The
azure-events region a live sample on this page reads was left where it is.
AzureSelf.GetStateAsync takes the cancellation of the poll that asked and carries it to the
token exchange and to all three reads, so a card the Admin tab has stopped drawing stops asking
Azure about this web app. It caches for sixty seconds either way, so the saving is a connection
and not a read.
Addendum, 2026-11-11 (1.0.5.24): the Azure card's view is kept built
What stopped being true: the addendum of 2026-10-29 says AzureSelf caches for sixty seconds. A 48-hour probe read /api/admin/azure at a cold p95 of 4.3 to 4.5 s, the token and the three reads made on the request each time the minute lapsed. From this version the card's view is kept the way the Cloud cards' are (ADR-102, the addendum of this version): under two minutes old it answers at once, past one minute the next is read behind the request, and one keeper reads it again each minute while somebody has asked in the last hour. A read Azure refuses is answered as available false and never kept, so a refusal never replaces a view the card already has. The poll's cancellation now stops only a read the request waits on.
Correction, 1.0.5.25: the paragraph above says the poll's cancellation stops a read the request waits on. From this version a request's cancellation ends only its own wait: the read goes on under two minutes and the host's stopping, other requests and the keeper share it, and its view is kept for the next request (ADR-102, the addendum of this version).
Enforced by
Not machine-checked. Held by review.