Skip to content

Commit

Permalink
Avoid changing a correct order of span references (#5121)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?
- Resolves #5122

## Description of the changes
- Avoid changing order in the case described above.

## How was this change tested?
- A test case is added.

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [X] I have signed all commits
- [X] I have added unit tests for the new functionality
- [X] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

Signed-off-by: Sherwood Wang <sherwoodwang@users.noreply.github.com>
  • Loading branch information
sherwoodwang committed Jan 19, 2024
1 parent 88efe47 commit adbdb2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions model/adjuster/parent_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ParentReference() Adjuster {
for _, span := range trace.Spans {
firstChildOfRef := -1
firstOtherRef := -1
for i := 1; i < len(span.References); i++ {
for i := 0; i < len(span.References); i++ {
if span.References[i].TraceID == span.TraceID {
if span.References[i].RefType == model.SpanRefType_CHILD_OF {
firstChildOfRef = i
Expand All @@ -40,7 +40,7 @@ func ParentReference() Adjuster {
if swap == -1 {
swap = firstOtherRef
}
if swap != -1 {
if swap != 0 && swap != -1 {
span.References[swap], span.References[0] = span.References[0], span.References[swap]
}
}
Expand Down
5 changes: 5 additions & 0 deletions model/adjuster/parent_reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func TestParentReference(t *testing.T) {
incoming: []model.SpanRef{childOf(b)},
expected: []model.SpanRef{childOf(b)},
},
{
name: "local, local follows - keep order",
incoming: []model.SpanRef{childOf(a), followsFrom(a)},
expected: []model.SpanRef{childOf(a), followsFrom(a)},
},
{
name: "local and remote child in order",
incoming: []model.SpanRef{childOf(a), childOf(b)},
Expand Down

0 comments on commit adbdb2d

Please sign in to comment.