Skip to content

Commit e20ace1

Browse files
committed
move virtualfield for simplicity
1 parent 4ca9a1b commit e20ace1

File tree

3 files changed

+9
-28
lines changed

3 files changed

+9
-28
lines changed

instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/context/ContextPropagator.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class ContextPropagator {
2222

2323
private static final Logger logger = Logger.getLogger(ContextPropagator.class.getName());
2424

25+
private static final VirtualField<Connection, Boolean> KNOWN_CONNECTION =
26+
VirtualField.find(Connection.class, Boolean.class);
27+
2528
// Internal RMI object ids that we don't want to trace
2629
private static final ObjID ACTIVATOR_ID = new ObjID(ObjID.ACTIVATOR_ID);
2730
private static final ObjID DGC_ID = new ObjID(ObjID.DGC_ID);
@@ -48,24 +51,22 @@ public boolean isOperationWithPayload(int operationId) {
4851
return operationId == CONTEXT_PAYLOAD_OPERATION_ID;
4952
}
5053

51-
public void attemptToPropagateContext(
52-
VirtualField<Connection, Boolean> knownConnections, Connection c, Context context) {
53-
if (checkIfContextCanBePassed(knownConnections, c)) {
54+
public void attemptToPropagateContext(Connection c, Context context) {
55+
if (checkIfContextCanBePassed(c)) {
5456
if (!syntheticCall(c, ContextPayload.from(context), CONTEXT_PAYLOAD_OPERATION_ID)) {
5557
logger.fine("Couldn't send context payload");
5658
}
5759
}
5860
}
5961

60-
private static boolean checkIfContextCanBePassed(
61-
VirtualField<Connection, Boolean> knownConnections, Connection c) {
62-
Boolean storedResult = knownConnections.get(c);
62+
private static boolean checkIfContextCanBePassed(Connection c) {
63+
Boolean storedResult = KNOWN_CONNECTION.get(c);
6364
if (storedResult != null) {
6465
return storedResult;
6566
}
6667

6768
boolean result = syntheticCall(c, null, CONTEXT_CHECK_CALL_OPERATION_ID);
68-
knownConnections.set(c, result);
69+
KNOWN_CONNECTION.set(c, result);
6970
return result;
7071
}
7172

instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/context/client/RmiClientContextInstrumentation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.opentelemetry.javaagent.instrumentation.rmi.context.client;
77

88
import static io.opentelemetry.javaagent.instrumentation.rmi.context.ContextPropagator.PROPAGATOR;
9-
import static io.opentelemetry.javaagent.instrumentation.rmi.context.client.VirtualFieldHelper.KNOWN_CONNECTION;
109
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
1110
import static net.bytebuddy.matcher.ElementMatchers.named;
1211
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@@ -77,7 +76,7 @@ public static void onEnter(@Advice.Argument(0) Connection c, @Advice.Argument(1)
7776
}
7877

7978
// caching if a connection can support enhanced format
80-
PROPAGATOR.attemptToPropagateContext(KNOWN_CONNECTION, c, currentContext);
79+
PROPAGATOR.attemptToPropagateContext(c, currentContext);
8180
}
8281
}
8382
}

instrumentation/rmi/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rmi/context/client/VirtualFieldHelper.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)