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

[Prometheus Remote Write Exporter] Handling Staleness flag from OTLP. #6679

Merged

Conversation

hyunuk
Copy link
Contributor

@hyunuk hyunuk commented Dec 9, 2021

Description:
This PR is to ensure the Prometheus Remote Write Exporter responds to OTLP flags from the Prometheus Receiver for all metric data types, including gauge, sum, histogram, and summary.
This PR checks MetricDataPointFlagNoRecordedValue flag and set the StaleNaN value to the sample of the data point.

Link to tracking Issue:
#6620

Testing:
Test cases have been implemented to verify the sample value is set to staleNaN if it has the OTLP flag.

@hyunuk hyunuk requested review from a team and tigrannajaryan December 9, 2021 22:00
Comment on lines 327 to 336
// check for staleness marker flag
if pt.Flags().HasFlag(pdata.MetricDataPointFlagNoRecordedValue) {
sample.Value = math.Float64frombits(value.StaleNaN)
} else {
switch pt.Type() {
case pdata.MetricValueTypeInt:
sample.Value = float64(pt.IntVal())
case pdata.MetricValueTypeDouble:
sample.Value = pt.DoubleVal()
}
Copy link
Member

Choose a reason for hiding this comment

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

Mayor be better to extract this as a separate func.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed else case.

} else {
switch pt.Type() {
case pdata.MetricValueTypeInt:
sample.Value = float64(pt.IntVal())
Copy link
Member

Choose a reason for hiding this comment

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

Not in this PR, but do we ever do this? I am sure that only Prometheus receiver does this stale marker, and they don't use the int.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The switch statement is for the case when the datapoint has no OTLP flag, which means the data is not a staleness marker. I changed it to enhance the readability.

I also checked the prometheusreceiver part and there is no usage that the metric value type is integer at this moment, but should we leave this switch-case in case of we have the integer values from OTLP in the future? I found some test cases like uint64_counter

Comment on lines +387 to +389
if pt.Flags().HasFlag(pdata.MetricDataPointFlagNoRecordedValue) {
bucket.Value = math.Float64frombits(value.StaleNaN)
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this the protocol in Prometheus that you do this for all the buckets?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure whether it is documented, but the observed behavior is that the stale marker is produced for individual buckets that disappear. Thus I would expect that when the entire histogram disappears each bucket should be marked stale.

Copy link
Member

Choose a reason for hiding this comment

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

@Aneurysm9 FYI you need a followup on our proto/specification to ensure that we send the buckets definition when we set the flag as well, because this was not clear to me at least.

@Aneurysm9 Aneurysm9 added the ready to merge Code review completed; ready to merge by maintainers label Dec 10, 2021
@hyunuk hyunuk requested a review from bogdandrutu December 13, 2021 18:16
@bogdandrutu bogdandrutu merged commit 21a6d99 into open-telemetry:main Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants