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 2024/03/12 08:16:26 UTC
(camel) branch mtag created (now c9bd7011133)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch mtag
in repository https://gitbox.apache.org/repos/asf/camel.git
at c9bd7011133 CAMEL-20525: camel-micrometer - Rename tag to be Camel specific and more understandable what it is.
This branch includes the following new commits:
new c9bd7011133 CAMEL-20525: camel-micrometer - Rename tag to be Camel specific and more understandable what it is.
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-20525: camel-micrometer - Rename tag to be Camel specific and more understandable what it is.
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mtag
in repository https://gitbox.apache.org/repos/asf/camel.git
commit c9bd701113352b07df961a64d269446eeec5b175
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Mar 12 09:15:56 2024 +0100
CAMEL-20525: camel-micrometer - Rename tag to be Camel specific and more understandable what it is.
---
.../camel/component/micrometer/MicrometerConstants.java | 5 +++++
.../eventnotifier/AbstractMicrometerEventNotifier.java | 5 +++--
.../MicrometerExchangeEventNotifierNamingStrategy.java | 13 +++++++------
.../MicrometerRouteEventNotifierNamingStrategy.java | 7 ++++---
.../messagehistory/MicrometerMessageHistoryFactory.java | 6 +++---
.../MicrometerMessageHistoryNamingStrategy.java | 7 ++++---
.../micrometer/routepolicy/MicrometerRoutePolicy.java | 5 +++--
.../routepolicy/MicrometerRoutePolicyNamingStrategy.java | 11 +++++------
.../modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc | 9 +++++++++
9 files changed, 43 insertions(+), 25 deletions(-)
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 a4a1a151d9b..e6b25516393 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
@@ -65,6 +65,11 @@ public final class MicrometerConstants {
public static final String EVENT_TYPE_TAG = "eventType";
public static final String METRICS_REGISTRY_NAME = "metricsRegistry";
+ public static final String KIND = "kind";
+ public static final String KIND_EXCHANGE = "CamelExchangeEvent";
+ public static final String KIND_ROUTE = "CamelRoute";
+ public static final String KIND_HISTORY = "CamelMessageHistory";
+ @Deprecated
public static final String SERVICE_NAME = "serviceName";
public static final String ENDPOINT_NAME = "endpointName";
diff --git a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/AbstractMicrometerEventNotifier.java b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/AbstractMicrometerEventNotifier.java
index ee8e9553a67..420ebb98eff 100644
--- a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/AbstractMicrometerEventNotifier.java
+++ b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/AbstractMicrometerEventNotifier.java
@@ -28,8 +28,9 @@ import org.apache.camel.spi.CamelEvent;
import org.apache.camel.support.EventNotifierSupport;
import org.apache.camel.support.service.ServiceHelper;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND_EXCHANGE;
import static org.apache.camel.component.micrometer.MicrometerConstants.METRICS_REGISTRY_NAME;
-import static org.apache.camel.component.micrometer.MicrometerConstants.SERVICE_NAME;
public abstract class AbstractMicrometerEventNotifier<T extends CamelEvent> extends EventNotifierSupport
implements CamelContextAware {
@@ -99,7 +100,7 @@ public abstract class AbstractMicrometerEventNotifier<T extends CamelEvent> exte
registryService.setMeterRegistry(getMeterRegistry());
registryService.setPrettyPrint(isPrettyPrint());
registryService.setDurationUnit(getDurationUnit());
- registryService.setMatchingTags(Tags.of(SERVICE_NAME, registryService.getClass().getSimpleName()));
+ registryService.setMatchingTags(Tags.of(KIND, KIND_EXCHANGE));
camelContext.addService(registryService);
// ensure registry service is started
ServiceHelper.startService(registryService);
diff --git a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerExchangeEventNotifierNamingStrategy.java b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerExchangeEventNotifierNamingStrategy.java
index 065c7c1c38e..c1d68d1e42a 100644
--- a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerExchangeEventNotifierNamingStrategy.java
+++ b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerExchangeEventNotifierNamingStrategy.java
@@ -30,13 +30,14 @@ import static org.apache.camel.component.micrometer.MicrometerConstants.DEFAULT_
import static org.apache.camel.component.micrometer.MicrometerConstants.ENDPOINT_NAME;
import static org.apache.camel.component.micrometer.MicrometerConstants.EVENT_TYPE_TAG;
import static org.apache.camel.component.micrometer.MicrometerConstants.FAILED_TAG;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND_EXCHANGE;
import static org.apache.camel.component.micrometer.MicrometerConstants.ROUTE_ID_TAG;
-import static org.apache.camel.component.micrometer.MicrometerConstants.SERVICE_NAME;
public interface MicrometerExchangeEventNotifierNamingStrategy {
Predicate<Meter.Id> EVENT_NOTIFIERS
- = id -> MicrometerEventNotifierService.class.getSimpleName().equals(id.getTag(SERVICE_NAME));
+ = id -> KIND_EXCHANGE.equals(id.getTag(KIND));
/**
* Default naming strategy that uses micrometer naming convention.
@@ -73,7 +74,7 @@ public interface MicrometerExchangeEventNotifierNamingStrategy {
if (routeId != null) {
return Tags.of(
CAMEL_CONTEXT_TAG, event.getExchange().getContext().getName(),
- SERVICE_NAME, MicrometerEventNotifierService.class.getSimpleName(),
+ KIND, KIND_EXCHANGE,
EVENT_TYPE_TAG, event.getClass().getSimpleName(),
ROUTE_ID_TAG, routeId,
ENDPOINT_NAME, uri,
@@ -81,7 +82,7 @@ public interface MicrometerExchangeEventNotifierNamingStrategy {
} else {
return Tags.of(
CAMEL_CONTEXT_TAG, event.getExchange().getContext().getName(),
- SERVICE_NAME, MicrometerEventNotifierService.class.getSimpleName(),
+ KIND, KIND_EXCHANGE,
EVENT_TYPE_TAG, event.getClass().getSimpleName(),
ENDPOINT_NAME, uri,
FAILED_TAG, Boolean.toString(event.getExchange().isFailed()));
@@ -92,12 +93,12 @@ public interface MicrometerExchangeEventNotifierNamingStrategy {
if (event.getExchange().getFromRouteId() != null) {
return Tags.of(
CAMEL_CONTEXT_TAG, event.getExchange().getContext().getName(),
- SERVICE_NAME, MicrometerEventNotifierService.class.getSimpleName(),
+ KIND, KIND_EXCHANGE,
ROUTE_ID_TAG, event.getExchange().getFromRouteId());
} else {
return Tags.of(
CAMEL_CONTEXT_TAG, event.getExchange().getContext().getName(),
- SERVICE_NAME, MicrometerEventNotifierService.class.getSimpleName());
+ KIND, KIND_EXCHANGE);
}
}
}
diff --git a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerRouteEventNotifierNamingStrategy.java b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerRouteEventNotifierNamingStrategy.java
index 693275c80ad..40cefd4f8fe 100644
--- a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerRouteEventNotifierNamingStrategy.java
+++ b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/MicrometerRouteEventNotifierNamingStrategy.java
@@ -29,12 +29,13 @@ import static org.apache.camel.component.micrometer.MicrometerConstants.DEFAULT_
import static org.apache.camel.component.micrometer.MicrometerConstants.DEFAULT_CAMEL_ROUTES_RELOADED;
import static org.apache.camel.component.micrometer.MicrometerConstants.DEFAULT_CAMEL_ROUTES_RUNNING;
import static org.apache.camel.component.micrometer.MicrometerConstants.EVENT_TYPE_TAG;
-import static org.apache.camel.component.micrometer.MicrometerConstants.SERVICE_NAME;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND_ROUTE;
public interface MicrometerRouteEventNotifierNamingStrategy {
Predicate<Meter.Id> EVENT_NOTIFIERS
- = id -> MicrometerEventNotifierService.class.getSimpleName().equals(id.getTag(SERVICE_NAME));
+ = id -> KIND_ROUTE.equals(id.getTag(KIND));
/**
* Default naming strategy that uses micrometer naming convention.
@@ -93,7 +94,7 @@ public interface MicrometerRouteEventNotifierNamingStrategy {
default Tags getTags(CamelContext camelContext) {
return Tags.of(
- SERVICE_NAME, MicrometerEventNotifierService.class.getSimpleName(),
+ KIND, KIND_ROUTE,
CAMEL_CONTEXT_TAG, camelContext.getName(),
EVENT_TYPE_TAG, RouteEvent.class.getSimpleName());
}
diff --git a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistoryFactory.java b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistoryFactory.java
index 940f74d6978..58581605930 100644
--- a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistoryFactory.java
+++ b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistoryFactory.java
@@ -35,8 +35,9 @@ import org.apache.camel.spi.MessageHistoryFactory;
import org.apache.camel.support.PatternHelper;
import org.apache.camel.support.service.ServiceSupport;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND_HISTORY;
import static org.apache.camel.component.micrometer.MicrometerConstants.METRICS_REGISTRY_NAME;
-import static org.apache.camel.component.micrometer.MicrometerConstants.SERVICE_NAME;
/**
* A factory to setup and use {@link MicrometerMessageHistory} as message history implementation.
@@ -168,8 +169,7 @@ public class MicrometerMessageHistoryFactory extends ServiceSupport
messageHistoryService.setMeterRegistry(getMeterRegistry());
messageHistoryService.setPrettyPrint(isPrettyPrint());
messageHistoryService.setDurationUnit(getDurationUnit());
- messageHistoryService
- .setMatchingTags(Tags.of(SERVICE_NAME, MicrometerMessageHistoryService.class.getSimpleName()));
+ messageHistoryService.setMatchingTags(Tags.of(KIND, KIND_HISTORY));
camelContext.addService(messageHistoryService);
}
} catch (Exception e) {
diff --git a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistoryNamingStrategy.java b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistoryNamingStrategy.java
index 69fc05a1aa0..1aff97c21c1 100644
--- a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistoryNamingStrategy.java
+++ b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistoryNamingStrategy.java
@@ -26,9 +26,10 @@ import org.apache.camel.component.micrometer.MicrometerUtils;
import static org.apache.camel.component.micrometer.MicrometerConstants.CAMEL_CONTEXT_TAG;
import static org.apache.camel.component.micrometer.MicrometerConstants.DEFAULT_CAMEL_MESSAGE_HISTORY_METER_NAME;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND_HISTORY;
import static org.apache.camel.component.micrometer.MicrometerConstants.NODE_ID_TAG;
import static org.apache.camel.component.micrometer.MicrometerConstants.ROUTE_ID_TAG;
-import static org.apache.camel.component.micrometer.MicrometerConstants.SERVICE_NAME;
/**
* Provides a strategy to derive a meter name from the route and node
@@ -36,7 +37,7 @@ import static org.apache.camel.component.micrometer.MicrometerConstants.SERVICE_
public interface MicrometerMessageHistoryNamingStrategy {
Predicate<Meter.Id> MESSAGE_HISTORIES
- = id -> MicrometerMessageHistoryService.class.getSimpleName().equals(id.getTag(SERVICE_NAME));
+ = id -> KIND_HISTORY.equals(id.getTag(KIND));
/**
* Default naming strategy that uses micrometer naming convention.
@@ -62,7 +63,7 @@ public interface MicrometerMessageHistoryNamingStrategy {
default Tags getTags(Route route, NamedNode node) {
return Tags.of(
CAMEL_CONTEXT_TAG, route.getCamelContext().getName(),
- SERVICE_NAME, MicrometerMessageHistoryService.class.getSimpleName(),
+ KIND, KIND_HISTORY,
ROUTE_ID_TAG, route.getId(),
NODE_ID_TAG, node.getId());
}
diff --git a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicy.java b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicy.java
index 7df31be65bd..5ccac1cc877 100644
--- a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicy.java
+++ b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicy.java
@@ -39,8 +39,9 @@ import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.util.ObjectHelper;
import static org.apache.camel.component.micrometer.MicrometerConstants.DEFAULT_CAMEL_ROUTE_POLICY_METER_NAME;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND;
+import static org.apache.camel.component.micrometer.MicrometerConstants.KIND_ROUTE;
import static org.apache.camel.component.micrometer.MicrometerConstants.METRICS_REGISTRY_NAME;
-import static org.apache.camel.component.micrometer.MicrometerConstants.SERVICE_NAME;
/**
* A {@link org.apache.camel.spi.RoutePolicy} which gathers statistics and reports them using {@link MeterRegistry}.
@@ -286,7 +287,7 @@ public class MicrometerRoutePolicy extends RoutePolicySupport implements NonMana
registryService.setMeterRegistry(getMeterRegistry());
registryService.setPrettyPrint(isPrettyPrint());
registryService.setDurationUnit(getDurationUnit());
- registryService.setMatchingTags(Tags.of(SERVICE_NAME, MicrometerRoutePolicyService.class.getSimpleName()));
+ registryService.setMatchingTags(Tags.of(KIND, KIND_ROUTE));
route.getCamelContext().addService(registryService);
ServiceHelper.startService(registryService);
}
diff --git a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyNamingStrategy.java b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyNamingStrategy.java
index 3ec3d138897..7949383d766 100644
--- a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyNamingStrategy.java
+++ b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyNamingStrategy.java
@@ -31,8 +31,7 @@ import static org.apache.camel.component.micrometer.MicrometerConstants.*;
*/
public interface MicrometerRoutePolicyNamingStrategy {
- Predicate<Meter.Id> ROUTE_POLICIES
- = id -> MicrometerRoutePolicyService.class.getSimpleName().equals(id.getTag(SERVICE_NAME));
+ Predicate<Meter.Id> ROUTE_POLICIES = id -> KIND_ROUTE.equals(id.getTag(KIND));
/**
* Default naming strategy that uses micrometer naming convention.
@@ -87,7 +86,7 @@ public interface MicrometerRoutePolicyNamingStrategy {
default Tags getTags(Route route) {
return Tags.of(
CAMEL_CONTEXT_TAG, route.getCamelContext().getName(),
- SERVICE_NAME, MicrometerRoutePolicyService.class.getSimpleName(),
+ KIND, KIND_ROUTE,
ROUTE_ID_TAG, route.getId(),
EVENT_TYPE_TAG, "route");
}
@@ -95,7 +94,7 @@ public interface MicrometerRoutePolicyNamingStrategy {
default Tags getTags(CamelContext camelContext) {
return Tags.of(
CAMEL_CONTEXT_TAG, camelContext.getName(),
- SERVICE_NAME, MicrometerRoutePolicyService.class.getSimpleName(),
+ KIND, KIND_ROUTE,
ROUTE_ID_TAG, "",
EVENT_TYPE_TAG, "context");
}
@@ -103,7 +102,7 @@ public interface MicrometerRoutePolicyNamingStrategy {
default Tags getExchangeStatusTags(Route route) {
return Tags.of(
CAMEL_CONTEXT_TAG, route.getCamelContext().getName(),
- SERVICE_NAME, MicrometerRoutePolicyService.class.getSimpleName(),
+ KIND, KIND_ROUTE,
ROUTE_ID_TAG, route.getId(),
EVENT_TYPE_TAG, "route");
}
@@ -111,7 +110,7 @@ public interface MicrometerRoutePolicyNamingStrategy {
default Tags getExchangeStatusTags(CamelContext camelContext) {
return Tags.of(
CAMEL_CONTEXT_TAG, camelContext.getName(),
- SERVICE_NAME, MicrometerRoutePolicyService.class.getSimpleName(),
+ KIND, KIND_ROUTE,
ROUTE_ID_TAG, "",
EVENT_TYPE_TAG, "context");
}
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
index b8494719a05..a49dbb4928d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc
@@ -196,6 +196,15 @@ on the `ManagementAgent` object. See more in the xref:jmx.adoc[JMX] documentatio
=== camel-micrometer and camel-metrics
+The `camel-micrometer` have renamed tag `serviceName` to `kind` and use naming that indicate that its from Camel:
+
+|===
+|**Before** | **After**
+| serviceName="MicrometerEventNotifierService" | kind="CamelExchangeEvent"
+| serviceName="MicrometerMessageHistoryService" | kind="CamelMessageHistory"
+| serviceName="MicrometerRoutePolicyService" | kind="CamelRoute"
+|===
+
Due to Kamelets are changed to act more like a Camel component, and not expose internal details as JMX MBeans, then
micrometer and metrics no longer include statistics for those Kamelet routes.