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 2019/08/24 07:04:00 UTC

[camel] branch master updated: CAMEL-13838: Fixed component had wrong syntax and made it configurable for tooling and fast endpoint configurer

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

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


The following commit(s) were added to refs/heads/master by this push:
     new fb2412b  CAMEL-13838: Fixed component had wrong syntax and made it configurable for tooling and fast endpoint configurer
fb2412b is described below

commit fb2412b7e7a44051325633f42b00c222443b54f1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Aug 24 09:03:17 2019 +0200

    CAMEL-13838: Fixed component had wrong syntax and made it configurable for tooling and fast endpoint configurer
---
 .../src/main/docs/microprofile-metrics-component.adoc  |  8 ++++----
 .../metrics/AbstractMicroProfileMetricsProducer.java   |  6 ++----
 .../metrics/MicroProfileMetricsComponent.java          |  5 +----
 .../metrics/MicroProfileMetricsEndpoint.java           | 15 +++++++++------
 .../metrics/MicroProfileMetricsEndpointTest.java       |  2 +-
 .../dsl/MicroProfileMetricsEndpointBuilderFactory.java | 18 +++++++++++++-----
 6 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/components/camel-microprofile-metrics/src/main/docs/microprofile-metrics-component.adoc b/components/camel-microprofile-metrics/src/main/docs/microprofile-metrics-component.adoc
index d03cb35..93eb1aa 100644
--- a/components/camel-microprofile-metrics/src/main/docs/microprofile-metrics-component.adoc
+++ b/components/camel-microprofile-metrics/src/main/docs/microprofile-metrics-component.adoc
@@ -45,12 +45,12 @@ The MicroProfile Metrics component supports 2 options, which are listed below.
 The MicroProfile Metrics endpoint is configured using URI syntax:
 
 ----
-microprofile-metrics:metricsType:metricsName
+microprofile-metrics:metricType:metricsName
 ----
 
 with the following path and query parameters:
 
-=== Path Parameters (3 parameters):
+=== Path Parameters (2 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -58,11 +58,10 @@ with the following path and query parameters:
 | Name | Description | Default | Type
 | *metricType* | *Required* Metric type |  | MetricType
 | *metricName* | *Required* Metric name |  | String
-| *tags* | Comma delimited list of tags associated with the metric in the format tagName=tagValue |  | List
 |===
 
 
-=== Query Parameters (12 parameters):
+=== Query Parameters (13 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -77,6 +76,7 @@ with the following path and query parameters:
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *mark* (producer) | The mark value to set when using the Meter metric type |  | Long
 | *metricUnit* (producer) | Sets a metric unit within the metric metadata |  | String
+| *tags* (producer) | Comma delimited list of tags associated with the metric in the format tagName=tagValue |  | String
 | *value* (producer) | The value to set when using the Histogram metric type |  | Long
 | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
diff --git a/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/AbstractMicroProfileMetricsProducer.java b/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/AbstractMicroProfileMetricsProducer.java
index 55f2ad2..27b5109 100644
--- a/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/AbstractMicroProfileMetricsProducer.java
+++ b/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/AbstractMicroProfileMetricsProducer.java
@@ -65,11 +65,9 @@ public abstract class AbstractMicroProfileMetricsProducer<T extends Metric> exte
         String metricUnit = getStringHeader(in, HEADER_METRIC_UNIT, endpoint.getMetricUnit());
         MetricType metricType = exchange.getIn().getHeader(HEADER_METRIC_TYPE,  endpoint.getMetricType(), MetricType.class);
 
-        List<Tag> defaultTags = endpoint.getTags();
-        String headerTags = getStringHeader(in, HEADER_METRIC_TAGS, "");
-
         List<Tag> allTags = new ArrayList<>();
-        allTags.addAll(defaultTags);
+        allTags.addAll(MicroProfileMetricsHelper.getMetricsTag(endpoint.getTags()));
+        String headerTags = getStringHeader(in, HEADER_METRIC_TAGS, "");
         allTags.addAll(MicroProfileMetricsHelper.getMetricsTag(headerTags));
 
         List<Tag> finalTags = allTags.stream()
diff --git a/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsComponent.java b/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsComponent.java
index cc19420..5e4092f 100644
--- a/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsComponent.java
+++ b/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsComponent.java
@@ -42,10 +42,7 @@ public class MicroProfileMetricsComponent extends DefaultComponent {
         String metricsName = MicroProfileMetricsHelper.getMetricsName(remaining);
         MetricType metricsType = MicroProfileMetricsHelper.getMetricsType(remaining);
 
-        String rawTags = getAndRemoveParameter(parameters, "tags", String.class, "");
-        List<Tag> tags = MicroProfileMetricsHelper.getMetricsTag(rawTags);
-
-        return new MicroProfileMetricsEndpoint(uri, this, metricRegistry, metricsType, metricsName, tags);
+        return new MicroProfileMetricsEndpoint(uri, this, metricRegistry, metricsType, metricsName);
     }
 
     public MetricRegistry getMetricRegistry() {
diff --git a/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpoint.java b/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpoint.java
index d4b3f16..bd4a4e5 100644
--- a/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpoint.java
+++ b/components/camel-microprofile-metrics/src/main/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpoint.java
@@ -31,7 +31,7 @@ import org.eclipse.microprofile.metrics.MetricRegistry;
 import org.eclipse.microprofile.metrics.MetricType;
 import org.eclipse.microprofile.metrics.Tag;
 
-@UriEndpoint(firstVersion = "3.0.0", scheme = "microprofile-metrics", title = "MicroProfile Metrics", syntax = "microprofile-metrics:metricsType:metricsName", producerOnly = true, label = "monitoring")
+@UriEndpoint(firstVersion = "3.0.0", scheme = "microprofile-metrics", title = "MicroProfile Metrics", syntax = "microprofile-metrics:metricType:metricsName", producerOnly = true, label = "monitoring")
 public class MicroProfileMetricsEndpoint extends DefaultEndpoint {
 
     protected final MetricRegistry metricRegistry;
@@ -42,8 +42,8 @@ public class MicroProfileMetricsEndpoint extends DefaultEndpoint {
     @UriPath(description = "Metric name")
     @Metadata(required = true)
     private final String metricName;
-    @UriPath(description = "Comma delimited list of tags associated with the metric in the format tagName=tagValue")
-    private final List<Tag> tags;
+    @UriParam(description = "Comma delimited list of tags associated with the metric in the format tagName=tagValue")
+    private String tags;
     @UriParam(description = "Action to use when using the timer type")
     private String action;
     @UriParam(description = "Mark value to set when using the meter type")
@@ -63,12 +63,11 @@ public class MicroProfileMetricsEndpoint extends DefaultEndpoint {
     @UriParam(description = "Metric unit. See org.eclipse.microprofile.metrics.MetricUnits")
     private String metricUnit;
 
-    public MicroProfileMetricsEndpoint(String uri, Component component, MetricRegistry metricRegistry, MetricType metricType, String metricsName, List<Tag> tags) {
+    public MicroProfileMetricsEndpoint(String uri, Component component, MetricRegistry metricRegistry, MetricType metricType, String metricsName) {
         super(uri, component);
         this.metricRegistry = metricRegistry;
         this.metricType = metricType;
         this.metricName = metricsName;
-        this.tags = tags;
     }
 
     @Override
@@ -105,10 +104,14 @@ public class MicroProfileMetricsEndpoint extends DefaultEndpoint {
         return metricName;
     }
 
-    public List<Tag> getTags() {
+    public String getTags() {
         return tags;
     }
 
+    public void setTags(String tags) {
+        this.tags = tags;
+    }
+
     public String getAction() {
         return action;
     }
diff --git a/components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpointTest.java b/components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpointTest.java
index c0b1fc5..1f139b4 100644
--- a/components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpointTest.java
+++ b/components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/MicroProfileMetricsEndpointTest.java
@@ -74,6 +74,6 @@ public class MicroProfileMetricsEndpointTest {
     }
 
     private MicroProfileMetricsEndpoint createEndpoint(MetricType metricType) {
-        return new MicroProfileMetricsEndpoint("microprofile-metrics:foo:bar", null, null, metricType, null, Collections.emptyList());
+        return new MicroProfileMetricsEndpoint("microprofile-metrics:foo:bar", null, null, metricType, null);
     }
 }
diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MicroProfileMetricsEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MicroProfileMetricsEndpointBuilderFactory.java
index 2040466..d4d59be 100644
--- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MicroProfileMetricsEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/MicroProfileMetricsEndpointBuilderFactory.java
@@ -182,6 +182,18 @@ public interface MicroProfileMetricsEndpointBuilderFactory {
             return this;
         }
         /**
+         * Comma delimited list of tags associated with the metric in the format
+         * tagName=tagValue.
+         * 
+         * The option is a: <code>java.lang.String</code> type.
+         * 
+         * Group: producer
+         */
+        default MicroProfileMetricsEndpointBuilder tags(String tags) {
+            setProperty("tags", tags);
+            return this;
+        }
+        /**
          * The value to set when using the Histogram metric type.
          * 
          * The option is a: <code>java.lang.Long</code> type.
@@ -275,7 +287,7 @@ public interface MicroProfileMetricsEndpointBuilderFactory {
      * Available as of version: 3.0
      * Maven coordinates: org.apache.camel:camel-microprofile-metrics
      * 
-     * Syntax: <code>microprofile-metrics:metricsType:metricsName</code>
+     * Syntax: <code>microprofile-metrics:metricType:metricsName</code>
      * 
      * Path parameter: metricType (required)
      * Metric type
@@ -284,10 +296,6 @@ public interface MicroProfileMetricsEndpointBuilderFactory {
      * 
      * Path parameter: metricName (required)
      * Metric name
-     * 
-     * Path parameter: tags
-     * Comma delimited list of tags associated with the metric in the format
-     * tagName=tagValue
      */
     default MicroProfileMetricsEndpointBuilder microProfileMetrics(String path) {
         class MicroProfileMetricsEndpointBuilderImpl extends AbstractEndpointBuilder implements MicroProfileMetricsEndpointBuilder, AdvancedMicroProfileMetricsEndpointBuilder {