← Back to Pull requests

test(metricdata): add unit tests for Extrema and Temporality #9091

Merged
shardool-patil merged 2 files (321 lines) on Oct 08, 2026 07:41 UTC
View on GitHub
shardool-patil shardool-patil commented on Oct 07, 2026 06:14 UTC
Author

Description

This PR introduces comprehensive unit test coverage for the go.opentelemetry.io/otel/sdk/metric/metricdata package, focusing on the public types Extrema[N] and Temporality. Prior to this change, the package had no direct unit test files (0.0% statement coverage).

Changes


  • Added sdk/metric/metricdata/data_test.go:

  • - Table-driven tests (testCases) for Extrema.Value() covering int64 and float64 across zero-values, positive, negative, and explicit zero states.
    - Table-driven tests (testCases) for Extrema.MarshalText() asserting text representation ("null" when uninitialized, scalar strings when defined).
    - Tests for Extrema.MarshalJSON():
    - Struct wrapper roundtrips for strongly typed int64 and float64 structs.
    - Table-driven tests (testCases) for pointer-receiver direct MarshalJSON() encoding across initialized and zero-value states.
  • Added sdk/metric/metricdata/temporality_test.go:

  • - Table-driven tests (testCases) for Temporality.String() testing CumulativeTemporality, DeltaTemporality, undefinedTemporality, and out-of-range bounds.
    - Table-driven tests (testCases) for Temporality.MarshalText() confirming byte matching against String().

    Verification


  • Module unit tests pass with 100.0% statement coverage:

  • ```bash
    cd sdk/metric && go test -v -count=1 -cover ./metricdata/...

    Diff: 321 lines (+321 / -0) across 2 files Reviewer: dmathieu Review duration: 1527m
    All Vouch review confidence checks passed
    Residual risk 0.13 = Change Risk (0.39) × (1 − Review Confidence (0.66)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 321 lines diff across 2 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.39 · 1 substantive comment(s)
    0.39
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    65%
    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.345
    Real PR Conversation Timeline
    4 items
    codecov[bot] codecov[bot] commented on Oct 07, 2026 06:17 UTC
    Bot

    Codecov Report


    :white_check_mark: All modified and coverable lines are covered by tests.
    :white_check_mark: Project coverage is 89.2%. Comparing base (8131b0a) to head (03d7afe).

    <details><summary>Additional details and impacted files</summary>

    ![Impacted file tree graph](https://app.codecov.io/gh/open-telemetry/opentelemetry-go/pull/9091?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)

    @@          Coverage Diff          @@
    ##            main   #9091   +/-   ##
    =====================================
      Coverage   89.2%   89.2%           
    =====================================
      Files        339     339           
      Lines      22340   22340           
    =====================================
    + Hits       19928   19933    +5     
    + Misses      2412    2407    -5     
    

    see 4 files with indirect coverage changes
    </details>
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • </details>

    dmathieu dmathieu approved these changes on Oct 07, 2026 07:41 UTC
    Approved Reviewer

    Approved these changes.

    ps-mir ps-mir approved these changes on Oct 07, 2026 09:09 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    shardool-patil shardool-patil
    Labels
    risk: low confidence: 65.6% 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% (MEDIUM) · Higher = larger blast radius
    39%
    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: 65.6% · Lower = rushed or shallow review
    65.6%
    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: 13.4% · Safe to merge
    13.4%