Skip to content

Adds metric value type#773

Merged
jerbly merged 11 commits intoopen-telemetry:mainfrom
jerbly:metric-value-type
Jun 11, 2025
Merged

Adds metric value type#773
jerbly merged 11 commits intoopen-telemetry:mainfrom
jerbly:metric-value-type

Conversation

@jerbly
Copy link
Contributor

@jerbly jerbly commented Jun 8, 2025

This PR partially addresses: open-telemetry/semantic-conventions#591

  • Adds value_type to metric group type.
  • Produces a warning if value_type is not specified.
  • registry emit uses the value_type to produce correct values
  • registry live-check compares the incoming value type from data-points and exemplars to produces a value_type_mismatch advice with information level.

@jerbly jerbly requested review from a team as code owners June 8, 2025 14:43
@codecov
Copy link

codecov bot commented Jun 8, 2025

Codecov Report

Attention: Patch coverage is 96.59091% with 3 lines in your changes missing coverage. Please review.

Project coverage is 76.2%. Comparing base (dbf27e3) to head (bc7f73a).

Files with missing lines Patch % Lines
crates/weaver_live_check/src/advice.rs 90.9% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #773     +/-   ##
=======================================
+ Coverage   75.9%   76.2%   +0.2%     
=======================================
  Files         69      69             
  Lines       5510    5576     +66     
=======================================
+ Hits        4187    4253     +66     
  Misses      1323    1323             

☔ 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.

Copy link
Member

@lmolkova lmolkova left a comment

Choose a reason for hiding this comment

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

thank you!

Copy link
Contributor

@lquerel lquerel left a comment

Choose a reason for hiding this comment

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

Two minor nits, otherwise this looks good to me. Thanks!

histogram.record(1.0, &attributes);
}
},
_ => match instrument {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not explicitly specify the second branch?

I agree, it’s unlikely, but if we ever introduce a third variant (both in OTLP and Semconv), the compiler won’t help us do the right thing.

fn json_to_value_type(value: &Value) -> Option<MetricValueTypeSpec> {
match value {
Value::Number(num) => {
if num.is_i64() {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about is_u64 ?

Copy link
Contributor

@jsuereth jsuereth left a comment

Choose a reason for hiding this comment

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

Overall this looks good, if we agree on the direction of enforcing types in weaver.

I think in our data model for OTLP, we don't actually limit metrics to remain the same type for a stream.

For example, from https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md, it says:

Within certain data point types (e.g., Sum and Gauge) there is variation permitted in the numeric point value; in this case, the associated variation (i.e., floating-point vs. integer) is not considered identifying.

This makes me think we should NOT be enforcing types in weaver generally.

@jerbly
Copy link
Contributor Author

jerbly commented Jun 10, 2025

@jsuereth - OK. I won't merge this then until we have a decision. Perhaps we have the value_type more as a recommendation and the out-of-the-box codegen can use this. Live-check advice-level could be changed to information instead of violation where there's a mismatch.

@jerbly jerbly merged commit 163f084 into open-telemetry:main Jun 11, 2025
23 checks passed
@jerbly jerbly deleted the metric-value-type branch June 11, 2025 22: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.

4 participants