Skip to content

Commit e2c19d0

Browse files
committed
Optimize code
1 parent 2646ed4 commit e2c19d0

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

instrumentation/apache-dubbo-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachedubbo/v2_7/RegistryCapturingClusterWrapperProxy.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
import org.apache.dubbo.rpc.cluster.Cluster;
1111
import org.apache.dubbo.rpc.cluster.Directory;
1212

13-
/**
14-
* Javaagent proxy for {@link RegistryCapturingClusterWrapper}. Dubbo SPI discovers this class by
15-
* name, so it must live in the javaagent module (which is not shaded) to keep a stable class name.
16-
*/
1713
public final class RegistryCapturingClusterWrapperProxy implements Cluster {
1814

1915
private final RegistryCapturingClusterWrapper delegate;

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
package io.opentelemetry.instrumentation.apachedubbo.v2_7.internal;
77

8+
import static io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboRegistryUtil.buildServiceTarget;
9+
import static io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboRegistryUtil.extractRegistryAddress;
10+
811
import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboRequest;
912
import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter;
1013
import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter;
@@ -22,17 +25,17 @@ public final class DubboClientNetworkAttributesGetter
2225
@Nullable
2326
@Override
2427
public String getServerAddress(DubboRequest request) {
25-
String registryAddress = DubboRegistryUtil.extractRegistryAddress(request.invocation());
28+
String registryAddress = extractRegistryAddress(request.invocation());
2629
if (registryAddress != null) {
27-
return registryAddress + "/" + DubboRegistryUtil.buildServiceTarget(request.url());
30+
return registryAddress + "/" + buildServiceTarget(request.url());
2831
}
2932
return request.url().getHost();
3033
}
3134

3235
@Nullable
3336
@Override
3437
public Integer getServerPort(DubboRequest request) {
35-
if (DubboRegistryUtil.extractRegistryAddress(request.invocation()) != null) {
38+
if (extractRegistryAddress(request.invocation()) != null) {
3639
return null;
3740
}
3841
return request.url().getPort();

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ private static MethodHandle resolveMethod(Class<?> clazz, String name) {
184184
m.setAccessible(true);
185185
return LOOKUP.unreflect(m);
186186
} catch (NoSuchMethodException | IllegalAccessException e) {
187-
return null;
187+
// ignore
188188
}
189+
return null;
189190
}
190191

191192
@Nullable
@@ -196,7 +197,7 @@ private static MethodHandle resolveField(Class<?> clazz, String name) {
196197
f.setAccessible(true);
197198
return LOOKUP.unreflectGetter(f);
198199
} catch (NoSuchFieldException | IllegalAccessException e) {
199-
// continue up the hierarchy
200+
// ignore
200201
}
201202
}
202203
return null;

0 commit comments

Comments
 (0)