feat(telemetry): scaffold ourios-telemetry crate (OTLP MeterProvider bootstrap) - #104
Conversation
…bootstrap) First slice of the telemetry code work unblocked by RFC 0001 §6.8 (the OTel SDK + OTLP-push amendment, #103) and RFC 0009 §3.6 (#102). Implements the §6.8 "Export architecture" dependency split: this is the single crate that carries the heavy OTel SDK + OTLP exporter + transport, so instrumented library crates can depend only on the lightweight `opentelemetry` API (`global::meter(...)`). - `init(&TelemetryConfig)` builds the OTLP push MeterProvider (periodic reader, configurable interval), sets `service.name = ourios-<role>` as a Resource attribute (not a data-point attribute, per §6.8), installs it as the process-global provider, and returns a `TelemetryGuard` whose `shutdown()` flushes on exit (Drop flushes best-effort). - `init_in_memory` (behind the `testing` feature) wires an InMemoryMetricExporter for other crates' tests (e.g. the miner's §8 metric-collection test) to collect the exported stream without an OTLP endpoint. No instrumentation yet — that lands in the follow-on slices (weaver name-constant codegen, then compaction instrumentation). Error type is hand-rolled to match the workspace convention (no thiserror dep). Verification: cargo fmt --check, clippy --all-targets --all-features -D warnings, and cargo test --workspace --all-features all green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@coderabbitai review |
|
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 a new ChangesOpenTelemetry Metrics Telemetry Module
Sequence Diagram(s)sequenceDiagram
participant Caller
participant init as init(config)
participant OTLPExporter
participant PeriodicReader
participant MeterProvider
participant GlobalRegistry
Caller->>init: TelemetryConfig
init->>OTLPExporter: build(endpoint, tonic)
OTLPExporter-->>init: MetricExporter
init->>PeriodicReader: wrap exporter + interval
PeriodicReader-->>init: PeriodicReader
init->>MeterProvider: new with reader + resource
MeterProvider-->>init: SdkMeterProvider
init->>GlobalRegistry: set_meter_provider()
init-->>Caller: TelemetryGuard
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Pull request overview
Adds a new ourios-telemetry crate that centralizes the OpenTelemetry SDK + OTLP exporter setup, aligning with the RFC 0001 §6.8 dependency split (library crates use only the OTel API, while this crate owns the SDK/exporter stack).
Changes:
- Introduces
ourios-telemetrywithTelemetryConfig,init()(OTLP pushSdkMeterProvider), andTelemetryGuardshutdown/drop handling. - Adds
testing-featureinit_in_memory()to support in-memory metric export for tests. - Wires the new crate into the workspace members and lockfile.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/ourios-telemetry/src/lib.rs | Implements OTLP MeterProvider bootstrap, guard-based shutdown, and an in-memory test pipeline + smoke test. |
| crates/ourios-telemetry/Cargo.toml | Defines the new crate, its OTel dependencies/features, and workspace lint settings. |
| Cargo.toml | Adds crates/ourios-telemetry to workspace members. |
| Cargo.lock | Locks new transitive deps pulled in by OTLP/tonic exporter stack. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ovider bootstrap)
|
@coderabbitai review |
✅ Action performedReview finished.
|
…MeterProvider bootstrap)
|
@coderabbitai review |
✅ Action performedReview finished.
|
What
Phase 1 of the telemetry code work, unblocked by the two merged telemetry RFCs (#102 RFC 0009 §3.6 metrics; #103 RFC 0001 §6.8 OTel-SDK + OTLP-push amendment).
Scaffolds the new
ourios-telemetrycrate — the single place the heavy OTel SDK + OTLP exporter + transport live, so instrumented library crates depend only on the lightweightopentelemetryAPI viaglobal::meter(...)(the §6.8 "Export architecture" dependency split, RFC-blessed in #103).API
init(&TelemetryConfig) -> Result<TelemetryGuard, _>— builds the OTLP pushMeterProvider(periodic reader, configurable interval), setsservice.name = ourios-<role>as a Resource attribute (per §6.8: producer identity is a resource attribute, never a data-point attribute), installs it as the process-global provider, and returns a guard.TelemetryGuard::shutdown()flushes explicitly;Dropflushes best-effort.init_in_memory(&str)(behind thetestingfeature) — wires anInMemoryMetricExporterso other crates' tests (e.g. the miner's §8 metric-collection test) can collect the exported stream without standing up an OTLP endpoint.Scope / what's deferred
semconv/registry/; (3) compaction instrumentation (RFC 0009 §3.6 viaglobal::meter("ourios.compaction"), seeding instruments at init per the §6.8 collect-on-read rule).Display+Error+From) to match the workspace convention — no newthiserrordependency.Versions
Aligned to the OTel stack already in the lockfile:
opentelemetry,opentelemetry_sdk,opentelemetry-otlpall0.32.Verification
cargo fmt --all --check✓cargo clippy --all-targets --all-features -- -D warnings✓ (pedantic clean)cargo test --workspace --all-features✓ (incl. the crate's in-memory metric-collection test)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores