-
Notifications
You must be signed in to change notification settings - Fork 104
Opencensus Tracing: Start tracing unary callable. #634
Conversation
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 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.
a7a3302 to
8e87c1e
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
|
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 |
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 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| @InternalApi("Visible for testing") | ||
| static SpanName getSpanName(@Nonnull ApiMethodDescriptor<?, ?> methodDescriptor) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| return future; | ||
| } catch (RuntimeException e) { | ||
| finisher.onFailure(e); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| @RunWith(JUnit4.class) | ||
| public class TraceFinisherTest { | ||
| @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Added operation cancellation tracing & added static imports as suggested in #640. 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, 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.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
This comment was marked as spam.
Sorry, something went wrong.
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.