Skip to content

Commit 51534a4

Browse files
committed
fix style
1 parent 6f50140 commit 51534a4

File tree

8 files changed

+30
-27
lines changed

8 files changed

+30
-27
lines changed

instrumentation/jsonrpc4j-1.6/javaagent/build.gradle.kts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ muzzle {
1111
}
1212
}
1313

14-
val jsonrpcVersion = "1.6"
15-
1614
dependencies {
1715
implementation(project(":instrumentation:jsonrpc4j-1.6:library"))
18-
library("com.github.briandilley.jsonrpc4j:jsonrpc4j:$jsonrpcVersion")
16+
17+
library("com.github.briandilley.jsonrpc4j:jsonrpc4j:1.6")
18+
1919
testImplementation(project(":instrumentation:jsonrpc4j-1.6:testing"))
2020
}
2121

2222
tasks {
2323
test {
24-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
2524
jvmArgs("-Dotel.javaagent.experimental.thread-propagation-debugger.enabled=false")
26-
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
2725
}
2826
}

instrumentation/jsonrpc4j-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jsonrpc4j/v1_6/JsonRpcClientInstrumentation.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,7 @@ public static void onEnter(
6161
@Advice.Argument(1) Object argument,
6262
@Advice.Argument(3) Map<String, String> extraHeaders,
6363
@Advice.Local("otelContext") Context context,
64-
@Advice.Local("otelScope") Scope scope) {
65-
Context parentContext = Context.current();
66-
SimpleJsonRpcRequest request = new SimpleJsonRpcRequest(methodName, argument);
67-
if (!CLIENT_INSTRUMENTER.shouldStart(parentContext, request)) {
68-
return;
69-
}
70-
71-
context = CLIENT_INSTRUMENTER.start(parentContext, request);
72-
scope = context.makeCurrent();
73-
}
64+
@Advice.Local("otelScope") Scope scope) {}
7465

7566
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
7667
public static void onExit(

instrumentation/jsonrpc4j-1.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jsonrpc4j/v1_6/JsonRpcServerInstrumentation.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.opentelemetry.javaagent.instrumentation.jsonrpc4j.v1_6;
77

88
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
9+
import static io.opentelemetry.javaagent.instrumentation.jsonrpc4j.v1_6.JsonRpcSingletons.SERVER_INVOCATION_LISTENER;
910
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
1011
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
1112
import static net.bytebuddy.matcher.ElementMatchers.named;
@@ -51,7 +52,7 @@ public static void setInvocationListener(
5152
@Advice.This JsonRpcBasicServer jsonRpcServer,
5253
@Advice.FieldValue(value = "invocationListener", readOnly = false)
5354
InvocationListener invocationListener) {
54-
invocationListener = JsonRpcSingletons.SERVER_INVOCATION_LISTENER;
55+
invocationListener = SERVER_INVOCATION_LISTENER;
5556
}
5657
}
5758

@@ -67,14 +68,13 @@ public static void setInvocationListener(
6768
VirtualField.find(JsonRpcBasicServer.class, Boolean.class);
6869
if (!Boolean.TRUE.equals(instrumented.get(jsonRpcServer))) {
6970
if (invocationListener == null) {
70-
invocationListener = JsonRpcSingletons.SERVER_INVOCATION_LISTENER;
71+
invocationListener = SERVER_INVOCATION_LISTENER;
7172
} else if (invocationListener instanceof MultipleInvocationListener) {
7273
((MultipleInvocationListener) invocationListener)
73-
.addInvocationListener(JsonRpcSingletons.SERVER_INVOCATION_LISTENER);
74+
.addInvocationListener(SERVER_INVOCATION_LISTENER);
7475
} else {
7576
invocationListener =
76-
new MultipleInvocationListener(
77-
invocationListener, JsonRpcSingletons.SERVER_INVOCATION_LISTENER);
77+
new MultipleInvocationListener(invocationListener, SERVER_INVOCATION_LISTENER);
7878
}
7979

8080
instrumented.set(jsonRpcServer, true);

instrumentation/jsonrpc4j-1.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jsonrpc4j/v1_6/AgentJsonRpcTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
1212
import org.junit.jupiter.api.extension.RegisterExtension;
1313

14-
public class AgentJsonRpcTest extends AbstractJsonRpcTest {
14+
class AgentJsonRpcTest extends AbstractJsonRpcTest {
1515

1616
@RegisterExtension
1717
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

instrumentation/jsonrpc4j-1.6/library/build.gradle.kts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ plugins {
22
id("otel.library-instrumentation")
33
}
44

5-
val jsonrpcVersion = "1.6"
65
val jacksonVersion = "2.13.3"
76

87
dependencies {
9-
library("com.github.briandilley.jsonrpc4j:jsonrpc4j:$jsonrpcVersion")
8+
library("com.github.briandilley.jsonrpc4j:jsonrpc4j:1.6")
109

11-
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
10+
library("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
1211

1312
testImplementation(project(":instrumentation:jsonrpc4j-1.6:testing"))
1413
}

instrumentation/jsonrpc4j-1.6/library/src/main/java/io/opentelemetry/instrumentation/jsonrpc4j/v1_6/JsonRpcClientAttributesGetter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ public String getSystem(SimpleJsonRpcRequest request) {
2121
@Override
2222
public String getService(SimpleJsonRpcRequest request) {
2323
// TODO
24-
return "NOT_IMPLEMENTED";
24+
if (request.getMethod() != null) {
25+
return request.getMethod().getDeclaringClass().getName();
26+
}
27+
return "NOT_AVAILABLE";
2528
}
2629

2730
@Override

instrumentation/jsonrpc4j-1.6/library/src/main/java/io/opentelemetry/instrumentation/jsonrpc4j/v1_6/SimpleJsonRpcRequest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,34 @@
55

66
package io.opentelemetry.instrumentation.jsonrpc4j.v1_6;
77

8+
import java.lang.reflect.Method;
9+
810
public final class SimpleJsonRpcRequest {
911

1012
private final String methodName;
1113
private final Object argument;
14+
private Method method;
1215

1316
public SimpleJsonRpcRequest(String methodName, Object argument) {
1417
this.methodName = methodName;
1518
this.argument = argument;
1619
}
1720

21+
public SimpleJsonRpcRequest(Method method, Object argument) {
22+
this.method = method;
23+
this.methodName = method.getName();
24+
this.argument = argument;
25+
}
26+
1827
public String getMethodName() {
1928
return methodName;
2029
}
2130

2231
public Object getArgument() {
2332
return argument;
2433
}
34+
35+
public Method getMethod() {
36+
return method;
37+
}
2538
}

instrumentation/jsonrpc4j-1.6/testing/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dependencies {
88
api(project(":testing-common"))
99

1010
implementation("com.github.briandilley.jsonrpc4j:jsonrpc4j:$jsonrpcVersion")
11-
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.3")
1211

13-
// ...
12+
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.3")
1413
}

0 commit comments

Comments
 (0)