feat(ingester): tenant derivation + fan-out (RFC0003.3/.4) - #133
Conversation
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>
|
Warning Review limit reached
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
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::tenantmodule withTenantRule,TenantResolutionError, andfan_outto derive tenants perResourceLogsand tag all materialized records. - Added
materialize_resource_logsto materialize all(ScopeLogs, LogRecord)under a singleResourceLogsgroup 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.
What
Fourth green slice of the OTLP receiver (RFC 0003 §6.3 / RFC 0001 §6.1 tenant derivation): per-
ResourceLogstenant 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 keyservice.name(the OTel-canonical "what application emitted this", mapping onto per-tenant template-tree partitioning[§3.7]).by_attributecovers operator-chosen keys.derive→TenantId, or a hand-rolledTenantResolutionError(nothiserror) 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 oneResourceLogs' scope × records under the resolved tenant (built onmaterialize_record).fan_out— derives the tenant once perResourceLogs, tags every record with it; the miner's per-tenant routing keeps streams separate. If anyResourceLogsfails 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)
Resource→ the whole batch is rejected and the error namesservice.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