← Back to Pull requests

OU-481: use natural sort for label columns in metrics query table #1462

Closed
unknown closed this pull request without merging on Nov 26, 2026 15:42 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 22:24 UTC
Author

Summary

  • Add naturalSort utility function using localeCompare with numeric: true option to sort strings with embedded numbers in numeric order rather than lexicographic order

  • Update QueryTable sorting in MetricsPage to use naturalSort for all label columns (keeps dedicated numeric sort for the Values column)

  • Add comprehensive unit tests for naturalSort covering numeric strings, mixed alphanumeric, direction, null/undefined handling, case insensitivity, and pure alphabetic strings
  • Problem

    The metrics query table sorted label columns lexicographically, producing incorrect ordering for columns containing numeric values. For example, labels with values 1, 10, 2, 20 were sorted as 1, 10, 2, 20 instead of the expected 1, 2, 10, 20. Port numbers, memory values, CPU counts, and any other numeric data in query result labels were affected.

    Fixes: https://github.com/openshift/console/issues/13543

    Test plan

  • Run npm run test:unit -- sort-utils.spec.ts — all new naturalSort tests pass

  • Run npm run lint:tsc — TypeScript compiles cleanly

  • Run npm run lint — ESLint passes

  • Navigate to Observe → Metrics, run up query, click a label column header, verify port numbers sort numerically (9090, 9091, 9100 not 9090, 9100, 9091)

  • Verify alphabetic labels (job names, namespaces) still sort correctly

  • Verify both ascending and descending directions work
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Improved metrics table sorting with natural alphanumeric ordering and case-insensitive comparisons, making mixed labels and version-like values easier to scan.
    Values sort numerically, with Prometheus positive and negative infinity labels handled correctly. NaN values appear last in either sort direction, while nonnumeric values follow numeric values.
    Empty and missing values are handled consistently when sorting.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 270 lines (+202 / -68) across 3 files Reviewer: jgbernalp Review duration: 3917m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 270 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.335
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1462"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.4% (MEDIUM) · Higher = larger blast radius
    39.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.6% · Safe to merge
    15.6%