Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ public void commit(CapturedContext lineContext, int line) {
if (shouldCommit) {
incrementBudget();
if (inBudget()) {
if (isCaptureSnapshot()) {
if (isFullSnapshot()) {
// freeze context just before commit because line probes have only one context
Duration timeout =
Duration.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2713,6 +2713,7 @@ public void captureExpressions() throws IOException, URISyntaxException {
LogProbe probe =
createProbeBuilder(PROBE_ID, CLASS_NAME, "doit", null)
.evaluateAt(MethodLocation.EXIT)
.captureSnapshot(false)
.captureExpressions(
Arrays.asList(
new LogProbe.CaptureExpression(
Expand Down Expand Up @@ -2744,12 +2745,48 @@ public void captureExpressions() throws IOException, URISyntaxException {
snapshot.getCaptures().getReturn(), "nullTyped_fld", Object.class.getTypeName(), null);
}

@Test
public void captureExpressionsLineProbe() throws IOException, URISyntaxException {
final String CLASS_NAME = "CapturedSnapshot08";
int line = getLineForLineProbe(CLASS_NAME, LINE_PROBE_ID3);
LogProbe probe =
createProbeBuilder(PROBE_ID, CLASS_NAME, line)
.captureSnapshot(false)
.captureExpressions(
Arrays.asList(
new LogProbe.CaptureExpression(
"typed_fld_fld_msg",
new ValueScript(
DSL.getMember(
DSL.getMember(DSL.getMember(DSL.ref("typed"), "fld"), "fld"),
"msg"),
"typed.fld.fld.msg"),
null),
new LogProbe.CaptureExpression(
"nullTyped_fld",
new ValueScript(
DSL.getMember(DSL.ref("nullTyped"), "fld"), "nullTyped.fld"),
null)))
.build();
TestSnapshotListener listener = installProbes(probe);
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
int result = Reflect.onClass(testClass).call("main", "1").get();
assertEquals(3, result);
Snapshot snapshot = assertOneSnapshot(listener);
CapturedContext capturedContext = snapshot.getCaptures().getLines().get(line);
assertEquals(2, capturedContext.getCaptureExpressions().size());
assertCaptureExpressions(
capturedContext, "typed_fld_fld_msg", String.class.getTypeName(), "hello");
assertCaptureExpressions(capturedContext, "nullTyped_fld", Object.class.getTypeName(), null);
}

@Test
public void captureExpressionsWithCaptureLimits() throws IOException, URISyntaxException {
final String CLASS_NAME = "CapturedSnapshot08";
LogProbe probe =
createProbeBuilder(PROBE_ID, CLASS_NAME, "doit", null)
.evaluateAt(MethodLocation.EXIT)
.captureSnapshot(false)
.captureExpressions(
Arrays.asList(
new LogProbe.CaptureExpression(
Expand Down
Loading