Skip to content

Code Quality: Metric parsing silently uses default values #31

@drmingdrmer

Description

@drmingdrmer

Summary

Metric value parsing silently falls back to 0.0 and histogram bucket parsing silently drops invalid entries.

Locations

crates/service/src/meta_node/meta_node.rs:509

let value: f64 = value_str.parse().unwrap_or(0.0);

crates/service/src/meta_node/meta_node.rs:714-718

.filter_map(|(le, cumulative_count)| {
    le.parse::<f64>()
        .ok()
        .map(|le_val| (le_val, *cumulative_count))
})

Problem

  • Invalid metric values become 0.0 silently
  • Invalid histogram bucket labels are dropped silently
  • Data corruption or format issues are masked
  • Monitoring dashboards may show incorrect data

Impact

  • Metrics dashboards show incorrect values
  • Capacity planning based on wrong data
  • Format changes go unnoticed
  • Data corruption is hidden

Suggested Fix

Log invalid values:

let value: f64 = value_str.parse().unwrap_or_else(|e| {
    warn!("Invalid metric value '{}': {}", value_str, e);
    0.0
});

// For histogram buckets
.filter_map(|(le, cumulative_count)| {
    match le.parse::<f64>() {
        Ok(le_val) => Some((le_val, *cumulative_count)),
        Err(e) => {
            warn!("Invalid histogram bucket '{}': {}", le, e);
            None
        }
    }
})

Priority

P3 - Observability improvement

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions