|
19 | 19 |
|
20 | 20 | import com.microsoft.applicationinsights.smoketest.schemav2.Data; |
21 | 21 | import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; |
| 22 | +import com.microsoft.applicationinsights.smoketest.schemav2.EventData; |
22 | 23 | import com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData; |
23 | 24 | import com.microsoft.applicationinsights.smoketest.schemav2.RequestData; |
24 | 25 | import java.util.List; |
@@ -60,6 +61,36 @@ void testCustomExceptionTypeAndMessage() throws Exception { |
60 | 61 | .isEqualTo("This is an custom exception with custom exception type"); |
61 | 62 | } |
62 | 63 |
|
| 64 | + @Test |
| 65 | + @TargetUri("/test-custom-event") |
| 66 | + void testCustomEvent() throws Exception { |
| 67 | + List<Envelope> rdList = testing.mockedIngestion.waitForItems("RequestData", 1); |
| 68 | + Envelope rdEnvelope = rdList.get(0); |
| 69 | + |
| 70 | + RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData(); |
| 71 | + assertThat(rd.getUrl()) |
| 72 | + .matches( |
| 73 | + "http://localhost:[0-9]+/OpenTelemetryApiLogBridge/test-custom-event"); |
| 74 | + assertThat(rd.getResponseCode()).isEqualTo("200"); |
| 75 | + assertThat(rd.getSuccess()).isTrue(); |
| 76 | + assertThat(rd.getSource()).isNull(); |
| 77 | + assertThat(rd.getProperties()).hasSize(1); |
| 78 | + assertThat(rd.getProperties()).containsEntry("_MS.ProcessedByMetricExtractors", "True"); |
| 79 | + |
| 80 | + assertThat(rdEnvelope.getIKey()).isEqualTo("00000000-0000-0000-0000-0FEEDDADBEEF"); |
| 81 | + assertThat(rdEnvelope.getTags()) |
| 82 | + .hasEntrySatisfying("ai.internal.sdkVersion", v -> assertThat(v).startsWith("java:3.")); |
| 83 | + |
| 84 | + String operationId = rdEnvelope.getTags().get("ai.operation.id"); |
| 85 | + List<Envelope> edList = |
| 86 | + testing.mockedIngestion.waitForItemsInOperation("EventData", 1, operationId); |
| 87 | + assertThat(edList.size()).isNotZero(); |
| 88 | + EventData ed = (EventData) ((Data<?>) edList.get(0).getData()).getBaseData(); |
| 89 | + assertThat(ed.getName()).isEqualTo("my_custom_event"); |
| 90 | + } |
| 91 | + |
| 92 | + |
| 93 | + |
63 | 94 | @Environment(TOMCAT_8_JAVA_8) |
64 | 95 | static class Tomcat8Java8Test extends OpenTelemetryApiLogBridgeTest {} |
65 | 96 |
|
|
0 commit comments