Skip to content

Conversation

@cijothomas
Copy link
Member

unit, desc were lost when the View did not explicitly specify them. This PR fixes this bug. If any aspect is not specified in the View's Stream configuration, it'll use the default (if advisory is available, that is considered first before default)

@cijothomas cijothomas requested a review from a team as a code owner May 20, 2025 18:04
@codecov
Copy link

codecov bot commented May 20, 2025

Codecov Report

Attention: Patch coverage is 96.46465% with 7 lines in your changes missing coverage. Please review.

Project coverage is 81.4%. Comparing base (d52dcef) to head (27eeade).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-sdk/src/metrics/pipeline.rs 80.0% 4 Missing ⚠️
opentelemetry-sdk/src/metrics/mod.rs 98.2% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2981     +/-   ##
=======================================
+ Coverage   81.2%   81.4%   +0.1%     
=======================================
  Files        126     126             
  Lines      24394   24571    +177     
=======================================
+ Hits       19827   20005    +178     
+ Misses      4567    4566      -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn view_test_rename() {
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests and the helper method need not be async.

otel_debug!(
name : "Metrics.InstrumentCreated",
instrument_name = stream.name.as_ref(),
instrument_name = stream.name.clone().unwrap_or_default().as_ref(),
Copy link
Contributor

Choose a reason for hiding this comment

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

We are being forced to introduce a lot of unwrap_or_default() method calls even though we know that the stream provided to cached_aggregator method would always have some name, unit, and description.

We should ideally create another internal struct that would have the same fields as Stream but they wouldn't be optional. Using such a struct instead of Stream would allow to get rid of these unwrap_or_default() calls which have weakened the contract for cached_aggregator method.

Copy link
Member Author

Choose a reason for hiding this comment

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

good point! we can modify this separately, as we use the unwrap_default for buckets, attribute_keys too.


let match_fn: Box<dyn Fn(&Instrument) -> bool + Send + Sync> = if contains_wildcard {
if !mask.name.is_empty() {
if mask.name.is_some() {
Copy link
Contributor

Choose a reason for hiding this comment

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

We still might have to check for empty string. A user could still provide an empty string as Some(String::new()).

Copy link
Contributor

@utpilla utpilla left a comment

Choose a reason for hiding this comment

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

Left some suggestions.

@cijothomas cijothomas merged commit cc93ead into open-telemetry:main May 21, 2025
26 of 27 checks passed
@cijothomas cijothomas deleted the cijothomas/view-bug1 branch May 21, 2025 00:59
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