This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 61cddec160a 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 (#14477)
61cddec160a is described below
commit 61cddec160a2844dda3a4199fbd626fe7649e484
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Jun 11 15:05:20 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 (#14477)
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../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;
+ }
}