diff --git a/core/builder/src/main/java/io/quarkus/builder/BuildContext.java b/core/builder/src/main/java/io/quarkus/builder/BuildContext.java
index d2bddb2f5010b..a3493fe3b0959 100644
--- a/core/builder/src/main/java/io/quarkus/builder/BuildContext.java
+++ b/core/builder/src/main/java/io/quarkus/builder/BuildContext.java
@@ -254,6 +254,7 @@ private void doProduce(ItemId id, BuildItem value) {
throw Messages.msg.cannotMulti(id);
}
}
+ execution.getMetrics().buildItemProduced(value);
}
void depFinished() {
diff --git a/core/builder/src/main/java/io/quarkus/builder/BuildMetrics.java b/core/builder/src/main/java/io/quarkus/builder/BuildMetrics.java
index 39071ad082bbc..e7c6a45d4b14f 100644
--- a/core/builder/src/main/java/io/quarkus/builder/BuildMetrics.java
+++ b/core/builder/src/main/java/io/quarkus/builder/BuildMetrics.java
@@ -13,6 +13,7 @@
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
+import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
@@ -21,6 +22,7 @@
import io.quarkus.builder.Json.JsonArrayBuilder;
import io.quarkus.builder.Json.JsonObjectBuilder;
+import io.quarkus.builder.item.BuildItem;
public class BuildMetrics {
@@ -30,6 +32,7 @@ public class BuildMetrics {
private volatile long duration;
private final String buildTargetName;
private final ConcurrentMap records = new ConcurrentHashMap<>();
+ private final ConcurrentMap buildItems = new ConcurrentHashMap<>();
private final AtomicInteger idGenerator;
public BuildMetrics(String buildTargetName) {
@@ -54,11 +57,22 @@ public void buildStepFinished(StepInfo stepInfo, String thread, LocalTime starte
new BuildStepRecord(idGenerator.incrementAndGet(), stepInfo, thread, started, duration));
}
+ public void buildItemProduced(BuildItem buildItem) {
+ buildItems.compute(buildItem.getClass().getName(), this::itemProduced);
+ }
+
+ private Integer itemProduced(String key, Integer val) {
+ if (val == null) {
+ return 1;
+ }
+ return val + 1;
+ }
+
public void dumpTo(Path file) throws IOException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSS");
- List sorted = new ArrayList<>(records.values());
- sorted.sort(new Comparator() {
+ List sortedSteps = new ArrayList<>(records.values());
+ sortedSteps.sort(new Comparator() {
@Override
public int compare(BuildStepRecord o1, BuildStepRecord o2) {
return Long.compare(o2.duration, o1.duration);
@@ -72,7 +86,7 @@ public int compare(BuildStepRecord o1, BuildStepRecord o2) {
JsonArrayBuilder steps = Json.array();
json.put("records", steps);
- for (BuildStepRecord rec : sorted) {
+ for (BuildStepRecord rec : sortedSteps) {
JsonObjectBuilder recObject = Json.object();
recObject.put("id", rec.id);
recObject.put("stepId", rec.stepInfo.getBuildStep().getId());
@@ -91,6 +105,27 @@ public int compare(BuildStepRecord o1, BuildStepRecord o2) {
recObject.put("dependents", dependentsArray);
steps.add(recObject);
}
+
+ List> sortedItems = new ArrayList<>(buildItems.size());
+ buildItems.entrySet().forEach(sortedItems::add);
+ sortedItems.sort(new Comparator>() {
+ @Override
+ public int compare(Entry o1, Entry o2) {
+ return Integer.compare(o2.getValue(), o1.getValue());
+ }
+ });
+ JsonArrayBuilder items = Json.array();
+ json.put("items", items);
+ Integer itemsCount = 0;
+ for (Entry e : sortedItems) {
+ JsonObjectBuilder itemObject = Json.object();
+ itemObject.put("class", e.getKey());
+ itemObject.put("count", e.getValue());
+ items.add(itemObject);
+ itemsCount += e.getValue();
+ }
+ json.put("itemsCount", itemsCount);
+
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file.toFile(), StandardCharsets.UTF_8))) {
json.appendTo(writer);
}
diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/BuildMetricsDevConsoleProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/BuildMetricsDevConsoleProcessor.java
index 174df44dbee5b..b72d13bff79af 100644
--- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/BuildMetricsDevConsoleProcessor.java
+++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/BuildMetricsDevConsoleProcessor.java
@@ -57,8 +57,8 @@ public Map get() {
buildDuration = data.getLong("duration");
buildStarted = LocalDateTime
.parse(data.getString("started"), DateTimeFormatter.ISO_LOCAL_DATE_TIME).toLocalTime();
- JsonArray records = data.getJsonArray("records");
+ JsonArray records = data.getJsonArray("records");
for (Object record : records) {
JsonObject recordObj = (JsonObject) record;
recordObj.put("encodedStepId", URLEncoder.encode(recordObj.getString("stepId"),
@@ -73,7 +73,10 @@ public Map get() {
}
steps.add(recordObj);
}
+
metrics.put("records", records);
+ metrics.put("items", data.getJsonArray("items"));
+ metrics.put("itemsCount", data.getInteger("itemsCount"));
metrics.put("duration", buildDuration);
} catch (IOException e) {
LOG.error(e);
diff --git a/extensions/vertx-http/deployment/src/main/resources/dev-templates/index.html b/extensions/vertx-http/deployment/src/main/resources/dev-templates/index.html
index 6fe4bd44f99a8..a3de5675e993c 100644
--- a/extensions/vertx-http/deployment/src/main/resources/dev-templates/index.html
+++ b/extensions/vertx-http/deployment/src/main/resources/dev-templates/index.html
@@ -15,6 +15,12 @@
Build Steps
+
+
+
+ Build Items
+
+
diff --git a/extensions/vertx-http/deployment/src/main/resources/dev-templates/io.quarkus.quarkus-vertx-http/build-items.html b/extensions/vertx-http/deployment/src/main/resources/dev-templates/io.quarkus.quarkus-vertx-http/build-items.html
new file mode 100644
index 0000000000000..c194a34652a1c
--- /dev/null
+++ b/extensions/vertx-http/deployment/src/main/resources/dev-templates/io.quarkus.quarkus-vertx-http/build-items.html
@@ -0,0 +1,34 @@
+{#let metrics=info:buildMetrics.get}
+
+{#include main fluid=true}
+{#title}Build Items{/title}
+{#body}
+
+Produced {metrics.itemsCount} build items.
+
+
+
+
+
+ # |
+ Build Item |
+ Count |
+
+
+
+ {#for item in metrics.items}
+
+ {item_count} |
+
+ {item.class}
+ |
+
+ {item.count}
+ |
+ {/for}
+
+
+
+{/include}
+
+{/let}
\ No newline at end of file