Skip to content

test(server): assert the caller's sampling decision governs (RFC 0039 slice 4) - #630

Merged
jensholdgaard merged 1 commit into
mainfrom
rfc0039-slice4-sampling
Jul 25, 2026
Merged

test(server): assert the caller's sampling decision governs (RFC 0039 slice 4)#630
jensholdgaard merged 1 commit into
mainfrom
rfc0039-slice4-sampling

Conversation

@jensholdgaard

@jensholdgaard jensholdgaard commented Jul 25, 2026

Copy link
Copy Markdown
Owner

What

RFC 0039 slice 4 — RFC0039.4: the caller's sampling decision governs, end to end. This closes the last §5 criterion, so RFC 0039 moves to green.

Test-only. RFC 0038 slice 4 already made the SDK resolve OTEL_TRACES_SAMPLER (rather than a bespoke config knob), so no production behaviour changes here — what needed proving is Ourios's wiring: that the context extracted at the ingress actually reaches the sampler.

Why the negative arm isn't vacuous

Two arms differing only in the sampled flag:

  • -01 → the query span exports, inside the caller's trace
  • -00 → nothing exports at all

Asserting "zero spans" is normally a weak test, since a broken harness passes it trivially. Here it's load-bearing, because of how ParentBased resolves: had extraction failed outright, the -00 span would be a root, ParentBased delegates roots to AlwaysOn, and it would export. Zero exported spans therefore proves extraction produced a valid-but-unsampled parent. The two arms validate each other under one harness.

Both arms also assert the response succeeds. Sampling is a telemetry decision and must never decide a request's outcome — a regression making extraction fallible would show up here.

The sampler is pinned explicitly rather than inherited from SdkTracerProvider's default (ParentBased(AlwaysOn) today, provider.rs:93): a test should state the regime it asserts under, not silently depend on an upstream default.

Lives in the consolidated it harness — a scoped subscriber suffices, so no new binary (RFC0028).

Two gaps found while checking green was earned

Claiming green means every §5 criterion has an asserting test, so I walked them. Two things didn't hold up:

  1. RFC0039.2 was unasserted for the ingest path. Nothing checked that an untraced batch is a fresh root with no parent — it was only inferable from "no traceparent was sent", which is exactly what a bug that invented a parent, or dropped the trace id, would defeat. Added a third arm to the RFC0039.3 test (additive; existing assertions filter by trace id and are untouched).
  2. tests/it/main.rs still said two harness-exempt binaries. Slice 3 made it three. Fixed, with the reason each is exempt.

Criteria coverage (RFC 0039 §5, complete)

Scenario Asserting test
RFC0039.1 rfc0039_1_query_propagation.rs (query) + rfc0039_3_ingest_propagation.rs (gRPC + HTTP)
RFC0039.2 same two, root arms — the ingest arm added here
RFC0039.3 rfc0039_3_ingest_propagation.rs, both transports past the spawn
RFC0039.4 rfc0039_4_sampling.rs (this slice)
RFC0039.5 rfc0039_1_query_propagation.rs + propagation.rs unit tests, both carriers
RFC0039.6 rfc0039_6_mcp_propagation.rs (SERVER kind, remote parent, local tool parent)

Invariants (CLAUDE.md §3)

None touched — no production code in this slice.

Verification

  • cargo fmt --all --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo nextest run --all-features ✅ 1252 passed, 38 skipped
  • mdbook build

Next

RFC 0040 — the ourios-df-otel crate and datafusion.operator.* spans. Two items remain open for the maintainer, neither blocking: the upstream SpanKind grammar fix (would retire four [sic] markers), and the redundant opentelemetry dev-dependency in ourios-server.

Summary by CodeRabbit

  • Observability

    • Improved inbound trace propagation across query, ingest, and tool-processing flows.
    • Trace relationships remain intact across asynchronous operations and supported transport paths.
    • Requests now correctly honor upstream sampling decisions, avoiding partial traces when tracing is disabled upstream.
  • Documentation

    • Updated trace propagation guidance and marked the related RFC as complete.
    • Expanded coverage documentation for supported propagation and sampling scenarios.

… slice 4)

Closes the last §5 criterion, so RFC 0039 moves to `green`.

RFC0039.4 is test-only: RFC 0038 slice 4 already made the SDK resolve
`OTEL_TRACES_SAMPLER`, so nothing in production changes. Two arms differing
only in the sampled flag -- `-01` exports the query span into the caller's
trace, `-00` exports nothing at all. They are mutually validating, which is
what stops the negative arm being vacuous: had extraction failed outright,
the `-00` span would be a root, `ParentBased` delegates roots to `AlwaysOn`,
and it would export. Zero exported spans therefore proves extraction
produced a valid-but-unsampled parent.

Both arms also assert the response succeeds. Sampling is a telemetry
decision and must never decide a request's outcome.

The sampler is pinned explicitly rather than inherited from
`SdkTracerProvider`'s default (`ParentBased(AlwaysOn)` today): a test should
state the regime it asserts under.

Two gaps found while checking that `green` is actually earned rather than
approximately true:

- Nothing asserted RFC0039.2 for the *ingest* path -- that an untraced batch
  is a fresh root with no parent. It was only inferable from "no traceparent
  was sent", which a bug inventing a parent would defeat. Added a third arm
  to the RFC0039.3 test.
- `tests/it/main.rs` still described two harness-exempt binaries; slice 3
  made it three.

Signed-off-by: Jens Holdgaard Pedersen <Jens@holdgaard.org>
@jensholdgaard
jensholdgaard requested a review from Copilot July 25, 2026 01:56
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c7e9129-6303-4a63-b817-0a95b925f002

📥 Commits

Reviewing files that changed from the base of the PR and between e73b810 and 7848539.

📒 Files selected for processing (4)
  • crates/ourios-ingester/tests/rfc0039_3_ingest_propagation.rs
  • crates/ourios-server/tests/it/main.rs
  • crates/ourios-server/tests/it/rfc0039_4_sampling.rs
  • docs/rfcs/0039-inbound-trace-context-propagation.md

📝 Walkthrough

Walkthrough

RFC0039 coverage now validates an untraced ingest root, inbound parent-based sampling for HTTP queries, test-harness registration, and the RFC’s completed status.

Changes

Inbound trace propagation

Layer / File(s) Summary
Ingest propagation arms
crates/ourios-ingester/tests/rfc0039_3_ingest_propagation.rs
Adds an untraced ingest arm and verifies a fresh root span, while retaining caller trace and parent assertions for propagated arms.

Inbound sampling coverage

Layer / File(s) Summary
Inbound sampling integration tests
crates/ourios-server/tests/it/rfc0039_4_sampling.rs, crates/ourios-server/tests/it/main.rs
Adds sampled and unsampled /v1/query traceparent tests using parent-based sampling and registers the new suite in the integration harness. The harness documentation reflects the updated binary exemptions.

RFC completion status

Layer / File(s) Summary
RFC status update
docs/rfcs/0039-inbound-trace-context-propagation.md
Changes the RFC status to green and records completed scenario coverage and amended design decisions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main test-only change around caller-sampling propagation.
Description check ✅ Passed The description covers the intent, rationale, verification, and RFC status, but it doesn't follow the template's exact headings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rfc0039-slice4-sampling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes RFC 0039’s final acceptance criterion (RFC0039.4) by adding integration tests that assert the caller’s sampling decision (via traceparent sampled flag) governs whether Ourios exports request spans, end-to-end. It also tightens RFC0039.2 coverage for the ingest path and updates the RFC’s status to green.

Changes:

  • Add a new server integration test (rfc0039_4_sampling) with two arms (-01 exports, -00 exports nothing) under an explicitly pinned ParentBased(AlwaysOn) sampler.
  • Strengthen ingest propagation coverage by adding an explicit “no traceparent → fresh root” arm to the existing ingest propagation test.
  • Mark RFC 0039 as green and document the slice history; update the consolidated it harness docs and module list.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
docs/rfcs/0039-inbound-trace-context-propagation.md Updates RFC 0039 status to green and summarizes the slices/tests that satisfy §5.
crates/ourios-server/tests/it/rfc0039_4_sampling.rs New integration test asserting sampled vs unsampled inbound parents control span export.
crates/ourios-server/tests/it/main.rs Updates harness documentation (three exempt binaries) and wires in the new test module.
crates/ourios-ingester/tests/rfc0039_3_ingest_propagation.rs Adds an explicit “no traceparent → fresh root span” assertion for ingest (RFC0039.2).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jensholdgaard
jensholdgaard merged commit 7e89677 into main Jul 25, 2026
28 checks passed
@jensholdgaard
jensholdgaard deleted the rfc0039-slice4-sampling branch July 25, 2026 02:04
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.

2 participants