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

Conversation

@igorbernstein2
Copy link
Contributor

This depends on #633 and is extracted from #613.

This introduces TracedUnaryCallables 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 Dec 28, 2018
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 understanding was that we can proceed with Traced* callable wrappers only if we find the way to make retrying logic non-aware of tracing (item 2 here).

Traced callables add a lot of complexity and I do not see a good way to get rid from tracing-specific logic in retry logic. If retries, as a more "core" piece, already have a hard dependency on tracing, I would make tracing just a core component of the whole thing (i.e. just put necessary tracing-specific stuff where needed, no need in wrapping instrumentation).

Also I do not understand the relationship between "not having Traced* callables in the callables chain" and "having noop tracer". It feels like exactly same thing (two ways to "turn tracing off").

I have really strong feelings about this one and would like to avoid Traced* callables if there is no strong need to have them.

This depends on googleapis#633 and is extracted from  googleapis#613.

This introduces TracedUnaryCallables 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.
@codecov-io
Copy link

Codecov Report

Merging #634 into master will increase coverage by 0.19%.
The diff coverage is 91.89%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #634      +/-   ##
============================================
+ Coverage     74.56%   74.76%   +0.19%     
- Complexity      949      958       +9     
============================================
  Files           180      182       +2     
  Lines          4172     4209      +37     
  Branches        334      334              
============================================
+ Hits           3111     3147      +36     
- Misses          908      909       +1     
  Partials        153      153
Impacted Files Coverage Δ Complexity Δ
...a/com/google/api/gax/grpc/GrpcCallableFactory.java 75.4% <100%> (+4.25%) 8 <1> (+1) ⬆️
...java/com/google/api/gax/tracing/TraceFinisher.java 100% <100%> (ø) 3 <3> (?)
...om/google/api/gax/tracing/TracedUnaryCallable.java 100% <100%> (ø) 2 <2> (?)
...ogle/api/gax/httpjson/HttpJsonCallableFactory.java 32% <57.14%> (+9.77%) 2 <1> (+1) ⬆️
...main/java/com/google/api/gax/tracing/SpanName.java 50% <0%> (+50%) 2% <0%> (+2%) ⬆️

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 122eda6...8e87c1e. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Jan 5, 2019

Codecov Report

Merging #634 into master will increase coverage by 0.07%.
The diff coverage is 89.47%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #634      +/-   ##
============================================
+ Coverage     74.56%   74.64%   +0.07%     
- Complexity      949      961      +12     
============================================
  Files           180      183       +3     
  Lines          4172     4216      +44     
  Branches        334      334              
============================================
+ Hits           3111     3147      +36     
- Misses          908      916       +8     
  Partials        153      153
Impacted Files Coverage Δ Complexity Δ
...java/com/google/api/gax/tracing/NoopApiTracer.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...a/com/google/api/gax/grpc/GrpcCallableFactory.java 74.57% <100%> (+3.42%) 9 <2> (+2) ⬆️
...java/com/google/api/gax/tracing/TraceFinisher.java 100% <100%> (ø) 4 <4> (?)
...om/google/api/gax/tracing/TracedUnaryCallable.java 100% <100%> (ø) 2 <2> (?)
...ogle/api/gax/httpjson/HttpJsonCallableFactory.java 32% <57.14%> (+9.77%) 3 <2> (+2) ⬆️
.../com/google/api/gax/grpc/GrpcTransportChannel.java 59.09% <0%> (-13.14%) 9% <0%> (ø)
.../com/google/api/gax/batching/BatchingSettings.java 80.95% <0%> (ø) 2% <0%> (ø) ⬇️
...om/google/api/gax/core/ResourceCloseException.java 0% <0%> (ø) 0% <0%> (?)
... and 1 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 122eda6...167a200. Read the comment docs.

@igorbernstein2
Copy link
Contributor Author

As discussed offline, the separate callables are necessary. I've rebased this PR on top of the plumbing work, so it's ready for review

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 with some comments, please address them before pushing.

}

@InternalApi("Visible for testing")
static SpanName getSpanName(MethodDescriptor<?, ?> methodDescriptor) {

This comment was marked as spam.

This comment was marked as spam.

}

@InternalApi("Visible for testing")
static SpanName getSpanName(@Nonnull ApiMethodDescriptor<?, ?> methodDescriptor) {

This comment was marked as spam.

This comment was marked as spam.

import com.google.common.util.concurrent.MoreExecutors;

/**
* A wrapper callable that will wrap a callable chain in a trace.

This comment was marked as spam.

This comment was marked as spam.

this.spanName = spanName;
}

/** Calls the wrapped {@link UnaryCallable} within the context of a new trace. */

This comment was marked as spam.

This comment was marked as spam.


return future;
} catch (RuntimeException e) {
finisher.onFailure(e);

This comment was marked as spam.

This comment was marked as spam.


@RunWith(JUnit4.class)
public class TraceFinisherTest {
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule();

This comment was marked as spam.

This comment was marked as spam.

@igorbernstein2
Copy link
Contributor Author

Added operation cancellation tracing & added static imports as suggested in #640.

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, with 2 (essentially 1) minor comments.

String fullServiceName = methodDescriptor.getFullMethodName().substring(0, index);
String methodName = methodDescriptor.getFullMethodName().substring(index + 1);
static SpanName getSpanName(@Nonnull MethodDescriptor<?, ?> methodDescriptor) {
Pattern pattern = Pattern.compile("^.*?([^./]+)/([^./]+)$");

This comment was marked as spam.

int index = methodDescriptor.getFullMethodName().indexOf('.');
String serviceName = methodDescriptor.getFullMethodName().substring(0, index);
String methodName = methodDescriptor.getFullMethodName().substring(index + 1);
Pattern pattern = Pattern.compile("^(.+)\\.(.+)$");

This comment was marked as spam.

@igorbernstein2 igorbernstein2 changed the title Start tracing unary callable. Opencensus Tracing: Start tracing unary callable. Jan 11, 2019
@igorbernstein2 igorbernstein2 merged commit 33a57b6 into googleapis:master Jan 11, 2019
@igorbernstein2 igorbernstein2 deleted the oc-unary branch January 11, 2019 19:05
This was referenced Jan 14, 2019
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