Remove incorrect API of Dubbo (#13076)
This commit is contained in:
parent
ab09fcee98
commit
d0795ecd48
|
|
@ -35,23 +35,13 @@ public final class DubboTelemetry {
|
|||
this.clientInstrumenter = clientInstrumenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Dubbo {@link Filter} that traces Dubbo RPC invocations.
|
||||
*
|
||||
* @deprecated Use {@link #newClientFilter} and {@link #newServerFilter} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Filter newFilter() {
|
||||
return TracingFilter.newFilter(serverInstrumenter, clientInstrumenter);
|
||||
}
|
||||
|
||||
/** Returns a new Dubbo client {@link Filter} that traces Dubbo RPC invocations. */
|
||||
public Filter newClientFilter() {
|
||||
return TracingFilter.newClientFilter(clientInstrumenter);
|
||||
return new TracingFilter(clientInstrumenter, true);
|
||||
}
|
||||
|
||||
/** Returns a new Dubbo server {@link Filter} that traces Dubbo RPC invocations. */
|
||||
public Filter newServerFilter() {
|
||||
return TracingFilter.newServerFilter(serverInstrumenter);
|
||||
return new TracingFilter(serverInstrumenter, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,52 +18,13 @@ import org.apache.dubbo.rpc.RpcInvocation;
|
|||
|
||||
final class TracingFilter implements Filter {
|
||||
|
||||
private final InstrumenterSupplier instrumenterSupplier;
|
||||
private final Instrumenter<DubboRequest, Result> instrumenter;
|
||||
|
||||
private TracingFilter(InstrumenterSupplier instrumenterSupplier) {
|
||||
this.instrumenterSupplier = instrumenterSupplier;
|
||||
}
|
||||
private final boolean isClientSide;
|
||||
|
||||
static TracingFilter newClientFilter(Instrumenter<DubboRequest, Result> clientInstrumenter) {
|
||||
return newFilter(clientInstrumenter, true);
|
||||
}
|
||||
|
||||
static TracingFilter newServerFilter(Instrumenter<DubboRequest, Result> serverInstrumenter) {
|
||||
return newFilter(serverInstrumenter, false);
|
||||
}
|
||||
|
||||
private static TracingFilter newFilter(
|
||||
Instrumenter<DubboRequest, Result> instrumenter, boolean isClientSide) {
|
||||
return new TracingFilter(
|
||||
new InstrumenterSupplier() {
|
||||
|
||||
@Override
|
||||
public Instrumenter<DubboRequest, Result> get(RpcContext rpcContext) {
|
||||
return instrumenter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClientSide(RpcContext rpcContext) {
|
||||
return isClientSide;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static TracingFilter newFilter(
|
||||
Instrumenter<DubboRequest, Result> serverInstrumenter,
|
||||
Instrumenter<DubboRequest, Result> clientInstrumenter) {
|
||||
return new TracingFilter(
|
||||
new InstrumenterSupplier() {
|
||||
@Override
|
||||
public Instrumenter<DubboRequest, Result> get(RpcContext rpcContext) {
|
||||
return rpcContext.isConsumerSide() ? clientInstrumenter : serverInstrumenter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClientSide(RpcContext rpcContext) {
|
||||
return rpcContext.isConsumerSide();
|
||||
}
|
||||
});
|
||||
TracingFilter(Instrumenter<DubboRequest, Result> instrumenter, boolean isClientSide) {
|
||||
this.instrumenter = instrumenter;
|
||||
this.isClientSide = isClientSide;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -78,7 +39,6 @@ final class TracingFilter implements Filter {
|
|||
return invoker.invoke(invocation);
|
||||
}
|
||||
|
||||
Instrumenter<DubboRequest, Result> instrumenter = instrumenterSupplier.get(rpcContext);
|
||||
Context parentContext = Context.current();
|
||||
DubboRequest request = DubboRequest.create((RpcInvocation) invocation, rpcContext);
|
||||
|
||||
|
|
@ -91,7 +51,7 @@ final class TracingFilter implements Filter {
|
|||
boolean isSynchronous = true;
|
||||
try (Scope ignored = context.makeCurrent()) {
|
||||
result = invoker.invoke(invocation);
|
||||
if (instrumenterSupplier.isClientSide(rpcContext)) {
|
||||
if (isClientSide) {
|
||||
CompletableFuture<Object> future = rpcContext.getCompletableFuture();
|
||||
if (future != null) {
|
||||
isSynchronous = false;
|
||||
|
|
@ -108,10 +68,4 @@ final class TracingFilter implements Filter {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private interface InstrumenterSupplier {
|
||||
Instrumenter<DubboRequest, Result> get(RpcContext rpcContext);
|
||||
|
||||
boolean isClientSide(RpcContext rpcContext);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue