fix: make resolve output deterministic by sorting groups#982
Merged
lquerel merged 8 commits intoopen-telemetry:mainfrom Oct 30, 2025
Merged
Conversation
Fixes open-telemetry#964 Added sorting of groups by id in the ResolvedRegistry::try_from_resolved_registry method. This ensures that the output of `weaver registry resolve` is deterministic and byte-for-byte identical across multiple runs, enabling diff checking and reproducible builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Optimize error handling by checking if errors occurred before sorting groups. This avoids unnecessary sorting operation when we're going to return an error anyway. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Added test to verify that groups in resolved registry are sorted alphabetically by ID, ensuring deterministic output across runs. - Added test_groups_sorted_deterministically test - Test creates registry with non-alphabetical groups (zebra, apple, middle) - Verifies output is sorted (apple, middle, zebra) - Confirms sorting is stable across multiple conversions - Updated test snapshots to reflect new sorted order 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Refactored group sorting to use itertools::sorted_by() in the iterator chain instead of a separate sort_by() call after collection. - Added itertools::Itertools import - Changed groups from mutable to immutable - Added .sorted_by() call in iterator chain before .collect() - Removed separate groups.sort_by() call This makes the code more functional and idiomatic while maintaining the same deterministic sorting behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Removed explicit type annotation from groups variable as it was not present in the original code and the type can be inferred. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Resolved conflicts by removing expected output files that will be regenerated by tests.
After merging main, regenerated expected output files with sorted groups. The registry.md files now reflect the deterministic alphabetical sorting of groups by ID implemented in the earlier commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
jsuereth
approved these changes
Oct 22, 2025
Contributor
jsuereth
left a comment
There was a problem hiding this comment.
Thanks for the fix! I think this is definitely a win for idempotent builds.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #982 +/- ##
=======================================
- Coverage 78.3% 78.3% -0.1%
=======================================
Files 77 77
Lines 6121 6122 +1
=======================================
- Hits 4795 4794 -1
- Misses 1326 1328 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
Fixes #964 by sorting groups alphabetically by ID, making resolve output deterministic.
Changes
ResolvedRegistry::try_from_resolved_registry()usingitertools::sorted_by()test_groups_sorted_deterministicallyTesting