Skip to content

Fix issue where Domain to UI model converter double reports the same …#579

Merged
yurishkuro merged 4 commits intomasterfrom
fix_double_ref_issue
Dec 4, 2017
Merged

Fix issue where Domain to UI model converter double reports the same …#579
yurishkuro merged 4 commits intomasterfrom
fix_double_ref_issue

Conversation

@black-adder
Copy link
Copy Markdown
Contributor

…Span Reference

Problem was that the converter removes the parentSpanID and replaces it with a parent child-of Reference. But if the child-of reference is already present in the model span, it gets double reported.

It seems like the whole if span.ParentSpanID != 0 && !preserveParentID { code path could be removed. Can any part of the jaeger system send in a span where ParentSpanID is filled out but the child-of reference is not present? Also, the logic here makes a couple of faulty assumptions.

Signed-off-by: Won Jun Jang wjang@uber.com

…Span Reference

Signed-off-by: Won Jun Jang <wjang@uber.com>
@ghost ghost assigned black-adder Dec 4, 2017
@ghost ghost added the review label Dec 4, 2017
}
for _, ref := range span.References {
out = append(out, json.Reference{
// TODO if the parentRef was wrongly added as a ChildOf ref above, this could
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this TODO, it might be easier to keep track of parentRef but not add it until we're done with this for loop and if the reference isn't added, add it post. This way, if the reference should be a FollowsFrom, we don't double report.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to fix it for good then?

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 42ba40f on fix_double_ref_issue into 00b1cb6 on master.

@yurishkuro
Copy link
Copy Markdown
Member

Can any part of the jaeger system send in a span where ParentSpanID is filled out but the child-of reference is not present?

iirc the only reason ParentSpanID even exists in the model is an optimization. In our deployment we hardly have any apps that create FollowsFrom references, so the overwhelming majority of spans have just a single parent of the child-of type. Instead of representing that link as a full blown Reference object we simply record the ParentSpanID (a single uint64).

Signed-off-by: Won Jun Jang <wjang@uber.com>
SpanID: json.SpanID(ref.SpanID.String()),
}
out = append(out, newRef)
if newRef.TraceID == json.TraceID(span.TraceID.String()) &&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comparison via strings is inefficient - you have the strongly typed ref in scope, why not use that?

}
}
if span.ParentSpanID != 0 && !preserveParentID && !parentRefAdded {
// TODO this (wrongly) assumes that the reference type is always ChildOf
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it assumes that correctly, because if ParentSpanID != 0 but there are no other references then that ParentSpanID does refer to child-of type (you may want to leave that as a comment)

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 264f056 on fix_double_ref_issue into 00b1cb6 on master.

Signed-off-by: Won Jun Jang <wjang@uber.com>
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 5c7a4c2 on fix_double_ref_issue into 00b1cb6 on master.

SpanID: json.SpanID(ref.SpanID.String()),
})
if ref.TraceID == span.TraceID && ref.SpanID == span.ParentSpanID {
// Check if the parent reference already exists
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this comment explains anything, maybe remove it?

parentRefAdded = true
}
}
if span.ParentSpanID != 0 && !preserveParentID && !parentRefAdded {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not directly related to this diff, but I see that the only time preserveParentID == true happens is when this conversion is called from ES storage WriteSpan function. What was the reason why we needed to preserve ParentSpanID in ES? Same performance/storage optimization?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't recall the exact reason but it probably has to do with keeping the es schema the same as the zipkin one.

@yurishkuro
Copy link
Copy Markdown
Member

Incidentally, I wonder if it would've been better to write an Adjuster for the domain model instead, and not have any of this business logic in the toJSON conversion.

Signed-off-by: Won Jun Jang <wjang@uber.com>
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 8926820 on fix_double_ref_issue into 00b1cb6 on master.

@yurishkuro yurishkuro merged commit e86551d into master Dec 4, 2017
@ghost ghost removed the review label Dec 4, 2017
@black-adder black-adder deleted the fix_double_ref_issue branch December 4, 2017 18:30
@yurishkuro
Copy link
Copy Markdown
Member

btw was there a ticket describing what the problem this was causing?

@black-adder
Copy link
Copy Markdown
Contributor Author

only internally, I thought it was an internal build issue. I'll put one up on github

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants