-
Notifications
You must be signed in to change notification settings - Fork 104
Opencensus Tracing: Start tracing server streaming callables. #635
Opencensus Tracing: Start tracing server streaming callables. #635
Conversation
This depends on googleapis#633 and is extracted from googleapis#613. This introduces TracedServerStreamingCallables that will create a trace and complete it. It is inserted as one of the outermost links in the callable chain to allow all other callables to contribute their annotations. google-cloud-java that extend the chains (like cloud bigtable) will also use this class to trace their extensions.
| String clientName = fullServiceName.substring(serviceIndex + 1); | ||
|
|
||
| return SpanName.of(clientName, methodName); | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
28f135d to
a60fb70
Compare
|
Rebased, this is ready for review |
Codecov Report
@@ Coverage Diff @@
## master #635 +/- ##
============================================
+ Coverage 74.64% 75.37% +0.72%
- Complexity 961 979 +18
============================================
Files 183 185 +2
Lines 4216 4239 +23
Branches 334 335 +1
============================================
+ Hits 3147 3195 +48
+ Misses 916 891 -25
Partials 153 153
Continue to review full report at Codecov.
|
|
I added cancellation handling similar to #634 |
vam-google
left a comment
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.
My only real concern now (it applies to all of the PRs) is the code duplication in the internal static classes inside the Traced*Callable classes.
| new StreamController() { | ||
| @Override | ||
| public void cancel() { | ||
| wasCancelled = true; |
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.
This looks like the only difference between this internal static class and the bidistream version https://github.com/googleapis/gax-java/pull/636/files#diff-08e9aa9f0dcb325e4bd2a1770d907a77R98. In general it seems like a lot of duplication (sometimes completely identical code, like this example) between the internal static classes of the Traced*Callable.
Please strongly consider. Moving the internal static classes to a package private classes under tracing package and reuse them in all of the Traced* callables.
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.
done
|
|
||
| @Override | ||
| public void onResponse(ResponseT response) { | ||
| tracer.responseReceived(); |
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.
Same ordering-specific question as in another PR (BTW, Ideally we would want this code to be shared, please see the above coment)
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.
From bidi PR
Does the order of calls make any difference here (or can make any at least potentially in a corner case)? It seems logical to report response received (i.e. call tracer) as a last statement, so the reporting is done when everything is really done.
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.
The span should only wrap the work that the client/callable is doing, not the user's callbacks. Ie. if someone does this:
client.readRowsCallable().call(request, new ResponseObserver() {
void onResponse(Row row) {
Thread.sleep(1000)
}
}We don't want to include the 1 second sleep. That should be part of the caller's span not the clients
| /** | ||
| * A wrapper callable that will wrap a callable chain in a trace. | ||
| * | ||
| * <p>This class is meant to be an internal implementation google-cloud-java clients only. |
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.
Please remove google-cloud-java from the documentation.
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.
From the bidi PR:
Please remove the mention of google-cloud-java from the doc. Gax should be generator-specific and should not really know about google-cloud-java. In @internalapi it is kind of ok, since the whole gist of the annotation is to talk about "internal stuff", but it is not ok in the actual documentation of the class.
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.
Is the implication that google-cloud-java clients are allowed to use any @InternalOnly api?
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.
It is ok to leave mention of google-cloud-java in @InternalApi annotation description (which, probably, can be considered as "permissions" to use in under google-cloud-java). Here I'm asking to remove it from the documentation only (google-cloud-java is mentioned twice in this class I'm asking to remove one of the mentions).
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.
done
| @Override | ||
| public void onError(Throwable t) { | ||
| if (wasCancelled) { | ||
| tracer.operationCancelled(); |
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.
From bidi PR
What would be the value of Throwable t here? Can it really be dropped? Won't it be same as cancellationCause? If no, why?
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.
This is to workaround the the retry implementation using cancellations to end polling. I don't want these to be traced as cancellations. I added a comment explaining the motivation
|
|
||
| @Override | ||
| public void onComplete() { | ||
| tracer.operationSucceeded(); |
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.
From bidi PR
Same ordering question as for the onResponse() method.
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.
Lets keep discussion, in https://github.com/googleapis/gax-java/pull/635/files#r251609835
|
All feedback should be addressed. PTAL |
vam-google
left a comment
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.
LGTM, but please check the comment about mentioning google-cloud-java in the doc.
|
Thanks for reviewing! |
This depends on #633 and is extracted from #613.
This introduces TracedServerStreamingCallables that will create a trace and complete it. It is inserted as one of the outermost links in the callable chain to allow all other callables to contribute their annotations.
google-cloud-java that extend the chains (like cloud bigtable) will also use this class to trace their extensions.