Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Conversation

@igorbernstein2
Copy link
Contributor

@igorbernstein2 igorbernstein2 commented Jan 2, 2019

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.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 2, 2019
@igorbernstein2 igorbernstein2 added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 3, 2019
@igorbernstein2 igorbernstein2 changed the title Start tracing server streaming callables. WIP: Start tracing server streaming callables. Jan 3, 2019
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.

@igorbernstein2 igorbernstein2 changed the title WIP: Start tracing server streaming callables. Start tracing server streaming callables. Jan 5, 2019
@igorbernstein2
Copy link
Contributor Author

Rebased, this is ready for review

@codecov-io
Copy link

codecov-io commented Jan 5, 2019

Codecov Report

Merging #635 into master will increase coverage by 0.72%.
The diff coverage is 90.47%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
...a/com/google/api/gax/grpc/GrpcCallableFactory.java 75.8% <100%> (+1.23%) 9 <0> (ø) ⬇️
...api/gax/tracing/TracedServerStreamingCallable.java 100% <100%> (ø) 2 <2> (?)
...google/api/gax/tracing/TracedResponseObserver.java 84% <84%> (ø) 6 <6> (?)
...m/google/api/gax/httpjson/HttpRequestRunnable.java 54.16% <0%> (-13.49%) 5% <0%> (ø)
...le/api/gax/rpc/ServerStreamingAttemptCallable.java 87.15% <0%> (+0.36%) 17% <0%> (ø) ⬇️
...m/google/api/gax/retrying/BasicRetryingFuture.java 93.61% <0%> (+0.75%) 23% <0%> (+1%) ⬆️
...n/java/com/google/api/gax/rpc/AttemptCallable.java 82.6% <0%> (+2.6%) 4% <0%> (ø) ⬇️
...om/google/api/gax/rpc/CheckingAttemptCallable.java 81.81% <0%> (+2.87%) 4% <0%> (ø) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33a57b6...394d839. Read the comment docs.

@igorbernstein2 igorbernstein2 removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Jan 5, 2019
@igorbernstein2 igorbernstein2 changed the title Start tracing server streaming callables. WIP: Start tracing server streaming callables. Jan 10, 2019
@igorbernstein2 igorbernstein2 added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 10, 2019
@igorbernstein2 igorbernstein2 removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 11, 2019
@igorbernstein2 igorbernstein2 changed the title WIP: Start tracing server streaming callables. Start tracing server streaming callables. Jan 11, 2019
@igorbernstein2
Copy link
Contributor Author

I added cancellation handling similar to #634

@igorbernstein2 igorbernstein2 changed the title Start tracing server streaming callables. Opencensus Tracing: Start tracing server streaming callables. Jan 11, 2019
Copy link
Contributor

@vam-google vam-google left a 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;
Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor

@vam-google vam-google Jan 31, 2019

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).

Copy link
Contributor Author

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();
Copy link
Contributor Author

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?

Copy link
Contributor Author

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();
Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@igorbernstein2
Copy link
Contributor Author

All feedback should be addressed. PTAL

Copy link
Contributor

@vam-google vam-google left a 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.

@igorbernstein2
Copy link
Contributor Author

Thanks for reviewing!

@igorbernstein2 igorbernstein2 merged commit b93f052 into googleapis:master Jan 31, 2019
@igorbernstein2 igorbernstein2 deleted the oc-server-streaming branch January 31, 2019 22:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants