[exporter/datadogexporter] Improve reset detection on cumulative metrics#6120
Merged
Merged
Conversation
- Take startTimestamp into account. - Differentiate between monotonic and non-monotonic diffs
mx-psi
commented
Nov 3, 2021
| if delta { | ||
| as.InsertInterpolate(lowerBound, upperBound, uint(count)) | ||
| } else if dx, ok := t.prevPts.putAndGetDiff(name, bucketTags, ts, float64(count)); ok { | ||
| } else if dx, ok := t.prevPts.Diff(name, bucketTags, startTs, ts, float64(count)); ok { |
Member
Author
There was a problem hiding this comment.
This could be MonotonicDiff, since the bucket count values should be increasing. However, in the case of a bug downstream, it could lead to reseting some bucket count values but not others, making the error harder to debug
| if delta { | ||
| consumer.ConsumeTimeSeries(ctx, fullName, Count, ts, count, bucketTags, host) | ||
| } else if dx, ok := t.prevPts.putAndGetDiff(fullName, bucketTags, ts, count); ok { | ||
| } else if dx, ok := t.prevPts.Diff(fullName, bucketTags, startTs, ts, count); ok { |
Member
Author
There was a problem hiding this comment.
Same comment applies here (this case would be easier to debug but for consistency I would keep it as is)
KSerrania
reviewed
Nov 3, 2021
KSerrania
approved these changes
Nov 4, 2021
Contributor
KSerrania
left a comment
There was a problem hiding this comment.
Left questions about tests, otherwise LGTM
KSerrania
approved these changes
Nov 5, 2021
bogdandrutu
approved these changes
Nov 5, 2021
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
The Datadog exporter automatically calculates the diff between points on cumulative monotonic sums, cumulative histograms and the fields of summaries that grow cumulatively. Until now we didn't take the start timestamp into account, so we were not detecting certain resets. We were also using monotonic diffs on non-monotonic metrics (e.g. histogram sum or count), which would omit negative values.
This PR updates the reset-detection code to conform to the "Resets and gaps" section of the data model specification.
Note that we don't report the first value we get, to account for Collector restarts.
Link to tracking Issue: Relates to #5378 discussion (this can avoid the
.summetric being 0 in certain cases)Testing: Added unit tests to test new behavior