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

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

commit 35e453d9e8ec17189d1ed52bab9d9179fba5c415
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sun May 26 10:32:13 2024 +0200

    CAMEL-20798: Add RemoteAddress to endpoints so they can tell the 
url/hostname etc for the system it connects. This is needed for better 
monitoring, tracing and management. Add this information into camel-tracer as 
tags.
---
 .../apache/camel/component/es/ElasticsearchEndpoint.java |  8 +++++++-
 .../org/apache/camel/component/fhir/FhirEndpoint.java    | 16 +++++++++++++++-
 .../tracing/decorators/ElasticsearchSpanDecorator.java   |  1 -
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchEndpoint.java
 
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchEndpoint.java
index b405b16be1f..84d8d07acd3 100644
--- 
a/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchEndpoint.java
+++ 
b/components/camel-elasticsearch/src/main/java/org/apache/camel/component/es/ElasticsearchEndpoint.java
@@ -20,6 +20,7 @@ import org.apache.camel.Category;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.spi.EndpointLocationAddress;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultEndpoint;
@@ -31,7 +32,7 @@ import org.elasticsearch.client.RestClient;
 @UriEndpoint(firstVersion = "3.19.0", scheme = "elasticsearch", title = 
"Elasticsearch",
              syntax = "elasticsearch:clusterName", producerOnly = true,
              category = { Category.SEARCH, Category.MONITORING }, headersClass 
= ElasticsearchConstants.class)
-public class ElasticsearchEndpoint extends DefaultEndpoint {
+public class ElasticsearchEndpoint extends DefaultEndpoint implements 
EndpointLocationAddress {
 
     @UriParam
     private final ElasticsearchConfiguration configuration;
@@ -49,6 +50,11 @@ public class ElasticsearchEndpoint extends DefaultEndpoint {
         return configuration;
     }
 
+    @Override
+    public String getAddress() {
+        return getConfiguration().getHostAddresses();
+    }
+
     @Override
     public Producer createProducer() {
         return new ElasticsearchProducer(this, configuration);
diff --git 
a/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirEndpoint.java
 
b/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirEndpoint.java
index feab190cbbd..4c234815549 100644
--- 
a/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirEndpoint.java
+++ 
b/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirEndpoint.java
@@ -42,6 +42,7 @@ import 
org.apache.camel.component.fhir.internal.FhirApiCollection;
 import org.apache.camel.component.fhir.internal.FhirApiName;
 import org.apache.camel.component.fhir.internal.FhirConstants;
 import org.apache.camel.component.fhir.internal.FhirPropertiesHelper;
+import org.apache.camel.spi.EndpointLocationAddress;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.component.AbstractApiEndpoint;
@@ -54,7 +55,7 @@ import 
org.apache.camel.support.component.ApiMethodPropertiesHelper;
 @UriEndpoint(firstVersion = "2.23.0", scheme = "fhir", title = "FHIR", syntax 
= "fhir:apiName/methodName",
              apiSyntax = "apiName/methodName",
              category = { Category.API })
-public class FhirEndpoint extends AbstractApiEndpoint<FhirApiName, 
FhirConfiguration> {
+public class FhirEndpoint extends AbstractApiEndpoint<FhirApiName, 
FhirConfiguration> implements EndpointLocationAddress {
 
     private static final String EXTRA_PARAMETERS_PROPERTY = "extraParameters";
 
@@ -69,6 +70,19 @@ public class FhirEndpoint extends 
AbstractApiEndpoint<FhirApiName, FhirConfigura
         this.configuration = endpointConfiguration;
     }
 
+    @Override
+    public String getAddress() {
+        return configuration.getServerUrl();
+    }
+
+    @Override
+    public Map<String, String> getAddressMetadata() {
+        if (configuration.getUsername() != null) {
+            return Map.of("username", configuration.getUsername());
+        }
+        return null;
+    }
+
     @Override
     public Producer createProducer() throws Exception {
         return new FhirProducer(this);
diff --git 
a/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/ElasticsearchSpanDecorator.java
 
b/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/ElasticsearchSpanDecorator.java
index 02c63d7c751..8d3083a89e7 100644
--- 
a/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/ElasticsearchSpanDecorator.java
+++ 
b/components/camel-tracing/src/main/java/org/apache/camel/tracing/decorators/ElasticsearchSpanDecorator.java
@@ -62,7 +62,6 @@ public class ElasticsearchSpanDecorator extends 
AbstractSpanDecorator {
         String cluster = stripSchemeAndOptions(endpoint);
         if (cluster != null) {
             span.setTag(ELASTICSEARCH_CLUSTER_TAG, cluster);
-            span.setTag(TagConstants.SERVER_ADDRESS, cluster);
         }
     }
 

Reply via email to