feat(semconv): generate ourios-semconv constants crate via weaver forge - #105
Conversation
Phase 2 of the telemetry code work. Adds the dependency-free leaf
crate `ourios-semconv` holding `const &str` names for every metric
and attribute in `semconv/registry/`, generated by `weaver registry
generate` from a forge template at `templates/registry/rust/`.
Instrumentation will reference these constants instead of hand-typed
strings, so code names provably match the registry. Mirrors upstream
`opentelemetry-semantic-conventions` (also a standalone weaver-
generated leaf crate); kept out of `ourios-core` so anyone wanting a
name pulls zero deps and the DAG direction stays clean.
- `templates/registry/rust/{weaver.yaml,lib.rs.j2}` — the generator.
- `crates/ourios-semconv/src/lib.rs` — GENERATED; do not hand-edit.
- The `semconv` CI job now also regenerates + `cargo fmt` + `git diff
--exit-code`, so the checked-in constants can't drift from the
registry (drift-proof, the maintainer-chosen path).
- A hand-written `tests/exports.rs` locks the public const names.
Blessed in RFC 0009 §3.6 (the new leaf crate + the codegen step),
the same way `ourios-telemetry` was blessed in RFC 0001 §6.8.
Verification: weaver registry check + generate (no-diff), cargo fmt
--all --check, clippy --all-targets --all-features -D warnings, cargo
test -p ourios-semconv, mdbook build — 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 (5)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughWeaver templates now generate OpenTelemetry metric and attribute name constants into a new dependency-free crate ChangesSemantic Conventions Code Generation and Validation
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 |
There was a problem hiding this comment.
Pull request overview
Adds a weaver-generated, dependency-free Rust crate (ourios-semconv) that exports const &str metric/attribute names derived from semconv/registry, plus CI enforcement to prevent drift between the registry and checked-in generated code.
Changes:
- Introduces
crates/ourios-semconvwith generated constants and a small export-lock test. - Adds weaver forge templates under
templates/registry/rust/to generate the crate’ssrc/lib.rs. - Extends the CI
semconv (weaver)job to regenerate + rustfmt the crate and fail on diffs; updates RFC 0009 to document the approach.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/registry/rust/weaver.yaml | Weaver-forge config to render the Rust generator template. |
| templates/registry/rust/lib.rs.j2 | Jinja template that generates metric/attribute pub const exports. |
| docs/rfcs/0009-compaction.md | Documents the codegen approach and drift-proof CI enforcement. |
| crates/ourios-semconv/tests/exports.rs | Integration test to lock a few representative public constant names/values. |
| crates/ourios-semconv/src/lib.rs | Generated constants module checked into the repo. |
| crates/ourios-semconv/Cargo.toml | New crate manifest (intentionally dependency-free). |
| Cargo.toml | Adds crates/ourios-semconv to the workspace members. |
| Cargo.lock | Records the new workspace package. |
| .github/workflows/ci.yml | Updates semconv (weaver) job to regenerate + format + no-diff verify. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)
104-105: ⚡ Quick win
git diff --exit-codewon't catch newly generated untracked files.
git diffonly compares tracked files, so if regeneration ever emits a new file undercrates/ourios-semconv/srcthat isn't yet committed, the drift check passes silently. Staging first makes the check cover additions/deletions too.♻️ Hardened drift check
- name: Verify generated constants are in sync - run: git diff --exit-code -- crates/ourios-semconv/src + run: | + git add -A -- crates/ourios-semconv/src + git diff --cached --exit-code -- crates/ourios-semconv/src🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/ci.yml around lines 104 - 105, The CI step "Verify generated constants are in sync" currently runs a plain git diff which misses untracked new files; change it to first stage all changes under the generated-constants directory, run git diff against the staged/index (so additions/deletions are detected), then unstage/reset the index so the workspace is unchanged; update the step that runs the existing git diff command to perform these three operations in sequence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@templates/registry/rust/lib.rs.j2`:
- Around line 4-7: The header comment in templates/registry/rust/lib.rs.j2
incorrectly references a non-existent CI job name "semconv-codegen"; update the
template to reference the actual job name "semconv" so regenerated headers
(e.g., crates/ourios-semconv/src/lib.rs) are accurate—search for the string
"semconv-codegen" in templates/registry/rust/lib.rs.j2 and replace it with
"semconv" (ensuring the surrounding sentence remains grammatically correct),
then regenerate the registry output to verify the comment now matches the job
name defined in .github/workflows/ci.yml.
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 104-105: The CI step "Verify generated constants are in sync"
currently runs a plain git diff which misses untracked new files; change it to
first stage all changes under the generated-constants directory, run git diff
against the staged/index (so additions/deletions are detected), then
unstage/reset the index so the workspace is unchanged; update the step that runs
the existing git diff command to perform these three operations in sequence.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d4656767-6579-4f43-a34e-af3553aab121
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
.github/workflows/ci.ymlCargo.tomlcrates/ourios-semconv/Cargo.tomlcrates/ourios-semconv/src/lib.rscrates/ourios-semconv/tests/exports.rsdocs/rfcs/0009-compaction.mdtemplates/registry/rust/lib.rs.j2templates/registry/rust/weaver.yaml
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
… crate via weaver forge
|
@coderabbitai review |
✅ Action performedReview finished.
|
What
Phase 2 of the telemetry code work. Adds the
ourios-semconvcrate — a dependency-free leaf of weaver-generatedconst &strnames for every metric and attribute insemconv/registry/— plus the generator and a CI no-diff guard.This is the drift-proof codegen path chosen for the constants: instrumentation references
ourios_semconv::OURIOS_COMPACTION_SWEEPSrather than a hand-typed"ourios.compaction.sweeps", so code names provably match the registry.Design
opentelemetry-semantic-conventions(itself a standalone weaver-generated crate). Kept out ofourios-coreso any crate wanting a name pulls nothing and the dependency DAG direction stays clean (maintainer decision).templates/registry/rust/{weaver.yaml,lib.rs.j2}— the weaver forge generator.crates/ourios-semconv/src/lib.rs— GENERATED, do-not-hand-edit (header says so).semconvjob now alsoweaver registry generate+cargo fmt -p ourios-semconv+git diff --exit-code, so the checked-in constants can't drift from the registry.tests/exports.rs— a hand-written guard locking the public const names (a rename breaks this compile/assert alongside the no-diff check).Blessing
The new leaf crate + the codegen step are blessed in RFC 0009 §3.6, the same way
ourios-telemetrywas blessed in RFC 0001 §6.8. (CLAUDE.md §7 layout extension.)Scope
No instrumentation yet — Phase 3 wires these constants into the compaction metrics (
global::meter("ourios.compaction"), seeded at init per §6.8 collect-on-read).Verification
weaver registry check+weaver registry generate(regenerate is a no-op vs the committed file) ✓cargo fmt --all --check,clippy --all-targets --all-features -D warnings,cargo test -p ourios-semconv✓mdbook build✓🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Chores
Tests