Skip to content

Commit b582819

Browse files
brunobatalesj
authored andcommitted
Reduce load and system stress by polling less with awatility
1 parent 6a700c6 commit b582819

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

integration-tests/observability-lgtm-prometheus/src/main/resources/application.properties

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ quarkus.log.category."io.quarkus.observability".level=DEBUG
22
quarkus.log.category."io.quarkus.devservices".level=DEBUG
33

44
quarkus.micrometer.binder-enabled-default=false
5+
6+
quarkus.http.access-log.enabled=true
7+
quarkus.http.access-log.pattern=%h %l %u %t "%r" %s %b %m "%{i,Referer}" "%{i,User-Agent}" "%{i,X-Request-Id}" "%{i,X-Organization-Id}" %D

integration-tests/observability-lgtm-prometheus/src/test/java/io/quarkus/observability/test/LgtmTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public void testPoke() {
3232
String response = RestAssured.get("/api/poke?f=100").body().asString();
3333
log.info("Response: " + response);
3434
GrafanaClient client = new GrafanaClient(endpoint, "admin", "admin");
35+
36+
Awaitility.setDefaultPollInterval(1, TimeUnit.SECONDS); // reduce load on the server. Default is .1s
37+
3538
Awaitility.await().atMost(61, TimeUnit.SECONDS).until(
3639
client::user,
3740
u -> "admin".equals(u.login));

integration-tests/observability-lgtm/src/test/java/io/quarkus/observability/test/LgtmTestHelper.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ protected void poke(String path) {
1818
String response = RestAssured.get(path + "/poke?f=100").body().asString();
1919
log.info("Response: " + response);
2020
GrafanaClient client = new GrafanaClient(grafanaEndpoint(), "admin", "admin");
21+
22+
Awaitility.setDefaultPollInterval(1, TimeUnit.SECONDS); // reduce load on the server. Default is .1s
23+
2124
Awaitility.await().atMost(61, TimeUnit.SECONDS).until(
2225
client::user,
2326
u -> "admin".equals(u.login));
@@ -28,5 +31,4 @@ protected void poke(String path) {
2831
() -> client.traces("quarkus-integration-test-observability-lgtm", 20, 3),
2932
result -> !result.traces.isEmpty());
3033
}
31-
3234
}

test-framework/observability/src/main/java/io/quarkus/observability/test/utils/GrafanaClient.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
import java.util.concurrent.atomic.AtomicReference;
1111
import java.util.function.BiConsumer;
1212
import java.util.function.Function;
13+
import java.util.logging.Logger;
1314

1415
import com.fasterxml.jackson.core.JsonProcessingException;
1516
import com.fasterxml.jackson.databind.ObjectMapper;
1617

1718
public class GrafanaClient {
19+
private static final Logger LOG = Logger.getLogger(GrafanaClient.class.getName());
20+
1821
private static final ObjectMapper MAPPER = new ObjectMapper();
1922

2023
private final String url;
@@ -87,7 +90,9 @@ public User user() {
8790
throw new UncheckedIOException(e);
8891
}
8992
});
90-
return ref.get();
93+
User user = ref.get();
94+
LOG.info("User: " + user);
95+
return user;
9196
}
9297

9398
public QueryResult query(String query) {
@@ -104,7 +109,9 @@ public QueryResult query(String query) {
104109
throw new UncheckedIOException(e);
105110
}
106111
});
107-
return ref.get();
112+
QueryResult queryResult = ref.get();
113+
LOG.info("Query: " + queryResult);
114+
return queryResult;
108115
}
109116

110117
public TempoResult traces(String service, int limit, int spss) {
@@ -123,6 +130,8 @@ public TempoResult traces(String service, int limit, int spss) {
123130
throw new UncheckedIOException(e);
124131
}
125132
});
126-
return ref.get();
133+
TempoResult tempoResult = ref.get();
134+
LOG.info("Traces: " + tempoResult);
135+
return tempoResult;
127136
}
128137
}

test-framework/observability/src/main/java/io/quarkus/observability/test/utils/User.java

+9
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,13 @@ public class User {
1111
public String email;
1212
@JsonProperty
1313
public String login;
14+
15+
@Override
16+
public String toString() {
17+
return "User{" +
18+
"id=" + id +
19+
", email='" + email + '\'' +
20+
", login='" + login + '\'' +
21+
'}';
22+
}
1423
}

0 commit comments

Comments
 (0)