This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-2.19.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.19.x by this push: new 2103a14 CAMEL-12289: camel-opentracing: URISyntaxException in AbstractSpanDecorator 2103a14 is described below commit 2103a142b28fe62dcfe18dd8a764c071471ed10c Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Feb 26 09:44:48 2018 +0100 CAMEL-12289: camel-opentracing: URISyntaxException in AbstractSpanDecorator --- .../opentracing/decorators/AbstractSpanDecorator.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractSpanDecorator.java index 74d42a0..702e43f 100644 --- a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractSpanDecorator.java +++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractSpanDecorator.java @@ -16,7 +16,6 @@ */ package org.apache.camel.opentracing.decorators; -import java.net.URI; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -26,6 +25,7 @@ import io.opentracing.tag.Tags; import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.opentracing.SpanDecorator; +import org.apache.camel.util.StringHelper; import org.apache.camel.util.URISupport; /** @@ -43,7 +43,7 @@ public abstract class AbstractSpanDecorator implements SpanDecorator { // OpenTracing aims to use low cardinality operation names. Ideally a specific // span decorator should be defined for all relevant Camel components that // identify a meaningful operation name - return URI.create(endpoint.getEndpointUri()).getScheme(); + return getComponentName(endpoint); } /** @@ -69,7 +69,8 @@ public abstract class AbstractSpanDecorator implements SpanDecorator { @Override public void pre(Span span, Exchange exchange, Endpoint endpoint) { - span.setTag(Tags.COMPONENT.getKey(), CAMEL_COMPONENT + URI.create(endpoint.getEndpointUri()).getScheme()); + String scheme = getComponentName(endpoint); + span.setTag(Tags.COMPONENT.getKey(), CAMEL_COMPONENT + scheme); // Including the endpoint URI provides access to any options that may have been provided, for // subsequent analysis @@ -116,4 +117,13 @@ public abstract class AbstractSpanDecorator implements SpanDecorator { return Collections.emptyMap(); } + private static String getComponentName(Endpoint endpoint) { + String[] splitURI = StringHelper.splitOnCharacter(endpoint.getEndpointUri(), ":", 2); + if (splitURI.length > 0) { + return splitURI[0]; + } else { + return null; + } + } + } -- To stop receiving notification emails like this one, please contact davscl...@apache.org.