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

Allow non-monontonic and empty sums on Histogram data points. #320

Closed
wants to merge 3 commits into from

Conversation

jsuereth
Copy link
Contributor

Fixes #303

  • Add a new enumeration to Histogram denoting the type of sum for that histogram.
  • Update documentation to denote this new enumeration is used for interpretataion of the sum field.
  • Default the value of this enumeration to "monotonic sum" for backwards compatiblity.

Fixes open-telemetry#303

- Add a new enumeration to Histogram denoting the type of sum for that histogram.
- Update documentation to denote this new enumeration is used for interpretataion of the sum field.
- Default the value of this enumeration to "monotonic sum" for backwards compatiblity.
@jsuereth jsuereth requested review from a team July 20, 2021 12:16
@jsuereth
Copy link
Contributor Author

FYI - I think this is what we discussed in the last metrics SiG: @jmacd @victlu @bogdandrutu

enum SumType {
// The histogram sum is a monotonic value and will not decrease.
// Note: This is the default for histograms if unspecified.
MONOTONIC = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we avoid 0 as we may not know if it's set or missing?

Maybe...
NONE = 0
MONOTONIC = 1
NON_MONOTONIC = 2
UNKNOWN_SUM = 3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Backwards-commpatiblity means previous users would NOT be specifying this value, which defaults to 0. So we should treat that as MONOTONIC.

Copy link
Member

@bogdandrutu bogdandrutu Jul 21, 2021

Choose a reason for hiding this comment

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

Was it that before? Did we have sum as monotonic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, sum was monotonic before

Copy link
Member

Choose a reason for hiding this comment

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

From here, that is not clear:

  // Note: Sum should only be filled out when measuring non-negative discrete
  // events, and is assumed to be monotonic over the values of these events.
  // Negative events *can* be recorded, but sum should not be filled out when
  // doing so.  This is specifically to enforce compatibility w/ OpenMetrics,
  // see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the linked bug. Basically we can't not fill out a sum, so due to the phrasing, we're always providing a sum and it's always monotonic.

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Instead of making "sum" special in terms of having an extra metadata, have we consider the following:

  1. Deprecating the current "sum" - keep it for backwards compatibility for 1.5y as we did for StatusCode in trace.
  2. Add a new sum with the type "google.protobuf.DoubleValue"?

The advantage is that this is a point scope property not a metric scope property? Is this important?

@jsuereth
Copy link
Contributor Author

@bogdandrutu

Instead of making "sum" special in terms of having an extra metadata, have we consider the following:

  1. Deprecating the current "sum" - keep it for backwards compatibility for 1.5y as we did for StatusCode in trace.

Didn't entertain removing sum completely. AFAICT something like it is expected as a value here. Care to comment on the viablity concerns to that approach?

  1. Add a new sum with the type "google.protobuf.DoubleValue"?

This doesn't solve the issue of understanding if the sum is monotonic or non-monotonic (which lead to the existing wonky wording we have). We'd like to keep sum, we just also need to know how to export it to prometheus so we need some kind of monotonicity marker.

The advantage is that this is a point scope property not a metric scope property? Is this important?

@jmacd pushed for the semantic of sum to be a metric-scope property vs. point scope (which was an earlier proposal). I could go either way myself, and see enough flexibility in metric-scope (given InstrumentationLibrary) that I think we're ok here.

// The histogram sum is a monotonic value and will not decrease.
// Note: This is the default for histograms if unspecified.
MONOTONIC = 0;
// The histogram sum may increasee or decrease.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// The histogram sum may increasee or decrease.
// The histogram sum may increase or decrease.

@bogdandrutu
Copy link
Member

@jsuereth

@jmacd pushed for the semantic of sum to be a metric-scope property vs. point scope (which was an earlier proposal). I could go either way myself, and see enough flexibility in metric-scope (given InstrumentationLibrary) that I think we're ok here.

For me this seems to be inconsistent with the flags. Why is a difference there?

@jmacd
Copy link
Contributor

jmacd commented Aug 5, 2021

In #316, the one new DataPointFlags value is about a condition that is specific to the point.

If there is a distinction to be made about the monotonicity of the Sum, then it appears to be a metric-level property, since it relates to the difference between points. I can't imagine what it means to have a stream of points where some declare their sum to be monotonic and some do not--those appear to be different streams, so I think the distinction belongs in the metric not the point.

I have in the past attempted to optimize the number of fields in these protocols by taking a cross-product of existing enums. We already have an AggregationTemporality field with two values, and now a SumType field with three values, (and I can imagine one more), so we could combine them as follows:

enum HistogramType {
  Unspecified = 0
  DeltaMonotonicSum = 1 // Backwards => AggregationTemporality_Delta w/ monotonic
  CumulativeMonotonicSum = 2 // Backwards => AggregationTemporality_Cumulative w/ monotonic
  DeltaUpDownSum = 3
  DeltaGaugeSum = 4
  CumulativeUpDownSum = 5
  CumulativeGaugeSum = 6
}

@bogdandrutu would that alleviate your concern about creating a new field?

@jsuereth
Copy link
Contributor Author

Going to propose we migrate to optional in proto, with justifcation. PR pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow sum to present with negative measurements in Histogram
7 participants