RATIS-2393 Add Span Context to RaftRpcRequestProto#1341
RATIS-2393 Add Span Context to RaftRpcRequestProto#1341taklwu wants to merge 9 commits intoapache:masterfrom
Conversation
|
@szetszwo Hi Nicholas, should I directly open PRs to master branch ? in addition , the test failure doesn't seem to be related to my changes |
szetszwo
left a comment
There was a problem hiding this comment.
@taklwu , thanks for working on this! Please see the comment inlined.
BTW, this change is very small. Let's combine the usage of the new SpanContextProto such as RATIS-2395 or some part of it. Otherwise, it is hard to determine whether this change is good or not.
|
@taklwu Please add license for the failed ci! |
|
@OneSizeFitsQuorum I have updated the license and good catch. |
szetszwo
left a comment
There was a problem hiding this comment.
@taklwu , thanks for the update!
Please see the comments inlined and also https://issues.apache.org/jira/secure/attachment/13081062/1341_review.patch
ratis-common/src/main/java/org/apache/ratis/protocol/RaftClientRequest.java
Outdated
Show resolved
Hide resolved
ratis-common/src/main/java/org/apache/ratis/trace/RatisAttributes.java
Outdated
Show resolved
Hide resolved
ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java
Outdated
Show resolved
Hide resolved
ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java
Outdated
Show resolved
Hide resolved
ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java
Outdated
Show resolved
Hide resolved
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
Outdated
Show resolved
Hide resolved
- First commit of using OpenTelemetry - use junit5 and default opentelemetry extension in test case. - Add test to mock client level span and inject when request is being sent - only include the server extract
1. use traceAsyncMethod 2. add ClientInvocationId 3. and other places
This comment was marked as off-topic.
This comment was marked as off-topic.
| /** | ||
| * Get the cause of the {@link Throwable} if it is a {@link CompletionException}. | ||
| */ | ||
| public static Throwable unwrapCompletionException(Throwable error) { |
There was a problem hiding this comment.
We already have a similar method
Let's reuse it and move the other methods to JavaUtils.
There was a problem hiding this comment.
What do you think about this comment?
There was a problem hiding this comment.
reusing existing method is good, sorry that I didn't know unwrapCompletionException was there.
| /** | ||
| * Construct {@link Span} instances originating from the client request. | ||
| */ | ||
| public class ClientRequestSpanBuilder implements Supplier<Span> { |
There was a problem hiding this comment.
We should use lambda and not to implement functional interface in general. See also https://www.oracle.com/technical-resources/articles/java/lambda.html
There was a problem hiding this comment.
I will give a try, it may take a bit.
but the idea was from the hbase implementation that few span builders was created.
| */ | ||
| package org.apache.ratis.server.impl; | ||
|
|
||
| import io.opentelemetry.api.trace.Span; |
There was a problem hiding this comment.
Sorry that I may not be clear in my last comment -- we should import io.opentelemetry only in ratis-common. Then, it will be easier to change the tracing dependency to be pluggable in the future.
We often see that a library may introduce incompatible changes (such as Dropwizard Metrics v3 vs v4). Since Ratis itself is also a library, we don't want to force our consumer applications to use a particular dependency (e.g. Ratis supports both Dropwizard Metrics v3 and v4 by making it pluggable). Another reason is that a dependency may have CVEs (e.g. the infamous Log4Shell case). Applications may choose to disable it.
BTW, we should add a conf to enable/disable tracing.
What changes were proposed in this pull request?
We're adding a new map to RaftRpcRequestProto that will be used for upcoming Opentelemetry integration.
see the usage of PoC https://github.com/taklwu/ratis/blob/opentelemetry0129/ratis-common/src/main/java/org/apache/ratis/trace/TraceUtils.java#L235-L251
Another official reference for how this map is going to be inject and extract from the http / rpc header
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2393
How was this patch tested?
running mvn clean package -DskipTests