forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 27
[awsemfexporter] Fix grouping for container insights metrics for mixed metric types #320
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6480c9b
Fix grouping for to allow multiple metric types in 1 emf log for cont…
lisguo 3de4ed9
Update tests, fix formatting
lisguo 967cd9b
Fix lint
lisguo bae5d1d
Fix typo for lint
lisguo 43d26f6
Change container insights gauge metrics to sum. Ensure unsupported ty…
lisguo f555eb3
Fix assert lint
lisguo 3eac67b
Remove logic to drop unsupported types for ci
lisguo 99cc28c
Merge branch 'aws-cwa-dev' into nvme-emf-fix
lisguo 775dd21
Merge branch 'aws-cwa-dev' into nvme-emf-fix
lisguo 49b21e9
Fix tests
lisguo 0f07e19
Fix linter again
lisguo 61eb7ab
Fix race condition
lisguo af63694
Update exporter/awsemfexporter/grouped_metric.go
lisguo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ package awsemfexporter | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"sort" | ||
"testing" | ||
"time" | ||
|
||
|
@@ -430,13 +431,24 @@ func TestAddToGroupedMetric(t *testing.T) { | |
} | ||
assert.Len(t, groupedMetrics, 2) | ||
expectedLabels := map[string]string{"label1": "value1"} | ||
idx := 0 | ||
|
||
// Sort metadata list to prevent race condition | ||
var metadataList []cWMetricMetadata | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a flaky test. The github runner runs the unit tests with -race. Had to fix it by sorting the metadata list |
||
for _, v := range groupedMetrics { | ||
metadataList = append(metadataList, v.metadata) | ||
} | ||
sort.Slice(metadataList, func(i, j int) bool { | ||
return metadataList[i].batchIndex < metadataList[j].batchIndex | ||
}) | ||
|
||
for i, metadata := range metadataList { | ||
expectedMetadata := generateTestMetricMetadata(namespace, timestamp, logGroup, logStreamName, instrumentationLibName, metrics.At(0).Type(), i) | ||
assert.Equal(t, expectedMetadata, metadata) | ||
} | ||
for _, v := range groupedMetrics { | ||
assert.Len(t, v.metrics, 1) | ||
assert.Len(t, v.labels, 1) | ||
assert.Equal(t, generateTestMetricMetadata(namespace, timestamp, logGroup, logStreamName, instrumentationLibName, metrics.At(0).Type(), idx), v.metadata) | ||
assert.Equal(t, expectedLabels, v.labels) | ||
idx++ | ||
} | ||
}) | ||
|
||
|
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.