-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fix flaky TestConsumeMetricsWithOTelRemapper #312
Merged
Merged
Conversation
This file contains 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
lahsivjar
commented
Jul 4, 2024
Comment on lines
-865
to
-883
// Configure scope for hostmetrics receiver | ||
sm.Scope().SetName("otelcol/hostmetricsreceiver/load") | ||
|
||
// Add a datapoint for a metric produced by hostmetrics receiver | ||
metric := sm.Metrics().AppendEmpty() | ||
metric.SetName("system.cpu.load_average.1m") | ||
dp := metric.SetEmptyGauge().DataPoints().AppendEmpty() | ||
dp.SetTimestamp(pcommon.NewTimestampFromTime(ts)) | ||
dp.SetDoubleValue(0.7) | ||
|
||
// process metric | ||
sm = rm.ScopeMetrics().AppendEmpty() | ||
sm.Scope().SetName("otelcol/hostmetricsreceiver/process") | ||
metric = sm.Metrics().AppendEmpty() | ||
metric.SetName("process.memory.usage") | ||
dp = metric.SetEmptySum().DataPoints().AppendEmpty() | ||
dp.SetTimestamp(pcommon.NewTimestampFromTime(ts)) | ||
dp.SetStartTimestamp(pcommon.NewTimestampFromTime(startTs)) | ||
dp.SetIntValue(1024) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[For reviewers] There should be no change in the tests. The tests just divides the load and the process scope into two separate tests.
kruskall
approved these changes
Jul 4, 2024
This was referenced Jul 5, 2024
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.
The flakiness in the test
TestConsumeMetricsWithOTelRemapper
was introduced in #309 when we added another scope in the metric.The root cause of the flakiness is the function
eventsMatch
. This function sorts the APMEvents by converting it into strings and later compares them at which point it usesprotocmp.SortRepeated
for metricset samples. The metricsets are created using maps (ref) which makes the order of metricsets undefined. While the tests use sorting on the metricset samples to get around this we still end up in an indeterministic state since the first sort doesn't sort on metricset samples (ref).We can fix the
eventsMatch
function by first sorting the samples in eachAPMEvent
and then sorting theAPMEvent
's themselves and this is what the PR does. In addition the PR also refactors the testTestConsumeMetricsWithOTelRemapper
which would avoid the special issue anyway.