feat(ingester): instrument the compaction sweep with RFC 0009 §3.6 metrics - #106
Conversation
…trics Phase 3 of the telemetry code work. Records the compaction metric set through OpenTelemetry, using the generated `ourios-semconv` name constants and the global meter (RFC 0001 §6.8 API/SDK split — the ingester depends only on the lightweight `opentelemetry` API; the SDK + OTLP exporter live in `ourios-telemetry`, configured by the binary). - New `CompactionMetrics` (crates/ourios-ingester/src/metrics.rs): builds the `ourios.compaction` instruments and seeds each counter with a zero measurement at construction so the full set is visible to the exporter before the first sweep (§6.8 collect-on-read). The duration histogram is deliberately not seeded — a synthetic `record(0)` would distort it. - `Compactor::run` builds the instruments once (seeded) before the loop and records each sweep: `sweeps` + `duration` carry the `ourios.compaction.result` attribute (committed / noop / error), and `partitions` / `files` / `rows` / `orphan.files` carry the volume. Sweep wall-clock is timed inside the blocking task. - `SweepReport` gains `files_compacted` (sum of each consolidated partition's `files_before`) for the H4 `ourios.compaction.files` signal. Deferred to a follow-up (need data this slice doesn't have): `ourios.compaction.io` (per-compaction byte counts aren't on `CompactionOutcome`), `ourios.compaction.backlog` (gauge semantics), and `ourios.storage.parquet.file.size` (an all-files H4 detector that belongs to the writer / a partition scan, not the compactor). Test: stands up an in-memory MeterProvider via `ourios-telemetry`'s `init_in_memory`, records a sweep, force-flushes, and asserts the exported stream carries every recorded instrument. Verification: cargo fmt --all --check, clippy --all-targets --all-features -D warnings, cargo test --workspace --all-features — all green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds OpenTelemetry metrics for compaction sweeps: new ChangesCompaction Metrics Instrumentation
Sequence DiagramsequenceDiagram
participant Daemon as Compactor::run
participant Metrics as CompactionMetrics
participant Meter as ourios.compaction meter
Daemon->>Metrics: record_sweep(result, elapsed)
Metrics->>Meter: record sweeps & duration (+ optional counters on Ok)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Adds OpenTelemetry instrumentation for the ingester compaction sweep per RFC 0009 §3.6, using ourios-semconv generated name constants and the global meter provider pattern from RFC 0001 §6.8.
Changes:
- Introduces
CompactionMetricsto build and record compaction sweep counters + duration histogram. - Wires metrics recording into
Compactor::run, including wall-clock timing inside the blocking sweep task. - Extends
SweepReportwithfiles_compactedto support theourios.compaction.filessignal.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/ourios-ingester/src/metrics.rs | New compaction metrics instruments + recording + in-memory export test. |
| crates/ourios-ingester/src/lib.rs | Exposes the new metrics module and re-exports CompactionMetrics. |
| crates/ourios-ingester/src/compactor.rs | Records metrics per sweep, times blocking work, and reports files_compacted. |
| crates/ourios-ingester/Cargo.toml | Adds OTel API + semconv constants dependency; adds telemetry/sdk test deps. |
| Cargo.lock | Updates lockfile for new dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@coderabbitai review |
✅ Action performedReview finished.
|
…C 0009 §3.6 metrics
|
@coderabbitai review |
✅ Action performedReview finished.
|
…with RFC 0009 §3.6 metrics
|
@coderabbitai review |
✅ Action performedReview finished.
|
What
Phase 3 of the telemetry code work: records the RFC 0009 §3.6 compaction metric set through OpenTelemetry, using the generated
ourios-semconvname constants (PR #105) and the global meter (RFC 0001 §6.8 API/SDK split — the ingester depends only on the lightweightopentelemetryAPI; the SDK + OTLP exporter live inourios-telemetry, PR #104).Changes
CompactionMetrics(newmetrics.rs): builds theourios.compactioninstruments and seeds each counter with a zero measurement at construction, so the full set is visible to the exporter before the first sweep (§6.8 collect-on-read). The duration histogram is deliberately not seeded — a syntheticrecord(0)would distort its distribution.Compactor::runbuilds the instruments once (seeded) before the loop and records every sweep:ourios.compaction.sweeps(+durationhistogram) carryourios.compaction.result=committed/noop/error;partitions/files/rows/orphan.filescarry the volume. Sweep wall-clock is timed inside the blocking task.SweepReport.files_compactedadded (sum of each consolidated partition'sfiles_before) for the H4ourios.compaction.filessignal.Deferred (need data this slice lacks)
ourios.compaction.io(per-compaction byte counts aren't onCompactionOutcome),ourios.compaction.backlog(gauge semantics), andourios.storage.parquet.file.size(an all-files H4 detector that belongs to the writer / a partition scan, not the compactor). Theourios-semconvconstants for these already exist; instrumentation lands when the data is plumbed.Hazard note (H4, RFC 0009 §3.6)
ourios.compaction.files(input files merged away) is the small-file mitigation signal; instruments are seeded so they don't silently disappear at zero traffic.Test
Stands up an in-memory
MeterProviderviaourios-telemetry::init_in_memory, records a sweep, force-flushes, and asserts the exported stream carries every recorded instrument.Verification
cargo fmt --all --check,clippy --all-targets --all-features -D warnings,cargo test --workspace --all-features— all green.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests