-
Notifications
You must be signed in to change notification settings - Fork 0
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
Tracing instrumentation at deep search path #6
Conversation
86c6175
to
68f1723
Compare
if (searchRequestContext.getPhaseSpan() != null) { | ||
searchRequestContext.getPhaseSpan().endSpan(); | ||
} | ||
searchRequestContext.setPhaseSpan( | ||
tracer.startSpan( | ||
SpanBuilder.from( | ||
"coordinator" + capitalize(context.getCurrentPhase().getName()), | ||
new SpanContext(searchRequestContext.getRequestSpan()) | ||
) | ||
) | ||
); | ||
SpanScope spanScope = tracer.withSpanInScope(searchRequestContext.getPhaseSpan()); |
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.
Every SpanScope has to be closed. This is not the right way to add the span in a Scope. It actually add the span the TheadLocal and wait for it to be ended then only it will be removed. Further spans can use this span as a parent span. Here it will stay in the TheardLocal of the current thread and if the phase is being executed in an async fashion and ended by some other thread or callback then this Span still will stay in the ThreadLocal and can be wrongly mapped as a parent for other spans from different requests.
I think that's the reason you had to end the phase before start at line no 34.
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.
Ok I understand the purpose of SpanScope for attaching/detaching to threads but have one follow up question. Let's say we have a main function that calls child functions a, b, & c. We want to start the span somewhere in a() and end it somewhere in c(). How can we declare the SpanScope in this case?
void main() {
a()
b()
c()
}
a() {
...
startSpan()
...
}
b() {
...
}
void c() {
...
endSpan()
...
}
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.
Added SpanScope for all spans in latest commit
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.
@Gaganjuneja there was a bug in the listener interface that was causing an issue. It is now fixed in latest revision. Please review again
server/src/main/java/org/opensearch/action/search/TransportSearchAction.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/opensearch/action/search/TransportSearchAction.java
Outdated
Show resolved
Hide resolved
ef55bf6
to
8d9e4a1
Compare
Signed-off-by: David Zane <[email protected]>
Signed-off-by: David Zane <[email protected]>
Signed-off-by: David Zane <[email protected]>
Signed-off-by: David Zane <[email protected]>
Description
Tracing instrumentation at deep search path
Added spans at:
Testing
Sample Span Details
1. Coordinator node
2. Coordinator node phase
3. Shard phase
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.