Repository navigation
Conversation
…metry P8)
The piece everything else in the programme hangs off. Verified against a real
`er run-all`, the ancestry is now:
process (service.name=er-cli) -> run (run_id, mode, model_version)
-> stage (ingest, 356ms, ok)
A statement span nests one level deeper, so when the emitters land every SQL
record will carry its stage, its run and its service **without any of them
being passed as an argument**. That is the whole point: `tracing` context is
ambient, so a generated query function three layers down is attributed to its
tenant without taking one.
## What this replaces from the plan, and why
The plan said to add `org_id` to `PipelineInputs`. That was wrong, and doing it
would have defeated the design: 21 struct-literal construction sites edited to
thread an identifier the dispatcher already has. Instead `dispatch_claimed` —
the single funnel every claimed job passes through — enters a `job` span with
org, kind and attempt, and the run and stage spans are created inside it. Org
is inherited, not threaded. The same reasoning is what will keep the 218
generated query signatures untouched in the emitter change.
The `job` span also records `jobs.trace_context`, which P3 started populating.
Making this span a true CHILD of that remote context needs the OTel context
propagator and so arrives with the exporter; recording it as a field means a
log search joins the two halves in the meantime.
## StageObserver finally carries timing
`observed()` now measures the stage's own wall clock. The trait never has —
despite `duration_ms` being one of the eleven promoted counters — so the ledger
has been taking its timing from SQL `now()` at each boundary. Measuring it in
one place means the span and the ledger agree rather than approximately agree.
## The blocking-hop gate, and why it is not a convention
`tokio::task::spawn_blocking` moves its closure to another thread, and
`tracing`'s current span is thread-local, so the bare form silently drops the
ambient span. Because DuckDB is synchronous the ENTIRE pipeline runs inside
those closures: one missed hop orphans every stage span and every statement
span beneath it from the job that caused them.
Nothing else catches it. No test fails, no type is wrong, every span is still
produced — they are parentless. It does not read as a bug, it reads as tracing
not working. So all 9 hops in er-server move to
`er_obs::spawn_blocking_in_span` (same signature, same JoinHandle, same
panic-as-JoinError contract) and `er-schema/tests/span_boundaries.rs` bans the
bare form, in the shape `freeform_sql.rs` established.
The gate was observed FAILING before being trusted: reintroducing one bare site
named `er-server/src/dispatcher.rs:583` exactly. It also asserts the wrapper is
still used at least 9 times, because proving the bare form absent means nothing
if the hops quietly disappeared.
## with_span_list, turned on
Found while verifying: with the span list off, a record carried only its
innermost span — so a statement-level event would have said which STAGE it was
in and nothing about the run, job or tenant. That is the attribution the whole
exercise exists for. Every record is now self-describing. It costs bytes, and
the lever against that is the filter, because a cheap line nobody can attribute
is not actually cheap.
One honest limitation: a span filtered out by target drops from the ancestry
too, so a narrow `RUST_LOG=er_cli=info` loses the service identity the process
span carries. The default filter enables it, and Fluent Bit attaches pod
identity independently.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
cargo-deny failed on #408 while passing locally. The CI job pins RUSTUP_TOOLCHAIN=1.85.0 deliberately — the workflow comment says it is there "to keep the check evaluating the lockfile" — and on 1.85 an inherited workspace dependency may not override default-features: error inheriting `tokio` from workspace root manifest's workspace.dependencies.tokio `default-features = false` cannot override workspace's `default-features` A newer local toolchain accepts it, which is exactly the gap the pin exists to close. Reproduced verbatim with RUSTUP_TOOLCHAIN=1.85.0 and now green under it: advisories ok, bans ok, licenses ok, sources ok. The override was unnecessary anyway. The workspace entry already carries rt-multi-thread and macros, which is everything `spawn_blocking` and `#[tokio::test]` need, so `tokio.workspace = true` is both correct and the house pattern (er-k8s and er-server both inherit and add features, neither overrides defaults). The dev-dependency went with it as redundant. Zero lock change; er-obs's 12 tests still pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Owner
Author
|
Superseded by a fresh PR from the same branch: GitHub returned an Internal Server Error on the push carrying the MSRV fix, and after that no |
This was referenced Nov 2, 2026
athvin
added a commit
that referenced
this pull request
Nov 3, 2026
…metry P8) (#416) * feat(obs): the ambient context spine — job, run and stage spans (telemetry P8) The piece everything else in the programme hangs off. Verified against a real `er run-all`, the ancestry is now: process (service.name=er-cli) -> run (run_id, mode, model_version) -> stage (ingest, 356ms, ok) A statement span nests one level deeper, so when the emitters land every SQL record will carry its stage, its run and its service **without any of them being passed as an argument**. That is the whole point: `tracing` context is ambient, so a generated query function three layers down is attributed to its tenant without taking one. The plan said to add `org_id` to `PipelineInputs`. That was wrong, and doing it would have defeated the design: 21 struct-literal construction sites edited to thread an identifier the dispatcher already has. Instead `dispatch_claimed` — the single funnel every claimed job passes through — enters a `job` span with org, kind and attempt, and the run and stage spans are created inside it. Org is inherited, not threaded. The same reasoning is what will keep the 218 generated query signatures untouched in the emitter change. The `job` span also records `jobs.trace_context`, which P3 started populating. Making this span a true CHILD of that remote context needs the OTel context propagator and so arrives with the exporter; recording it as a field means a log search joins the two halves in the meantime. `observed()` now measures the stage's own wall clock. The trait never has — despite `duration_ms` being one of the eleven promoted counters — so the ledger has been taking its timing from SQL `now()` at each boundary. Measuring it in one place means the span and the ledger agree rather than approximately agree. `tokio::task::spawn_blocking` moves its closure to another thread, and `tracing`'s current span is thread-local, so the bare form silently drops the ambient span. Because DuckDB is synchronous the ENTIRE pipeline runs inside those closures: one missed hop orphans every stage span and every statement span beneath it from the job that caused them. Nothing else catches it. No test fails, no type is wrong, every span is still produced — they are parentless. It does not read as a bug, it reads as tracing not working. So all 9 hops in er-server move to `er_obs::spawn_blocking_in_span` (same signature, same JoinHandle, same panic-as-JoinError contract) and `er-schema/tests/span_boundaries.rs` bans the bare form, in the shape `freeform_sql.rs` established. The gate was observed FAILING before being trusted: reintroducing one bare site named `er-server/src/dispatcher.rs:583` exactly. It also asserts the wrapper is still used at least 9 times, because proving the bare form absent means nothing if the hops quietly disappeared. Found while verifying: with the span list off, a record carried only its innermost span — so a statement-level event would have said which STAGE it was in and nothing about the run, job or tenant. That is the attribution the whole exercise exists for. Every record is now self-describing. It costs bytes, and the lever against that is the filter, because a cheap line nobody can attribute is not actually cheap. One honest limitation: a span filtered out by target drops from the ancestry too, so a narrow `RUST_LOG=er_cli=info` loses the service identity the process span carries. The default filter enables it, and Fluent Bit attaches pod identity independently. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(obs): er-obs cannot override tokio's default-features on the MSRV cargo-deny failed on #408 while passing locally. The CI job pins RUSTUP_TOOLCHAIN=1.85.0 deliberately — the workflow comment says it is there "to keep the check evaluating the lockfile" — and on 1.85 an inherited workspace dependency may not override default-features: error inheriting `tokio` from workspace root manifest's workspace.dependencies.tokio `default-features = false` cannot override workspace's `default-features` A newer local toolchain accepts it, which is exactly the gap the pin exists to close. Reproduced verbatim with RUSTUP_TOOLCHAIN=1.85.0 and now green under it: advisories ok, bans ok, licenses ok, sources ok. The override was unnecessary anyway. The workspace entry already carries rt-multi-thread and macros, which is everything `spawn_blocking` and `#[tokio::test]` need, so `tokio.workspace = true` is both correct and the house pattern (er-k8s and er-server both inherit and add features, neither overrides defaults). The dev-dependency went with it as redundant. Zero lock change; er-obs's 12 tests still pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
The piece everything else in the programme hangs off. Verified against a real
er run-all:A statement span nests one level deeper, so when the emitters land every SQL record will carry its stage, its run and its service without any of them being passed as an argument. That is the whole point of ambient context — a generated query function three layers down is attributed to its tenant without taking one.
What I dropped from the plan, and why
The plan said to add
org_idtoPipelineInputs. That was wrong, and doing it would have defeated the design: 21 struct-literal construction sites edited to thread an identifier the dispatcher already has.Instead
dispatch_claimed— the single funnel every claimed job passes through — enters ajobspan with org, kind and attempt, and the run and stage spans are created inside it. Org is inherited, not threaded. The same reasoning keeps the 218 generated query signatures untouched in P10.The
jobspan also recordsjobs.trace_context, which #384 started populating. Making it a true child of that remote context needs the OTel propagator and so arrives with the exporter; recording it as a field means a log search joins the two halves meanwhile.StageObserver finally carries timing
observed()now measures the stage's own wall clock. The trait never has — despiteduration_msbeing one of the eleven promoted counters — so the ledger has been taking timing from SQLnow()at each boundary. Measuring it in one place means the span and the ledger agree rather than approximately agree.The blocking-hop gate, and why it isn't a convention
tokio::task::spawn_blockingmoves its closure to another thread, andtracing's current span is thread-local, so the bare form silently drops the ambient span. Because DuckDB is synchronous the entire pipeline runs inside those closures — one missed hop orphans every stage span and every statement span beneath it from the job that caused them.And nothing catches it. No test fails, no type is wrong, every span is still produced — they're parentless. It doesn't read as a bug, it reads as tracing not working.
So all 9 hops move to
er_obs::spawn_blocking_in_span(same signature, sameJoinHandle, same panic-as-JoinErrorcontract), ander-schema/tests/span_boundaries.rsbans the bare form in the shapefreeform_sql.rsestablished.The gate was observed failing before being trusted — reintroducing one bare site named
er-server/src/dispatcher.rs:583exactly:It also asserts the wrapper is still used ≥9 times, because proving the bare form absent means nothing if the hops quietly disappeared.
with_span_list, turned on
Found while verifying, not while writing: with the span list off a record carried only its innermost span — so a statement-level event would have reported which stage it was in and nothing about the run, job or tenant. That's precisely the attribution this programme exists for. Every record is now self-describing.
It costs bytes, and the lever against that is the filter — because a cheap line nobody can attribute is not actually cheap.
One honest limitation, documented in the code: a span filtered out by target drops from the ancestry too, so a narrow
RUST_LOG=er_cli=infoloses the service identity the process span carries. The default filter enables it, and Fluent Bit attaches pod identity independently.Verification
make checkgreen at exit 0, first attempt. Plus a realer run-allagainst thebase_10fixture, with the ancestry printed above read out of the actual log.🤖 Generated with Claude Code