|
15 | 15 | import static org.junit.jupiter.api.Assertions.assertNull; |
16 | 16 | import static org.junit.jupiter.api.Assertions.assertTrue; |
17 | 17 | import static org.mockito.Mockito.mock; |
| 18 | +import static org.mockito.Mockito.times; |
18 | 19 | import static org.mockito.Mockito.verify; |
19 | 20 | import static org.mockito.Mockito.when; |
20 | 21 | import static utils.InstrumentationTestHelper.compileAndLoadClass; |
@@ -155,6 +156,24 @@ public void methodActiveSpanCondition() throws IOException, URISyntaxException { |
155 | 156 | assertEquals("5", span.getTags().get("tag1")); |
156 | 157 | } |
157 | 158 |
|
| 159 | + @Test |
| 160 | + public void methodActiveSpanConditionFalse() throws IOException, URISyntaxException { |
| 161 | + final String CLASS_NAME = "com.datadog.debugger.CapturedSnapshot20"; |
| 162 | + SpanDecorationProbe.Decoration decoration = |
| 163 | + createDecoration(eq(ref("arg"), value("5")), "arg == '5'", "tag1", "{arg}"); |
| 164 | + installSingleSpanDecoration( |
| 165 | + CLASS_NAME, ACTIVE, decoration, "process", "int (java.lang.String)"); |
| 166 | + Class<?> testClass = compileAndLoadClass(CLASS_NAME); |
| 167 | + int result = Reflect.on(testClass).call("main", "0").get(); |
| 168 | + assertEquals(84, result); |
| 169 | + assertEquals(1, traceInterceptor.getAllTraces().size()); |
| 170 | + MutableSpan span = traceInterceptor.getAllTraces().get(0).get(0); |
| 171 | + // probe executed, but no tag set |
| 172 | + assertFalse(span.getTags().containsKey("tag1")); |
| 173 | + // EMITTING status is not sent |
| 174 | + verify(probeStatusSink, times(0)).addEmitting(ArgumentMatchers.eq(PROBE_ID)); |
| 175 | + } |
| 176 | + |
158 | 177 | @Test |
159 | 178 | public void methodTagEvalError() throws IOException, URISyntaxException { |
160 | 179 | final String CLASS_NAME = "com.datadog.debugger.CapturedSnapshot20"; |
|
0 commit comments