You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/05/10 11:19:46 UTC
(camel) branch cnt created (now 7dedff1bf664)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch cnt
in repository https://gitbox.apache.org/repos/asf/camel.git
at 7dedff1bf664 CAMEL-23385: camel-diagram - Show live counters
This branch includes the following new commits:
new 7dedff1bf664 CAMEL-23385: camel-diagram - Show live counters
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(camel) 01/01: CAMEL-23385: camel-diagram - Show live counters
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch cnt
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7dedff1bf664d68e9ac1e627946620f396d721f8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun May 10 13:19:31 2026 +0200
CAMEL-23385: camel-diagram - Show live counters
---
.../camel/diagram/DefaultRouteDiagramDumper.java | 2 +-
.../apache/camel/diagram/RouteDiagramRenderer.java | 54 +++++++++++++++++++++-
2 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/components/camel-diagram/src/main/java/org/apache/camel/diagram/DefaultRouteDiagramDumper.java b/components/camel-diagram/src/main/java/org/apache/camel/diagram/DefaultRouteDiagramDumper.java
index 97a78d434494..888fe011be09 100644
--- a/components/camel-diagram/src/main/java/org/apache/camel/diagram/DefaultRouteDiagramDumper.java
+++ b/components/camel-diagram/src/main/java/org/apache/camel/diagram/DefaultRouteDiagramDumper.java
@@ -109,7 +109,7 @@ public class DefaultRouteDiagramDumper extends ServiceSupport implements CamelCo
// use dev-console to render the route structure in json format which the diagram render expects
DevConsole dc = getCamelContext().getCamelContextExtension().getContextPlugin(DevConsoleRegistry.class)
.resolveById("route-structure");
- JsonObject root = (JsonObject) dc.call(DevConsole.MediaType.JSON, Map.of("filter", filter));
+ JsonObject root = (JsonObject) dc.call(DevConsole.MediaType.JSON, Map.of("filter", filter, "metric", "true"));
var routes = RouteDiagramHelper.parseRoutes(root);
return renderImage(routes, theme.name(), fontSize, nodeWidth, nodeLabel.name());
}
diff --git a/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramRenderer.java b/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramRenderer.java
index a77ff9722ef4..0edeb47de347 100644
--- a/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramRenderer.java
+++ b/components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramRenderer.java
@@ -99,6 +99,8 @@ public class RouteDiagramRenderer {
private Color bg;
private Color text;
private Color arrow;
+ private Color counter;
+ private Color counterFail;
private Color routeLabel;
private Color nodeFrom;
private Color nodeTo;
@@ -127,6 +129,8 @@ public class RouteDiagramRenderer {
c.bg = parseColor(map.get("bg"));
c.text = parseColor(map.getOrDefault("text", "#ffffff"));
c.arrow = parseColor(map.getOrDefault("arrow", "#b4b4b4"));
+ c.counter = parseColor(map.getOrDefault("counter", "#2e7d32"));
+ c.counterFail = parseColor(map.getOrDefault("counter", "#ff0000"));
c.routeLabel = parseColor(map.getOrDefault("label", "#c8c8c8"));
c.nodeFrom = parseColor(map.getOrDefault("from", "#2e7d32"));
c.nodeTo = parseColor(map.getOrDefault("to", "#1565c0"));
@@ -164,6 +168,14 @@ public class RouteDiagramRenderer {
return text;
}
+ public Color getCounter() {
+ return counter;
+ }
+
+ public Color getCounterFail() {
+ return counterFail;
+ }
+
public Color getArrow() {
return arrow;
}
@@ -292,8 +304,17 @@ public class RouteDiagramRenderer {
}
private void drawArrowFromMerge(Graphics2D g, LayoutNode to, DiagramColors colors) {
+ var stat = to.treeNode.info.stat;
+ long total = stat != null ? stat.exchangesTotal : 0;
+ long failed = stat != null ? stat.exchangesFailed : 0;
+ long ok = total - failed;
+
g.setColor(colors.getArrow());
- g.setStroke(new BasicStroke(STROKE_WIDTH));
+ if (total > 0) {
+ g.setStroke(new BasicStroke(STROKE_WIDTH));
+ } else {
+ g.setStroke(DASHED_STROKE);
+ }
int toCx = to.x + nodeWidth / 2;
int toTy = getTopY(to);
@@ -309,6 +330,16 @@ public class RouteDiagramRenderer {
g.drawLine(toCx, midY, toCx, toTy - ARROW_SIZE / 2);
}
drawArrowHead(g, toCx, toTy);
+
+ if (ok > 0) {
+ g.setColor(colors.getCounter());
+ g.drawString("" + ok, toCx + 2 + fontSizeNode, toTy - 2 - fontSizeNode);
+ }
+ if (failed > 0) {
+ g.setColor(colors.getCounterFail());
+ // TOOD: calc width depending on length of string
+ g.drawString("" + failed, toCx - 2 - fontSizeNode - fontSizeNode, toTy - 2 - fontSizeNode);
+ }
}
private void drawNode(Graphics2D g, LayoutNode node, DiagramColors colors) {
@@ -345,8 +376,17 @@ public class RouteDiagramRenderer {
}
private void drawArrow(Graphics2D g, LayoutNode from, LayoutNode to, DiagramColors colors) {
+ var stat = to.treeNode.info.stat;
+ long total = stat != null ? stat.exchangesTotal : 0;
+ long failed = stat != null ? stat.exchangesFailed : 0;
+ long ok = total - failed;
+
g.setColor(colors.getArrow());
- g.setStroke(new BasicStroke(STROKE_WIDTH));
+ if (total > 0) {
+ g.setStroke(new BasicStroke(STROKE_WIDTH));
+ } else {
+ g.setStroke(DASHED_STROKE);
+ }
int fromCx = from.x + nodeWidth / 2;
int fromBy = from.y + from.height;
@@ -362,6 +402,16 @@ public class RouteDiagramRenderer {
g.drawLine(toCx, midY, toCx, toTy - ARROW_SIZE / 2);
}
drawArrowHead(g, toCx, toTy);
+
+ if (ok > 0) {
+ g.setColor(colors.getCounter());
+ g.drawString("" + ok, toCx + 2 + fontSizeNode, toTy - 2 - fontSizeNode);
+ }
+ if (failed > 0) {
+ g.setColor(colors.getCounterFail());
+ // TOOD: calc width depending on length of string
+ g.drawString("" + failed, toCx - 2 - fontSizeNode - fontSizeNode, toTy - 2 - fontSizeNode);
+ }
}
private void drawArrowHead(Graphics2D g, int x, int y) {