You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2024/06/11 12:47:48 UTC

(camel) 01/01: CAMEL-20798: EndpointServiceLocation on components to make it possible to know which remote system Camel connects to to assist for monitoring and observability - AWS Cloudwatch

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

acosentino pushed a commit to branch CAMEL-20798-AWS-CW
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5a8ba1adee11905ba1c73b281f1868f5c97721aa
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jun 11 14:47:27 2024 +0200

    CAMEL-20798: EndpointServiceLocation on components to make it possible to know which remote system Camel connects to to assist for monitoring and observability - AWS Cloudwatch
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel/component/aws2/cw/Cw2Endpoint.java       | 30 +++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
index a24f5e926e6..21beb3aee47 100644
--- a/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
+++ b/components/camel-aws/camel-aws2-cw/src/main/java/org/apache/camel/component/aws2/cw/Cw2Endpoint.java
@@ -16,12 +16,15 @@
  */
 package org.apache.camel.component.aws2.cw;
 
+import java.util.Map;
+
 import org.apache.camel.Category;
 import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.component.aws2.cw.client.Cw2ClientFactory;
+import org.apache.camel.spi.EndpointServiceLocation;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultEndpoint;
@@ -33,7 +36,7 @@ import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
  */
 @UriEndpoint(firstVersion = "3.1.0", scheme = "aws2-cw", title = "AWS CloudWatch", syntax = "aws2-cw:namespace",
              producerOnly = true, category = { Category.CLOUD, Category.MONITORING }, headersClass = Cw2Constants.class)
-public class Cw2Endpoint extends DefaultEndpoint {
+public class Cw2Endpoint extends DefaultEndpoint implements EndpointServiceLocation {
 
     @UriParam
     private Cw2Configuration configuration;
@@ -92,4 +95,29 @@ public class Cw2Endpoint extends DefaultEndpoint {
     public CloudWatchClient getCloudWatchClient() {
         return cloudWatchClient;
     }
+
+    @Override
+    public String getServiceUrl() {
+        if (!configuration.isOverrideEndpoint()) {
+            if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
+                return configuration.getRegion();
+            }
+        } else if (ObjectHelper.isNotEmpty(configuration.getUriEndpointOverride())) {
+            return configuration.getUriEndpointOverride();
+        }
+        return null;
+    }
+
+    @Override
+    public String getServiceProtocol() {
+        return "cloudwatch";
+    }
+
+    @Override
+    public Map<String, String> getServiceMetadata() {
+        if (configuration.getNamespace() != null) {
+            return Map.of("namespace", configuration.getNamespace());
+        }
+        return null;
+    }
 }