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 2022/09/27 10:09:25 UTC
[camel] branch main updated (0523e132668 -> 1bd37fbea1d)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from 0523e132668 Sync deps
new 928f49fb646 camel-core - Completed exchange event to output time taken
new 1bd37fbea1d camel-jbang - Show last/delta processing time
The 2 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.
Summary of changes:
.../camel/impl/event/ExchangeCompletedEvent.java | 15 ++++++++-
.../camel/impl/console/ContextDevConsole.java | 9 ++++++
.../apache/camel/impl/console/RouteDevConsole.java | 16 ++++++++++
.../core/commands/process/CamelContextStatus.java | 26 +++++++++++++++-
.../commands/process/CamelProcessorStatus.java | 36 ++++++++++++++++++++--
.../core/commands/process/CamelRouteStatus.java | 26 +++++++++++++++-
6 files changed, 123 insertions(+), 5 deletions(-)
[camel] 01/02: camel-core - Completed exchange event to output time taken
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 928f49fb6465991ff9219a2d87062a3fe3fc0c5f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Sep 27 11:24:26 2022 +0200
camel-core - Completed exchange event to output time taken
---
.../apache/camel/impl/event/ExchangeCompletedEvent.java | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/event/ExchangeCompletedEvent.java b/core/camel-base/src/main/java/org/apache/camel/impl/event/ExchangeCompletedEvent.java
index 172c949aac5..88b9259a722 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/event/ExchangeCompletedEvent.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/event/ExchangeCompletedEvent.java
@@ -18,16 +18,29 @@ package org.apache.camel.impl.event;
import org.apache.camel.Exchange;
import org.apache.camel.spi.CamelEvent;
+import org.apache.camel.util.TimeUtils;
public class ExchangeCompletedEvent extends AbstractExchangeEvent implements CamelEvent.ExchangeCompletedEvent {
private static final long serialVersionUID = -3231801412021356098L;
+ private final long timeTaken;
public ExchangeCompletedEvent(Exchange source) {
super(source);
+ long created = getExchange().getCreated();
+ if (created > 0) {
+ this.timeTaken = System.currentTimeMillis() - created;
+ } else {
+ this.timeTaken = -1;
+ }
}
@Override
public String toString() {
- return getExchange().getExchangeId() + " exchange completed";
+ if (timeTaken > -1) {
+ return getExchange().getExchangeId() + " exchange completed"
+ + " took: " + TimeUtils.printDuration(timeTaken, true);
+ } else {
+ return getExchange().getExchangeId() + " exchange completed";
+ }
}
}
[camel] 02/02: camel-jbang - Show last/delta processing time
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1bd37fbea1dc63b4fca02ea7f6ffb6c7be39fc88
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Sep 27 12:09:07 2022 +0200
camel-jbang - Show last/delta processing time
---
.../camel/impl/console/ContextDevConsole.java | 9 ++++++
.../apache/camel/impl/console/RouteDevConsole.java | 16 ++++++++++
.../core/commands/process/CamelContextStatus.java | 26 +++++++++++++++-
.../commands/process/CamelProcessorStatus.java | 36 ++++++++++++++++++++--
.../core/commands/process/CamelRouteStatus.java | 26 +++++++++++++++-
5 files changed, 109 insertions(+), 4 deletions(-)
diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/ContextDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/ContextDevConsole.java
index 0fe00122e48..db1f38eff84 100644
--- a/core/camel-console/src/main/java/org/apache/camel/impl/console/ContextDevConsole.java
+++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/ContextDevConsole.java
@@ -77,6 +77,11 @@ public class ContextDevConsole extends AbstractDevConsole {
sb.append(String.format("\n Mean Time: %s", TimeUtils.printDuration(mb.getMeanProcessingTime(), true)));
sb.append(String.format("\n Max Time: %s", TimeUtils.printDuration(mb.getMaxProcessingTime(), true)));
sb.append(String.format("\n Min Time: %s", TimeUtils.printDuration(mb.getMinProcessingTime(), true)));
+ if (mb.getExchangesTotal() > 0) {
+ sb.append(String.format("\n Last Time: %s", TimeUtils.printDuration(mb.getLastProcessingTime(), true)));
+ sb.append(
+ String.format("\n Delta Time: %s", TimeUtils.printDuration(mb.getDeltaProcessingTime(), true)));
+ }
Date last = mb.getLastExchangeCreatedTimestamp();
if (last != null) {
String ago = TimeUtils.printSince(last.getTime());
@@ -144,6 +149,10 @@ public class ContextDevConsole extends AbstractDevConsole {
stats.put("meanProcessingTime", mb.getMeanProcessingTime());
stats.put("maxProcessingTime", mb.getMaxProcessingTime());
stats.put("minProcessingTime", mb.getMinProcessingTime());
+ if (mb.getExchangesTotal() > 0) {
+ stats.put("lastProcessingTime", mb.getLastProcessingTime());
+ stats.put("deltaProcessingTime", mb.getDeltaProcessingTime());
+ }
Date last = mb.getLastExchangeCreatedTimestamp();
if (last != null) {
String ago = TimeUtils.printSince(last.getTime());
diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteDevConsole.java
index 621a68b4cec..417aa59b745 100644
--- a/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteDevConsole.java
+++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/RouteDevConsole.java
@@ -94,6 +94,10 @@ public class RouteDevConsole extends AbstractDevConsole {
sb.append(String.format("\n Mean Time: %s", TimeUtils.printDuration(mrb.getMeanProcessingTime(), true)));
sb.append(String.format("\n Max Time: %s", TimeUtils.printDuration(mrb.getMaxProcessingTime(), true)));
sb.append(String.format("\n Min Time: %s", TimeUtils.printDuration(mrb.getMinProcessingTime(), true)));
+ if (mrb.getExchangesTotal() > 0) {
+ sb.append(String.format("\n Last Time: %s", TimeUtils.printDuration(mrb.getLastProcessingTime(), true)));
+ sb.append(String.format("\n Delta Time: %s", TimeUtils.printDuration(mrb.getDeltaProcessingTime(), true)));
+ }
Date last = mrb.getLastExchangeCreatedTimestamp();
if (last != null) {
String ago = TimeUtils.printSince(last.getTime());
@@ -158,6 +162,10 @@ public class RouteDevConsole extends AbstractDevConsole {
sb.append(String.format("\n Mean Time: %s", TimeUtils.printDuration(mp.getMeanProcessingTime(), true)));
sb.append(String.format("\n Max Time: %s", TimeUtils.printDuration(mp.getMaxProcessingTime(), true)));
sb.append(String.format("\n Min Time: %s", TimeUtils.printDuration(mp.getMinProcessingTime(), true)));
+ if (mp.getExchangesTotal() > 0) {
+ sb.append(String.format("\n Last Time: %s", TimeUtils.printDuration(mp.getLastProcessingTime(), true)));
+ sb.append(String.format("\n Delta Time: %s", TimeUtils.printDuration(mp.getDeltaProcessingTime(), true)));
+ }
Date last = mp.getLastExchangeCompletedTimestamp();
if (last != null) {
String ago = TimeUtils.printSince(last.getTime());
@@ -209,6 +217,10 @@ public class RouteDevConsole extends AbstractDevConsole {
stats.put("meanProcessingTime", mrb.getMeanProcessingTime());
stats.put("maxProcessingTime", mrb.getMaxProcessingTime());
stats.put("minProcessingTime", mrb.getMinProcessingTime());
+ if (mrb.getExchangesTotal() > 0) {
+ stats.put("lastProcessingTime", mrb.getLastProcessingTime());
+ stats.put("deltaProcessingTime", mrb.getDeltaProcessingTime());
+ }
Date last = mrb.getLastExchangeCreatedTimestamp();
if (last != null) {
String ago = TimeUtils.printSince(last.getTime());
@@ -291,6 +303,10 @@ public class RouteDevConsole extends AbstractDevConsole {
stats.put("meanProcessingTime", mp.getMeanProcessingTime());
stats.put("maxProcessingTime", mp.getMaxProcessingTime());
stats.put("minProcessingTime", mp.getMinProcessingTime());
+ if (mp.getExchangesTotal() > 0) {
+ stats.put("lastProcessingTime", mp.getLastProcessingTime());
+ stats.put("deltaProcessingTime", mp.getDeltaProcessingTime());
+ }
Date last = mp.getLastExchangeCompletedTimestamp();
if (last != null) {
String ago = TimeUtils.printSince(last.getTime());
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
index f266b9619e3..13f51f96008 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelContextStatus.java
@@ -82,7 +82,15 @@ public class CamelContextStatus extends ProcessBaseCommand {
row.inflight = stats.get("exchangesInflight").toString();
row.failed = stats.get("exchangesFailed").toString();
row.reloaded = stats.get("reloaded").toString();
- Object last = stats.get("sinceLastCreatedExchange");
+ Object last = stats.get("lastProcessingTime");
+ if (last != null) {
+ row.last = last.toString();
+ }
+ last = stats.get("deltaProcessingTime");
+ if (last != null) {
+ row.delta = last.toString();
+ }
+ last = stats.get("sinceLastCreatedExchange");
if (last != null) {
row.sinceLastStarted = last.toString();
}
@@ -137,6 +145,8 @@ public class CamelContextStatus extends ProcessBaseCommand {
new Column().header("TOTAL").with(r -> r.total),
new Column().header("FAIL").with(r -> r.failed),
new Column().header("INFLIGHT").with(r -> r.inflight),
+ new Column().header("LAST").with(r -> r.last),
+ new Column().header("DELTA").with(this::getDelta),
new Column().header("SINCE-LAST").with(this::getSinceLast))));
}
@@ -182,6 +192,18 @@ public class CamelContextStatus extends ProcessBaseCommand {
}
}
+ protected String getDelta(Row r) {
+ if (r.delta != null) {
+ if (r.delta.startsWith("-")) {
+ return r.delta;
+ } else if (!"0".equals(r.delta)) {
+ // use plus sign to denote slower when positive
+ return "+" + r.delta;
+ }
+ }
+ return r.delta;
+ }
+
protected String getSinceLast(Row r) {
String s1 = r.sinceLastStarted != null ? r.sinceLastStarted : "-";
String s2 = r.sinceLastCompleted != null ? r.sinceLastCompleted : "-";
@@ -218,6 +240,8 @@ public class CamelContextStatus extends ProcessBaseCommand {
String total;
String failed;
String inflight;
+ String last;
+ String delta;
String sinceLastStarted;
String sinceLastCompleted;
String sinceLastFailed;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorStatus.java
index 3c92a47a24b..5ff490c08ad 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorStatus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelProcessorStatus.java
@@ -94,7 +94,15 @@ public class CamelProcessorStatus extends ProcessBaseCommand {
}
row.max = stats.get("maxProcessingTime").toString();
row.min = stats.get("minProcessingTime").toString();
- Object last = stats.get("sinceLastCreatedExchange");
+ Object last = stats.get("lastProcessingTime");
+ if (last != null) {
+ row.last = last.toString();
+ }
+ last = stats.get("deltaProcessingTime");
+ if (last != null) {
+ row.delta = last.toString();
+ }
+ last = stats.get("sinceLastCreatedExchange");
if (last != null) {
row.sinceLastStarted = last.toString();
}
@@ -156,7 +164,15 @@ public class CamelProcessorStatus extends ProcessBaseCommand {
}
row.max = stats.get("maxProcessingTime").toString();
row.min = stats.get("minProcessingTime").toString();
- Object last = stats.get("sinceLastCompletedExchange");
+ Object last = stats.get("lastProcessingTime");
+ if (last != null) {
+ row.last = last.toString();
+ }
+ last = stats.get("deltaProcessingTime");
+ if (last != null) {
+ row.delta = last.toString();
+ }
+ last = stats.get("sinceLastCompletedExchange");
if (last != null) {
row.sinceLastCompleted = last.toString();
}
@@ -196,6 +212,8 @@ public class CamelProcessorStatus extends ProcessBaseCommand {
new Column().header("MEAN").with(r -> r.mean),
new Column().header("MIN").with(r -> r.min),
new Column().header("MAX").with(r -> r.max),
+ new Column().header("LAST").with(r -> r.last),
+ new Column().header("DELTA").with(this::getDelta),
new Column().header("SINCE-LAST").with(this::getSinceLast))));
}
@@ -224,6 +242,18 @@ public class CamelProcessorStatus extends ProcessBaseCommand {
return s1 + "/" + s2;
}
+ protected String getDelta(Row r) {
+ if (r.delta != null) {
+ if (r.delta.startsWith("-")) {
+ return r.delta;
+ } else if (!"0".equals(r.delta)) {
+ // use plus sign to denote slower when positive
+ return "+" + r.delta;
+ }
+ }
+ return r.delta;
+ }
+
protected String getName(Row r) {
return r.processorId == null ? r.name : "";
}
@@ -275,6 +305,8 @@ public class CamelProcessorStatus extends ProcessBaseCommand {
String mean;
String max;
String min;
+ String last;
+ String delta;
String sinceLastStarted;
String sinceLastCompleted;
String sinceLastFailed;
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
index 002476c4225..77ce7872dfa 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/process/CamelRouteStatus.java
@@ -119,7 +119,15 @@ public class CamelRouteStatus extends ProcessBaseCommand {
}
row.max = stats.get("maxProcessingTime").toString();
row.min = stats.get("minProcessingTime").toString();
- Object last = stats.get("sinceLastCreatedExchange");
+ Object last = stats.get("lastProcessingTime");
+ if (last != null) {
+ row.last = last.toString();
+ }
+ last = stats.get("deltaProcessingTime");
+ if (last != null) {
+ row.delta = last.toString();
+ }
+ last = stats.get("sinceLastCreatedExchange");
if (last != null) {
row.sinceLastStarted = last.toString();
}
@@ -177,6 +185,8 @@ public class CamelRouteStatus extends ProcessBaseCommand {
new Column().header("MEAN").with(r -> r.mean),
new Column().header("MIN").with(r -> r.min),
new Column().header("MAX").with(r -> r.max),
+ new Column().header("LAST").with(r -> r.last),
+ new Column().header("DELTA").with(this::getDelta),
new Column().header("SINCE-LAST").with(this::getSinceLast))));
}
@@ -241,6 +251,18 @@ public class CamelRouteStatus extends ProcessBaseCommand {
}
}
+ protected String getDelta(Row r) {
+ if (r.delta != null) {
+ if (r.delta.startsWith("-")) {
+ return r.delta;
+ } else if (!"0".equals(r.delta)) {
+ // use plus sign to denote slower when positive
+ return "+" + r.delta;
+ }
+ }
+ return r.delta;
+ }
+
static class Row {
String pid;
String name;
@@ -258,6 +280,8 @@ public class CamelRouteStatus extends ProcessBaseCommand {
String mean;
String max;
String min;
+ String last;
+ String delta;
String sinceLastStarted;
String sinceLastCompleted;
String sinceLastFailed;