Skip to content

feat(ingester): tenant derivation + fan-out (RFC0003.3/.4) - #133

Merged
jensholdgaard merged 1 commit into
mainfrom
feat/otlp-receiver-tenant-fanout
Jun 6, 2026
Merged

feat(ingester): tenant derivation + fan-out (RFC0003.3/.4)#133
jensholdgaard merged 1 commit into
mainfrom
feat/otlp-receiver-tenant-fanout

Conversation

@jensholdgaard

Copy link
Copy Markdown
Owner

What

Fourth green slice of the OTLP receiver (RFC 0003 §6.3 / RFC 0001 §6.1 tenant derivation): per-ResourceLogs tenant derivation + fan-out, flipping RFC0003.3/.4 live. Builds on materialisation (#132).

Design (rule pinned by RFC 0001 §6.1 — no open question)

  • receiver::tenant::TenantRule — the operator-configured derivation rule: a single string-valued resource attribute, default key service.name (the OTel-canonical "what application emitted this", mapping onto per-tenant template-tree partitioning [§3.7]). by_attribute covers operator-chosen keys.
  • deriveTenantId, or a hand-rolled TenantResolutionError (no thiserror) naming the attribute when it's absent, non-string, or empty — the receiver never invents a tenant the operator hasn't declared.
  • materialize::materialize_resource_logs — flattens one ResourceLogs' scope × records under the resolved tenant (built on materialize_record).
  • fan_out — derives the tenant once per ResourceLogs, tags every record with it; the miner's per-tenant routing keeps streams separate. If any ResourceLogs fails to resolve, the entire export is rejected (?-propagated before any records are returned — no partial batch). Per-Resource partial rejection is out of scope per RFC 0001 §6.1.

Scenarios (now live)

  • .3 — a two-service export fans out to two tenants; body markers prove a record never lands under the wrong tenant.
  • .4 — a resolvable + an unresolvable Resource → the whole batch is rejected and the error names service.name; no records accepted.

Plus tenant-module unit tests for derive (default key, missing/non-string/empty → error, custom operator key).

Verification

  • cargo test -p ourios-ingester ✓ — RFC0003.3–.10 live; 7 scenarios remain ignored (.1/.2/.11–.15, the transport / WAL-before-ack / concurrency group). No new dependencies.
  • cargo fmt --all --check ✓ · cargo clippy --all-targets --all-features -- -D warnings ✓ (workspace)

🤖 Generated with Claude Code

Fourth green slice of the OTLP receiver (RFC 0003 §6.3 / RFC 0001 §6.1
tenant derivation). Derives a tenant per ResourceLogs and fans the export
out into per-tenant records; flips RFC0003.3/.4 live.

- `receiver::tenant::TenantRule` — the operator-configured derivation rule
  (a single string-valued resource attribute; default key `service.name`,
  the OTel-canonical "what application emitted this"). `derive` resolves
  the attribute to a `TenantId`, or returns a hand-rolled
  `TenantResolutionError` naming the attribute when it's absent, non-string,
  or empty — the receiver never invents a tenant the operator hasn't
  declared.
- `receiver::materialize::materialize_resource_logs` — flattens one
  ResourceLogs' scope × records under the resolved tenant (built on
  materialize_record; takes the tenant by ref).
- `receiver::tenant::fan_out` — derives the tenant once per ResourceLogs
  and tags every record with it; the miner's per-tenant routing keeps
  streams separate (RFC0003.3, no cross-contamination). If any
  ResourceLogs fails to resolve, the ENTIRE export is rejected
  (RFC0003.4) — `?`-propagated before any records are returned, so no
  partial batch is accepted. Per-Resource partial rejection is out of
  scope per RFC 0001 §6.1.

Tests: rfc0003_3 (two services → two tenants, body markers prove no
cross-contamination), rfc0003_4 (a resolvable + an unresolvable Resource →
whole batch rejected, error names `service.name`), plus tenant-module unit
tests for derive (default key, missing/non-string/empty → error, custom
operator key). No new dependencies.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jensholdgaard, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 42 minutes and 30 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f310e01a-223f-40e9-a040-e88b55977348

📥 Commits

Reviewing files that changed from the base of the PR and between 5ae5435 and d7babf1.

📒 Files selected for processing (6)
  • crates/ourios-ingester/src/lib.rs
  • crates/ourios-ingester/src/receiver.rs
  • crates/ourios-ingester/src/receiver/materialize.rs
  • crates/ourios-ingester/src/receiver/tenant.rs
  • crates/ourios-ingester/tests/rfc0003_3_tenant_fanout.rs
  • crates/ourios-ingester/tests/rfc0003_4_tenant_resolution_failure.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/otlp-receiver-tenant-fanout

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 and usage tips.

@jensholdgaard
jensholdgaard requested a review from Copilot June 6, 2026 15:32
@jensholdgaard

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Implements the RFC 0001 §6.1 tenant-derivation rule and RFC0003.3/.4 behavior in the ingester receiver by deriving a TenantId per ResourceLogs group and fanning out materialized records accordingly, with all-or-nothing rejection when any group fails tenant resolution.

Changes:

  • Added receiver::tenant module with TenantRule, TenantResolutionError, and fan_out to derive tenants per ResourceLogs and tag all materialized records.
  • Added materialize_resource_logs to materialize all (ScopeLogs, LogRecord) under a single ResourceLogs group for a resolved tenant.
  • Flipped RFC0003.3 and RFC0003.4 tests from ignored stubs to live assertions covering fan-out and whole-batch rejection.

Reviewed changes

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

Show a summary per file
File Description
crates/ourios-ingester/tests/rfc0003_4_tenant_resolution_failure.rs Activates RFC0003.4 test asserting whole-export rejection with missing attribute named.
crates/ourios-ingester/tests/rfc0003_3_tenant_fanout.rs Activates RFC0003.3 test asserting per-tenant fan-out without cross-contamination.
crates/ourios-ingester/src/receiver/tenant.rs Introduces tenant derivation rule/error and fan_out implementation plus unit tests.
crates/ourios-ingester/src/receiver/materialize.rs Adds materialize_resource_logs to materialize all records under one ResourceLogs for a tenant.
crates/ourios-ingester/src/receiver.rs Wires in tenant module and re-exports tenant + new materialization entrypoints.
crates/ourios-ingester/src/lib.rs Updates crate-level docs to reflect tenant derivation + fan-out slice is landed.

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

@jensholdgaard
jensholdgaard merged commit 8a890fc into main Jun 6, 2026
11 checks passed
@jensholdgaard
jensholdgaard deleted the feat/otlp-receiver-tenant-fanout branch June 6, 2026 15:37
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