diff --git a/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/DecoratorRegistry.java b/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/DecoratorRegistry.java index 265f07c329..c8f2ec465e 100644 --- a/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/DecoratorRegistry.java +++ b/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/DecoratorRegistry.java @@ -31,7 +31,8 @@ public class DecoratorRegistry { result.put("disruptor", new InternalSpanDecorator()); result.put("disruptor-vm", new InternalSpanDecorator()); result.put("elasticsearch", new DbSpanDecorator("elasticsearch", "elasticsearch")); - result.put("http4", new HttpSpanDecorator()); + result.put("http4", new Http4SpanDecorator()); + result.put("https4", new Https4SpanDecorator()); result.put("http", new HttpSpanDecorator()); result.put("ironmq", new MessagingSpanDecorator("ironmq")); result.put("jdbc", new DbSpanDecorator("jdbc", DbSystemValues.OTHER_SQL)); diff --git a/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/Http4SpanDecorator.java b/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/Http4SpanDecorator.java new file mode 100644 index 0000000000..65bffd7c01 --- /dev/null +++ b/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/Http4SpanDecorator.java @@ -0,0 +1,27 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators; + +import javax.annotation.Nullable; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; + +class Http4SpanDecorator extends HttpSpanDecorator { + @Override + protected String getProtocol() { + return "http4"; + } + + @Nullable + @Override + protected String getHttpUrl(Exchange exchange, Endpoint endpoint) { + String url = super.getHttpUrl(exchange, endpoint); + if (url != null) { + return url.replace(getProtocol(), getProtocol().substring(0, getProtocol().length() - 1)); + } + return null; + } +} diff --git a/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/HttpSpanDecorator.java b/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/HttpSpanDecorator.java index 99427f1c3d..f2aa2b8514 100644 --- a/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/HttpSpanDecorator.java +++ b/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/HttpSpanDecorator.java @@ -39,6 +39,10 @@ class HttpSpanDecorator extends BaseSpanDecorator { private static final String POST_METHOD = "POST"; private static final String GET_METHOD = "GET"; + protected String getProtocol() { + return "http"; + } + protected static String getHttpMethod(Exchange exchange, Endpoint endpoint) { // 1. Use method provided in header. Object method = exchange.getIn().getHeader(Exchange.HTTP_METHOD); @@ -131,7 +135,7 @@ class HttpSpanDecorator extends BaseSpanDecorator { return (String) uri; } else { // Try to obtain from endpoint - int index = endpoint.getEndpointUri().lastIndexOf("http:"); + int index = endpoint.getEndpointUri().lastIndexOf(getProtocol() + ":"); if (index != -1) { return endpoint.getEndpointUri().substring(index); } diff --git a/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/Https4SpanDecorator.java b/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/Https4SpanDecorator.java new file mode 100644 index 0000000000..b2ea1594ef --- /dev/null +++ b/instrumentation/apache-camel-2.20/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachecamel/decorators/Https4SpanDecorator.java @@ -0,0 +1,13 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators; + +class Https4SpanDecorator extends Http4SpanDecorator { + @Override + protected String getProtocol() { + return "https4"; + } +}