Skip to content

refactor(rust): let callers name the meter provider type - #48

Merged
yordis merged 1 commit into
mainfrom
yordis/refactor-rust-meter-generic
Oct 13, 2026
Merged

yordis merged 1 commit into
mainfrom
yordis/refactor-rust-meter-generic

Conversation

@yordis

@yordis yordis commented Oct 13, 2026 •

Copy link
Copy Markdown
Member
  • The meter constructor was the only generated Rust constructor that hid its provider type, so callers could not name it explicitly the way they can for the logger and tracer.
  • A named type parameter keeps the generated public API consistent and leaves room to evolve without breaking callers.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@cursor

cursor Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Template and golden-test output only; same runtime logic with a signature tweak that should remain source-compatible for typical &provider call sites.

Overview
Updates generated Rust Meter::new so the meter provider is a named generic P instead of an impl MeterProvider reference parameter.

The Jinja template meter.rs.j2 and all matching expected meter.rs fixtures under templates/code/rust/tests/*/expected/ are kept in sync with the new signature new<P: opentelemetry::metrics::MeterProvider + ?Sized>(provider: &P, ...). Behavior inside new is unchanged; only the public type signature changes so call sites can pin or infer a concrete provider type (e.g. when passing wrapped providers).

Reviewed by Cursor Bugbot for commit 464e743. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 745d709d-f005-4ced-9243-0db2bde481be
📥 Commits

Reviewing files that changed from the base of the PR and between 039cf30 and 464e743.

📒 Files selected for processing: 10
  • templates/code/rust/meter.rs.j2
  • templates/code/rust/tests/allocations/expected/meter.rs
  • templates/code/rust/tests/histogram_boundaries_by_unit/expected/meter.rs
  • templates/code/rust/tests/histogram_boundaries_by_unit_params/expected/meter.rs
  • templates/code/rust/tests/imported/expected/meter.rs
  • templates/code/rust/tests/imported_typed/expected/meter.rs
  • templates/code/rust/tests/literal_escaping/expected/meter.rs
  • templates/code/rust/tests/metrics/expected/meter.rs
  • templates/code/rust/tests/naming/expected/meter.rs
  • templates/code/rust/tests/params/expected/meter.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The Rust meter template and its expected outputs now declare the MeterProvider type as a named generic parameter. The trait bound, ?Sized constraint, and provider handling remain unchanged.

Changes

Rust Meter Signature

Layer / File(s) Summary
Update the meter signature and expected outputs
templates/code/rust/meter.rs.j2, templates/code/rust/tests/*/expected/meter.rs
Meter::new uses a named generic parameter P bounded by MeterProvider + ?Sized. The expected Rust outputs reflect the same signature. The remaining parameters and provider handling are unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 464e7

The change is limited to naming an existing generic provider type and is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 9 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the Rust API change and its purpose. It matches the changeset.
Title check Passed The title accurately and concisely describes the main change: callers can name the meter provider type.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 9 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checked the meter's type,
And named its P with care;
The bound stayed put, the code stayed still,
The tests now match the template,
Then hopped away through syntax fair.

Comment @coderabbitai help to get the list of available commands.

@yordis
yordis merged commit 6ec8e99 into main Oct 13, 2026
6 of 9 checks passed
@yordis
yordis deleted the yordis/refactor-rust-meter-generic branch October 13, 2026 21:00
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.

1 participant