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 2023/12/19 11:44:00 UTC

(camel) 06/07: Experiment

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0a21bce2cc10bb79985a79292c4c4d4c484f282f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Dec 19 12:21:20 2023 +0100

    Experiment
---
 .../component/micrometer/prometheus/MicrometerPrometheus.java  | 10 ++++++++--
 .../apache/camel/component/micrometer/MicrometerConstants.java |  7 +++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
index cbe38ac8515..0fb8ae2257e 100644
--- a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
+++ b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
@@ -292,11 +292,17 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
                         if (re.getIndex() >= re.getTotal()) {
                             LOG.info("Resetting Micrometer Registry after reloading routes");
 
-                            // remove all meters that are from Camel and associated routes via routeId as tag
+                            // remove all meters (not counters) that are from Camel and associated routes via routeId as tag
                             List<Meter> toRemove = new ArrayList<>();
                             for (Meter m : meterRegistry.getMeters()) {
                                 String n = m.getId().getName();
-                                if (n.startsWith("camel_") || n.startsWith("camel.")) {
+                                boolean camel = n.startsWith("camel_") || n.startsWith("camel.");
+                                boolean inflight
+                                        = n.startsWith("camel.exchanges.inflight") || n.startsWith("camel_exchanges_inflight");
+                                boolean keep = n.startsWith("camel.exchanges.") || n.startsWith("camel_exchanges_");
+                                // remove camel or inflight, but keep those special camel.exchanges. counters
+                                boolean remove = camel && (inflight || !keep);
+                                if (remove) {
                                     String t = m.getId().getTag("routeId");
                                     if (t != null) {
                                         toRemove.add(m);
diff --git a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerConstants.java b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerConstants.java
index a748f629763..d9008beafe4 100644
--- a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerConstants.java
+++ b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerConstants.java
@@ -41,6 +41,7 @@ public final class MicrometerConstants {
     public static final String HEADER_METRIC_TAGS = HEADER_PREFIX + "Tags";
 
     public static final String DEFAULT_CAMEL_MESSAGE_HISTORY_METER_NAME = "camel.message.history";
+
     public static final String DEFAULT_CAMEL_ROUTE_POLICY_EXCHANGES_FAILED_METER_NAME = "camel.exchanges.failed";
     public static final String DEFAULT_CAMEL_ROUTE_POLICY_EXCHANGES_SUCCEEDED_METER_NAME = "camel.exchanges.succeeded";
     public static final String DEFAULT_CAMEL_ROUTE_POLICY_EXCHANGES_TOTAL_METER_NAME = "camel.exchanges.total";
@@ -48,16 +49,16 @@ public final class MicrometerConstants {
             = "camel.exchanges.failures.handled";
     public static final String DEFAULT_CAMEL_ROUTE_POLICY_EXCHANGES_EXTERNAL_REDELIVERIES_METER_NAME
             = "camel.exchanges.external.redeliveries";
+    public static final String DEFAULT_CAMEL_ROUTES_EXCHANGES_INFLIGHT = "camel.exchanges.inflight";
+
     public static final String DEFAULT_CAMEL_ROUTE_POLICY_METER_NAME = "camel.route.policy";
     public static final String DEFAULT_CAMEL_ROUTE_POLICY_LONGMETER_NAME = "camel.route.policy.long.task";
     public static final String DEFAULT_CAMEL_EXCHANGE_EVENT_METER_NAME = "camel.exchange.event.notifier";
     public static final String DEFAULT_CAMEL_ROUTES_ADDED = "camel.routes.added";
     public static final String DEFAULT_CAMEL_ROUTES_RUNNING = "camel.routes.running";
     public static final String DEFAULT_CAMEL_ROUTES_RELOADED = "camel.routes.reloaded";
-    public static final String DEFAULT_CAMEL_ROUTES_EXCHANGES_INFLIGHT = "camel.exchanges.inflight";
 
     public static final String ROUTE_ID_TAG = "routeId";
-    public static final String ROUTE_DESCRIPTION_TAG = "routeDescription";
     public static final String NODE_ID_TAG = "nodeId";
     public static final String FAILED_TAG = "failed";
     public static final String CAMEL_CONTEXT_TAG = "camelContext";
@@ -68,8 +69,6 @@ public final class MicrometerConstants {
     public static final String ENDPOINT_NAME = "endpointName";
 
     public static final Predicate<Meter.Id> CAMEL_METERS = id -> id.getTag(CAMEL_CONTEXT_TAG) != null;
-    public static final Predicate<Meter.Id> TIMERS = id -> id.getType() == Meter.Type.TIMER;
-    public static final Predicate<Meter.Id> DISTRIBUTION_SUMMARIES = id -> id.getType() == Meter.Type.DISTRIBUTION_SUMMARY;
     public static final Predicate<Meter.Id> ALWAYS = id -> true;
 
     private MicrometerConstants() {