Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Jul 10, 2025

Description

Spans could have zero duration. This will cause NaN values (floating point divide by zero), which when used in Blazor view will product NaN% strings.

This wouldn't break the page - the browser will ignore it - but it will avoid browser writing CSS warning.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where spans with zero duration would cause NaN percentage values in the dashboard's waterfall visualization. The fix introduces a helper method to safely calculate percentages by returning 0 when the total duration is 0, preventing division by zero errors.

Key changes:

  • Added a CalculatePercent helper method to handle division by zero scenarios
  • Enhanced test helper methods to support creating spans and logs with zero duration
  • Added comprehensive test coverage for the zero duration scenario

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/Aspire.Dashboard/Model/Otlp/SpanWaterfallViewModel.cs Added CalculatePercent helper method and replaced direct percentage calculations to prevent NaN values
tests/Aspire.Dashboard.Tests/Model/SpanWaterfallViewModelTests.cs Added test case to verify zero duration spans are handled correctly
tests/Shared/Telemetry/TelemetryTestHelpers.cs Enhanced test helpers with additional parameters and utility methods for better test support

@JamesNK JamesNK merged commit f3141e3 into main Jul 10, 2025
252 checks passed
@JamesNK JamesNK deleted the jamesnk/improve-percentage-calculation branch July 10, 2025 23:22
@github-actions github-actions bot locked and limited conversation to collaborators Aug 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants