Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
add test for merging capture limits
  • Loading branch information
jpbempel committed Jul 9, 2024
1 parent 9ff331d commit ebff4fa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -628,18 +628,6 @@ private ProbeDefinition selectReferenceDefinition(
.build();
}

private LogProbe.Sampling mergeSampling(
LogProbe.Sampling current, LogProbe.Sampling newSampling) {
if (current == null) {
return newSampling;
}
if (newSampling == null) {
return current;
}
return new LogProbe.Sampling(
Math.max(current.getSnapshotsPerSecond(), newSampling.getSnapshotsPerSecond()));
}

private LogProbe.Capture mergeCapture(LogProbe.Capture current, LogProbe.Capture newCapture) {
if (current == null) {
return newCapture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,25 @@ public void fieldExtractorDepth1() throws IOException, URISyntaxException {
assertEquals(DEPTH_REASON, simpleDataFields.get("listValue").getNotCapturedReason());
}

@Test
public void fieldExtractorDuplicateUnionDepth() throws IOException, URISyntaxException {
final String CLASS_NAME = "CapturedSnapshot04";
LogProbe.Builder builder = createProbeBuilder(PROBE_ID, CLASS_NAME, "createSimpleData", "()");
LogProbe probe1 = builder.capture(0, 100, 50, Limits.DEFAULT_FIELD_COUNT).build();
LogProbe probe2 = builder.capture(3, 100, 50, Limits.DEFAULT_FIELD_COUNT).build();
TestSnapshotListener listener = installProbes(CLASS_NAME, probe1, probe2);
Class<?> testClass = compileAndLoadClass(CLASS_NAME);
int result = Reflect.onClass(testClass).call("main", "").get();
assertEquals(143, result);
List<Snapshot> snapshots = assertSnapshots(listener, 2);
CapturedContext.CapturedValue simpleData =
snapshots.get(0).getCaptures().getReturn().getLocals().get("simpleData");
Map<String, CapturedContext.CapturedValue> simpleDataFields = getFields(simpleData);
assertEquals(4, simpleDataFields.size());
assertEquals("foo", simpleDataFields.get("strValue").getValue());
assertEquals(42, simpleDataFields.get("intValue").getValue());
}

@Test
public void fieldExtractorCount2() throws IOException, URISyntaxException {
final String CLASS_NAME = "CapturedSnapshot04";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ <T extends ProbeDefinition> T createMock(
ProbeDefinition mock = mock(clazz);
doAnswer(
invocation -> {
// invocationOrder.add(mock);
return InstrumentationResult.Status.INSTALLED;
})
.when(mock)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,13 @@ PROBE_ID2, ACTIVE, singletonList(decoration2), CLASS_NAME, "process", null, null
.probeId(PROBE_ID3)
.where(CLASS_NAME, "process")
.captureSnapshot(true)
.sampling(3.0)
.capture(1, 50, 50, 10)
.build();
LogProbe logProbe2 =
LogProbe.builder()
.probeId(PROBE_ID4)
.where(CLASS_NAME, "process")
.captureSnapshot(true)
.sampling(10.0)
.capture(5, 200, 200, 30)
.build();
Configuration configuration =
Expand Down

0 comments on commit ebff4fa

Please sign in to comment.