Skip to content

Commit 0b4861a

Browse files
committed
changes before merge from main
1 parent 9f13f0f commit 0b4861a

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

smoke-tests/apps/LiveMetrics/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ plugins {
55
dependencies {
66
smokeTestImplementation("org.awaitility:awaitility:4.2.0")
77
implementation("log4j:log4j:1.2.17")
8+
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations:1.22.1")
89
}

smoke-tests/apps/LiveMetrics/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestServlet.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import javax.servlet.http.HttpServlet;
1010
import javax.servlet.http.HttpServletRequest;
1111
import javax.servlet.http.HttpServletResponse;
12+
import io.opentelemetry.instrumentation.annotations.WithSpan;
1213
import org.apache.log4j.LogManager;
1314
import org.apache.log4j.Logger;
1415

@@ -24,6 +25,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
2425
resp.getWriter().println("ok");
2526
}
2627

28+
@WithSpan
2729
private void doWork() {
2830
System.out.println("Doing work to generate a dependency call, exception, and trace.");
2931
logger.error("This message should generate an exception!", new Exception("Fake Exception"));

smoke-tests/apps/LiveMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/LiveMetricsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ abstract class LiveMetricsTest {
3232
void doMostBasicTest() throws Exception {
3333

3434
Awaitility.await()
35-
.atMost(Duration.ofSeconds(10));
35+
.atMost(Duration.ofSeconds(20));
36+
3637
//.until(() -> testing.mockedIngestion.isLiveMetricsPingReceived());
3738
}
3839

smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtension.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ private void prepareEnvironment(Environment environment) throws Exception {
205205
}
206206
mockedIngestion.startServer();
207207
mockedIngestion.setRequestLoggingEnabled(true);
208+
mockedIngestion.setQuickPulseRequestLoggingEnabled(true);
208209
if (useOtlpEndpoint) {
209210
mockedOtlpIngestion.startServer();
210211
}
@@ -536,6 +537,7 @@ public void afterAll(ExtensionContext context) throws Exception {
536537

537538
mockedIngestion.stopServer();
538539
mockedIngestion.setRequestLoggingEnabled(false);
540+
mockedIngestion.setQuickPulseRequestLoggingEnabled(false);
539541
if (useOtlpEndpoint) {
540542
mockedOtlpIngestion.stopServer();
541543
}

smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,8 @@ public void run() {
319319
public void setRequestLoggingEnabled(boolean enabled) {
320320
servlet.setRequestLoggingEnabled(enabled);
321321
}
322+
323+
public void setQuickPulseRequestLoggingEnabled(boolean enabled) {
324+
quickPulseServlet.setRequestLoggingEnabled(enabled);
325+
}
322326
}

smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServlet.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ List<Envelope> waitForItems(
100100

101101
@Override
102102
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
103-
logit("request path info: " + req.getPathInfo());
104-
if (!"/v2.1/track".equals(req.getPathInfo())) {
105-
resp.sendError(404, "Unknown URI");
106-
return;
107-
}
108-
109103
String contentEncoding = req.getHeader("content-encoding");
110104
Readable reader;
111105
if ("gzip".equals(contentEncoding)) {

smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedQuickPulseServlet.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ public class MockedQuickPulseServlet extends HttpServlet {
2323
private static final String MOCK_RESPONSE_JSON_DEFAULT_CONFIG =
2424
"{\"ETag\":\"fake::etag\",\"Metrics\":[],\"QuotaInfo\":null,\"DocumentStreams\":[{\"Id\":\"all-types-default\",\"DocumentFilterGroups\":[{\"TelemetryType\":\"Request\",\"Filters\":{\"Filters\":[{\"FieldName\":\"Success\",\"Predicate\":\"Equal\",\"Comparand\":\"false\"}]}},{\"TelemetryType\":\"Dependency\",\"Filters\":{\"Filters\":[{\"FieldName\":\"Success\",\"Predicate\":\"Equal\",\"Comparand\":\"false\"}]}},{\"TelemetryType\":\"Exception\",\"Filters\":{\"Filters\":[]}},{\"TelemetryType\":\"Event\",\"Filters\":{\"Filters\":[]}},{\"TelemetryType\":\"Trace\",\"Filters\":{\"Filters\":[]}}]}]}";
2525

26+
private volatile boolean loggingEnabled;
2627
public MockedQuickPulseServlet() {
2728

2829
}
2930

31+
@SuppressWarnings("SystemOut")
32+
private void logit(String message) {
33+
if (loggingEnabled) {
34+
System.out.println("FAKE INGESTION: INFO - " + message);
35+
}
36+
}
37+
3038
@Override
3139
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
3240
throws IOException {
@@ -36,20 +44,20 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
3644
String body = sw.toString();
3745

3846
String path = req.getPathInfo();
39-
System.out.println("QuickPulse received: " + path);
40-
if (path.equals("QuickPulse.svc/ping")) {
47+
logit("QuickPulse received: " + path);
48+
if (path.equals("/ping")) {
4149
liveMetricsPingReceived.incrementAndGet();
4250
pingBody.set(body);
43-
System.out.println("ping body: " + body);
51+
logit("ping body: " + body);
4452
// want the following request to be a post
4553
resp.setHeader("x-ms-qps-subscribed", "true");
4654
resp.setContentType("application/json");
4755
resp.getWriter().write(MOCK_RESPONSE_JSON_DEFAULT_CONFIG);
4856

49-
} else if (path.equals("QuickPulse.svc/post")) {
57+
} else if (path.equals("/post")) {
5058
liveMetricsPostReceived.incrementAndGet();
5159
lastPostBody.set(body);
52-
System.out.println("post body: " + body);
60+
logit("post body: " + body);
5361
// continue to post
5462
resp.setHeader("x-ms-qps-subscribed", "true");
5563
} else {
@@ -73,4 +81,8 @@ public String getLastPostBody() {
7381
return lastPostBody.get();
7482
}
7583

84+
public void setRequestLoggingEnabled(boolean enabled) {
85+
loggingEnabled = enabled;
86+
}
87+
7688
}

0 commit comments

Comments
 (0)