Skip to content

Commit f5fafc0

Browse files
committed
Keep old api and mark it as deprecated
1 parent 92583fc commit f5fafc0

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTelemetry.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,23 @@ public static DubboTelemetryBuilder builder(OpenTelemetry openTelemetry) {
3535
this.clientInstrumenter = clientInstrumenter;
3636
}
3737

38+
/**
39+
* Returns a new Dubbo {@link Filter} that traces Dubbo RPC invocations.
40+
*
41+
* <p>Use {@link #newClientFilter} and {@link #newServerFilter} instead.
42+
*/
43+
@Deprecated
44+
public Filter newFilter() {
45+
return new TracingFilter(serverInstrumenter, clientInstrumenter);
46+
}
47+
3848
/** Returns a new Dubbo client {@link Filter} that traces Dubbo RPC invocations. */
3949
public Filter newClientFilter() {
40-
return new TracingFilter(clientInstrumenter, true);
50+
return new TracingFilter(clientInstrumenter, null);
4151
}
4252

4353
/** Returns a new Dubbo server {@link Filter} that traces Dubbo RPC invocations. */
4454
public Filter newServerFilter() {
45-
return new TracingFilter(serverInstrumenter, false);
55+
return new TracingFilter(null, serverInstrumenter);
4656
}
4757
}

instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TracingFilter.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
final class TracingFilter implements Filter {
2020

21-
private final Instrumenter<DubboRequest, Result> instrumenter;
22-
private final boolean isClient;
21+
private final Instrumenter<DubboRequest, Result> clientInstrumenter;
22+
private final Instrumenter<DubboRequest, Result> serverInstrumenter;
2323

24-
TracingFilter(Instrumenter<DubboRequest, Result> instrumenter, boolean isClient) {
25-
this.instrumenter = instrumenter;
26-
this.isClient = isClient;
24+
TracingFilter(
25+
Instrumenter<DubboRequest, Result> clientInstrumenter,
26+
Instrumenter<DubboRequest, Result> serverInstrumenter) {
27+
this.clientInstrumenter = clientInstrumenter;
28+
this.serverInstrumenter = serverInstrumenter;
2729
}
2830

2931
@Override
@@ -38,6 +40,15 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) {
3840
return invoker.invoke(invocation);
3941
}
4042

43+
Instrumenter<DubboRequest, Result> instrumenter;
44+
boolean isServer = rpcContext.isProviderSide();
45+
if (this.clientInstrumenter != null && this.serverInstrumenter != null) {
46+
instrumenter = isServer ? serverInstrumenter : clientInstrumenter;
47+
} else {
48+
instrumenter =
49+
this.clientInstrumenter != null ? this.clientInstrumenter : this.serverInstrumenter;
50+
}
51+
4152
Context parentContext = Context.current();
4253
DubboRequest request = DubboRequest.create((RpcInvocation) invocation, rpcContext);
4354

@@ -50,7 +61,7 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) {
5061
boolean isSynchronous = true;
5162
try (Scope ignored = context.makeCurrent()) {
5263
result = invoker.invoke(invocation);
53-
if (isClient) {
64+
if (instrumenter == this.clientInstrumenter) {
5465
CompletableFuture<Object> future = rpcContext.getCompletableFuture();
5566
if (future != null) {
5667
isSynchronous = false;

0 commit comments

Comments
 (0)