feat: Add #[must_use] to AsyncInstrumentBuilder
#3246
+1
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This prevents code like the following from compiling:
meter .i64_observable_up_down_counter("my_counter") .with_callback(|observer| { observer.observe(1, &[]); });This code is missing the
.build()at the end. Before this commit, it would compile, but the callback would never be called. After this commit, it will cause a mostly helpful compile error:Most builders need to be built to be useful. Normal metrics are built and then observations are reported to them, where a failure to call
build()would be discovered at compile-time. However, observable metrics (async instruments) don't have that natural use point, as the result of building anAsyncInstrumentBuilderisn't typically needed. This makesAsyncInstrumentBuilderespecially error-prone without the#[must_use]declaration.Fixes #
Design discussion issue (if applicable) #
Changes
Please provide a brief description of the changes here.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes