-
Notifications
You must be signed in to change notification settings - Fork 1.2k
log: Fix comparison of unordered map values #5306
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
log: Fix comparison of unordered map values #5306
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5306 +/- ##
=====================================
Coverage 84.6% 84.6%
=====================================
Files 268 268
Lines 17695 17704 +9
=====================================
+ Hits 14971 14981 +10
+ Misses 2412 2411 -1
Partials 312 312
|
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.
While I agree that for maps the order should not make any difference, I do not think the same applies for slices.
My linked PR for logrus has different orders based on the OS (my mac, and linux on CI), which caused failures. |
Can you sort your slice values before creating the attribute? |
Or sort in tests if for logrus the order is not preserved. PS. Maybe https://pkg.go.dev/github.com/stretchr/testify/assert#ElementsMatch will help. |
Actually, my failing logrus test is because of a map, not a slice. So I have removed slice sorting from here. |
482ba99
to
d34abd9
Compare
Can you update the benchmark results? I believe they will be different 😉 |
I have updated them (with only map->map comparison to ease reading). Surprisingly, the difference is very small. |
@MadVikingGod PTAL |
49977a0
to
4e2e11e
Compare
Map attributes should be equal even if their order is different, which can cause issues, for example in open-telemetry/opentelemetry-go-contrib#5356.