Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram handle of double.NaN bounds and values #3279

Closed
wants to merge 2 commits into from
Closed

Histogram handle of double.NaN bounds and values #3279

wants to merge 2 commits into from

Conversation

mic-max
Copy link
Contributor

@mic-max mic-max commented May 12, 2022

Fixes #3171

Changes

  • It will correctly place double.NaN values in the final histogram bucket
  • Exception will be thrown if double.NaN is used as a histogram bound

For significant contributions please make sure you have completed the following items:

  • Appropriate CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

It also correctly will place `double.NaN` values in the final histogram bucket
@mic-max mic-max changed the title Histogram handle of double.NaN bounds and values Histogram handle of double.NaN bounds and values May 12, 2022
@mic-max mic-max marked this pull request as ready for review May 12, 2022 20:34
@mic-max mic-max requested a review from a team May 12, 2022 20:34
@@ -30,7 +30,7 @@ public class ExplicitBucketHistogramConfiguration : MetricStreamConfiguration
/// Requirements:
/// <list type="bullet">
/// <item>The array must be in ascending order with distinct
/// values.</item>
/// values. double.NaN is not allowed</item>
Copy link
Member

Choose a reason for hiding this comment

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

What about other IEEE754 subnormal (e.g. -Inf)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good callout. I could do a follow up change for other subnormals.
@reyang @alanwest How should we treat subnormals being used as bounds or values.
I assume bounds, we should throw exception. But for values, there's decisions to be made (SDK specific) of whether we should have them affect bucket counts (and which bucket), sum, min, and max for histograms. But I guess this also expands to the other instrument types.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

The 2nd link applies to exponential histogram, but many ideas might be helpful for explicit bucket histogram, too.

Copy link
Member

Choose a reason for hiding this comment

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

Nice. Hadn't seen the new wording for exponential histograms. I think it makes sense to follow this for explicit-bound histograms too. That is, effectively drop all sub-normal values from affecting min, max, and sum. I also think this wording would suggest that it is ok to not modify bucket counts either:

because these values do not map into a valid bucket

Copy link
Member

Choose a reason for hiding this comment

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

Sharing some additional context/thoughts:

image

Copy link
Member

@reyang reyang May 14, 2022

Choose a reason for hiding this comment

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

I think for Sum, the challenge is that even if we don't take subnormal as the input, the output could still be subnormal:

counter.Add(1.0E308);
counter.Add(1.0E308);
provider.ForceFlush();
var cursor = PrometheusSerializer.WriteMetric(buffer, 0, metrics[0]);
Assert.Matches(
("^"
+ "# TYPE test_counter counter\n"
+ "test_counter \\+Inf \\d+\n"
+ "$").Replace('\'', '"'),

@mic-max
Copy link
Contributor Author

mic-max commented May 13, 2022

@CodeBlanch I changed how recording a double.NaN affects the histogram sum. I thought it should not affect it, this fails the prometheus serializer test. How do you think we should handle this value? I don't see a specific mention of it in the OTel spec

@reyang
Copy link
Member

reyang commented May 13, 2022

this fails the prometheus serializer test. How do you think we should handle this value?

@mic-max PrometheusExporter is still experimental, feel free to make changes to it (including the tests) if you think it makes sense (based on what the latest Stable SDK spec says).

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label May 21, 2022
@github-actions
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Issues and pull requests which have been flagged for closing due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add double.NaN to Histogram Boundaries Tests
3 participants