Skip to content

feat(rust): accept the global meter provider without a wrapper type - #45

Merged
yordis merged 1 commit into
mainfrom
yordis/feat-rust-unsized-provider
Oct 13, 2026
Merged

yordis merged 1 commit into
mainfrom
yordis/feat-rust-unsized-provider

Conversation

@yordis

@yordis yordis commented Oct 13, 2026 •

Copy link
Copy Markdown
Member
  • Consumers that hold the global meter provider only have a trait object, so they had to write a forwarding wrapper type just to construct a handle.
  • Removing that friction lets applications adopt the generated handles with whatever provider they already have.

@cursor

cursor Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
This widens constructor generics only; existing concrete-provider call sites should keep compiling, with no telemetry pipeline or security behavior changes.

Overview
Generated Meter, Tracer, and Logger new methods now take unsized OpenTelemetry providers (?Sized), so callers can pass trait objects such as &*opentelemetry::global::meter_provider() without a forwarding wrapper type.

The Rust template README documents that pattern with a global meter example. A metrics test asserts that a meter built from the global provider still exports the expected instrumentation scope and metric name. Weaver snapshot fixtures for generated handle modules were updated to match the new signatures.

Reviewed by Cursor Bugbot for commit 01abbea. 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 →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c15f314c-249c-4887-bfed-75e09ea15eb6
📥 Commits

Reviewing files that changed from the base of the PR and between 78cf29b and 01abbea.

📒 Files selected for processing: 1
  • templates/code/rust/README.md

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: ca83bd5a-6ceb-4c98-9ac9-d91d70ea5b95
📥 Commits

Reviewing files that changed from the base of the PR and between baafc32 and 78cf29b.

📒 Files selected for processing: 26
  • templates/code/rust/README.md
  • templates/code/rust/logger.rs.j2
  • templates/code/rust/meter.rs.j2
  • templates/code/rust/tests/allocations/expected/logger.rs
  • templates/code/rust/tests/allocations/expected/meter.rs
  • templates/code/rust/tests/event_no_attributes/expected/logger.rs
  • templates/code/rust/tests/events/expected/logger.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/logger.rs
  • templates/code/rust/tests/imported/expected/meter.rs
  • templates/code/rust/tests/imported/expected/tracer.rs
  • templates/code/rust/tests/imported_typed/expected/logger.rs
  • templates/code/rust/tests/imported_typed/expected/meter.rs
  • templates/code/rust/tests/imported_typed/expected/tracer.rs
  • templates/code/rust/tests/literal_escaping/expected/meter.rs
  • templates/code/rust/tests/metrics/expected/meter.rs
  • templates/code/rust/tests/metrics/test.rs
  • templates/code/rust/tests/naming/expected/meter.rs
  • templates/code/rust/tests/no_namespace/expected/logger.rs
  • templates/code/rust/tests/no_namespace/expected/tracer.rs
  • templates/code/rust/tests/params/expected/logger.rs
  • templates/code/rust/tests/params/expected/meter.rs
  • templates/code/rust/tests/params/expected/tracer.rs
  • templates/code/rust/tests/spans/expected/tracer.rs
  • templates/code/rust/tracer.rs.j2

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

Rust meter, logger, and tracer constructors now accept potentially unsized provider types. Generated outputs reflect the updated signatures. Documentation and a test demonstrate constructing a generated meter from the global meter provider.

Changes

Rust provider support

Layer / File(s) Summary
Allow unsized provider types
templates/code/rust/{logger,meter,tracer}.rs.j2, templates/code/rust/tests/*/expected/{logger,meter,tracer}.rs
The constructors add ?Sized to their provider bounds. Expected generated outputs use the updated signatures.
Document and test global-provider meter use
templates/code/rust/README.md, templates/code/rust/tests/metrics/test.rs
The README shows constructing a generated meter from the global provider. The test constructs one from a global provider trait object, records MyappTaskStarted, and checks exported scope, schema URL, and metric name.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 78cf2

Generated Rust constructors now accept the global meter provider trait object without a wrapper type. The change is backward compatible, and the README and test cover the new use. Merge risk is minimal.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 8.70% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 22 files. (4 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly summarizes the main change: Rust handles can accept the global meter provider without a wrapper type.
Description check Passed The description directly explains why the change is needed and how it helps consumers use existing global meter provider trait objects.
Full details: Docstring Coverage

Explanation

Docstring coverage is 8.70% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 22 files. (4 skipped: 4 unsupported.)

✨ 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

I’m a rabbit with a meter to try,
I gather a task and let its notes fly.
Providers unsized can join in the run,
Their metrics are checked when the flush is done.
I nibble a clover and hop by the stream.

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

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis force-pushed the yordis/feat-rust-unsized-provider branch from 78cf29b to 01abbea Compare October 13, 2026 20:03
@yordis
yordis merged commit 45342bf into main Oct 13, 2026
7 checks passed
@yordis
yordis deleted the yordis/feat-rust-unsized-provider branch October 13, 2026 20:07
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