Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testLatestDeps in dubbo instrumentation #6754

Merged
merged 15 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions instrumentation/apache-dubbo-2.7/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ tasks.withType<Test>().configureEach {
jvmArgs("--add-opens=java.base/java.math=ALL-UNNAMED")
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")

systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
package io.opentelemetry.instrumentation.apachedubbo.v2_7

import io.opentelemetry.instrumentation.test.AgentTestTrait
import spock.lang.IgnoreIf

// TODO (trask) fix the test on latest version of dubbo
@IgnoreIf({ Boolean.getBoolean("testLatestDeps") })
class DubboTraceChainTest extends AbstractDubboTraceChainTest implements AgentTestTrait {
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ tasks.withType<Test>().configureEach {
jvmArgs("--add-opens=java.base/java.math=ALL-UNNAMED")
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")

systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
package io.opentelemetry.instrumentation.apachedubbo.v2_7

import io.opentelemetry.instrumentation.test.LibraryTestTrait
import spock.lang.IgnoreIf

// TODO (trask) fix the test on latest version of dubbo
@IgnoreIf({ Boolean.getBoolean("testLatestDeps") })
class DubboTraceChainTest extends AbstractDubboTraceChainTest implements LibraryTestTrait {
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
return service
}

ServiceConfig configureMiddleServer(GenericService genericService) {
ServiceConfig configureMiddleServer(ReferenceConfig<HelloService> referenceConfig) {
def registerConfig = new RegistryConfig()
registerConfig.setAddress("N/A")
ServiceConfig<MiddleServiceImpl> service = new ServiceConfig<>()
service.setInterface(MiddleService)
service.setRef(new MiddleServiceImpl(genericService))
service.setRef(new MiddleServiceImpl(referenceConfig))
service.setRegistry(registerConfig)
return service
}
Expand All @@ -89,7 +89,7 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
DubboBootstrap middleBootstrap = DubboBootstrap.newInstance()
middleBootstrap.application(new ApplicationConfig("dubbo-demo-middle"))
.reference(reference)
.service(configureMiddleServer(reference.get()))
.service(configureMiddleServer(reference))
.protocol(middleProtocolConfig)
.start()

Expand Down Expand Up @@ -154,6 +154,9 @@ abstract class AbstractDubboTraceChainTest extends InstrumentationSpecification
"$SemanticAttributes.RPC_METHOD" "\$invoke"
"$SemanticAttributes.NET_PEER_NAME" "localhost"
"$SemanticAttributes.NET_PEER_PORT" Long
"net.sock.peer.addr" { it == null || String }
"net.sock.peer.port" { it == null || Long }
"net.sock.peer.name" { it == null || String }
}
}
span(4) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
package io.opentelemetry.instrumentation.apachedubbo.v2_7.impl;

import io.opentelemetry.instrumentation.apachedubbo.v2_7.api.MiddleService;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.rpc.service.GenericService;

public class MiddleServiceImpl implements MiddleService {

private final GenericService genericService;
private final ReferenceConfig<?> referenceConfig;

public MiddleServiceImpl(GenericService genericService) {
this.genericService = genericService;
public MiddleServiceImpl(ReferenceConfig<?> referenceConfig) {
this.referenceConfig = referenceConfig;
}

@Override
public String hello(String hello) {
GenericService genericService = (GenericService) referenceConfig.get();
return genericService
.$invoke("hello", new String[] {String.class.getName()}, new Object[] {hello})
.toString();
Expand Down