-
Notifications
You must be signed in to change notification settings - Fork 292
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
Add evaluateAt support for probe instrumentations #4320
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import java.util.regex.Pattern; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.Type; | ||
import org.objectweb.asm.tree.AbstractInsnNode; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.FieldInsnNode; | ||
import org.objectweb.asm.tree.FieldNode; | ||
|
@@ -55,11 +56,31 @@ public void instrument() { | |
fillLineMap(); | ||
addLineMetric(lineMap); | ||
} else { | ||
InsnList insnList = callMetric(metricProbe); | ||
methodNode.instructions.insert(methodEnterLabel, insnList); | ||
switch (definition.getEvaluateAt()) { | ||
case ENTRY: | ||
case DEFAULT: | ||
{ | ||
InsnList insnList = callMetric(metricProbe); | ||
methodNode.instructions.insert(methodEnterLabel, insnList); | ||
break; | ||
} | ||
case EXIT: | ||
{ | ||
processInstructions(); | ||
break; | ||
} | ||
default: | ||
throw new IllegalArgumentException( | ||
"Invalid evaluateAt attribute: " + definition.getEvaluateAt()); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected InsnList getBeforeReturnInsnList(AbstractInsnNode node) { | ||
return callMetric(metricProbe); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would we be able to add condition for metrics in this fashion as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
private InsnList callCount(MetricProbe metricProbe) { | ||
InsnList insnList = new InsnList(); | ||
if (metricProbe.getValue() == null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this become a NPE in the caller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm no, why?