Skip to content

test(server): prove audit_log.trace_id is populated from the caller's traceparent (#840) - #841

Merged
athvin merged 3 commits into
mainfrom
issue/840-traceid-gate
Nov 8, 2026
Merged

athvin merged 3 commits into
mainfrom
issue/840-traceid-gate

Conversation

@athvin

@athvin athvin commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Closes #840

🚧 Claimed by an agent session — 2026-11-08T05:43:53Z, session 01a1b892-4cde-7a53-bb3e-9ed2e764acdc on Mac.
The claim is this open draft PR: closing it releases the ticket.

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Why

Proof

Risk & rollback

Post-merge ledger

Closed by: agent · session 01a1b892-4cde-7a53-bb3e-9ed2e764acdc on Mac · 2026-11-08T07:40:00Z

  • main is green with this change on it — merge SHA dc394ccd; its own rust push run was cancelled by the next merge landing on top, so the proof is the later-head rule: 7fdf5b32 (child of dc394ccd) has rust 42458642997, frontend 42458643044, infra 42458643036, devcontainer 42458642983, images 42458643027, deploy 42458919308 — all success.
  • images built — 42457534130 success on the merge SHA (rebuilt on the er-obs source touch; the changed module is test-support-gated, so the runtime payload is unchanged).
  • deploy converged — process-emitted line, not the workflow conclusion: 2026-11-08T07:14:00Z INFO er-server listening addr=0.0.0.0:8000 in /er/dev/containers from the pod the deploy (42457784287) rolled out; deploy itself success at 07:15:26Z.
  • the push-only surface no pull request can pre-test — deploy success (above); drift last scheduled 2026-11-07 success; kind nightly green 2026-11-07 + dispatch-verified 2026-11-08 (this session's The kind probe has never passed in CI — land the first green run and re-decide its gate status #655); Agentic Maintenance intermittently red pre-existing, scheduled, unrelated.
  • the board card reached Done through the automation rather than by hand — gh project item-list 2 --owner athvin: gate: prove audit_log.trace_id is populated — pg_orgs.rs phase (from #660) #840 at Done; the issue closed on merge.
  • follow-ups are open for everything deferred here — none from this diff; the live re-probe stays on The request span starts a new trace instead of continuing the caller's #660 (blocked on er-dev rejects the er-readonly identity with 401 — EKS access entry drift suspected #839, the EKS access-entry 401 found while verifying this deploy).
  • what was learned is written down where the next session will find it — the callsite-interest-cache race (thread-local subscriber + concurrent test binary = flaky zero-span captures) is written into er-obs/src/testing.rs on global_recorder(), the API this PR added precisely so the next test does not rediscover it.

Specific to this change

Context — plan, discoveries, measurements, files

Plan

  1. pg_orgs.rs gains audit_rows_carry_the_requests_trace_id: one assertion per state audit_log.trace_id can be in — (a) request with traceparent → the caller's trace id; (b) request without → a fresh non-null root id; (c) a write with no request behind it → NULL.
  2. er_obs::testing::global_recorder() — a once-per-process global recording subscriber + rebuild_interest_cache(), because the thread-local capture_spans composition flapped under the concurrent pg shard (see Discoveries).
  3. Anti-vacuity assertion before the ledger assertions: the recorder must have seen the traced request's span, so a recording regression names itself.
  4. Gates: make check green; the failing CI leg (pg m-z shard) reproduced locally and re-run green 4/4.

Discoveries

  • The first version of this test was green locally and red in CI — a real find, caught by the gate this PR exists to add. capture_spans installs a thread-local subscriber; callsite interest is cached process-wide, and in the 32-test shard a callsite first hit on an unsubscribed thread caches "never interested" for every thread. Observed as captured=0 spans (case 1 null) in two runs and a missing second request span (case 2 null) in a third. The global recorder makes the none dispatch unreachable after install, closing the race. Verified: shard green 4/4 locally after the fix.
  • The issue's "one without writes null" is not the code's intent on the HTTP path: with a subscriber installed, a headerless request is still a traced request (fresh root). NULL is the documented answer for callers with no request span. The test asserts all three states as the code intends them.
  • pg_serial.rs counts #[tokio::test] attributes per file and this file's one is taken — so the test is a plain #[test] driving a current-thread runtime.
  • The span-lineage half (telemetry_trace_continuation.rs) locks the exported span; this test closes the loop into the ledger (the JOIN KEY column itself).

Files

  • rust/crates/er-obs/src/testing.rs — global_recorder() + GlobalRecorder, and to_captured factored out of capture_spans.
  • rust/crates/er-server/tests/pg_orgs.rs — the new test (request phase + assertion phase).

… traceparent

The column is the JOIN KEY to the span store and no gate at any level
proved it is ever populated. One assertion per state it can be in: a
request carrying traceparent writes its trace id; a headerless request
writes a fresh root id (traced is not untraced); a write with no request
behind it writes NULL, permanently and on purpose. Runs under
capture_spans on a current-thread runtime so request spans record on the
polling thread — without a subscriber case 1 would pass vacuously.
… traceparent

The column is the JOIN KEY to the span store and no gate at any level
proved it is ever populated. One assertion per state it can be in: a
request carrying traceparent writes its trace id; a headerless request
writes a fresh root id (traced is not untraced); a write with no request
behind it writes NULL, permanently and on purpose.

The first version installed the recorder thread-locally via capture_spans
and passed alone but flapped in the pg shard — callsite interest is cached
process-wide, and a callsite first hit on an unsubscribed thread caches
"never interested" for every thread. er_obs::testing gains
global_recorder(): a once-per-process global default plus
rebuild_interest_cache, so no thread can ever evaluate the none dispatch.
The test's anti-vacuity assertion (the recorder saw the traced request's
span) runs before the ledger assertions, so a recording regression names
itself instead of surfacing as a bare trace_id: null.
@athvin
athvin marked this pull request as ready for review November 8, 2026 07:07
@athvin
athvin merged commit dc394cc into main Nov 8, 2026
45 checks passed
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.

gate: prove audit_log.trace_id is populated — pg_orgs.rs phase (from #660)

2 participants