Skip to content

Conversation

@jerbly
Copy link
Contributor

@jerbly jerbly commented Jun 1, 2025

Closes #748 and #752

Emits a metric for every one defined in the model.

Deficiencies:

  • While the unit is defined you cannot tell whether this is int or float. So integer instruments are created in all cases.
  • Examples are not given for the metric value, only attributes. So 1 is used in all cases.

Bug fixes:
This feature highlighted two issues which are fixed here with regression tests.

  • Enum samples were always emitted as string, meaning ints, bools and doubles would fail with undefined_enum_variant in live-check.
  • Otel illegal_namespace advice was raised by the rego policy when the attribute collision was with a deprecated attribute.

@jerbly jerbly requested a review from a team as a code owner June 1, 2025 19:14
@codecov
Copy link

codecov bot commented Jun 1, 2025

Codecov Report

Attention: Patch coverage is 55.73770% with 27 lines in your changes missing coverage. Please review.

Project coverage is 75.7%. Comparing base (d765132) to head (4b39aa3).

Files with missing lines Patch % Lines
crates/weaver_emit/src/metrics.rs 50.0% 15 Missing ⚠️
crates/weaver_emit/src/lib.rs 50.0% 12 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #767     +/-   ##
=======================================
- Coverage   75.9%   75.7%   -0.3%     
=======================================
  Files         67      68      +1     
  Lines       5435    5494     +59     
=======================================
+ Hits        4127    4159     +32     
- Misses      1308    1335     +27     

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

I made few suggestions to better separate metrics from spans but otherwise LGTM


// TODO Emit metrics
// Emit metrics
let meter_provider = match tracer_provider_config {
Copy link
Contributor

Choose a reason for hiding this comment

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

tracer_provider_config could be renamed/generalized into signal_provider_config

let meter_provider = match tracer_provider_config {
ExporterConfig::Stdout => init_stdout_meter_provider(),
ExporterConfig::Otlp { endpoint } => {
init_meter_provider(endpoint).map_err(|e| Error::TracerProviderError {
Copy link
Contributor

Choose a reason for hiding this comment

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

TracerProviderError -> MetricProviderError ?

/// Values are generated based on the attribute type and examples where possible.
#[must_use]
fn get_attribute_name_value(attribute: &Attribute) -> KeyValue {
pub fn get_attribute_name_value(attribute: &Attribute) -> KeyValue {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not that be moved into a dedicated module?

@jerbly jerbly merged commit 02fadad into open-telemetry:main Jun 2, 2025
22 checks passed
@jerbly jerbly deleted the emit-metrics branch June 2, 2025 23: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.

Add Metrics to Emit

2 participants