-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[internal/core]: Introduce OrderMapByKey() function #34318
Conversation
@@ -75,13 +77,13 @@ func GroupDataPoints(metric pmetric.Metric, ag *AggGroups) { | |||
func MergeDataPoints(to pmetric.Metric, aggType AggregationType, ag AggGroups) { | |||
switch to.Type() { | |||
case pmetric.MetricTypeGauge: | |||
mergeNumberDataPoints(ag.gauge, aggType, to.Gauge().DataPoints()) | |||
mergeNumberDataPoints(pmetrictest.OrderMapByKey(ag.gauge), aggType, to.Gauge().DataPoints()) |
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.
Could we either duplicate this functionality or include it somewhere as a non-testing library? It feels odd to rely on a test package like this.
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.
I moved it to internal/common/maps
, any better suggestions?
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
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.
We don't need a changelog for this, since packages/modules under internal
can't be used outside the repo (source).
@@ -37,3 +39,22 @@ func CloneStringMap(m map[string]string) map[string]string { | |||
} | |||
return m2 | |||
} | |||
|
|||
func OrderMapByKey[K any](input map[string]K) map[string]K { |
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.
What property of the map does this affect? From what I can tell, map iteration order isn't stable, so changing the insertion order shouldn't have an impact on iteration order.
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.
hmm good point, do you think we should throw out this PR then?
Description: