From 810c321bbed8391136fd86b172f7207c996b2cab Mon Sep 17 00:00:00 2001 From: jean-philippe bempel Date: Thu, 2 Nov 2023 17:41:10 +0100 Subject: [PATCH] Factorize the line probe condition for evluateAt --- .../trace/bootstrap/debugger/CapturedContext.java | 12 ++---------- .../trace/bootstrap/debugger/MethodLocation.java | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/CapturedContext.java b/dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/CapturedContext.java index d0b062f281c..0bb90dc0305 100644 --- a/dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/CapturedContext.java +++ b/dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/CapturedContext.java @@ -327,22 +327,14 @@ public Status evaluate( ValueReferences.DURATION_EXTENSION_NAME, duration / 1_000_000.0); // convert to ms } this.thisClassName = thisClassName; - boolean shouldEvaluate = resolveEvaluateAt(probeImplementation, methodLocation); + boolean shouldEvaluate = + MethodLocation.isSame(methodLocation, probeImplementation.getEvaluateAt()); if (shouldEvaluate) { probeImplementation.evaluate(this, status, methodLocation); } return status; } - private static boolean resolveEvaluateAt( - ProbeImplementation probeImplementation, MethodLocation methodLocation) { - if (methodLocation == MethodLocation.DEFAULT) { - // line probe, no evaluation of probe's evaluateAt - return true; - } - return MethodLocation.isSame(methodLocation, probeImplementation.getEvaluateAt()); - } - public Status getStatus(String probeId) { Status result = statusByProbeId.get(probeId); if (result == null) { diff --git a/dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/MethodLocation.java b/dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/MethodLocation.java index c7ad8d70e7c..93b62f44fee 100644 --- a/dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/MethodLocation.java +++ b/dd-java-agent/agent-debugger/debugger-bootstrap/src/main/java/datadog/trace/bootstrap/debugger/MethodLocation.java @@ -7,7 +7,7 @@ public enum MethodLocation { public static boolean isSame(MethodLocation methodLocation, MethodLocation evaluateAt) { if (methodLocation == MethodLocation.DEFAULT) { - // line probe always assume we are the right location + // line probe, no evaluation of probe's evaluateAt return true; } if (methodLocation == MethodLocation.ENTRY) {