Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metrics API] Rename init to build #2232

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

utpilla
Copy link
Contributor

@utpilla utpilla commented Oct 24, 2024

Towards #1699

Changes

  • Rename init method to build

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@utpilla utpilla requested a review from a team as a code owner October 24, 2024 00:14
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.1%. Comparing base (8bd529a) to head (5cbf860).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-sdk/src/metrics/mod.rs 96.9% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2232   +/-   ##
=====================================
  Coverage   79.1%   79.1%           
=====================================
  Files        121     121           
  Lines      21171   21171           
=====================================
+ Hits       16760   16762    +2     
+ Misses      4411    4409    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -12,6 +12,17 @@
- Updated the return types of `InstrumentProvider` trait methods to return the instrument instead of a `Result`. [#2227](https://github.com/open-telemetry/opentelemetry-rust/pull/2227)
- **Breaking change for exporter authors:** Marked `KeyValue` related structs and enums as `non_exhaustive`. [#2228](https://github.com/open-telemetry/opentelemetry-rust/pull/2228)
- **Breaking change for log exporter authors:** Marked `AnyValue` enum as `non_exhaustive`. [#2230](https://github.com/open-telemetry/opentelemetry-rust/pull/2230)
- **Breaking change for Metrics users:** The `init` method used to create instruments has been renamed to `build`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changelog about try_init still refers to "init". lets change that also.

Alternatively, we can make a single changelog entry consolidating the user-facing changes. Something like
Removed try_init method from instrument builders. To build instruments, user the build() method.
This method always return an instrument - in case of no sdk being enabled or instrument validation failed (invalid name etc.), or the instrument is disabled using views, the instrument internally uses a no-op.
eg:
before:
let counter = meter.u64_counter("my_counter").init();
let counter = meter.u64_counter("my_counter").try_init();
after:
let counter = meter.u64_counter("my_counter").build();

@cijothomas cijothomas merged commit a7de955 into open-telemetry:main Oct 24, 2024
25 checks passed
@cijothomas
Copy link
Member

Merging. The changelog suggestions can be handled in a consolidated way before next release.

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.

2 participants