Hubs/Scopes Merge 28 - Fix breadcrumb ordering - #3355
Merged
Merged
Conversation
…pes-merge-2-add-scopes
…ainScopes to rootScopes
adinauer
requested review from
markushi,
romtsn and
stefanosiano
as code owners
April 15, 2024 11:32
Contributor
|
7 tasks
markushi
approved these changes
Apr 19, 2024
lbloder
reviewed
Apr 22, 2024
| public int compareTo(@NotNull Breadcrumb o) { | ||
| // TODO also use nano time if equal | ||
| return timestamp.compareTo(o.timestamp); | ||
| int timestampCompare = timestamp.compareTo(o.timestamp); |
Collaborator
There was a problem hiding this comment.
In order to have consistent ordering, should we always use nanos?
We would also have to change the constructor to take a nano time.
Member
Author
There was a problem hiding this comment.
Yeah makes sense, e.g. for OTEL where we likely have to create breadcrumbs after the fact. Will change it to only use nanos in a follow up PR.
9 tasks
runningcode
added a commit
that referenced
this pull request
Sep 14, 2026
Breadcrumb.compareTo ordered purely by a System.nanoTime() reading taken in the constructor. A breadcrumb rebuilt from a serialized one — read back from disk, or handed over by a hybrid SDK — got that reading at parse time, so a breadcrumb recorded yesterday sorted as if it had just happened, and the merged order in CombinedScopeView became parse order. The clone constructor had the same problem: copying a breadcrumb moved it to the end of the order. Order by the recorded timestamp instead, and keep the creation tick only as the tie-breaker it was added for in #3355, since timestamps are millisecond-granular. A deserialized breadcrumb carries no tick, and a clone carries the original's, so neither jumps position. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
runningcode
added a commit
that referenced
this pull request
Sep 15, 2026
Breadcrumb.compareTo ordered purely by a System.nanoTime() reading taken in the constructor. A breadcrumb rebuilt from a serialized one — read back from disk, or handed over by a hybrid SDK — got that reading at parse time, so a breadcrumb recorded yesterday sorted as if it had just happened, and the merged order in CombinedScopeView became parse order. The clone constructor had the same problem: copying a breadcrumb moved it to the end of the order. Order by the recorded timestamp instead, and keep the creation tick only as the tie-breaker it was added for in #3355, since timestamps are millisecond-granular. A deserialized breadcrumb carries no tick, and a clone carries the original's, so neither jumps position. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
#skip-changelog
📜 Description
Use
System.nanoTime()to have a more detailed timestamp for ordering breadcrumbs.The actual value shouldn't matter too much as breadcrumbs should be created / deserialized in order and
nanosare only used iftimestampis the same.💡 Motivation and Context
To have better ordering of breadcrumbs and avoid random order when timestamp is equal. This also caused flaky tests.
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps